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

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

int main() {
  int M, N;

  while (cin >> M >> N, M != 0 && N != 0) {
    bool flag[1005] = {};
    int jb = 0;
    int cnt = 1;
    int d = 0;
    bool lock = false;
    while (cnt <= N) {
      string S;
      cin >> S;
      if (!lock) {
        if (S == "FizzBuzz") {
          if (cnt % 15 != 0) {
            flag[jb] = true;
            d++;
          }
        } else if (S == "Fizz") {
          if (cnt % 3 != 0 || cnt % 15 == 0) {
            flag[jb] = true;
            d++;
          }
        } else if (S == "Buzz") {
          if (cnt % 5 != 0 || cnt % 15 == 0) {
            flag[jb] = true;
            d++;
          }
        } else {
          int val = atoi(S.c_str());
          if (val != cnt || cnt % 3 == 0 || cnt % 5 == 0) {
            flag[jb] = true;
            d++;
          }
        }
        if (d == M - 1) {
          lock = true;
        }
        (jb += 1) %= M;
        while (flag[jb]) {
          (jb += 1) %= M;
        }
      }
      cnt++;
    }
    vector<int> ans;
    for (int i = 0; i < M; i++) {
      if (!flag[i]) {
        ans.push_back(i + 1);
      }
    }
    cout << ans[0];
    for (int i = 1; i < ans.size(); i++) {
      cout << " " << ans[i];
    }
    cout << endl;
  }
  return (0);
}


Error: TLE

Fixed submission:

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

