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

#include <bits/stdc++.h>
using namespace std;
#define EPS 1e-14
int stringintoint(string s) {
  int res = 0;
  int X = 1;
  for (int i = (int)s.length() - 1; i >= 0; i--) {
    res += (s[i] - '0') * X;
    X *= 10;
  }
  return res;
}
int main() {
  while (true) {
    int M, N;
    scanf("%d%d", &M, &N);
    if (M == 0 && N == 0)
      break;
    vector<int> ans;
    for (int i = 0; i < M; i++)
      ans.push_back(i);
    int x = 0;
    for (int i = 1; i <= N; i++) {
      string S;
      cin >> S;
      if (i % 15 == 0) {
        if (S != "FizzBuzz") {
          ans.erase(ans.begin() + x);
          x--;
        }
        x++;
      } else if (i % 3 == 0) {
        if (S != "Fizz") {
          ans.erase(ans.begin() + x);
          x--;
        }
        x++;
      } else if (i % 5 == 0) {
        if (S != "Buzz") {
          ans.erase(ans.begin() + x);
          x--;
        }
        x++;
      } else {
        if (stringintoint(S) != i) {
          ans.erase(ans.begin() + x);
          x--;
        }
        x++;
      }
      if (x >= (int)ans.size()) {
        x = 0;
      }
    }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define EPS 1e-14
int stringintoint(string s) {
  int res = 0;
  int X = 1;
  for (int i = (int)s.length() - 1; i >= 0; i--) {
    res += (s[i] - '0') * X;
    X *= 10;
  }
  return res;
}
int main() {
  while (true) {
    int M, N;
    scanf("%d%d", &M, &N);
    if (M == 0 && N == 0)
      break;
    bool flag[10009];
    for (int i = 0; i < 10009; i++)
      flag[i] = true;
    int x = 0;
    for (int i = 1; i <= N; i++) {
      string S;
      cin >> S;
      if (i % 15 == 0) {
        if (S != "FizzBuzz") {
          flag[x] = false;
        }
        x++;
      } else if (i % 3 == 0) {
        if (S != "Fizz") {

          flag[x] = false;
        }
        x++;
      } else if (i % 5 == 0) {
        if (S != "Buzz") {
          flag[x] = false;
        }
        x++;
      } else {
        if (stringintoint(S) != i) {
          flag[x] = false;
        }
        x++;
      }
      if (x == M)
        x = 0;
      while (!flag[x]) {
        x++;
        if (x == M)
          x = 0;
      }
    }
    vector<int> ans;
    for (int i = 0; i < M; i++) {
      if (flag[i])
        ans.push_back(i);
    }
    printf("%d", ans[0] + 1);
    for (int i = 1; i < (int)ans.size(); i++) {
      printf(" %d", ans[i] + 1);
    }
    printf("\\n");
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int m, n;

  while (cin >> m >> n && (m || n)) {
    vector<int> v;
    for (int i = 1; i <= m; i++)
      v.push_back(i);
    int now = 0;
    for (int i = 1; i <= n; i++, now = (now + 1) % v.size()) {
      stringstream ss;
      if (i % 3 == 0)
        ss << "Fizz";
      if (i % 5 == 0)
        ss << "Buzz";
      if (ss.str() == "")
        ss << i;
      string s1 = ss.str();

      string s2;
      cin >> s2;

      if (s1 != s2 && v.size() > 1) {
        v.erase(v.begin() + now);
        now--;
      }
    }

    cout << v[0];
    for (int i = 1; i < v.size(); i++)
      cout << " " << v[i];
    cout << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

vector<int> rem;

int main(void) {
  int n, m;

  while (cin >> n >> m && (n || m)) {
    rem.clear();
    for (int i = 1; i <= n; i++)
      rem.push_back(i);

    int now = 0;
    for (int i = 1; i <= m; i++, now = (now + 1) % rem.size()) {
      stringstream ss;
      if (i % 3 == 0)
        ss << "Fizz";
      if (i % 5 == 0)
        ss << "Buzz";
      if (ss.str() == "")
        ss << i;

      string si;
      cin >> si;
      if (ss.str() != si) {
        rem.erase(rem.begin() + now);
        now--;
      }
    }

    for (int i = 0; i < rem.size() - 1; i++) {
      cout << rem[i] << " ";
    }
    cout << rem[rem.size() - 1] << endl;
  }

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

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

int main() {
  using namespace std;
  int i, n, m, ps;
  char opn[20], ans[20];
  bool ff, bf;
  list<int> player;
  list<int>::iterator it;
  do {
    scanf("%d %d", &m, &n);
    if (!m && !n)
      break;
    for (i = 0; i < m; i++)
      player.push_back(i + 1);
    for (i = 0, it = player.begin(), ps = m; i < n; i++) {
      scanf("%s", opn);
      if (ps < 2)
        continue;
      ff = (i + 1) % 3 == 0, bf = (i + 1) % 5 == 0;
      if (ff || bf) {
        sprintf(ans, "%s%s", ff ? "Fizz" : "", bf ? "Buzz" : "");
      } else {
        sprintf(ans, "%d", i + 1);
      }
      if (strcmp(ans, opn)) {
        it = player.erase(it);
        ps--;
      } else {
        it++;
      }
      if (it == player.end())
        it = player.begin();
    }
    it = player.begin();
    while (it != player.end()) {
      printf("%d", *it);
      it++;
      if (it != player.end())
        printf(" ");
    }
    printf("\\n");
    player.clear();
  } while (1);
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  using namespace std;
  int i, n, m, ps;
  char opn[10], ans[10];
  bool ff, bf;
  list<int> player;
  list<int>::iterator it;
  do {
    scanf("%d %d", &m, &n);
    if (!m && !n)
      break;
    for (i = 0; i < m; i++)
      player.push_back(i + 1);
    for (i = 0, it = player.begin(), ps = m; i < n; i++) {
      scanf("%s", opn);
      if (ps < 2)
        continue;
      ff = (i + 1) % 3 == 0, bf = (i + 1) % 5 == 0;
      if (ff || bf) {
        sprintf(ans, "%s%s", ff ? "Fizz" : "", bf ? "Buzz" : "");
      } else {
        sprintf(ans, "%d", i + 1);
      }
      if (strcmp(ans, opn)) {
        it = player.erase(it);
        ps--;
      } else {
        it++;
      }
      if (it == player.end())
        it = player.begin();
    }
    it = player.begin();
    while (it != player.end()) {
      printf("%d", *it);
      it++;
      if (it != player.end())
        printf(" ");
    }
    printf("\\n");
    player.clear();
  } while (1);
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main() {
  int s, t, v, a[1000];
  string str;

  while (1) {
    cin >> s >> t;
    if (s == 0 && t == 0) {
      break;
    }
    queue<int> que;

    for (int i = 1; i <= s; i++) {
      que.push(i);
    }

    for (int i = 1; i <= t; i++) {
      cin >> str;
      if (que.size() == 1) {
        continue;
      }
      if (i % 3 == 0 && i % 5 == 0) {
        if (str == "FizzBuzz") {
          que.push(que.front());
        }
      } else if (i % 3 == 0) {
        if (str == "Fizz") {
          que.push(que.front());
        }
      } else if (i % 5 == 0) {
        if (str == "Buzz") {
          que.push(que.front());
        }
      } else {
        v = atoi(str.c_str());
        if (v == i) {
          que.push(que.front());
        }
      }
      que.pop();
    }
    v = 0;
    while (!que.empty()) {
      a[v++] = que.front();
      que.pop();
    }
    sort(a, a + v);

    cout << a[0];
    for (int i = 1; i < v; i++) {
      cout << " " << a[i];
    }
    cout << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main(int argc, char **argv) {
  int n, m, *a, x, y;
  string s;

  while (1) {
    cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    }
    a = (int *)calloc(n + 1, sizeof(int));

    for (int i = 1, j = 1; i <= m; i++, j++) {
      cin >> s;

      if (j > n) {
        j = 1;
      }
      while (a[j] != 0) {
        j++;
        if (j > n) {
          j = 1;
        }
      }

      x = i % 3;
      y = i % 5;
      if (x == 0 && y == 0 && "FizzBuzz" != s) {
        a[j] = 1;
      } else if (x == 0 && s != "Fizz") {
        a[j] = 1;
      } else if (y == 0 && s != "Buzz") {
        a[j] = 1;
      } else if (x != 0 && y != 0 && s == "FizzBuzz") {
        a[j] = 1;
      } else if (x != 0 && s == "Fizz") {
        a[j] = 1;
      } else if (y != 0 && s == "Buzz") {
        a[j] = 1;
      } else if (s != "Fizz" && s != "Buzz" && s != "FizzBuzz") {
        if (i != atoi(s.c_str())) {
          a[j] = 1;
        }
      }
    }

    for (int i = 1, f = 0; i <= n; i++) {
      if (a[i] == 0) {
        if (f == 1) {
          cout << " " << i;
        } else {
          f = 1;
          cout << i;
        }
      }
    }
    cout << endl;

    free(a);
  }

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

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

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

  for (int i = 0; i < s.length(); i++)
    if (s[i] < '0' || s[i] > '9')
      return false;

  return (atoi(s.c_str()) == n);
}

int main() {
  int n, m;
  string s;

  while (scanf("%d %d\\n", &m, &n), m) {

    vector<int> rem(m);
    for (int i = 0; i < m; i++) {
      rem[i] = i + 1;
    }
    int c = 0;
    for (int i = 1; i <= n; i++) {
      getline(cin, s);
      if (rem.size() == 1)
        continue;
      if (!fizzBuzzCheck(i, s)) {
        rem.erase(remove(rem.begin(), rem.end(), rem[c]), rem.end());
      } else {
        c++;
      }
      c %= rem.size();
    }
    for (int i = 0; i < rem.size(); i++) {
      cout << (i ? " " : "") << rem[i];
    }
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c)                                                              \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1 << 29;

int main() {
  int m, n;
  while (cin >> m >> n, m || n) {
    string s;
    vector<bool> v(m, 1);
    int now = 0;
    int nownum = m;
    REP(i, n) {
      cin >> s;
      int cnt = i + 1;
      bool f = 0;
      if (cnt % 3 == 0 && cnt % 5 == 0) {
        if (s != "FizzBuzz")
          f = 1;
      } else if (cnt % 3 == 0) {
        if (s != "Fizz")
          f = 1;
      } else if (cnt % 5 == 0) {
        if (s != "Buzz")
          f = 1;
      } else if (s.size() != 1 || s[0] - '0' != cnt) {
        f = 1;
      }
      if (f) {
        v[now] = 0;
        nownum--;
        if (nownum == 0)
          break;
      }
      do {
        now = (now + 1) % m;
      } while (!v[now]);
    }
    int hoge = 0;
    REP(i, v.size()) {
      if (v[i]) {
        if (hoge)
          cout << " ";
        else
          hoge = 1;
        cout << i + 1;
      }
    }
    cout << endl;
  }
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

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

struct person {
  int num;
  struct person *prev;
  struct person *next;
};

struct person *head, *p, *now;
int m, n;
char s[128];

void set() {
  for (int i = 0; i < m; i++) {
    p[i].num = i + 1;
    p[i].prev = p + i - 1;
    p[i].next = p + i + 1;
  }
  p[0].prev = p + m - 1;
  p[m - 1].next = p;
}

void del(struct person *a) {
  (a->prev)->next = a->next;
  (a->next)->prev = a->prev;
  if (a == head)
    head = a->next;
}

void show(struct person *a) {
  std::cout << a->num;
  if (a->next == head)
    return;
  else {
    std::cout << ' ';
    show(a->next);
  }
}

int main() {
  while (true) {
    std::cin >> m >> n;
    if (!m && !n)
      return 0;
    p = new struct person[m];
    head = p;
    now = head;
    set();
    for (int i = 0; i < n; i++) {
      std::cin >> s;
      if (now == now->next) {
        continue;
      } else if ((i + 1) % 15 == 0) {
        if (strcmp(s, "FizzBuzz") != 0)
          del(now);
      } else if ((i + 1) % 3 == 0) {
        if (strcmp(s, "Fizz") != 0)
          del(now);
      } else if ((i + 1) % 5 == 0) {
        if (strcmp(s, "Buzz") != 0)
          del(now);
      } else {
        std::string str(s);
        std::istringstream ss(str);
        int a = 0;
        ss >> a;
        if (a != i + 1)
          del(now);
      }
      now = now->next;
    }
    show(head);
    std::cout << std::endl;
    delete[] p;
  }
}

Error: TLE

Fixed submission:

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

struct person {
  int num;
  struct person *prev;
  struct person *next;
};

struct person *head, *p, *now;
int m, n;
char s[128];

void set() {
  for (int i = 0; i < m; i++) {
    p[i].num = i + 1;
    p[i].prev = p + i - 1;
    p[i].next = p + i + 1;
  }
  p[0].prev = p + m - 1;
  p[m - 1].next = p;
}

void del(struct person *a) {
  (a->prev)->next = a->next;
  (a->next)->prev = a->prev;
  if (a == head)
    head = a->next;
}

void show(struct person *a) {
  std::cout << a->num;
  if (a->next == head)
    return;
  else {
    std::cout << ' ';
    show(a->next);
  }
}

int main() {
  while (true) {
    std::cin >> m >> n;
    if (!m && !n)
      return 0;
    p = new struct person[m];
    head = p;
    now = head;
    set();
    for (int i = 0; i < n; i++) {
      std::cin >> s;
      if (now == now->next) {
        goto FIN;
      } else if ((i + 1) % 15 == 0) {
        if (strcmp(s, "FizzBuzz") != 0)
          del(now);
      } else if ((i + 1) % 3 == 0) {
        if (strcmp(s, "Fizz") != 0)
          del(now);
      } else if ((i + 1) % 5 == 0) {
        if (strcmp(s, "Buzz") != 0)
          del(now);
      } else {
        std::string str(s);
        std::istringstream ss(str);
        int a = 0;
        ss >> a;
        if (a != i + 1)
          del(now);
      }
      now = now->next;
    }
  FIN:;
    show(head);
    std::cout << std::endl;
    delete[] p;
  }
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

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

string ansFizzBuzz(int n) {
  string result;
  if (n % 15 == 0) {
    result = "FizzBuzz";
  } else if (n % 3 == 0) {
    result = "Fizz";
  } else if (n % 5 == 0) {
    result = "Buzz";
  } else {
    stringstream ss;
    ss << n;
    ss >> result;
  }
  return result;
}

int main() {
  while (true) {
    int m, n;
    cin >> m >> n;
    if ((m | n) == 0) {
      break;
    }
    vector<int> players(m);
    for (int i = 0; i < m; i++) {
      players[i] = i + 1;
    }
    vector<string> lines(n);
    for (int i = 0; i < n; i++) {
      cin >> lines[i];
    }
    int pos = 0;
    for (int i = 0; i < n; i++) {
      if (players.size() <= 1) {
        break;
      }
      if (lines[i] != ansFizzBuzz(i + 1)) {
        players.erase(players.begin() + pos);
      } else {
        pos++;
      }
      pos = pos % players.size();
    }
    string result;
    for (vector<int>::iterator it = players.begin(); it != players.end();
         it++) {
      stringstream ss;
      ss << *it;
      result += " " + ss.str();
    }
    result.erase(0, 1);
    cout << result << endl;
  }
}

Error: TLE

Fixed submission:

#include <cstdlib>
#include <cstring>
#include <iostream>

using namespace std;

int main() {
  int m, n;
  while (cin >> m >> n, m + n) {
    int p = 1;
    int p_num = m;
    bool exist[1001];
    memset(exist, true, sizeof(exist));

    for (int i = 1; i <= n; i++) {
      bool ok;
      if (i % 3 != 0 && i % 5 != 0) {
        int com;
        cin >> com;
        ok = com == i;
      } else {
        string com;
        cin >> com;
        if (i % 15 == 0) {
          ok = com == "FizzBuzz";
        } else if (i % 3 == 0) {
          ok = com == "Fizz";
        } else if (i % 5 == 0) {
          ok = com == "Buzz";
        } else
          ok = false;
      }

      if (!ok) {
        exist[p] = false;
        p_num--;
      }
      if (p_num == 1)
        break;
      do {
        if (++p > m)
          p = 1;
      } while (!exist[p]);
    }

    int i = 1;
    while (i <= m && !exist[i])
      i++;
    if (i <= m)
      cout << i;
    i++;
    while (i <= m) {
      if (exist[i])
        cout << " " << i;
      i++;
    }
    cout << endl;
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  int a, b;
  while (cin >> a >> b, a || b) {
    vector<bool> me(a, true);
    int k = 0;
    int co = 0;
    loop(i, 1, b + 1) {
      string s;
      cin >> s;
      bool h = false;
      if (i % 15 == 0) {
        if (s == "FizzBuzz")
          h = true;
      } else if (i % 5 == 0) {
        if (s == "Buzz")
          h = true;
      } else if (i % 3 == 0) {
        if (s == "Fizz")
          h = true;
      } else if (atoi(&s[0]) == i)
        h = true;
      while (1) {
        if (!me[k]) {
          k++;
          if (k == a)
            k = 0;
        } else
          break;
      }
      if (!h) {
        co++;
        me[k] = false;
      }
      if (co + 1 == a) {
        rep(q, b - i) cin >> s;
        break;
      }
      k++;
      if (k == a)
        k = 0;
    }
    vector<int> out;
    rep(i, a) if (me[i]) out.pb(i + 1);
    rep(i, out.size() - 1) cout << out[i] << " ";
    cout << out[out.size() - 1] << endl;
  }
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  int a, b;
  while (cin >> a >> b, a || b) {
    vector<bool> me(a, true);
    int k = 0;
    int co = 0;
    loop(i, 1, b + 1) {
      string s;
      cin >> s;
      bool h = false;
      if (i % 15 == 0) {
        if (s == "FizzBuzz")
          h = true;
      } else if (i % 5 == 0) {
        if (s == "Buzz")
          h = true;
      } else if (i % 3 == 0) {
        if (s == "Fizz")
          h = true;
      } else if (atoi(&s[0]) == i)
        h = true;
      while (1) {
        if (!me[k]) {
          k++;
          if (k == b)
            k = 0;
        } else
          break;
      }
      if (!h) {
        co++;
        me[k] = false;
      }
      if (co + 1 == a) {
        rep(q, b - i) cin >> s;
        break;
      }
      k++;
      if (k == b)
        k = 0;
    }
                /*vector<int>out;
		rep(i,a)if(me[i])out.pb(i+1);
		rep(i,out.size()-1)cout<<out[i]<<" ";
		cout<<out[out.size()-1]<<endl;
	*/}
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int m, n;
string s;
vector<int> vec;
int main() {
  while (cin >> m >> n, m) {
    int cnt = 0;
    vec.clear();
    for (int i = 1; i <= m; i++)
      vec.push_back(i);
    for (int i = 1; i <= n; i++) {
      cin >> s;
      if (i % 15 == 0) {
        if (s != "FizzBuzz" && vec.size() - 1)
          vec.erase(vec.begin() + cnt);
        else
          cnt++;
      } else if (i % 3 == 0) {
        if (s != "Fizz" && vec.size() - 1)
          vec.erase(vec.begin() + cnt);
        else
          cnt++;
      } else if (i % 5 == 0) {
        if (s != "Buzz" && vec.size() - 1)
          vec.erase(vec.begin() + cnt);
        else
          cnt++;
      } else {
        if (s != to_string(i) && vec.size() - 1)
          vec.erase(vec.begin() + cnt);
        else
          cnt++;
      }
      cnt %= vec.size();
    }
    for (int i = 0; i < vec.size(); i++) {
      if (i)
        cout << " ";
      cout << vec[i];
    }
    cout << endl;
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  int m, n;
  while (1) {
    cin >> m;
    if (m == 0)
      break;
    cin >> n;
    vector<int> v;
    string s;
    rep(i, m) v.push_back(i + 1);
    for (int i = 1; i <= n; i++) {
      cin >> s;
      if (i % 3 == 0 && s != "Fizz")
        v.erase(v.begin());
      else if (i % 5 == 0 && s != "Buzz")
        v.erase(v.begin());
      else if (i % 15 == 0 && s != "FizzBuzz")
        v.erase(v.begin());
      else {
        v.push_back(v[0]);
        v.erase(v.begin());
      }
      // for(int k=0; k<v.size(); k++) cout<<v[k]<<" "; cout<<endl;
    }
    sort(v.begin(), v.end());
    rep(i, (int)v.size()) {
      if (i > 0)
        cout << " " << v[i];
      else
        cout << v[i];
    }
    cout << endl;
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int m, n, s, i;
  char no[100];
  while (cin >> m >> n, m != 0 || n != 0) {
    queue<int> q;
    for (int j = 0; j < m; j++)
      q.push(j + 1);
    i = 1;
    while (n--) {
      if (q.size() != 1) {
        cin >> no;
        int p = q.front();
        q.pop();
        if (i % 3 == 0 && i % 5 == 0) {
          if (strcmp(no, "FizzBuzz") == 0)
            q.push(p);
        } else if (i % 3 == 0 && strcmp(no, "Fizz") == 0)
          q.push(p);
        else if (i % 5 == 0 && strcmp(no, "Buzz") == 0)
          q.push(p);
        else if (i % 3 != 0 && i % 5 != 0 && i == atoi(no))
          q.push(p);
        i++;
      } else
        cin >> no;
    }

    vector<int> v(1050);
    while (q.size()) {
      v.push_back(q.front());
      q.pop();
    }
    sort(v.begin(), v.end());
    while (v.size()) {
      if (v[0]) {
        cout << v[0];
        if (v.size() - 1)
          cout << ' ';
      }
      v.erase(v.begin());
    }
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

using namespace std;

int main() {
  int m, n, s, i;
  while (cin >> m >> n, m != 0 || n != 0) {
    queue<int> q;

    for (int j = 0; j < m; j++)
      q.push(j + 1);
    i = 1;
    while (n--) {
      if (q.size() != 1) {
        string no;
        cin >> no;
        int p = q.front();
        q.pop();
        if (p % 3 == 0 && p % 5 == 0) {
          if (no == "FizzBuzz")
            q.push(p);
        } else if (i % 3 == 0 && no == "Fizz")
          q.push(p);
        else if (i % 5 == 0 && no == "Buzz")
          q.push(p);
        else if (i % 3 != 0 && i % 5 != 0 && '0' <= no[0] && no[0] <= '9')
          q.push(p);
        i++;
      }
    }
    vector<int> v(1050);
    while (q.size()) {
      v.push_back(q.front());
      q.pop();
    }
    sort(v.begin(), v.end());
    while (v.size()) {
      if (v[0]) {
        cout << v[0];
        if (v.size() - 1)
          cout << ' ';
      }
      v.erase(v.begin());
    }
    cout << endl;
  }
  return 0;
}