Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i++)
#define loop(i,a,b) for(int i = a ; i < b ; i++)
void move(){
  cout<<"move"<<endl;
}
int stoi(string s){
  int r = 0;
  rep(i,s.size())r = r * 10 + s[i] - '0';
  return r;
}
int main(void){
  int m,n;
  
  while(cin>>m>>n,m+n){
    vector<vector<int> > s(m,vector<int>(3));   
    s[0][0] = m-1; // prev
    s[0][1] = 1; // alive
    s[0][2] = 1; // nex
    
    loop(i,1,m-1){
      s[i][0] = i-1;
      s[i][1] = 1;
      s[i][2] = i+1;
    }
    s[m-1][0] = m-2; // prev
    s[m-1][1] = 1; // alive
    s[m-1][2] = 0; // nex
    int now = 0;
    //rep(i,m)rep(j,3)cout<<s[i][j]<<(j==2?'\n':' ');
    rep(i,n){
      string ss;
      cin>>ss;
      //cout<<i+1<<" "<<ss<<endl;
      //rep(j,m)if(s[j][0]==1)cout<<j<<" ";cout<<endl;
      if((i+1)%15 == 0 && ss != "FizzBuzz"){
	//cout<<"FB "<<now<<endl;
	s[now][1] = 0; // dead
	int prev = s[now][0];
	int nex = s[now][2];
	s[prev][2] = nex; // prev-now-nex -> prev-nex
	s[nex][0] = prev; // nex-now-prev -> nex-prev
	n = new;
	continue;
      }else if((i+1)%3 == 0 && ss != "Fizz"){
	s[now][1] = 0; // dead
	//cout<<"F "<<now<<endl;
	int prev = s[now][0];
	int nex = s[now][2];
	s[prev][2] = nex; // prev-now-nex -> prev-nex
	s[nex][0] = prev; // nex-now-prev -> nex-prev
	n = new;
	continue;
      }else if((i+1)%5 == 0 && ss != "Buzz"){
	s[now][1] = 0; // dead
	//cout<<"B "<<now<<endl;
	int prev = s[now][0];
	int nex = s[now][2];
	s[prev][2] = nex; // prev-now-nex -> prev-nex
	s[nex][0] = prev; // nex-now-prev -> nex-prev
	n = new;
	continue;
      }else if((i+1)%3==0 || (i+1)%5==0){
	now = s[now][2];
	continue;
      }else if(ss == "FizzBuzz" || ss == "Fizz" || ss == "Buzz"
	       || i + 1 != stoi(ss)){// out
	s[now][1] = 0; // dead
	//cout<<"out "<<now<<endl;
	int prev = s[now][0];
	int nex = s[now][2];
	s[prev][2] = nex; // prev-now-nex -> prev-nex
	s[nex][0] = prev; // nex-now-prev -> nex-prev
	n = new;
	continue;
      }
      now = s[now][2];
    }
    //cout<<"ans"<<endl;
    rep(i,m){
      if(s[i][1]==1)cout<<i+1<<" ";
    }
    cout<<endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:16: error: expected type-specifier before ';' token
   47 |         n = new;
      |                ^
a.cc:56:16: error: expected type-specifier before ';' token
   56 |         n = new;
      |                ^
a.cc:65:16: error: expected type-specifier before ';' token
   65 |         n = new;
      |                ^
a.cc:71:32: error: call of overloaded 'stoi(std::string&)' is ambiguous
   71 |                || i + 1 != stoi(ss)){// out
      |                            ~~~~^~~~
a.cc:11:5: note: candidate: 'int stoi(std::string)'
   11 | int stoi(string s){
      |     ^~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:78:16: error: expected type-specifier before ';' token
   78 |         n = new;
      |                ^