int main() {
  int M, N;

  while (cin >> M >> N, M != 0 && N != 0) {
    bool flag[1005] = {};
    int jb = 0;
    int cnt = 1;
    int d = 0;
    bool lock = false;
    while (cnt <= N) {
      string S;
      cin >> S;
      while (!lock) {
        if (S == "FizzBuzz") {
          if (cnt % 15 != 0) {
            flag[jb] = true;
            d++;
          }
        } else if (S == "Fizz") {
          if (cnt % 3 != 0 || cnt % 15 == 0) {
            flag[jb] = true;
            d++;
          }
        } else if (S == "Buzz") {
          if (cnt % 5 != 0 || cnt % 15 == 0) {
            flag[jb] = true;
            d++;
          }
        } else {
          int val = atoi(S.c_str());
          if (val != cnt || cnt % 3 == 0 || cnt % 5 == 0) {
            flag[jb] = true;
            d++;
          }
        }
        if (d == M - 1) {
          lock = true;
        }
        (jb += 1) %= M;
        while (flag[jb]) {
          (jb += 1) %= M;
        }
      }
      cnt++;
    }
    vector<int> ans;
    for (int i = 0; i < M; i++) {
      if (!flag[i]) {
        ans.push_back(i + 1);
      }
    }
    cout << ans[0];
    for (int i = 1; i < ans.size(); i++) {
      cout << " " << ans[i];
    }
    cout << endl;
  }
  return (0);
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  string s;
  while (cin >> n >> m, n) {
    vector<int> v;
    for (int i = 0; i < n; i++)
      v.push_back(i + 1);
    for (int i = 1; i <= m; i++) {
      cin >> s;
      if (i % 3 == 0 && i % 5 == 0) {
        if (s != "FizzBuzz")
          v.erase(v.begin());
        else {
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      } else if (i % 3 == 0) {
        if (s != "Fizz")
          v.erase(v.begin());
        else {
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      } else if (i % 5 == 0) {
        if (s != "Buzz")
          v.erase(v.begin());
        else {
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      } else {
        stringstream ss(s);
        int p;
        ss >> p;
        if (p != i)
          v.erase(v.begin());
        else {
          v.push_back(v[0]);
          v.erase(v.begin());
        }
      }
      if ((int)v.size() == 1) {
        for (; i < m; i++)
          cin >> s;
        break;
      }
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < v.size(); i++) {
      if (i)
        cout << ' ';
      cout << v[i];
    }
    cout << endl;
  }
}

Error: TLE

Fixed submission:

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

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

/*int sea(string s){
        reverse(s.begin(),s.end());
        int sum=0;
        for(int i=0;i<s.size();i++){
                sum+=(s[i]-'0')*(int)pow(10,i);
        }
        return sum;
        }*/

string correct(int i) {
  if (i % 3 == 0 && i % 5 == 0)
    return "FizzBuzz";
  else if (i % 3 == 0)
    return "Fizz";
  else if (i % 5 == 0)
    return "Buzz";
  else
    return to_string(i);
}

int main() {
  while (1) {

    int m, n;
    int a[10000] = {};
    set<int> done;
    cin >> m >> n;
    if (m == 0 && n == 0) {
      break;
    }
    for (int i = 0; i < m; i++) {
      a[i] = i + 1;
    }
    a[m] = 1;
    int b = m;
    int w = 1;
    int count = 0;
    for (int i = 1; i <= n; i++) {
      string s;
      bool j = true;
      cin >> s;
      if (count < m - 1) {
        /*if(i%15==0 && s!="FizzBuzz"){j=false;}
        else if(i%5==0 && s!="Buzz"){j=false;}
        else if(i%3==0 && s!="Fizz"){j=false;}
        if(i%15!=0 && i%5!=0 && i%3!=0 && ){j=false;}
        if(j){b=w; w=a[w];}
        if(!j){
        }*/
        if (correct(i) != s) {
          done.insert(i);
          a[b] = a[w];
          done.insert(w);
          w = a[w];
          count++;
        } else {
          b = w;
          w = a[w];
        }
      }
    }
    bool d = true;
    for (int i = 1; i <= m; i++) {
      if (done.find(i) == done.end()) {
        if (d) {
          cout << i;
          d = false;
        } else {
          cout << " " << i;
        }
      }
    }
    cout << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  while (1) {

    int m, n;
    int a[10000] = {};
    set<int> done;
    cin >> m >> n;
    if (m == 0 && n == 0) {
      break;
    }
    for (int i = 0; i < m; i++) {
      a[i] = i + 1;
    }
    a[m] = 1;
    int b = m;
    int w = 1;
    int count = 0;
    for (int i = 1; i <= n; i++) {
      string s;
      bool j = true;
      cin >> s;
      if (i % 15 == 0 && s != "FizzBuzz") {
        j = false;
      } else if (i % 5 == 0 && s != "Buzz") {
        j = false;
      } else if (i % 3 == 0 && s != "Fizz") {
        j = false;
      }
      if (i % 15 != 0 && i % 5 != 0 && i % 3 != 0 &&
          (s[0] != '0' + i || s.size() != 1)) {
        j = false;
      }
      if (j) {
        b = w;
        w = a[w];
      }
      if (!j) {
        a[b] = a[w];
        done.insert(w);
        w = a[w];
        count++;
      }
      if (count >= m - 1) {
        break;
      }
    }
    bool d = true;
    for (int i = 1; i <= m; i++) {
      if (done.find(i) == done.end()) {
        if (d) {
          cout << i;
          d = false;
        } else {
          cout << " " << i;
        }
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int power(int num) {
  int ans = 1;
  for (int i = 0; i < num; i++)
    ans *= 10;
  return ans;
}
int main() {
  int n, m;
  while (cin >> m >> n, n, m) {
    string str, fb[3] = {"FizzBuzz", "Fizz", "Buzz"};
    bool player[1000] = {};
    for (int i = 1, now = 0, out = m; i <= n; i++, now = (now + 1) % m) {
      cin >> str;
      int num = 0, co = -1;
      if (out > 1) {
        while (player[now])
          now = (now + 1) % m;
        if (i % 15 < 1)
          co = 0;
        else if (i % 3 < 1)
          co = 1;
        else if (i % 5 < 1)
          co = 2;
        else {
          for (int j = 0; j < str.size(); j++)
            num += (str[j] - '0') * power(str.size() - 1 - j);
          if (num != i)
            player[now] = 1;
        }
        if (co > -1 && str != fb[co] || co < 0 && i != num)
          player[now] = 1;
        if (player[now])
          out--;
      }
    }
    for (int i = 0, co = 0; i < m; i++) {
      if (co == 0 && !player[i]) {
        cout << i + 1;
        co++;
      } else if (!player[i])
        cout << " " << i + 1;
    }
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int power(int num) {
  int ans = 1;
  for (int i = 0; i < num; i++)
    ans *= 10;
  return ans;
}
int main() {
  int n, m, zi[3] = {15, 3, 5};
  while (cin >> m >> n, n, m) {
    string str, fb[3] = {"FizzBuzz", "Fizz", "Buzz"};
    bool player[1000] = {};
    for (int i = 1, now = 0, out = m; i <= n; i++, now = (now + 1) % m) {
      cin >> str;
      int co = -1;
      if (out > 1) {
        while (player[now])
          now = (now + 1) % m;
        for (int j = 0; j < 3; j++)
          if (i % zi[j] < 1)
            co = j;
        if (co > -1 && str != fb[co])
          player[now] = 1;
        if (co < 0) {
          int num = 0;
          for (int j = 0; j < str.size(); j++)
            num += (str[j] - '0') * power(str.size() - 1 - j);
          if (num != i && co < 0)
            player[now] = 1;
          if (player[now])
            out--;
        }
      }
    }
    for (int i = 0, co = 0; i < m; i++) {
      if (co == 0 && !player[i]) {
        cout << i + 1;
        co++;
      } else if (!player[i])
        cout << " " << i + 1;
    }
    cout << endl;
  }
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int power(int num) {
  int ans = 1;
  for (int i = 0; i < num; i++)
    ans *= 10;
  return ans;
}
int main() {
  int n, m;
  while (cin >> m >> n, n, m) {
    string str;
    bool player[1000] = {};
    for (int i = 1, now = 0, out = m; i <= n; i++, now = (now + 1) % m) {
      cin >> str;
      if (out > 1) {
        while (player[now])
          now = (now + 1) % m;
        if (i % 15 == 0 && str != "FizzBuzz" ||
            i % 3 == 0 && i % 5 > 0 && str != "Fizz" ||
            i % 5 == 0 && i % 3 > 0 && str != "Buzz")
          player[now] = 1;
        else if (i % 3 > 0 && i % 5 > 0) {
          int num = 0;
          for (int j = 0; j < str.size(); j++)
            num += (str[j] - '0') * power(str.size() - 1 - j);
          if (num != i)
            player[now] = 1;
        }
        if (player[now])
          out--;
      }
    }
    for (int i = 0, co = 0; i < m; i++) {
      if (co == 0 && !player[i]) {
        cout << i + 1;
        co++;
      } else if (!player[i])
        cout << " " << i + 1;
    }
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (cin >> m >> n, n, m) {
    string str;
    bool player[1000] = {};
    for (int i = 1, now = 0, out = m; i <= n; i++, now = (now + 1) % m) {
      while (player[now] && out)
        now = (now + 1) % m;
      cin >> str;
      if (i % 3 == 0 && i % 5 == 0 && str != "FizzBuzz" ||
          i % 3 == 0 && str != "Fizz" || i % 5 == 0 && str != "Buzz")
        player[now] = 1;
      else if (i % 3 > 0 && i % 5 > 0) {
        int num = 0;
        for (int j = 0; j < str.size(); j++)
          num += (str[j] - '0') * pow(10, str.size() - 1 - j);
        if (num != i)
          player[now] = 1;
      }
      if (player[now])
        out--;
    }
    for (int i = 0, co = 0; i < m; i++) {
      if (co == 0 && !player[i]) {
        cout << i + 1;
        co++;
      } else if (!player[i])
        cout << " " << i + 1;
    }
    cout << endl;
  }
}
Problem p00221 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

bool check(string s, int cnt) {
  if (cnt % 15 == 0)
    return s == "FizzBuzz";
  if (cnt % 5 == 0)
    return s == "Buzz";
  if (cnt % 3 == 0)
    return s == "Fizz";
  rep(i, s.size()) {
    if (s[i] < '0' || s[i] > '9')
      return false;
  }
  return atoi(s.c_str()) == cnt;
}

int main() {
  int m, n;
  while (cin >> m >> n, m | n) {
    vector<int> player(m);
    rep(i, m) player[i] = i;

    int p = 0;
    FOR(i, 1, n + 1) {
      string s;
      cin >> s;
      if (player.size() == 1)
        continue;

      if (!check(s, i))
        player.erase(player.begin() + p);
      else
        p++;
      p %= player.size();
    }
    rep(i, player.size()) { cout << (i ? " " : "") << player[i] + 1; }
    cout << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

bool check(string s, int cnt) {
  if (cnt % 15 == 0)
    return s == "FizzBuzz";
  if (cnt % 5 == 0)
    return s == "Buzz";
  if (cnt % 3 == 0)
    return s == "Fizz";
  rep(i, s.size()) {
    if (s[i] < '0' || s[i] > '9')
      return false;
  }
  return atoi(s.c_str()) == cnt;
}

int main() {
  int m, n;
  while (cin >> m >> n, m | n) {
    vector<int> player(m);
    rep(i, m) player[i] = i;

    int p = 0;
    FOR(i, 1, n + 1) {
      string s;
      cin >> s;
      if (player.size() == 1)
        continue;

      if (!check(s, i))
        player.erase(player.begin() + p);
      else
        p = (p + 1) % player.size();
    }
    rep(i, player.size()) { cout << (i ? " " : "") << player[i] + 1; }
    cout << endl;
  }

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

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

int main() {
  int i, j, n, m, k, l, in, t, out;
  string str;
  bool mm[1001];
  while (1) {
    cin >> m >> n;
    if (n == 0 && m == 0)
      break;
    for (i = 1; i <= m; i++)
      mm[i] = 1;
    in = 0;
    out = 0;
    for (i = 1; i <= n; i++) {
      cin >> str;
      in++;
      if (in > m)
        in -= m;
      if (out == m - 1)
        continue;
      while (!mm[in]) {
        in++;
        if (in > m)
          in -= m;
      }

      if (i % 5 == 0 && i % 3 == 0 && str != "FizzBuzz") {
        mm[in] = 0;
        out++;
      } else if (i % 3 == 0 && i % 5 != 0 && str != "Fizz" ||
                 i % 5 == 0 && i % 3 != 0 && str != "Buzz") {
        mm[in] = 0;
        out++;
      } else if (i % 5 == 0 && i % 3 == 0 && str == "FizzBuzz")
        continue;
      else if (i % 3 == 0 && str == "Fizz" || i % 5 == 0 && str == "Buzz")
        continue;
      else {
        k = 0;
        j = 1;
        for (l = str.size() - 1; l >= 0; l--) {
          if (str[l] < '0' && '9' < str[l]) {
            k = -1;
            break;
          } else {
            k += (str[l] - '0') * j;
            j *= 10;
          }
        }
        if (i != k) {
          mm[in] = 0;
          out++;
        }
      }
    }

    bool c = true;
    for (i = 1; i <= m; i++) {
      if (mm[i] && c) {
        cout << i;
        c = false;
      } else if (mm[i])
        cout << " " << i;
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int i, j, n, m, mm[1001], k, l, in, t;
  string str;
  while (1) {
    cin >> m >> n;
    if (n == 0 && m == 0)
      break;
    for (i = 1; i <= m; i++)
      mm[i] = 1;
    for (i = 1; i <= n; i++) {
      cin >> str;
      in = 0;
      for (t = 0; t < i; t++) {
        in++;
        if (!mm[in])
          t--;
        if (in > m)
          in -= m;
      }
      if (i % 5 == 0 && i % 3 == 0 && str != "FizzBuzz") {
        mm[in] = 0;
      } else if (i % 3 == 0 && str != "Fizz" || i % 5 == 0 && str != "Buzz") {
        mm[in] = 0;
      }
      if ((i % 5 != 0 || i % 3 != 0) && str == "FizzBuzz") {
        mm[in] = 0;
      } else if (i % 3 != 0 && str == "Fizz" || i % 5 != 0 && str == "Buzz") {
        mm[in] = 0;
      }

      else if (i % 3 != 0 && i % 5 != 0) {
        k = 0;
        j = 1;
        for (l = str.size() - 1; l >= 0; l--) {
          k += (str[l] - '0') * j;
          j *= 10;
        }
        if (i != k) {
          mm[in] = 0;
        }
      }
    }

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

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

string its(int n) {
  stringstream s;
  s << n;
  return s.str();
}

int main() {
  int n, m;

  while (cin >> n >> m, n + m) {
    vector<int> v;
    for (int i = 0; i < n; i++)
      v.push_back(i + 1);

    int cnt = 1, t = 0;
    string str;

    while (m--) {
      bool check = false;

      cin >> str;
      if (cnt % 15 == 0) {
        if (str != "FizzBuzz") {
          check = true;
        }
      } else if (cnt % 3 == 0) {
        if (str != "Fizz") {
          check = true;
        }
      } else if (cnt % 5 == 0) {
        if (str != "Buzz") {
          check = true;
        }
      } else {
        if (str != its(cnt)) {
          check = true;
        }
      }

      if (check && v.size() > 1) {
        v.erase(v.begin() + t);
        t %= v.size();
      } else
        t = (t + 1) % v.size();

      cnt++;
    }
    for (int i = 0; i < v.size(); i++) {
      if (!i)
        cout << v[i];
      else
        cout << ' ' << v[i];
    }
    cout << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

string its(int n) {
  stringstream s;
  s << n;
  return s.str();
}

int main() {
  int n, m;

  while (cin >> n >> m, n + m) {
    vector<int> v;
    for (int i = 0; i < n; i++)
      v.push_back(i + 1);

    int cnt = 1, t = 0;
    string str;

    while (m--) {
      bool check = false;

      cin >> str;
      if (cnt % 15 == 0) {
        if (str != "FizzBuzz") {
          check = true;
        }
      } else if (cnt % 3 == 0) {
        if (str != "Fizz") {
          check = true;
        }
      } else if (cnt % 5 == 0) {
        if (str != "Buzz") {
          check = true;
        }
      } else {
        if (str != its(cnt)) {
          check = true;
        }
      }

      if (check) {
        v.erase(v.begin() + t);
        t %= v.size();
      } else if (v.size() != 0)
        t = (t + 1) % v.size();

      cnt++;
    }
    for (int i = 0; i < v.size(); i++) {
      if (!i)
        cout << v[i];
      else
        cout << ' ' << v[i];
    }
    cout << endl;
  }

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

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

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

  while (cin >> m >> n, m || n) {
    int prevplayer = m - 1;
    int currplayer = 0;
    int nextplayer[1024];

    for (int i = 0; i < m; i++) {
      nextplayer[i] = (i + 1) % m;
    }

    bool flag = true;
    for (int i = 1; i <= n; i++) {
      cin >> s;

      if (flag) {
        stringstream ans;

        if (i % 3 == 0 && i % 5 == 0)
          ans << "FizzBuzz";
        else if (i % 3 == 0)
          ans << "Fizz";
        else if (i % 5 == 0)
          ans << "Buzz";
        else
          ans << i;

        if (s == ans.str()) {
          prevplayer = currplayer;
          currplayer = nextplayer[currplayer];
        } else {
          nextplayer[prevplayer] = nextplayer[currplayer];
          nextplayer[currplayer] = -1;
          currplayer = nextplayer[prevplayer];
        }

        if (currplayer == nextplayer[currplayer]) {
          flag = false;
        }
      }
    }

    flag = false;
    for (int i = 0; i < m; i++) {
      if (nextplayer[i] != -1) {
        cout << (flag ? " " : "");
        cout << i + 1;
        flag = true;
      }
    }
    cout << endl;
  }
}

Error: WA

Fixed submission:

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

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

  while (cin >> m >> n, m || n) {
    int prevplayer = m - 1;
    int currplayer = 0;
    int nextplayer[1024];

    for (int i = 0; i < m; i++) {
      nextplayer[i] = (i + 1) % m;
    }

    for (int i = 1; i <= n; i++) {
      stringstream ans;

      if (i % 3 == 0 && i % 5 == 0)
        ans << "FizzBuzz";
      else if (i % 3 == 0)
        ans << "Fizz";
      else if (i % 5 == 0)
        ans << "Buzz";
      else
        ans << i;

      cin >> s;

      if (s == ans.str()) {
        prevplayer = currplayer;
        currplayer = nextplayer[currplayer];
      } else {
        nextplayer[prevplayer] = nextplayer[currplayer];
        nextplayer[currplayer] = -1;
        currplayer = nextplayer[prevplayer];
      }
    }

    int cnt = 0;
    for (int i = 0; i < m; i++) {
      if (nextplayer[i] != -1) {
        cnt++;
        cout << i + 1 << " ";
      }
    }
    cout << endl;

    if (cnt == 0) {
      int *test = NULL;
      (*test) = 0;
    }
  }
}