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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, j;
  double qq;
  scanf("%lf", &qq);
  n = (int)qq;
  j = (int)(100000 * qq) - 100000 * n;
  // cout<<n<<' '<<j<<endl;
  while (n >= 0) {
    int nn = n;
    int ji[8] = {}, kyo[4] = {}, a = 0;
    for (int i = 0; i < 8; i++) {
      if (nn % 2 != 0) {
        ji[i] = 1;
      } else {
        ji[i] = 0;
      }
      nn = nn / 2;
      // cout<<nn<<endl;
    }
    if (nn) {
      a = 1;
    } else {
      int c = 50000;
      for (int i = 0; i < 4; i++) {
        // cout<<j<<endl;
        if ((j - c) >= 0) {
          kyo[i] = 1;
          j -= c;
        } else {
          kyo[i] = 0;
        }
        c /= 2;
        // cout<<c<<endl;
      }
    }
    if (j) {
      a = 1;
    }
    if (a == 0) {
      for (int i = 7; i >= 0; i--) {
        cout << ji[i];
      }
      cout << '.';
      for (int i = 0; i < 4; i++) {
        cout << kyo[i];
      }
      cout << endl;
    } else {
      cout << "NA" << endl;
    }
    scanf("%lf", &qq);
    n = (int)qq;
    j = (int)(100000 * qq) - 100000 * n;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, j;
  double qq;
  scanf("%lf", &qq);
  n = (int)qq;
  j = (int)(10000 * qq) - 10000 * n;
  // cout<<n<<' '<<j<<endl;
  while (n >= 0) {
    int nn = n;
    int ji[8], kyo[4], a = 0;
    for (int i = 0; i < 8; i++) {
      if (nn % 2 != 0) {
        ji[i] = 1;
      } else {
        ji[i] = 0;
      }
      nn = nn / 2;
      // cout<<nn<<endl;
    }
    if (nn) {
      a = 1;
    } else if (j < 10000) {
      while (j < 1000) {
        j *= 10;
      }
      int c = 5000;
      for (int i = 0; i < 4; i++) {
        // cout<<j<<endl;
        if ((j - c) >= 0) {
          kyo[i] = 1;
          j -= c;
        } else {
          kyo[i] = 0;
        }
        c /= 2;
        // cout<<c<<endl;
      }
    }
    if (j) {
      a = 1;
    }
    if (a == 0) {
      for (int i = 7; i >= 0; i--) {
        cout << ji[i];
      }
      cout << '.';
      for (int i = 0; i < 4; i++) {
        cout << kyo[i];
      }
      cout << endl;
    } else {
      cout << "NA" << endl;
    }
    scanf("%lf", &qq);
    n = (int)qq;
    j = (int)(1000 * qq) - 1000 * n;
  }
  return 0;
}
Problem p00220 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void) {
  double dn;
  double list[4] = {0.5, 0.25, 0.125, 0.0625};
  string sm;
  while (cin >> dn, dn >= 0) {
    int n = (int)dn;
    double m = dn - n;
    bitset<8> nn(n);
    bool pm[4] = {false};

    if (n > 255) {
      cout << "NA" << endl;
      continue;
    }

    for (int i = 0; i < 4; i++) {
      if (m >= list[i]) {
        m -= list[i];
        pm[i] = true;
      }
    }
    if (m != 0) {
      cout << "NA" << endl;
      continue;
    }
    cout << nn << ".";
    for (int i = 0; i < 4; i++) {
      cout << pm[i];
    }
    cout << endl;
  }

  return 0;
}

int StrToInt(string s) {
  stringstream ss;
  ss << s;
  int val;
  ss >> val;
  return val;
}
string IntToStr(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void) {
  int n;
  string sm;
  while (scanf("%d.", &n)) {
    cin >> sm;
    while (1) {
      if (sm.length() == 4) {
        break;
      }
      sm += "0";
    }
    int m = StrToInt(sm);
    if (n < 0)
      break;
    if (n > 511) {
      cout << "NA" << endl;
      continue;
    }
    bitset<8> re(n);

    int d[4] = {0};
    double d_ans = 0.5;
    rep(i, 4) {
      d[i] = (int)(d_ans * 10000);
      d_ans /= 2.0;
    }
    string s;
    rep(i, 4) {
      if (m >= d[i]) {
        m -= d[i];
        s += "1";
      } else {
        s += "0";
      }
    }
    if (m != 0) {
      cout << "NA" << endl;
      continue;
    }

    cout << re << "." << s << endl;
  }

  return 0;
}

