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

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

int m, n;

int main(void) {
  while (cin >> m >> n, m | n) {
    list<int> sur;
    for (int i = 1; i <= m; i++)
      sur.push_back(i);
    typeof(sur.begin()) itr;
    itr = sur.begin();
    for (int i = 1; i <= n; i++) {
      string S;
      bool ok = false;
      cin >> S;
      if (itr == sur.end())
        itr = sur.begin();
      if (sur.size() == 1)
        continue;
      if (!(i % 15) && (S == "FizzBuzz"))
        ok = true;
      else if (!(i % 5) && (S == "Buzz"))
        ok = true;
      else if (!(i % 3) && (S == "Fizz"))
        ok = true;
      else if (i == atoi(S.c_str()) && (i % 3 && i % 5))
        ok = true;
      if (ok) {
        itr++;
      } else {
        itr = sur.erase(itr);
      }
    }
    cout << *(sur.begin());
    if (sur.size() != 1)
      for (typeof(sur.begin()) it = ++sur.begin(); it != sur.end(); it++)
        cout << " " << *it;
    cout << endl;
  }
}

Error: TLE

Fixed submission:

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

int m, n;

int main(void) {
  while (cin >> m >> n, m | n) {
    list<int> sur;
    for (int i = 1; i <= m; i++)
      sur.push_back(i);
    typeof(sur.begin()) itr;
    itr = sur.begin();
    for (int i = 1; i <= n; i++) {
      if (itr == sur.end())
        itr = sur.begin();
      if (sur.size() == 1)
        break;
      string S;
      bool ok = false;
      cin >> S;
      if (!(i % 15) && (S == "FizzBuzz"))
        ok = true;
      else if (!(i % 5) && (S == "Buzz"))
        ok = true;
      else if (!(i % 3) && (S == "Fizz"))
        ok = true;
      else if (i == atoi(S.c_str()) && (i % 3 && i % 5))
        ok = true;
      if (ok) {
        itr++;
      } else {
        itr = sur.erase(itr);
      }
    }
    cout << *(sur.begin());
    for (typeof(sur.begin()) it = ++sur.begin(); it != sur.end(); it++)
      cout << " " << *it;
    cout << endl;
  }
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int m, n;

  while (scanf("%d %d", &m, &n), m + n) {
    bool flag[2048] = {false};
    int p = 0;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      char str[128];
      scanf("%s", str);

      if (cnt < m - 1) {
        char str2[128];
        if (i % 15 == 0) {
          strcpy(str2, "FizzBuzz");
        } else if (i % 3 == 0) {
          strcpy(str2, "Fizz");
        } else if (i % 5 == 0) {
          strcpy(str2, "Buzz");
        } else {
          sprintf(str2, "%d", i);
        }

        if (strcmp(str, str2) != 0) {
          flag[p % m] = true;
          cnt++;
        }
        while (1) {
          p++;
          if (flag[p % m] == false) {
            break;
          }
        }
      }
    }

    bool f = false;
    for (int i = 0; i < m; i++) {
      if (flag[i] == false) {
        if (f) {
          printf(" ");
        }
        printf("%d", i + 1);
        f = true;
      }
    }
    puts("");
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int m, n;

  while (scanf("%d %d", &m, &n), m + n) {
    bool flag[2048] = {false};
    int p = 0;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      char str[128];
      scanf("%s", str);

      if (cnt < m - 1) {
        char str2[128];
        if (i % 15 == 0) {
          strcpy(str2, "FizzBuzz");
        } else if (i % 3 == 0) {
          strcpy(str2, "Fizz");
        } else if (i % 5 == 0) {
          strcpy(str2, "Buzz");
        } else {
          sprintf(str2, "%d", i);
        }

        if (strcmp(str, str2) != 0) {
          flag[p % m] = true;
        }
        while (1) {
          p++;
          if (flag[p % m] == false) {
            break;
          }
        }
      }
    }

    bool f = false;
    for (int i = 0; i < m; i++) {
      if (f) {
        printf(" ");
      }
      if (flag[i] == false) {
        printf("%d", i + 1);
        f = true;
      }
    }
    puts("");
  }

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

