Problem:
FizzBuzz
「Fizz Buzz」と言われる数字を使ったゲームがあります。このゲームは複数のプレイヤーで数字を1 から順にひとつずつ数え上げていくもので、各プレイヤーは直前のプレイヤーが発言した次の数字をひとつだけ発言します。その時、3 で割り切れる場合は 「Fizz」, 5 で割り切れる場合は 「Buzz」、両者で割り切れる場合は「FizzBuzz」と数の代わりに発言しなければなりません。例えば、最初の 16 までの発言は以下のようになります。
1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, ・・・
太郎君は友達と「Fizz Buzz」をして遊ぶことにしました。太郎君たちはルールを次のように決めました。
「間違えた人は脱落する。その次の人は間違えた数の次の数から始める。つまり、1, 2, 3 と発言した場合、3 で間違えたので次は 4 から始めることになる。」
このルールに従ってゲームを行うのですが、ゲームに慣れていないため、間違えたことに気付かないことがあり、公平な判断ができません。そこであなたは太郎君たちがこのゲームを楽しめるように、決められた発言回数が終わった時点で残っていた人を出力するプログラムを作成することにしました。
プレイヤー数、ゲーム中に発言された回数、それぞれの発言を入力とし、入力が終わった時点で残っているプレイヤーの番号を小さい順に出力するプログラムを作成してください。ただし、プレイヤーには 1 から番号が割り振られており、発言順番も 1 番目のプレイヤーから順に行い、一通り発言が終わると、再度 1 番目のプレイヤーから発言することとします。順番の回ってきたプレイヤーが既に脱落している場合は、その次のプレイヤーが発言します。また、このプログラムは、プレイヤーが一人になった時点で、その後の発言を無視しなければなりません。
Input
複数のデータセットの並びが入力として与えられます。入力の終わりはゼロふたつの行で示されます。
各データセットは以下の形式で与えられます。
m
n
s
1
s
2
:
s
n
1 行目にプレイヤー数
m
(2 ≤
m
≤ 1000) と発言回数
n
(1 ≤
n
≤ 10000) が与えられます。
続く
n
行に
i
番目の発言
s
1
が与えられます。
s
i
は整数、Fizz、Buzz、または FizzBuzz を示す文字列（8文字以下）です。
データセットの数は 50 を超えません。
Output
入力データセットごとに、指定された発言回数まで入力されたときに残っているプレイヤーの番号を小さい順に出力します。
Sample Input
5 7
1
2
Fizz
4
Buzz
6
7
3 5
1
2
3
4
5
0 0
Output for the Sample Input
2 3 4 5
1

Submitted solutions:

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

