Language: C++

#include"bits/stdc++.h"
using namespace std;
int main() {
	int a[1001], b[1001], m, n, j = 1, j2, hideo = 0;
	char str[30], str1[10] = { "Fizz" }, str2[10] = { "Buzz" }, str3[10] = { "FizzBuzz" };
	while (1) {
		cin >> m >> n;
		if (m == 0 && n == 0)return 0;
		for (int i = 1; i <= m; i++)a[i] = 1;
		for (int i = 1; i <= n; i++) {
			if (hideo ==1)goto ruio;
			if (j > m)j = 1;
			if (a[j] != 1) {
				j2 = j;
				for (int x = j; x <= m; x++) {
					if (a[x] == 1)j = x;
				}
				if (j == j2) {
					for (int x = 1; x < j; x++) {
						if (a[x] == 1)j = x;
					}
			}
			memset(str, NULL, sizeof(str));
			cin >> str;
			if (strcmp(str, str3) == 0) {
				if (i %15==0)goto hell;
				else {
					a[j] = -1; hideo--;
				}
			}
			else if (strcmp(str, str1) == 0) {
				if (i % 3 == 0 )goto hell;
				else {
					a[j] = -1; hideo--;
				}
			}
			else if (strcmp(str, str2) == 0) {
				if (i % 5 == 0)goto hell;
				else {
					a[j] = -1; hideo--;
				}
			}
			else {
				char *s = str;
				int len;
				len = atoi(str);
				if (len > 0 && len < 10001)if (len % 3 == 0 || len % 5 == 0) {
					a[j] = -1;
					hideo--;
				}
			}
		hell:;
			j++;
		}
	goto souya;
	ruio:;
		for (int i = 1; i <= m; i++) {
			if (a[i] == 1) {
				cout << i << endl;
				break;
			}
		}
	souya:;
		j = 0;
		for (int i = 1; i <= m; i++) {
			if (a[i] == 1) {
				b[j] = i;
				j++;
			}
		}
		for (int i = 0; i < j; i++) {
			cout << b[i];
			if (i < j-1)cout << " ";
		}
		cout << endl;
	}

}

/*#include"bits/stdc++.h"
using namespace std;
int main() {
	int a[1001], n, m, s, j = 1,sum;
	char str[20];
	char str1[] = { "FizzBuzz" }, str2[] = { "Fizz" }, str3[] = { "Buzz" };
	cin >> m >> n;
	sum = m;
	for (int i = 0; i <= 1000; i++)a[i] = 1;
	for (int i = 1; i <= m;) {
		if (sum == 1)break;
		if (j > m)j = 1;
		if (a[j] == 1) {
			i++;
			cin >> str;
			if (strcmp(str, str1) == 0) {
				if (i % 15 != 0) {
					a[j] = -1;
					sum--;
				}
			}
			else if (strcmp(str, str2) == 0) {
				if (i % 3 != 0) {
					a[j] = -1;
					sum--;
				}
			}
			else if (strcmp(str, str3) == 0) {
				if (i % 5 != 0) { 
					a[j] = -1; 
					sum--;
				}
			}
			else {
				char *strx = str;
				int suu = atoi(strx);
				if (suu >= 1 && suu <= 1000) {
					if (suu % 3 == 0 || suu % 5 == 0) {
						a[j] = -1;
						sum--;
					}
				}
			}
			j++;
		}
		else {
			j++;
		}
	}
	for (int i = 1; i <= m; i++) {
		if (a[i] == 1)cout << i << " ";
	}
}*/

Compiler output:
a.cc: In function 'int main()':
a.cc:23:37: warning: passing NULL to non-pointer argument 2 of 'void* memset(void*, int, size_t)' [-Wconversion-null]
   23 |                         memset(str, NULL, sizeof(str));
      |                                     ^~~~
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:37: note:   declared here
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                                 ~~~~^~~
a.cc:78:2: error: expected '}' at end of input
   78 | }
      |  ^
a.cc:3:12: note: to match this '{'
    3 | int main() {
      |            ^