#include <bits/stdc++.h>
typedef long long ll;
#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
  int m, n;
  char s[9];
  while (scanf("%d%d", &m, &n) && m && n) {
    bool mem[m];
    REP(i, m) mem[i] = false;
    int p = 0, c = 1;
    for (int i = 1; i <= n; i++) {
      scanf("%s", s);
      if (c < m) {
        int f = 0;
        if (i % 15 == 0) {
          if (strcmp(s, "FizzBuzz"))
            f = 1;
        } else if (i % 5 == 0) {
          if (strcmp(s, "Buzz"))
            f = 1;
        } else if (i % 3 == 0) {
          if (strcmp(s, "Fizz"))
            f = 1;
        } else {
          if (i != atoi(s))
            f = 1;
        }
        if (f)
          mem[p] = i, ++c;
        do {
          p = (p + 1) % m;
        } while (mem[p]);
      }
    }
    int f = 0;
    for (int i = 0; i < m; i++) {
      if (!mem[i]) {
        printf(f ? " %d" : "%d", i + 1);
        f = 1;
      }
    }
    printf("\\n");
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
#define MP make_pair
#define PB push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
bool p[1000];
int main() {
  int m, n;
  string input;
  while (cin >> m >> n && n && m) {
    int now = 0, c = 0;
    REP(i, m) p[i] = true;
    for (int i = 1; i <= n; i++) {
      if (c >= m)
        break;
      cin >> input;
      int f = 0;
      if (i % 15 == 0) {
        if (input == "FizzBuzz")
          f = 1;
      } else if (i % 5 == 0) {
        if (input == "Buzz")
          f = 1;
      } else if (i % 3 == 0) {
        if (input == "Fizz")
          f = 1;
      } else if (i == (input[0] - '0'))
        f = 1;
      if (f == 0)
        p[now] = false, c++;
      do {
        now = (now + 1) % m;
      } while (!p[now]);
    }
    int f = 0;
    for (int i = 0; i < m; i++) {
      if (p[i]) {
        if (f == 1)
          printf(" ");
        printf("%d", i + 1);
        f = 1;
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  int n = 0, remain = 0, player = 0;
  int plnum = 0;
  string num = "";
  while (1) {
    bool bo[1001] = {false};
    plnum = 0;
    cin >> player >> n;
    if (player == 0 && n == 0)
      break;
    remain = player;
    for (int i = 1; i <= n; ++i) {
      cin >> num;
      if (remain == 1)
        continue;
      plnum++;
      if (plnum == player + 1)
        plnum = 1;
      while (bo[plnum]) {
        plnum++;
        if (plnum == player + 1)
          plnum = 1;
      }
      if (i % 3 == 0 || i % 5 == 0) {
        if (i % 15 == 0 && num != "FizzBuzz") {
          bo[plnum] = true;
          remain--;
        } else if (i % 15 != 0 && i % 3 == 0 && num != "Fizz") {
          bo[plnum] = true;
          remain--;
        } else if (i % 15 != 0 && i % 5 == 0 && num != "Buzz") {
          bo[plnum] = true;
          remain--;
        }
      } else if (num[0] < '0' || '9' < num[0]) {
        bo[plnum] = true;
        remain--;
      } else {
        if (stoi(num) != i) {
          bo[plnum] = true;
          remain--;
        }
      }
    }
    bool flag = false;
    for (int i = 1; i <= player; ++i) {
      if (!bo[i]) {
        cout << (flag ? " " : "") << i;
        flag = true;
      }
    }
    cout << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int n = 0, remain = 0, player = 0;
  int plnum = 0;
  string num = "";
  while (1) {
    bool bo[1001] = {false};
    plnum = 0;
    cin >> player >> n;
    if (player == 0 && n == 0)
      break;
    remain = player;
    for (int i = 1; i <= n; ++i) {
      cin >> num;
      if (remain == 1)
        continue;
      plnum++;
      if (plnum == player + 1)
        plnum = 1;
      while (bo[plnum]) {
        plnum++;
        if (plnum == player + 1)
          plnum = 1;
      }
      if (i % 3 == 0 || i % 5 == 0) {
        if (i % 15 == 0 && num != "FizzBuzz") {
          bo[plnum] = true;
          remain--;
        } else if (i % 3 == 0 && num != "Fizz") {
          bo[plnum] = true;
          remain--;
        } else if (i % 5 == 0 && num != "Buzz") {
          bo[plnum] = true;
          remain--;
        }
      } else {
        if (stoi(num) != i) {
          bo[plnum] = true;
          remain--;
        }
      }
    }
    bool flag = false;
    for (int i = 1; i <= player; ++i) {
      if (!bo[i]) {
        cout << (flag ? " " : "") << i;
        flag = true;
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstring>
#include <iostream>
#include <sstream>

using namespace std;

const int MAX = 1010;
bool fail[MAX];

bool isOK(const string &s, int n) {
  if (n % 15 == 0)
    return s == "FizzBuzz";
  if (n % 5 == 0)
    return s == "Buzz";
  if (n % 3 == 0)
    return s == "Fizz";

  stringstream ss(s);
  int a;
  ss >> a;
  return a == n;
}

int main() {

  int m, n;
  while (cin >> m >> n && m + n) {
    memset(fail, false, sizeof(fail));
    fail[0] = true;

    int rem = m;
    int player = 1;
    for (int i = 1; i <= n; i++) {
      string s;
      cin >> s;
      if (rem == 1)
        continue;
      while (fail[player])
        player = (player + 1) % (m + 1);
      if (!isOK(s, i)) {
        fail[player] = true;
        rem--;
      }
      player = (player + 1) % (m + 1);
    }

    bool f = false;

    for (int i = 1; i <= m; i++) {
      if (fail[i])
        continue;
      if (f)
        cout << " ";
      cout << i;
      f = true;
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;
const int MAX = 10001;
bool alive[MAX];
int m, n;

void init() {
  memset(alive, true, sizeof(alive));
  // for(int i = 0; i < m; i++) alive[i] = true;
}

string toS(int num) {
  string s = "";

  while (num) {
    s += (num % 10) + '0';
    num /= 10;
  }
  reverse(s.begin(), s.end());

  return s;
}

bool isright(string in, int num) {
  if (num % 15 == 0)
    return (in == "FizzBuzz");
  if (num % 5 == 0)
    return (in == "Buzz");
  if (num % 3 == 0)
    return (in == "Fizz");
  return (in == toS(num));
}

int next(int now) {
  while (1) {
    now++;
    now %= m;
    if (alive[now])
      return now;
  }
}

void print() {
  bool f = false;

  for (int i = 0; i < m; i++) {
    if (f)
      cout << " ";
    if (alive[i]) {
      cout << i + 1;
      f = true;
    }
  }
  cout << endl;
}

int main() {
  while (cin >> m >> n && m + n) {
    init();
    int now = 0;
    for (int i = 0; i < n; i++) {
      string in;
      cin >> in;
      if (!isright(in, i + 1))
        alive[now] = false;
      now = next(now);
    }
    print();
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int CheckAnswer(int, string);
int Atoi(const string);

int main() {
  int i, j, m, n;
  string s;
  vector<int> data;

  while (1) {
    cin >> m >> n;
    if (m == 0 && n == 0)
      break;

    for (i = 0; i < m; ++i)
      data.push_back(i + 1);

    for (i = 0, j = 0; i < n; ++i, ++j) {
      cin >> s;

      if (data.size() != 1) {
        if (CheckAnswer(i + 1, s) == 0) {
          data.erase(data.begin() + j);
          --j;
        }
        if (j >= data.size() - 1)
          j = -1;
      }
    }

    for (i = 0; i < data.size() - 1; ++i)
      cout << data[i] << " ";
    cout << data[data.size() - 1] << endl;

    data.clear();
  }

  return 0;
}

int CheckAnswer(int n, string s) {
  int x, ans = 0;

  if (n % 15 == 0) {
    if (s == "FizzBuzz")
      ans = 1;
  } else if (n % 5 == 0) {
    if (s == "Buzz")
      ans = 1;
  } else if (n % 3 == 0) {
    if (s == "Fizz")
      ans = 1;
  } else {
    if (s != "FizzBuzz" || s != "Buzz" || s != "Fizz") {
      x = Atoi(s);
      if (x == n)
        ans = 1;
    }
  }

  return ans;
}

int Atoi(const string c) {
  int i, x = 0, digit = 1;

  for (i = c.size() - 1; i >= 0; --i) {
    x = x + (c[i] - 48) * digit;
    digit *= 10;
  }
  return x;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int CheckAnswer(int, string);
int Atoi(const string);

int main() {
  int i, j, m, n;
  string s;
  vector<int> data;

  while (1) {
    cin >> m >> n;
    if (m == 0 && n == 0)
      break;

    for (i = 0; i < m; ++i)
      data.push_back(i + 1);

    for (i = 0, j = 0; i < n; ++i, ++j) {
      cin >> s;
      if (CheckAnswer(i + 1, s) == 0) {
        data.erase(data.begin() + j);
        --j;
      }
      if (j >= data.size() - 1)
        j = -1;
    }

    for (i = 0; i < data.size() - 1; ++i)
      cout << data[i] << " ";
    cout << data[data.size() - 1] << endl;

    data.clear();
  }

  return 0;
}

int CheckAnswer(int n, string s) {
  int x, ans = 0;

  if (n % 15 == 0) {
    if (s == "FizzBuzz")
      ans = 1;
  } else if (n % 5 == 0) {
    if (s == "Buzz")
      ans = 1;
  } else if (n % 3 == 0) {
    if (s == "Fizz")
      ans = 1;
  } else {
    if (s != "FizzBuzz" || s != "Buzz" || s != "Fizz") {
      x = Atoi(s);
      if (x == n)
        ans = 1;
    }
  }

  return ans;
}

int Atoi(const string c) {
  int i, x = 0, digit = 1;

  for (i = c.size() - 1; i >= 0; --i) {
    x = x + (c[i] - 48) * digit;
    digit *= 10;
  }
  return x;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s;
  int n, m, mem, plnum;
  while (1) {
    int cnt = 0;
    plnum = 1;
    cin >> m >> n;
    if (m == 0 && n == 0)
      break;
    bool pl[m + 1];
    memset(pl, true, sizeof(pl));
    for (int i = 1; i <= n; i++) {
      cin >> s;
      if (i % 15 == 0) {
        if (s != "FizzBuzz") {
          pl[plnum] = false;
          cnt++;
        }
      } else if (i % 3 == 0) {
        if (s != "Fizz") {
          cnt++;
          pl[plnum] = false;
        }
      } else if (i % 5 == 0) {
        if (s != "Buzz") {
          cnt++;
          pl[plnum] = false;
        }
      } else if (i != atoi(s.c_str())) {
        cnt++;
        pl[plnum] = false;
      }
      if (m - cnt == 1) {
        for (int j = i + 1; j <= n; j++)
          cin >> s;
        break;
      }
      do {
        (plnum == m) ? plnum = 1 : plnum++;
      } while (!pl[plnum]);
    }
    for (int i = 1; i <= m; i++) {
      if (pl[i])
        mem = i;
    }
    for (int i = 1; i <= mem; i++) {
      if (pl[i]) {
        (i == mem) ? cout << i << endl : cout << i << " ";
      }
    }
  }
}

Error: 0

Fixed submission:

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

int main() {
  string s;
  int n, m, mem = 0, sta = 0, plnum = 1;
  while (1) {
    int cnt = 0;
    cin >> m >> n;
    if (m == 0 && n == 0)
      break;
    bool pl[m + 1];
    memset(pl, true, sizeof(pl));
    for (int i = 1; i <= n; i++) {
      cin >> s;
      if (i % 15 == 0 && s != "FizzBuzz") {
        pl[plnum] = false;
        cnt++;
        sta++;
      } else if (i % 3 == 0 && s != "Fizz") {
        cnt++;
        sta++;
        pl[plnum] = false;
      } else if (i % 5 == 0 && s != "Buzz") {
        cnt++;
        sta++;
        pl[plnum] = false;
      }
      if (m - cnt == 1) {
        for (int j = i + 1; j <= n; j++)
          cin >> s;
        break;
      }
      while (!pl[plnum]) {
        (plnum == m) ? plnum = 1 : plnum++;
      }
    }
    for (int i = 1; i <= m; i++) {
      if (pl[i])
        mem = i;
    }
    for (int i = 1; i <= mem; i++) {
      if (pl[i]) {
        (i == mem) ? cout << i << endl : cout << i << " ";
      }
    }
  }
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

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

string to_s(int n) {
  string s;
  while (n) {
    s += n % 10 + '0';
    n /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
string FizzBuzz(int n) {
  if (n % 3 == 0 && n % 5 == 0)
    return "FizzBuzz";
  if (n % 3 == 0)
    return "Fizz";
  if (n % 5 == 0)
    return "Buzz";
  return to_s(n);
}

int main() {
  int m, n;
  bool f[1000];
  while (cin >> m >> n, m | n) {
    fill_n(f, m, true);
    string s;
    int rest = m;
    int num = 1, a = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      if (rest == 1)
        continue;
      while (!f[a]) {
        a = (a + 1) % m;
      }
      if (s != FizzBuzz(num)) {
        f[a] = false;
        rest--;
      }
      a = (a + 1) % m;
      num++;
    }
    bool first = true;
    for (int i = 0; i < m; i++) {
      if (!f[i])
        continue;
      if (!first)
        cout << ' ';
      first = false;
      cout << i + 1;
    }
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

string to_s(int n) {
  string s;
  while (n) {
    s += n % 10 + '0';
    n /= 10;
  }
  reverse(s.begin(), s.end());
  return s;
}
string FizzBuzz(int n) {
  if (n % 3 == 0 && n % 5 == 0)
    return "FizzBuzz";
  if (n % 3 == 0)
    return "Fizz";
  if (n % 5 == 0)
    return "Buzz";
  return to_s(n);
}

int main() {
  int m, n;
  bool f[1000];
  while (cin >> m >> n, m | n) {
    fill_n(f, m, true);
    string s;
    int rest = m;
    int num = 1, a = 0;
    for (int i = 0; i < n; i++) {
      cin >> s;
      if (rest == 1)
        break;
      while (!f[a]) {
        a = (a + 1) % m;
      }
      if (s != FizzBuzz(num)) {
        f[a] = false;
        rest--;
      }
      a = (a + 1) % m;
      num++;
    }
    bool first = true;
    for (int i = 0; i < m; i++) {
      if (!f[i])
        continue;
      if (!first)
        cout << ' ';
      first = false;
      cout << i + 1;
    }
    cout << endl;
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, Q;

  while (cin >> N >> Q, N) {
    vector<int> alive(N);
    iota(alive.begin(), alive.end(), 1);

    int person = 0, alive_cnt = N, game_end = false;
    for (int word = 1; word <= Q; word++) {
      string s;
      cin >> s;

      if (game_end)
        continue;

      bool ok = true;
      if (word % 15 == 0) {
        if (s != "FizzBuzz")
          ok = false;
      } else if (word % 3 == 0) {
        if (s != "Fizz")
          ok = false;
      } else if (word % 5 == 0) {
        if (s != "Buzz")
          ok = false;
      } else {
        if (s != to_string(word))
          ok = false;
      }

      if (!ok) {
        alive.erase(alive.begin() + person);
        person %= alive.size();
        alive_cnt--;
        if (alive_cnt == 1)
          game_end = true;
      } else {
        person = (person + 1) % alive.size();
      }
    }

    for (size_t i = 0; i < alive.size(); i++) {
      cout << alive[i] << " \\n"[i + 1 == alive.size()];
    }
  }
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int N, Q;

  while (cin >> N >> Q, N) {
    vector<int> alive(N);
    iota(alive.begin(), alive.end(), 1);

    int person = 0, alive_cnt = N;
    for (int word = 1; word <= Q; word++) {
      string s;
      cin >> s;

      bool ok = true;
      if (word % 15 == 0) {
        if (s != "FizzBuzz")
          ok = false;
      } else if (word % 3 == 0) {
        if (s != "Fizz")
          ok = false;
      } else if (word % 5 == 0) {
        if (s != "Buzz")
          ok = false;
      } else {
        if (to_string(word) != s)
          ok = false;
      }

      if (!ok) {
        alive.erase(alive.begin() + person);
        if (alive_cnt == 1)
          break;
      } else {
        person = (person + 1) % alive.size();
      }
    }

    for (size_t i = 0; i < alive.size(); i++) {
      cout << alive[i] << " \\n"[i + 1 == alive.size()];
    }
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

bool judge(const int x, const char str[]) {

  char ans[1000];

  if (x % 3 == 0 && x % 5 == 0)
    strcpy(ans, "FizzBuzz");
  else if (x % 3 == 0)
    strcpy(ans, "Fizz");
  else if (x % 5 == 0)
    strcpy(ans, "Buzz");
  else
    sprintf(ans, "%d", x);

  /*
  cout << "judge" << endl;
  cout << "-" << str << "-" << endl;
  cout << "-" << ans << "-" << endl;
  */
  if (strcmp(ans, str))
    return false;

  return true;
}

int main(void) {
  int m, n;
  while (scanf("%d%d", &m, &n) && m != 0 && n != 0) {

    queue<int> Q;
    char str[1000];
    vector<int> ans;

    for (int i = 1; i <= m; i++)
      Q.push(i);

    for (int i = 1; i <= n; i++) {
      scanf("%s", str);
      if (Q.size() == 1)
        continue;

      if (judge(i, str)) {
        Q.push(Q.front());
        Q.pop();
      } else {
        Q.pop();
      }
    }

    while (!Q.empty()) {
      ans.push_back(Q.front());
      Q.pop();
    }

    sort(ans.begin(), ans.end());

    for (int i = 0; i < ans.size(); i++) {
      printf("%d%s", ans[i], i == ans.size() - 1 ? "\\n" : " ");
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int m, n;
  int i, j = 0, k, ans = 1, num, c = 0;
  bool player[1001] = {0}, flag = 0, fl2 = 0;
  char str[10], coll[10];

  for (;;) {
    scanf("%d %d", &m, &n);
    if (m == 0)
      break;
    for (i = 0; i < m; i++) {
      player[i] = 1;
    }
    for (i = 0; i < n; i++) {
      scanf("%s", str);
      if (fl2 == 0) {
        if (ans % 3 == 0 && ans % 5 == 0) {
          strcpy(coll, "FizzBuzz");
          if (strcmp(coll, str)) {
            flag = 1;
          }
        } else if (ans % 3 == 0) {
          strcpy(coll, "Fizz");
          if (strcmp(coll, str)) {
            flag = 1;
          }
        } else if (ans % 5 == 0) {
          strcpy(coll, "Buzz");
          if (strcmp(coll, str)) {
            flag = 1;
          }
        } else {
          num = atoi(str);
          if (num != ans) {
            flag = 1;
          }
        }
        for (; j < m; j++) {
          if (player[j] == 1) {
            if (flag == 1) {
              player[j] = 0;
              flag = 0;
            }
            break;
          }
        }
      }
      for (k = 0; k < m; k++) {
        if (player[k] == 1) {
          c++;
        }
      }
      if (c == 1)
        fl2 = 1;
      c = 0;
      j++;
      if (j == m)
        j = 0;
      ans++;
    }
    flag = 0;
    for (i = 0; i < m; i++) {
      if (player[i] == 1) {
        if (flag == 1)
          printf(" ");
        printf("%d", i + 1);
        flag = 1;
      }
    }
    printf("\\n");
    j = 0;
    ans = 1;
    flag = 0;
    fl2 = 0;
  }
  return 0;
}