int main() {
	int n, m;
	while (1) {
		cin >> m >> n;
		if (m == 0) break;
		vector<string> words(n);
		vector<int>  player(m);
		int t = 1;
		for (auto& i : player) i = t++;
		for (auto& i : words) cin >> i;
		for (int i = 1, j = 0; i <= n; i++) {
			if (player.size() == 1) break;
			if (i % 15 == 0) {
				if (words[i - 1] != "FizzBuzz") player.erase(player.begin() + j);
				else j++;
			}
			else if (i % 3 == 0) {
				if (words[i - 1] != "Fizz") player.erase(player.begin() + j);
				else j++;
			}
			else if (i % 5 == 0) {
				if (words[i - 1] != "Buzz") player.erase(player.begin() + j);
				else j++;
			}
			else {
				string tmp;
				t = i;
				while (t) {
					tmp.push_back(t % 10 + '0');
					t /= 10;
				}
				reverse(tmp.begin(), tmp.end());
				if (words[i - 1] != tmp) player.erase(player.begin() + j);
				else j++;
			}
			j %= player.size();
		}
		for (int i = 0; i < player.size() - 1; i++) {
			cout << player[i] << ' ';
		}
		cout << player[player.size() - 1] << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3856
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define fi first
#define se second
#define v(T) vector<T>
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const long double PI = acos(-1.0);
const ll mod = 1e9+7;
//const ll mod = 998244353;
const int INF = 1e9+50;
const ll INFL = 1e15;
const int di[] = {1,0,-1,0};
const int dj[] = {0,1,0,-1};
template<typename T>istream& operator>>(istream&i,v(T)&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>ostream& operator<<(ostream&o,const v(T)&v){rep(j,v.size())o<<v[j]<<endl;return o;}
ll max(ll a, ll b) {if(a < b) return b; else return a;}
ll min(ll a, ll b) {if(a > b) return b; else return a;}
ll gcd(ll a, ll b) {if(a == 0 || b == 0) return max(a,b); else if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
void chmax(ll &a, ll b) {if(a < b) a = b;}
void chmin(ll &a, ll b) {if(a > b) a = b;}





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

        vi vec(n+1,0);
        rep(i,n) {
            string s;
            cin >> s;
            if(s == "Fizz") vec[i+1] = 100000;
            else if(s == "Buzz") vec[i+1] = 200000;
            else if(s == "FizzBuzz") vec[i+1] = 300000;
            else {
                rep(j,s.size()) {
                    int k = s[j]-'0';
                    vec[i+1] += k * pow(10, s.size()-j-1);
                }
            }
        }

        vi p(m+1,0);
        int i = 1;
        int cur = 1;
        int cnt = m;
        while(i <= n && cnt != 1) {
            if(p[cur] == -1) {
                cur++;
                if(cur == m+1) cur = 1;
                continue;
            }

            int val = i;
            if(i % 15 == 0) val = 300000;
            else if(i % 5 == 0) val = 200000;
            else if(i % 3 == 0) val = 100000;

            if(val != vec[i]) {
                p[cur] = -1;
                cnt--;
            }
            
            i++;
            cur++;
            if(cur == m+1) cur = 1;
        }

        int k = 0;
        rep(i,m) {
            if(p[i+1] == 0) {
                if(k) cout << " ";
                k++;
                cout << i+1;
            }
        }
        cout << endl;
    }
}
// g++ test.cpp && ./a.out
accuracy: 1
time_ms: 20
memory_kb: 3848
final_rank: 17

code_snippet: #include<iostream>
#include<string>
#include<cmath>
#include<cstring>

using namespace std;

#define FIZZ 10000000
#define BUZZ 20000000
#define FIZZBUZZ 30000000

int x[100000], y[10000], n, m, num, turn, C, cnt, L; string S; char T[11] = "0123456789";
int main() {
	while (true) {
		memset(x, 0, sizeof(x));
		memset(y, 0, sizeof(y));
		num = 1; turn = 1; cnt = 0;
		cin >> n >> m; L = n;
		if (n == 0 && m == 0) { break; }
		for (int i = 1; i <= m; i++) { 
			cin >> S; 
			if (S == "Fizz") { x[i] = FIZZ; }
			else if (S == "Buzz") { x[i] = BUZZ; }
			else if (S == "FizzBuzz") { x[i] = FIZZBUZZ; }
			else if (S.size() >= 10) { x[i] = -1; }
			else {
				for (int j = 0; j < S.size(); j++) {
					for (int k = 0; k < 10; k++) {
						if (S[j] == T[k]) { x[i] += (int)pow(10, S.size() - j - 1)*k; goto E; }
					}
					x[i] = 0; goto F;
				E:;
				}
			F:;
			}
		}
		while (num <= m && L > 1) {
			if (y[turn] == 1) { goto G; }
			if (num % 15 == 0) { C = FIZZBUZZ; }
			else if (num % 5 == 0) { C = BUZZ; }
			else if (num % 3 == 0) { C = FIZZ; }
			else { C = num; }
			if (C != x[num]) { y[turn] = 1; L--; }
			num++;
		G:;
			turn++;
			if (turn > n) { turn -= n; }
		}
		for (int i = 1; i <= n; i++) {
			if (y[i] == 0) {
				if (cnt >= 1) { cout << ' '; }
				cout << i;
				cnt++;
			}
		}
		cout << endl;
	}
}
accuracy: 1
time_ms: 20
memory_kb: 4056
final_rank: 19

code_snippet: #include <iostream>
#include <string>
using namespace std;
#include <vector>
#include <set>

void solve() {
    while(1) {
        int M, N; cin >> M >> N;

        if (M == 0 and N == 0) break;

        set<int> player_set;
        for(int n=1; n<=M; n++) player_set.insert(n);

        auto now = player_set.begin();
        for(int n=1; n<=N; n++) {
            if (player_set.size() == 1) {
                string s; cin>>s;
                continue;
            }

            if (n%15 == 0) {
                string s; cin >> s;
                if (s != "FizzBuzz") {
                    now = player_set.erase(now);
                }
                else {
                    advance(now, 1);
                }
                if (now == player_set.end()) now = player_set.begin();
            }
            else if (n%5 == 0) {
                string s; cin >> s;
                if (s != "Buzz") {
                    now = player_set.erase(now);
                }
                else {
                    advance(now, 1);
                }
                if (now == player_set.end()) now = player_set.begin();
            }
            else if (n%3 == 0) {
                string s; cin >> s;
                if (s != "Fizz") {
                    now = player_set.erase(now);
                }
                else {
                    advance(now, 1);
                }
                if (now == player_set.end()) now = player_set.begin();
            }
            else {
                int s; cin >> s;
                if (s != n) {
                    now = player_set.erase(now);
                }
                else {
                    advance(now, 1);
                }
                if (now == player_set.end()) now = player_set.begin();
            }
        }

        // 残っている人間を出力
        vector<int> players = vector<int>(player_set.begin(), player_set.end());
        for(int i=0; i<players.size(); i++) {
            cout << players.at(i);
            if (i == players.size()-1) cout << endl;
            else cout << " ";
        }
    }
}

int main() {
    solve();
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3388
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main()
{

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int n, m;

    const string fizz = "Fizz";
    const string buzz = "Buzz";
    const string fizzbuzz = "FizzBuzz";
    while (cin >> m >> n)
    {
        if (n == 0 && m == 0)
            break;

        vector<string> v(n);
        for (int i = 0; i < n; i++)
            cin >> v[i];

        vector<int> ans(m, 0);
        int player = 0;
        int cnt = 0;
        for (int i = 1; i <= n; i++)
        {
            string should = "";
            if (i % 15 == 0)
                should = fizzbuzz;
            else if (i % 3 == 0)
                should = fizz;
            else if (i % 5 == 0)
                should = buzz;
            else
                should = to_string(i);

            if (cnt < m - 1)
            {
                if (v[i - 1] != should)
                {
                    ans[player % m]++;
                    cnt++;
                }

                player++;
                while (ans[player % m])
                    player++;
            }
        }

        bool ok = false;
        for (int i = 0; i < m; i++)
        {
            if (!ans[i])
            {
                if (ok)
                    cout << " ";
                cout << i + 1;
                ok = true;
            }
        }
        cout << "\n";
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3900
final_rank: 18

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m, n;
    while (cin >> m >> n, m) {
        int rem = m;
        set<int> st;
        for (int i = 0; i < m; i++) {
            st.insert(i + 1);
        }
        auto it = st.begin();
        for (int i = 1; i <= n; i++) {
            string s, t;
            cin >> s;
            if (rem == 1) continue;
            if (i % 15 == 0) t = "FizzBuzz";
            else if (i % 3 == 0) t = "Fizz";
            else if (i % 5 == 0) t = "Buzz";
            else t = to_string(i);
            if (s != t) {
                it = st.erase(it);
                rem -= 1;
                if (it == st.end()) it = st.begin();
            } else {
                it++;
                if (it == st.end()) it = st.begin();
            }
        }
        bool f = false;
        for (auto id : st) {
            if (f) cout << " ";
            cout << id;
            f = true;
        }
        cout << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3460
final_rank: 8

code_snippet: #include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
int main(){
  for(int i=1;i<=59;i++){
    int n,m;
    int Y;
    cin>>m>>n;
    Y=m;
    if(m==0&&n==0) break;
    string s[10009];
    queue<int> T;
    for(int j=1;j<=n;j++) cin>>s[j];
    for(int j=1;j<=m;j++) T.push(j);
    for(int j=1;j<=n;j++){
      if(Y==1) break;
      int J=j;
      string CA=std::to_string(J);
      if(j%3==0) CA="Fizz";
      if(j%5==0) CA="Buzz";
      if(j%3==0&&j%5==0) CA="FizzBuzz";
      if(s[j]==CA) {
        T.push(T.front());
        T.pop();
      }
      else {
        T.pop();
        Y--;
      }
    }
    int A[1009];
    for(int j=1;j<=m;j++){
      if(T.empty()) {
        break;
      }
      A[j]=T.front();
      T.pop();
    }
    sort(A+1,A+Y+1);
    for(int j=1;j<=Y;j++){
      if(j<Y) cout<<A[j]<<" ";
      else cout<<A[j];
    }
    cout<<endl;
  }
}
accuracy: 1
time_ms: 20
memory_kb: 3588
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(void){
    string a;
    string b;
    int c,d;
    int e;
    int rest;
    int turn;
    int digit;
    int count;
while (true){
    cin>>c>>d;
    if(c==0){
        break;
    }
    vector<int> member(c);
    rest=1;
    turn=0;
    digit=1;
    for(int i=0;i<c;i+=1){
        member.at(i)=i+1;
    }
    for(int i=1;i<=d;i+=1){
        if(i==10||i==100||i==1000||i==10000){
            digit+=1;
        }
        cin>>a;
        if(rest==1){
        if(i%5==0||i%3==0){
            if(i%15==0){
                if(a!="FizzBuzz"){
                    member.at(turn)=0;
                }
            }else
            if(i%5==0){
                if(a!="Buzz"){
                    member.at(turn)=0;
                }
            }else
            if(i%3==0){
                if(a!="Fizz"){
                    member.at(turn)=0;
                }
            }
        }else{
            if(digit==a.size()){
            b=a;
            for(int j=0,k=i;j<digit;j+=1){
                b.at(digit-1-j)=k%10+'0';
                k/=10;
            }
            if(b!=a){
                member.at(turn)=0;
            }
            }else{
                member.at(turn)=0;
            }
        }
        e=turn;
        do{
            turn=(turn+1)%c;
        }while(member.at(turn)==0);
        if(e==turn){
            rest=0;
        }
        }
    }
    count=0;
    for(int i=0;i<c;i+=1){
        if(member.at(i)!=0){
            if(count==0){
            cout<<member.at(i);
            count+=1;
        }else{
           cout<<' '<<member.at(i); 
        }
        }
    }
    cout<<endl;
}
}
accuracy: 1
time_ms: 30
memory_kb: 3052
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll n,m,num;
bool tf[10000];
int main(void){
    while(cin>>n>>m,n){
        num=n;
        for(ll i=0;i<n;i++){
            tf[i]=true;
        }
        ll i=0,j=1;
        for(;num>1 && j<=m;j++){
            string s;
            cin>>s;
            string t=to_string(j);
            if(j%15==0){
                t="FizzBuzz";
            }else if(j%5==0){
                t="Buzz";
            }else if(j%3==0){
                t="Fizz";
            }
            if(s!=t){
                num--,tf[i]=false;
            }
            i=(i+1)%n;
            while(!tf[i]){
                i=(i+1)%n;
            }
        }
        for(;j<=m;j++){
            string s;
            cin>>s;
        }
        ll k=0;
        for(ll i=0;i<n;i++){
            if(tf[i]){
                cout<<(k++ ? " " : "")<<i+1;
            }
        }
        cout<<"\n";
    }
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3472
final_rank: 9

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

int main(){
  for(;;){
    int m,n;
    cin >> m >> n;
    if(m == 0 && n == 0) break;
    queue<int> que;
    for(int i=1;i<=m;i++) que.push(i);
    for(int i=1;i<=n;i++){
      string S;
      cin >> S;
      if(que.size() == 1) continue;
      if(i%15 == 0){
        if(S == "FizzBuzz"){
          int t = que.front();
          que.pop();
          que.push(t);
        }
        else que.pop();
      }
      else if(i%5 == 0){
        if(S == "Buzz"){
          int t = que.front();
          que.pop();
          que.push(t);
        }
        else que.pop();
      }
      else if(i%3 == 0){
        if(S == "Fizz"){
          int t = que.front();
          que.pop();
          que.push(t);
        }
        else que.pop();
      }
      else{
        int s = 0;
        for(int j=0;j<S.size();j++) s = s*10+S[j]-'0';
        if(s == i){
          int t = que.front();
          que.pop();
          que.push(t);
        }
        else que.pop();
      }
    }
    vector<int> ans(0);
    while(!que.empty()){
      ans.push_back(que.front());
      que.pop();
    }
    sort(ans.begin(),ans.end());
    cout << ans[0];
    for(int i=1;i<ans.size();i++) cout << " " << ans[i];
    cout << endl;
  }
}
accuracy: 1
time_ms: 40
memory_kb: 3124
final_rank: 3

code_snippet: #include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<list>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<iomanip>
#include<regex>
#include<sstream>
#include<random>
using namespace std;
#define int long long
#define uint unsigned long long
const int mod=1e9+7;
const int inf=mod*mod;
signed main(){
	int m,n;
	while(cin>>m>>n,m){
		bool dead[1000]={};
		int tmp=0,rem=m;
		for(int i=1;i<=n;i++){
			string s;
			cin>>s;
			string t;
			if(i%15==0)
				t="FizzBuzz";
			else if(i%5==0)
				t="Buzz";
			else if(i%3==0)
				t="Fizz";
			else
				t=to_string(i);
			if(s!=t){
				dead[tmp]=1;
				rem--;
				if(rem==1){
					for(int j=0;j<n-i;j++)
						cin>>s;
					break;
				}
			}
			tmp=(tmp+1)%m;
			while(dead[tmp])
				tmp=(tmp+1)%m;
		}
		bool fst=1;
		for(int i=0;i<m;i++){
			if(dead[i])
				continue;
			if(fst)
				fst=0;
			else
				cout<<' ';
			cout<<i+1;
		}
		cout<<endl;
	}
}
accuracy: 1
time_ms: 20
memory_kb: 3332
final_rank: 6

code_snippet: #include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define popcount(v) __builtin_popcount(v)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=1LL<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T,class U,class V>void scan(tuple<T,U,V>& p){scan(get<0>(p));scan(get<1>(p));scan(get<2>(p));}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){return (a+b-1)/b;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    while(1){
        INT(n,m);
        if(m==0)return 0;
        string s;
        int j=0,cnt=0;
        vector<bool> t(n,false);
        for(int i=1;i<=m;i++){
            cin>>s;
            if(cnt==n-1)continue;
            if(i%15==0){
                if(s!="FizzBuzz"){t[j%n]=true;cnt++;}
            }else if(i%5==0){
                if(s!="Buzz"){t[j%n]=true;cnt++;}
            }else if(i%3==0){
                if(s!="Fizz"){t[j%n]=true;cnt++;}
            }else{
                if(stoi(s)!=i){t[j%n]=true;cnt++;}
            }
            if(cnt==n-1)continue;
            j++;
            while(t[j%n])j++;
        }
        vector<int> ans;
        rep(i,n){
            if(!t[i])ans.push_back(i+1);
        }
        if(ans.empty())continue;
        out(ans);
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3556
final_rank: 11

code_snippet: #include <iostream>
#include <string>

using namespace std;

int main()
{
    int m, n;
    while (cin >> m >> n, m || n)
    {
        bool p[1000] = {};
        string s, check;
        int remain = m, num = 0;
        for (int i = 1; i <= n; ++i)
        {
            cin >> s;
            if (remain == 1)
                continue;
            if (i % 15 == 0)
                check = "FizzBuzz";
            else if (i % 5 == 0)
                check = "Buzz";
            else if (i % 3 == 0)
                check = "Fizz";
            else
                check = to_string(i);
            if (s != check)
            {
                p[num] = true;
                --remain;
            }
            else
                num = (num + 1) % m;
            while (p[num])
                num = (num + 1) % m;
        }
        for (int i = 0; i < m; ++i)
        {
            if (!p[i])
            {
                cout << i + 1;
                --remain;
                if (remain != 0)
                    cout << " ";
            }
        }
        cout << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3196
final_rank: 4

code_snippet: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
using P = pair<int,int>;
using ll = long long;

const long double EPS = 1e-10;
const int MAX = 1010;
bool alive[MAX];

int main(){

  int m,n;
  string s;
  while(true){
    cin >> m >> n;
    if(m == 0 && n == 0)
      break;
    for(int i = 0 ; i < m ; i++)
      alive[i] = true;
    int turn = 0;
    int remain = m;
    for(int i = 1 ; i <= n ; i++){
      cin >> s;
      if(remain == 1);
      else if(i % 15 == 0){
        if(s != "FizzBuzz"){
          alive[turn] = false;
          remain--;
        }
      }
      else if(i % 5 == 0){
        if(s != "Buzz"){
          alive[turn] = false;
          remain--;
        }
      }
      else if(i % 3 == 0){
        if(s != "Fizz"){
          alive[turn] = false;
          remain--;
        }
      }
      else{
        if(s != to_string(i)){
          alive[turn] = false;
          remain--;
        }
      }
      turn = (turn+1)%m;
      while(!alive[turn])
        turn = (turn+1)%m;
    }
    bool first = true;
    for(int i = 0 ; i < m ; i++){
      if(alive[i]){
        if(first){
          cout << i+1;
          first = false;
        }
        else
          cout << " " << i+1;
      }
    }
    cout << endl;
  }

}
accuracy: 1
time_ms: 340
memory_kb: 3228
final_rank: 20

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0) break;

        vector<bool> ok(m);
        for(int i=0; i<m; i++){
            string s;
            cin >> s;
            string a = "";
            int j = i+1;
            if(j%3!=0 and j%5!=0){
                a = to_string(j);
            }
            if(j%3 == 0) a += "Fizz";
            if(j%5 == 0) a += "Buzz";
            if(s == a) ok[i] = true;
        }
        vector<bool> rem(n, true);
        int count = 0;
        int pos = 0;
        for(int i=0; i<m; i++){
            if(!ok[i]){
                rem[pos] = false;
                count++;
                if(count == n-1) break;
            }
            do{
                pos = (pos+1)%n;
            }while(!rem[pos]);
        }
        vector<int> ans;
        for(int i=0; i<n; i++){
            if(rem[i]) ans.push_back(i+1);
        }
        for(int i=0; i<(int)ans.size()-1; i++){
            cout << ans[i] << " ";
        }
        cout << ans.back() << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3228
final_rank: 5

code_snippet: #include<string>
#include<sstream>
#include<iostream>
using namespace std;
int main(){
	for(int m,n;cin>>m>>n,m;){
		static bool flg[1000];
		static int bef[1000],nxt[1000];
		for(int i=0;i<m;i++)	flg[i]=true,bef[i]=(i+m-1)%m,nxt[i]=(i+1)%m;
		int pos=0,num=m;
		for(int i=1;i<=n;i++){
			string s;	cin>>s;
			if(num==1)	continue;
			bool ok=1;
			if(i%15==0){	if(s!="FizzBuzz")	ok=0;	}
			else if(i%3==0){	if(s!="Fizz")	ok=0;	}
			else if(i%5==0){	if(s!="Buzz")	ok=0;	}
			else{
				stringstream ss;	ss<<i;
				if(s!=ss.str())	ok=0;
			}
			if(!ok){
				flg[pos]=0;
				int tmpb=bef[pos],tmpn=nxt[pos];
				bef[tmpn]=tmpb;
				nxt[tmpb]=tmpn;
				num--;
			}pos=nxt[pos];
		}
		for(int i=0,j=0;i<m;i++)if(flg[i])	cout<<(j++?" ":"")<<i+1;
		cout<<endl;
	}
}
accuracy: 1
time_ms: 60
memory_kb: 3028
final_rank: 2

code_snippet: #include <iostream>
#include <string>
#include <list>

std::string getFizzBuzz(int n)
{
	if (n % 15 == 0)
	{
		return "FizzBuzz";
	}
	else if (n % 5 == 0)
	{
		return "Buzz";
	}
	else if (n % 3 == 0)
	{
		return "Fizz";
	}
	else
	{
		return std::to_string(n);
	}
}

void fizzbuzz(int m, int n)
{
	std::list<int> lst;

	for (int i = 1; i <= m; ++i)
	{
		lst.push_back(i);
	}

	for (int i = 1; i <= n; ++i)
	{
		std::string rem;
		std::cin >> rem;

		if (lst.size() <= 1)
		{
			continue;
		}

		int player = *(lst.begin());
		lst.pop_front();

		std::string ret = getFizzBuzz(i);

		if (rem == ret)
		{
			lst.push_back(player);
		}
	}

	lst.sort();
	for (auto itr = lst.begin(); itr != lst.end(); ++itr)
	{
		if (itr != lst.begin())
		{
			std::cout << " ";
		}
		std::cout << *itr;
	}
	std::cout << std::endl;

	return;
}

int main(void)
{
	int m;
	int n;

	while (std::cin >> m >> n && m != 0 && n != 0)
	{
		fizzbuzz(m, n);
	}
	return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 3216
final_rank: 12

code_snippet: #include <iostream>
#include <string>
#include <list>

std::string getFizzBuzzString(int n)
{
	if (n % 15 == 0)
	{
		return "FizzBuzz";
	}
	else if (n % 5 == 0)
	{
		return "Buzz";
	}
	else if (n % 3 == 0)
	{
		return "Fizz";
	}
	else
	{
		return std::to_string(n);
	}
}

void fizzbuzz(int m, int n)
{
	std::list<int> lst;

	for (int i = 1; i <= m; ++i)
	{
		lst.push_back(i);
	}

	for (int i = 1; i <= n; ++i)
	{
		std::string rem;
		std::cin >> rem;

		if (lst.size() <= 1)
		{
			continue;
		}

		int player = *(lst.begin());
		lst.pop_front();

		std::string ret = getFizzBuzzString(i);

		if (rem == ret)
		{
			lst.push_back(player);
		}
	}

	lst.sort();
	for (auto itr = lst.begin(); itr != lst.end(); ++itr)
	{
		if (itr != lst.begin())
		{
			std::cout << " ";
		}
		std::cout << *itr;
	}
	std::cout << std::endl;

	return;
}

int main(void)
{
	int m;
	int n;

	while (std::cin >> m >> n && m != 0 && n != 0)
	{
		fizzbuzz(m, n);
	}
	return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 3280
final_rank: 15

code_snippet: #include <iostream>
#include <string>
#include <list>

std::string getFizzBuzzString(int n)
{
	if (n % 15 == 0)
	{
		return "FizzBuzz";
	}
	else if (n % 5 == 0)
	{
		return "Buzz";
	}
	else if (n % 3 == 0)
	{
		return "Fizz";
	}
	else
	{
		return std::to_string(n);
	}
}

void fizzbuzz(int m, int n)
{
	std::list<int> lst;

	for (int i = 1; i <= m; ++i)
	{
		lst.push_back(i);
	}

	for (int i = 1; i <= n; ++i)
	{
		std::string rem;
		std::cin >> rem;

		if (lst.size() <= 1)
		{
			continue;
		}

		int player = *(lst.begin());
		lst.pop_front();

		std::string ret = getFizzBuzzString(i);

		if (rem == ret)
		{
			lst.push_back(player);
		}
	}

	lst.sort();
	for (auto itr = lst.begin(); itr != lst.end(); ++itr)
	{
		if (itr != lst.begin())
		{
			std::cout << " ";
		}
		std::cout << *itr;
	}
	std::cout << std::endl;

	return;
}

int main(void)
{
	int m;
	int n;

	while (std::cin >> m >> n && m != 0 && n != 0)
	{
		fizzbuzz(m, n);
	}
	std::cin >> m;
	return 0;
}
accuracy: 1
time_ms: 140
memory_kb: 3240
final_rank: 14

code_snippet: #include <iostream>
#include <string>
#include <list>

std::string getFizzBuzzString(int n)
{
	if (n % 15 == 0)
	{
		return "FizzBuzz";
	}
	else if (n % 5 == 0)
	{
		return "Buzz";
	}
	else if (n % 3 == 0)
	{
		return "Fizz";
	}
	else
	{
		return std::to_string(n);
	}
}

void fizzbuzz(int m, int n)
{
	std::list<int> lst;

	for (int i = 1; i <= m; ++i)
	{
		lst.push_back(i);
	}

	for (int i = 1; i <= n; ++i)
	{
		std::string rem;
		std::cin >> rem;

		if (lst.size() <= 1)
		{
			continue;
		}

		int player = *(lst.begin());
		lst.pop_front();

		std::string ret = getFizzBuzzString(i);

		if (rem == ret)
		{
			lst.push_back(player);
		}
	}

	lst.sort();
	for (auto itr = lst.begin(); itr != lst.end(); ++itr)
	{
		if (itr != lst.begin())
		{
			std::cout << " ";
		}
		std::cout << *itr;
	}
	std::cout << std::endl;

	return;
}

int main(void)
{
	int m;
	int n;

	while (true)
	{
		std::cin >> m >> n;

		if (m == 0 && n == 0)
		{
			break;
		}

		fizzbuzz(m, n);
	}

	return 0;
}
accuracy: 1
time_ms: 130
memory_kb: 3164
final_rank: 10