int StrToInt(string s) {
  stringstream ss;
  ss << s;
  int val;
  ss >> val;
  return val;
}
string IntToStr(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}
Problem p00220 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main() {

  string in;
  string ls, rs;
  string ans;
  long long li, ri;
  bool f;
  int sdata[8];
  int fdata[4] = {5000, 2500, 1250, 625};

  for (int i = 0; i < 8; i++) {
    sdata[i] = pow(2, i);
  }

  while (1) {
    cin >> in;
    if (in[0] == '-')
      break;

    ls = "", rs = "";
    f = false;
    for (int i = 0; i < in.size(); i++) {
      if (in[i] == '.')
        f = true;
      else if (f) {
        rs += in[i];
      } else {
        ls += in[i];
      }
    }

    li = 0;
    for (int i = 0; i < ls.size(); i++) {
      li += (ls[ls.size() - 1 - i] - '0') * pow(10, i);
    }

    ri = 0;
    for (int i = 0; i < rs.size(); i++) {
      ri += (rs[rs.size() - 1 - i] - '0') * pow(10, i);
    }
    for (int i = 0; i < 4 - rs.size(); i++) {
      ri *= 10;
    }
    ans = "";
    for (int i = 7; i >= 0; i--) {
      if (li >= sdata[i]) {
        li -= sdata[i];
        ans += "1";
      } else
        ans += "0";
    }
    if (li != 0) {
      cout << "NA" << endl;
      continue;
    }
    ans += ".";

    for (int i = 0; i < 4; i++) {
      if (ri >= fdata[i]) {
        ri -= fdata[i];
        ans += "1";
      } else
        ans += "0";
    }
    if (ri != 0) {
      cout << "NA" << endl;
      continue;
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main() {

  string in;
  string ls, rs;
  string ans;
  int li, ri;
  bool f;
  int sdata[8];
  int fdata[4] = {5000, 2500, 1250, 625};

  for (int i = 0; i < 8; i++) {
    sdata[i] = pow(2, i);
  }

  while (1) {
    cin >> in;
    if (in[0] == '-')
      break;

    ls = "", rs = "";
    f = false;
    for (int i = 0; i < in.size(); i++) {
      if (in[i] == '.')
        f = true;
      else if (f) {
        rs += in[i];
      } else {
        ls += in[i];
      }
    }

    li = 0;
    for (int i = 0; i < ls.size(); i++) {
      li += (ls[ls.size() - 1 - i] - '0') * pow(10, i);
    }

    ri = 0;
    for (int i = 0; i < rs.size(); i++) {
      ri += (rs[rs.size() - 1 - i] - '0') * pow(10, i);
    }
    while (ri < 1000)
      ri *= 10;
    ans = "";
    for (int i = 7; i >= 0; i--) {
      if (li >= sdata[i]) {
        li -= sdata[i];
        ans += "1";
      } else
        ans += "0";
    }
    if (li != 0) {
      cout << "NA" << endl;
      continue;
    }
    ans += ".";

    for (int i = 0; i < 4; i++) {
      if (ri >= fdata[i]) {
        ri -= fdata[i];
        ans += "1";
      } else
        ans += "0";
    }
    if (ri != 0) {
      cout << "NA" << endl;
      continue;
    }
    cout << ans << endl;
  }
}
Problem p00220 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

string decToBin(float n) {
  string binInteger, binDecimal;
  int decInteger;
  float decDecimal;
  ostringstream oss;

  decInteger = floor(n);
  decDecimal = n - decInteger;

  while (decInteger) {
    binInteger += '0' + (decInteger % 2);
    decInteger /= 2;
  }
  reverse(binInteger.begin(), binInteger.end());
  if (binInteger.length() > 8)
    return "NA";

  while (1) {
    decDecimal = (decDecimal - floor(decDecimal)) * 2;
    if (decDecimal == 0.0)
      break;
    binDecimal += '0' + floor(decDecimal);
  }
  if (binDecimal.length() > 4)
    return "NA";

  oss << setfill('0') << setw(8) << binInteger << "." << left << setw(4)
      << binDecimal;

  return oss.str();
}

int main() {
  float n;
  while (cin >> n, n >= 0.0) {
    cout << decToBin(n) << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

string decToBin(float n) {
  string binInteger, binDecimal;
  int decInteger;
  float decDecimal;
  ostringstream oss;

  decInteger = floor(n);
  decDecimal = n - decInteger;

  while (decInteger) {
    binInteger += '0' + (decInteger % 2);
    decInteger /= 2;
  }
  reverse(binInteger.begin(), binInteger.end());
  if (binInteger.length() > 8)
    return "NA";

  while (decDecimal != 1.0) {
    decDecimal = (decDecimal - floor(decDecimal)) * 2;
    binDecimal += '0' + floor(decDecimal);
  }
  if (binDecimal.length() > 4)
    return "NA";

  oss << setfill('0') << setw(8) << binInteger << "." << left << setw(4)
      << binDecimal;

  return oss.str();
}

int main() {
  float n;
  while (cin >> n, n >= 0.0) {
    cout << decToBin(n) << endl;
  }
  return 0;
}
Problem p00220 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  double n;
  double b[12] = {128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25, 0.125, 0.0625};
  while (cin >> n, n != -1.0) {
    string s;
    for (int i = 0; i < 12; i++) {
      if (n >= b[i]) {
        n -= b[i];
        s += "1";
      } else {
        s += "0";
      }
      if (i == 7)
        s += ".";
    }
    if (n > 0)
      cout << "NA" << endl;
    else
      cout << s << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

char solve(int m, int e, int j) {
  if (m == 100 || e == 100 || j == 100)
    return 'A';
  if ((m + e) >= 180 || (m + e + j) >= 240)
    return 'A';
  if ((m + e + j) >= 210 || ((m + e + j) >= 150 && (m >= 80 || e >= 80)))
    return 'B';
  return 'C';
}

int main() {
  int n, m, e, j;
  while (cin >> n, n) {
    for (int i = 0; i < n; ++i) {
      cin >> m >> e >> j;
      cout << solve(m, e, j) << endl;
    }
  }
}
Problem p00220 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  char c;
  while (1) {
    string str;
    long long a, b;
    getline(cin, str);
    if (str[0] == '-') {
      break;
    }
    a = b = 0;
    int i = 0;
    while (str[i] != '.' && i < str.size()) {
      a *= 10;
      a += str[i] - '0';
      i++;
    }
    i++;
    int d = 1000;
    while (i < str.size()) {
      b += d * (str[i] - '0');
      d /= 10;
      i++;
    }

    a *= 16;
    b *= 16;
    a += b / 10000;

    if ((~(0xfff) & a) || (b % 10000))
      cout << "NA" << endl;
    else {
      for (int i = 0; i < 12; i++) {
        if (i == 8)
          cout << ".";
        cout << !!(a & (0x1 << (11 - i)));
      }
      cout << endl;
    }
  }
}

Error: 0

Fixed submission:

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

int main() {
  char c;
  while (1) {
    string str;
    long long a, b;
    getline(cin, str);
    if (str[0] == '-') {
      break;
    }
    a = b = 0;
    int i = 0;
    while (str[i] != '.') {
      a *= 10;
      a += str[i] - '0';
      i++;
    }
    i++;
    int d = 1000;
    while (i < str.size()) {
      b += d * (str[i] - '0');
      d /= 10;
      i++;
    }

    a *= 16;
    b *= 16;
    a += b / 10000;

    if ((~(0xfff) & a) || (b % 10000))
      cout << "NA" << endl;
    else {
      for (int i = 0; i < 12; i++) {
        if (i == 8)
          cout << ".";
        cout << !!(a & (0x1 << (11 - i)));
      }
      cout << endl;
    }
  }
}
Problem p00220 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int d[8] = {128, 64, 32, 16, 8, 4, 2, 1};
float f[4] = {0.5, 0.25, 0.125, 0.0625};
int main() {
  double in;
  while (cin >> in, in > 0) {
    vector<int> ans(12, 0);
    bool used = false;

    for (int i = 0; i < 8; i++) {
      if (d[i] <= in) {
        ans[i] = 1;
        in -= d[i];
        used = true;
      }
    }
    for (int i = 0; i < 4; i++) {
      if (f[i] <= in) {
        ans[i + 8] = 1;
        in -= f[i];
        used = true;
      }
    }
    if (used && in == 0) {
      for (int i = 0; i < 8; i++) {
        cout << ans[i];
      }
      cout << '.';
      for (int i = 8; i < 12; i++) {
        cout << ans[i];
      }
      cout << endl;
    } else
      cout << "NA" << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
int de[8] = {128, 62, 32, 16, 8, 4, 2, 1};
double dou[4] = {0.5, 0.25, 0.125, 0.0625};

using namespace std;

int main(void) {
  double in;
  while (cin >> in, in) {
    vector<int> ans(12, 0);
    bool used = false;
    for (int i = 0; i < 8; i++) {
      if (in > de[i]) {
        ans[i] = 1;
        in -= de[i];
        used = true;
      }
    }
    for (int i = 0; i < 4; i++) {
      if (in > dou[i]) {
        if (in > dou[i]) {
          ans[i + 8] = 1;
          in -= dou[i];
          used = true;
        }
      }
    }
    if (used && in == 0) {
      for (int i = 0; i < 8; i++)
        cout << ans[i];
      cout << ".";
      for (int i = 8; i < 12; i++)
        cout << ans[i];
      cout << endl;
    } else
      cout << "NA" << endl;
  }
}
Problem p00221 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#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 all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
const int inf = 1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
string itos(int a) {
  string s = "";
  while (a) {
    s = (char)(a % 10 + '0') + s;
    a /= 10;
  }
  return s;
}
int main() {
  int n, m;
  while (cin >> n >> m, n + m) {
    vector<bool> ha(n, true);
    vector<string> in(m);
    rep(i, m) cin >> in[i];
    int co = 0;
    int no = n;
    loop(i, 1, m + 1) {
      if (no == 1)
        break;
      //??£?§£???????¨?
      string s = itos(i);
      if (i % 15 == 0)
        s = "FizzBuzz";
      else if (i % 5 == 0)
        s = "Buzz";
      else if (i % 3 == 0)
        s = "Fizz";
      //??°????¨???????
      while (ha[co] == false) {
        co++;
        if (co == n)
          co = 0;
      }
      //????¨?????????£?§£????????±???
      string a = in[i - 1];
      if (a != s) {
        no--;
        ha[co] = false;
      }
      co++;
      if (co == n)
        co = 0;
    }
    vi out;
    rep(i, n) if (ha[i]) out.pb(i + 1);
    rep(i, out.size() - 1) cout << out[i] << " ";
    cout << out[out.size() - 1] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <time.h>
#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 all(in) in.begin(), in.end()
const double PI = acos(-1);
const double EPS = 1e-10;
const int inf = 1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
string itos(int a) {
  string s = "";
  while (a) {
    s = (char)(a % 10 + '0') + s;
    a /= 10;
  }
  return s;
}
int main() {
  int n, m;
  while (cin >> n >> m, n + m) {
    vector<bool> ha(n, true);
    int co = 0;
    int no = n;
    loop(i, 1, m + 1) {
      if (no == 1)
        break;
      // テヲツュツ」ティツァツ」テ」ツ?ョテァツ卍コティツィツ?
      string s = itos(i);
      if (i % 15 == 0)
        s = "FizzBuzz";
      else if (i % 5 == 0)
        s = "Buzz";
      else if (i % 3 == 0)
        s = "Fizz";
      // ティツェツーテ」ツ?古ィツィツ?」ツ??」ツ??
      while (ha[co] == false) {
        co++;
        if (co == n)
          co = 0;
      }
      // テァツ卍コティツィツ?」ツ?古、ツクツ催ヲツュツ」ティツァツ」テ」ツ?ェテ」ツつ嘉・ツ、ツアテヲツ?シ
      string a;
      cin >> a;
      if (a != s) {
        no--;
        ha[co] = false;
      }
      co++;
      if (co == n)
        co = 0;
    }
    vi out;
    rep(i, n) if (ha[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: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;

string fb(int x) {
  if (x % 15 == 0)
    return "FizzBuzz";
  if (x % 3 == 0)
    return "Fizz";
  if (x % 5 == 0)
    return "Buzz";
  char c[1050];
  sprintf(c, "%d", x);
  string res = c;
  return res;
}

int main() {
  int a, b;
  while (cin >> a >> b, a | b) {
    set<int> alive;
    int left = a, p = 0;
    for (int i = 0; i < a; i++)
      alive.insert(i);
    set<int>::iterator it = alive.begin();
    for (int i = 1; i <= b; i++) {
      string u;
      cin >> u;
      if (left == 1)
        continue;
      if (u != fb(i)) {
        alive.erase(it++);
        left--;
      } else {
        it++;
      }
      if (it == alive.end())
        it = alive.begin();
    }
    it = alive.begin();
    while (it != alive.end()) {
      if (it != alive.begin())
        cout << " ";
      cout << 1 + *it;
      it++;
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;

string fb(int x) {
  if (x % 15 == 0)
    return "FizzBuzz";
  if (x % 3 == 0)
    return "Fizz";
  if (x % 5 == 0)
    return "Buzz";
  char c[1050];
  sprintf(c, "%d", x);
  string res = c;
  return res;
}

int main() {
  int a, b;
  while (cin >> a >> b, a | b) {
    set<int> alive;
    int left = a, p = 0;
    for (int i = 0; i < a; i++)
      alive.insert(i);
    set<int>::iterator it = alive.begin();
    for (int i = 1; i <= b; i++) {
      string u;
      cin >> u;
      if (u != fb(i)) {
        alive.erase(it++);
        left--;
        if (left == 1)
          break;
      } else {
        it++;
      }
      if (it == alive.end())
        it = alive.begin();
    }
    it = alive.begin();
    while (it != alive.end()) {
      if (it != alive.begin())
        cout << " ";
      cout << 1 + *it;
      it++;
    }
    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, j, suu;
  while ((cin >> m >> n) && m != 0 || n != 0) {
    int check[1001] = {0};
    for (int i = 1; i <= m; i++)
      check[i] = i;
    j = 1;
    suu = m;
    for (int i = 1; i <= n; i++) {
      string str;

      cin >> str;
      if (suu > 1) {
        if (i % 15 == 0) {
          if (str != "FizzBuzz") {
            check[j] = 0;
            suu--;
          }
        } else if (i % 3 == 0) {
          if (str != "Fizz") {
            check[j] = 0;
            suu--;
          }
        } else if (i % 5 == 0) {
          if (str != "Buzz") {
            check[j] = 0;
            suu--;
          }
        } else {
          char buf[10] = {NULL};
          sprintf(buf, "%d", i);
          if (str != buf) {
            check[j] = 0;
            suu--;
          }
        }
        // j++;
        /*int x;
                for (x = j; check[x] == 0;) {
                        x++;
                        if (x > m)x = 1;
                }
        j = x;*/
        int j2 = j;
        for (int x = j + 1; x <= m; x++) {
          if (check[x] != 0) {
            j2 = x;
            break;
          }
        }
        if (j == j2)
          for (int x = 1; x < j; x++) {
            if (check[x] != 0) {
              j2 = x;
              break;
            }
          }
        j = j2;
      }
    }
    int las;
    for (int i = m; i > 0; i--)
      if (check[i] != 0) {
        las = i;
        break;
      }
    for (int i = 1; i <= m; i++) {
      if (check[i] != 0) {
        cout << i;
        if (i < las)
          cout << " ";
      }
    }
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
int main() {
  int n, m, j, suu;
  while ((cin >> m >> n) && m != 0 || n != 0) {
    int check[1001] = {0};
    for (int i = 1; i <= m; i++)
      check[i] = i;
    j = 1;
    suu = m;
    for (int i = 1; i <= n; i++) {
      string str;
      cin >> str;
      if (suu > 1) {
        if (i % 15 == 0) {
          if (str != "FizzBuzz") {
            check[j] = 0;
            suu--;
          }
        } else if (i % 3 == 0) {
          if (str != "Fizz") {
            check[j] = 0;
            suu--;
          }
        } else if (i % 5 == 0) {
          if (str != "Buzz") {
            check[j] = 0;
            suu--;
          }
        } else {
          char buf[10] = {NULL};
          sprintf(buf, "%d", i);
          if (str != buf) {
            check[j] = 0;
            suu--;
          }
        }
        j++;
        int x;
        for (x = j;;) {
          if (check[x] == 1)
            break;
          x++;
          if (x > m)
            x = 1;
        }
        j = x;
      }
    }
    int las;
    for (int i = m; i > 0; i--)
      if (check[i] != 0) {
        las = i;
        break;
      }
    for (int i = 1; i <= m; i++) {
      if (check[i] != 0) {
        cout << i;
        if (i < las)
          cout << " ";
      }
    }
    cout << endl;
  }
}