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

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

  int x;
  cin >> x;

  int ans = 0;
  map<int, int> xx;
  map<int, int> yy;
  yy[0]++;
  ans++;
  int deg = x;
  bool chk = false;
  while (!chk) {
    if (deg == 0) {
      break;
    } else {
      ans++;
      deg = (deg + x) % 360;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

  int x;
  cin >> x;
  int ans = 0;
  map<int, int> muki;
  int deg = 0;
  set<int> s;
  s.insert(0);
  ans = 1;
  deg = x;
  while (!s.empty()) {
    if (s.find((deg + 180) % 360) != s.end()) {
      s.erase((deg + 180) % 360);
    } else {
      s.insert(deg);
    }
    deg = (deg + x) % 360;
    ans++;
  }
  cout << ans << endl;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using itn = int;

int main(void) {
  int x;
  cin >> x;

  for (int i = 1; i <= 10000; i++) {
    if (i * x % 360 == 0) {
      cout << i << endl;
      break;
    }
    /*if(i * (180 - x) % 360 == 0){
        cout << i << endl;
        break;
    }*/
  }

  // cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using itn = int;

int main(void) {
  int x;
  cin >> x;

  int ans = 0, en = 360, en2 = 360;
  while (1) {
    if (en % x == 0) {
      ans = en / x;
      break;
    } else
      en += en % x;

    if (en2 % (180 - x) == 0) {
      ans = en2 / (180 - x);
      break;
    } else
      en2 += en2 % (180 - x);
  }

  cout << ans << endl;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define MOD 1000000007
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define vvll vector<vector<ll>>
#define mll map<ll, ll>
#define mcl map<char, ll>
#define sc set<char>
#define sll set<ll>
#define ssll stack<ll>
#define CHK(param) cout << #param << " is : " << param << "\\n";
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define LAUV                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define TC                                                                     \\
  ll TTTT;                                                                     \\
  cin >> TTTT;                                                                 \\
  while (TTTT--)
using namespace std;

int32_t main() {
  LAUV;
  // TC
  {
    ll x;
    cin >> x;
    ll k = 1;
    while ((k * x) % 360 != 0) {
      k++;
    }
    cout << k << '\\n';
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
#define forn(i, start, end) for (ll i = start; i < ll(end); i++)
#define input(arr, n) forn(i, 0, n) cin >> arr[i];
#define MOD 1000000007
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define vvll vector<vector<ll>>
#define mll map<ll, ll>
#define mcl map<char, ll>
#define sc set<char>
#define sll set<ll>
#define ssll stack<ll>
#define CHK(param) cout << #param << " is : " << param << "\\n";
#define pb push_back
#define ppb pop_back
#define mk make_pair
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define LAUV                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define TC                                                                     \\
  ll TTTT;                                                                     \\
  cin >> TTTT;                                                                 \\
  while (TTTT--)
using namespace std;

int32_t main() {
  LAUV;
  // TC
  {
    ll x;
    cin >> x;
    ll k = 1;
    while (k * x != 360) {
      k++;
    }
    cout << k << '\\n';
  }
  return 0;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define int long long
using namespace std;

const int N = 2e5 + 5;

int kol[N];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x;
  cin >> x;
  // for (int x = 1; x <= 179; x++) {
  kol[0]++;
  int ans = 1;
  int sum = 1;
  int cur = 0;
  double cx = 0, cy = 0;
  cx = 1;
  while (abs(cx) > 1e-10 || abs(cy) > 1e-10) {
    cur += x;
    cur %= 360;
    ans++;
    /*if (cur >= 180) {
        kol[cur - 180]--;
        if (kol[cur - 180] == 0)
            sum--;
        else
            if (kol[cur - 180] == -1)
                sum++;
        cout << kol[cur - 180] << endl;
    } else {
        kol[cur]++;
        if (kol[cur] == 0)
            sum--;
        else if (kol[cur] == 1)
            sum++;
    }
    cout << cur << ' ' << sum << endl;
    */
    cy += sin(cur * 1.0 / 180 * acos(-1));
    cx += cos(cur * 1.0 / 180 * acos(-1));
    // cout << cx << ' ' << cy << endl;
  }
  cout << ans;
  // cout << x << endl;
  // }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define int long long
using namespace std;

const int N = 2e5 + 5;

int kol[N];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int x;
  cin >> x;
  kol[0]++;
  int ans = 1;
  int sum = 1;
  int cur = 0;
  while (sum != 0) {
    cur += x;
    cur %= 360;
    ans++;
    if (cur >= 180) {
      kol[cur - 180]--;
      if (kol[cur - 180] == 0)
        sum--;
      else if (kol[cur - 180] == -1)
        sum++;
    } else {
      kol[cur]++;
      if (kol[cur] == 0)
        sum--;
      else if (kol[cur] == 1)
        sum++;
    }
  }
  cout << ans;
  return 0;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstdlib>
using namespace std;
int x, now;
int main() {
  scanf("%d", &x);
  for (int ii = 1;; ++ii) {
    now += x;
    if (now % 360 == 0) {
      printf("%d", ii);
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;
int x, cnt[181], flag = 1, now;
int main() {
  scanf("%d", &x);
  for (int ii = 1;; ++ii) {
    cnt[now] += flag;
    now += x;
    if (now >= 180) {
      now -= 180;
      flag *= -1;
    }
    for (int i = 0; i < 180; ++i)
      if (cnt[i])
        goto lp;
    printf("%d", ii);
    return 0;
  lp:;
  }
}
Problem p02633 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

int hcf(int a, int b) {
  if (b == 0)
    return a;
  return hcf(b, a % b);
}

int main() {
  fastio();

  int x;
  cin >> x;

  cout << 360 / hcf(360, x) << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

int main() {
  fastio();

  int x;
  cin >> x;

  // x/180 = 1 - 2/n
  assert(360 % x == 0);

  cout << 360 / (x) << endl;

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

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long int x;
  cin >> x;
  // x = 180 - x;
  for (long long int i = 3;; i++) {
    long double n = i;
    if ((i * x) % 360 == 0)
      return cout << i, 0;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  long double x;
  cin >> x;
  x = 180 - x;
  for (long double i = 3;; i++) {
    long double n = i;
    if (x * n == 180 * (n - 2))
      return cout << i, 0;
  }
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define puts(i) cout << i << endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

ll divisor = 1000000007;

int main() {
  int x;
  cin >> x;
  int i = 1;
  while (true) {
    if ((i * x) % 360 == 0) {
      puts(i);
      return 0;
    }
    i++;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define puts(i) cout << i << endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define inf 10000
using ll = long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

ll divisor = 1000000007;

int main() {
  int x;
  cin >> x;
  int i = 1;
  while (true) {
    if ((i * x) % 360 == 0) {
      puts(i);
      return 0;
    }
  }
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int k;

  cin >> k;
  //	for(int k = 1;k<=179;k++)
  {
    vector<int> sin(91), cos(91);
    int now = 0;
    for (int i = 0;; i++) {
      if (now <= 90) {
        sin[now]++;
        cos[now]++;
      } else if (now <= 180) {
        int x = 180 - now;
        sin[x]++;
        cos[x]--;
      } else if (now <= 270) {
        int x = now - 180;
        sin[x]--;
        cos[x]--;
      } else {
        int x = 360 - now;
        sin[x]--;
        cos[x]++;
      }
      bool flg = true;
      for (int j = 1; j < 91; j++)
        if (sin[j])
          flg = false;
      for (int j = 0; j < 90; j++)
        if (cos[j])
          flg = false;
      if ((i + 1) * k % 360 == 0) {
        cout << i + 1 << endl;
        break;
        return 0;
      }
      (now += k) %= 360;
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int k;
  cin >> k;
  vector<int> sin(91), cos(91);
  int now = 0;
  for (int i = 0;; i++) {
    if (now <= 90) {
      sin[now]++;
      cos[now]++;
    } else if (now <= 180) {
      int x = 180 - now;
      sin[x]++;
      cos[x]--;
    } else if (now <= 270) {
      int x = 270 - now;
      sin[x]--;
      cos[x]--;
    } else {
      int x = 360 - now;
      sin[x]--;
      cos[x]++;
    }
    bool flg = true;
    for (int j = 1; j < 91; j++)
      if (sin[j])
        flg = false;
    for (int j = 0; j < 90; j++)
      if (cos[j])
        flg = false;
    if (flg) {
      cout << i + 1 << endl;
      return 0;
    }
    (now += k) %= 360;
  }
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i <= (int)n; i++)
#define sp(n) cout << fixed << setprecision(n)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef long long ll;
using namespace std;
int main(void) {
  int x;
  cin >> x;
  int y = 1;
  while (true) {
    if (360 * y % x == 0) {
      cout << 360 * y / x << endl;
      return 0;
    }
    y++;
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep1(i, n) for (int i = 1; i <= (int)n; i++)
#define sp(n) cout << fixed << setprecision(n)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef long long ll;
using namespace std;
int main(void) {
  int x;
  cin >> x;
  int y = 1;
  while (true) {
    if (360 * y % x == 0) {
      cout << 360 * y / x << endl;
      return 0;
    }
  }
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, i = 0, s = 1;
  cin >> n;
  while (s != 0) {
    i++;
    s = n * i;
    s = s % 360;
  }
  cout << i << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, i = 1, s = 1;
  cin >> n;
  while (s != 0) {
    s = n * i;
    s = s % 360;
  }
  cout << i << endl;
  return 0;
}
Problem p02633 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#include <bits/stdc++.h>
#include <unordered_map>
#define M 1000000007
#define T 998244353
#define pi 3.14159265
#define N 100003
#define inf 1000000002
#define ll long long
#define fo(i, a, b) for (i = a; i <= b; i++)
#define ro(i, b, a) for (i = b; i >= a; i--)
#define foe(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fil(x, y) memset(x, y, sizeof(x))
#define deb(x) cout << #x << " " << x << "\\n"

using namespace std;

int gcd(int a, int b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
void solve() {
  int x;
  cin >> x;
  cout << lcm(360, x) / x << "\\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  // int _t;cin >> _t; while(_t--)
  solve();
  return 0;
}


Error: WA

Fixed submission:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#include <bits/stdc++.h>
#include <unordered_map>
#define M 1000000007
#define T 998244353
#define pi 3.14159265
#define N 100003
#define inf 1000000002
#define ll long long
#define fo(i, a, b) for (i = a; i <= b; i++)
#define ro(i, b, a) for (i = b; i >= a; i--)
#define foe(it, x) for (auto it = x.begin(); it != x.end(); it++)
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define fil(x, y) memset(x, y, sizeof(x))
#define deb(x) cout << #x << " " << x << "\\n"

using namespace std;

int gcd(int a, int b) {
  if (a == 0)
    return b;
  return gcd(b % a, a);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
void solve() {
  int x;
  cin >> x;
  cout << lcm(360, x) / x << "\\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  int _t;
  cin >> _t;
  while (_t--)
    solve();
  return 0;
}
Problem p02633 (C++) — buggy submission, verdict: Runtime Error

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

#define faster                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

#define sq(x) (x) * (x)
#define PI acos(-1.0)
#define nl '\\n'

typedef long long int ll;
typedef unsigned long long int llu;

int main() {
  int n, ans = 0, x = 0;
  cin >> n;
  while (1) {
    x += n;
    ans++;
    if (x % 360 == 0)
      break;
  }
  cout << ans << nl;

  return 0;
}


Error: 0

Fixed submission:

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

#define faster                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

#define sq(x) (x) * (x)
#define PI acos(-1.0)
#define nl '\\n'

typedef long long int ll;
typedef unsigned long long int llu;

int main() {
  int n;
  cin >> n;
  cout << 360 / (n - 1) << nl;
  return 0;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair

int main() {
  ll x;
  cin >> x;
  ll a = 360;
  while (1) {
    if (a % x == 0) {
      cout << a / x << endl;
      return 0;
    }
    a += 360;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair

int main() {
  ll x;
  cin >> x;
  while (1) {
    ll a = 360;
    if (a % x == 0) {
      cout << a / x << endl;
      return 0;
    }
    a += 360;
  }
}
Problem p02633 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#include <iomanip>
#include <math.h>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1001001001;
vector<pair<int64_t, int64_t>> pppp(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int64_t i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}

int main() {
  int X;
  cin >> X;
  cout << X * 360 / __gcd(X, 360) / X << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#include <iomanip>
#include <math.h>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1001001001;
vector<pair<int64_t, int64_t>> pppp(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int64_t i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}

int main() {
  int X;
  cout << 360 / X << endl;
  return 0;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int saisyo(int a, int b) { // a > b
  int x = a * b;
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return x / b;
}

int main(void) {
  int x;
  int k;
  cin >> x;

  int dig = saisyo(360, x);

  //  cout << "dig" << dig << '\\n';

  k = dig / x;

  //  cout << "ans" << k;
  cout << k;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int x;
  int k;
  cin >> x;

  int i = 1;

  while (1) {
    int dig = 360 * i;
    if (dig % x == 0) {
      k = dig / x;
      break;
    }
  }

  cout << k;

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

#include <iostream>

#define int long long

int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

signed main() {
  int x;
  std::cin >> x;

  int y = gcd(x, 360);
  std::cout << 360 / y << std::endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

#define int long long

int gcd(int a, int b) {
  if (a == 0)
    return b;

  return gcd(a, b % a);
}

signed main() {
  int x;
  std::cin >> x;

  int y = gcd(x, 360);
  int lcm = x / y;
  lcm *= 360;
  std::cout << lcm / x << std::endl;

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

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

int main(void) {
  int X, K = 2;
  static const double pi = 3.141592653589793;
  cin >> X;

  float x = 0.0, y = 1.0, theta;
  while (true) {
    theta = float(X * (K - 1) * pi) / 180.0;
    x += sin(theta);
    y += cos(theta);
    if (x < 0.001 && x > -0.001 && y < 0.001 && y > -0.001) {
      break;
    }
    K++;
  }
  cout << K;
}

Error: TLE

Fixed submission:

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

int main(void) {
  int X, K = 2;
  static const double pi = 3.141592653589793;
  cin >> X;

  float x = 0.0, y = 1.0, theta;
  while (true) {
    theta = float(X * (K - 1) * pi) / 180.0;
    x += sin(theta);
    y += cos(theta);
    if (x < 0.0001 && x > -0.0001 && y < 0.0001 && y > -0.0001) {
      break;
    }
    K++;
  }
  cout << K;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main(void) {
  IOS;
  int x;
  cin >> x;
  int y = 360;
  int g = __gcd(x, y);
  x /= g, y /= g;
  cout << y << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main(void) {
  IOS;
  int x;
  cin >> x;
  if (360 % x == 0)
    cout << 360 / x << endl;
  else
    while (1)
      ;
  return 0;
}
Problem p02633 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 998244353;
const double PI = 2 * acos(0);
int cnt[180];

int main() {
  int X;
  scanf("%d", &X);
  if (360 % X == 0) {
    cout << 360 / X << "\\n";
    return 0;
  }
  cnt[0]++;
  int sudut = 360 - X, ans = 1;
  while (1) {
    ans++;
    if (sudut >= 180)
      cnt[sudut - 180]--;
    else
      cnt[sudut]++;
    sudut -= X;
    if (sudut < 0)
      sudut += 360;
    bool cek = 1;
    for (int i = 0; i < 180; i++)
      if (cnt[i] != 0)
        cek = 0;
    if (cek) {
      printf("%d\\n", ans);
      return 0;
    }
  }
}

Error: TLE

Fixed submission:

// A
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 998244353;
const double PI = 2 * acos(0);
int cnt[180];

int main() {
  int X;
  scanf("%d", &X);
  cnt[0]++;
  int sudut = 360 - X, ans = 1;
  while (1) {
    ans++;
    if (sudut >= 180)
      cnt[sudut - 180]--;
    else
      cnt[sudut]++;
    sudut -= X;
    if (sudut < 0)
      sudut += 360;
    bool cek = 1;
    for (int i = 0; i < 180; i++)
      if (cnt[i] != 0)
        cek = 0;
    if (cek) {
      printf("%d\\n", ans);
      return 0;
    }
  }
}