prithivMLmods/Coder-Stat huggingface dataset:
Problem p03581 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define For(i, a, b) for (int i = a, i##E = b; i <= i##E; ++i)
#define rFor(i, a, b) for (int i = a, i##E = b; i >= i##E; --i)
typedef long long LL;
using namespace std;
const int N = 2010;
const LL mod = 1e9 + 7;
template <typename T> inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T> inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T> inline void read(T &x) {
  x = 0;
  int _f(0);
  char ch = getchar();
  while (!isdigit(ch))
    _f |= (ch == '-'), ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = _f ? -x : x;
}
inline void file() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
}
int n, m;
LL C[N][N], S[N][N], ans;
inline void init(int n) {
  C[0][0] = 1;
  For(i, 1, n) For(j, 0, i) C[i][j] =
      (C[i - 1][j] + (j ? C[i - 1][j - 1] : 0)) % mod;
  For(i, 0, n) For(j, 0, n) S[i][j] = ((j ? S[i][j - 1] : 0) + C[i][j]) % mod;
}
int main() {
  file();
  read(n), read(m);
  init(max(n, m));
  ans = n + 1;
  For(i, 0, n) {
    LL ret = 0;
    For(j, 1, n - i) ret =
        (ret + C[m - 1][j] * S[j - 1][n - i - j] % mod) % mod;
    ans = (ans + ret * ((LL)i + 1) % mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define For(i, a, b) for (int i = a, i##E = b; i <= i##E; ++i)
#define rFor(i, a, b) for (int i = a, i##E = b; i >= i##E; --i)
typedef long long LL;
using namespace std;
const int N = 2010;
const LL mod = 1e9 + 7;
template <typename T> inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T> inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T> inline void read(T &x) {
  x = 0;
  int _f(0);
  char ch = getchar();
  while (!isdigit(ch))
    _f |= (ch == '-'), ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = _f ? -x : x;
}
inline void file() {
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
}
int n, m;
LL C[N][N], S[N][N], ans;
inline void init(int n) {
  C[0][0] = 1;
  For(i, 1, n) For(j, 0, i) C[i][j] =
      (C[i - 1][j] + (j ? C[i - 1][j - 1] : 0)) % mod;
  For(i, 0, n) For(j, 0, n) S[i][j] = ((j ? S[i][j - 1] : 0) + C[i][j]) % mod;
}
int main() {
  // file();
  read(n), read(m);
  init(max(n, m));
  ans = n + 1;
  For(i, 0, n) {
    LL ret = 0;
    For(j, 1, n - i) ret =
        (ret + C[m - 1][j] * S[j - 1][n - i - j] % mod) % mod;
    ans = (ans + ret * ((LL)i + 1) % mod) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
Problem p03581 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define syosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P, int> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const ll INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};

const int M = 2005;
ll A, B, C[M][M], S[M][M + 1], dp[2 * M][M];

int main() {
  cin >> A >> B;
  C[0][0] = S[0][1] = dp[0][0] = 1;
  for (int i = 1; i < M; i++)
    for (int j = 0; j <= i; j++)
      C[i][j] = (C[i - 1][j] + (j ? C[i - 1][j - 1] : 0)) % mod;
  for (int i = 1; i < M; i++)
    for (int j = 1; j <= i + 1; j++)
      S[i][j] = (C[i][j - 1] + S[i][j - 1]) % mod;
  for (int i = 1; i < 2 * M; i++)
    for (int j = 0; j <= min(M, i); j++) {
      if (j)
        dp[i][j] = (dp[i - 1][j] + S[j - 1][j] -
                    S[j - 1][max(0, 2 * j - i - 1)] + mod) %
                   mod;
      else
        dp[i][j]++;
    }
  ll res = 0;
  for (int i = 0; i <= A; i++)
    for (int j = max(1ll, B - A + i); j <= B; j++)
      (res += C[B - 1][j - 1] * dp[A - i][B - j]) %= mod;
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define syosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P, int> pip;
typedef vector<pip> vip;
const int inf = 1 << 30;
const ll INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};

const int M = 2005;
ll A, B, C[M][M], S[M][M + 1], dp[2 * M][M];

int main() {
  cin >> A >> B;
  C[0][0] = S[0][1] = dp[0][0] = 1;
  for (int i = 1; i < M; i++)
    for (int j = 0; j <= i; j++)
      C[i][j] = (C[i - 1][j] + (j ? C[i - 1][j - 1] : 0)) % mod;
  for (int i = 1; i < M; i++)
    for (int j = 1; j <= i + 1; j++)
      S[i][j] = (C[i][j - 1] + S[i][j - 1]) % mod;
  for (int i = 1; i < 2 * M; i++)
    for (int j = 0; j <= min(M, i); j++) {
      if (j)
        dp[i][j] = (dp[i - 1][j] + S[j - 1][j] -
                    S[j - 1][max(0, min(j, 2 * j - i - 1))] + mod) %
                   mod;
      else
        dp[i][j]++;
    }
  ll res = 0;
  for (int i = 0; i <= A; i++)
    for (int j = max(1ll, B - A + i); j <= B; j++)
      (res += C[B - 1][j - 1] * dp[A - i][B - j]) %= mod;
  cout << res << endl;
}
Problem p03582 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
string ans;
void dfs(int a, int b, int c, string aa, string bb, string cc) {
  string nowa, nowb, nowc;
  if (a == 0) {
    dfs(b, c, 0, bb, cc, "");
  }
  if ((b == 0) && (c == 0)) {
    int i;
    for (i = 0; i < a; i++) {
      ans += aa;
    }
    return;
  }
  nowa = aa;
  int j;
  for (j = 0; j < c / a; j++) {
    nowa += cc;
  }
  int newc = c % a;
  nowc = nowa + cc;
  a -= newc;
  for (j = 0; j < b / a; j++) {
    nowa += bb;
  }
  int newb = b % a;
  nowb = nowa + bb;
  a -= newb;
  dfs(a, newb, newc, nowa, nowb, nowc);
}
int main() {
#ifdef absi2011
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  dfs(a, b, c, "a", "b", "c");
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;
string ans;
void dfs(int a, int b, int c, string aa, string bb, string cc) {
  string nowa, nowb, nowc;
  if (a == 0) {
    dfs(b, c, 0, bb, cc, "");
    return;
  }
  if ((b == 0) && (c == 0)) {
    int i;
    for (i = 0; i < a; i++) {
      ans += aa;
    }
    return;
  }
  nowa = aa;
  int j;
  for (j = 0; j < c / a; j++) {
    nowa += cc;
  }
  int newc = c % a;
  nowc = nowa + cc;
  a -= newc;
  for (j = 0; j < b / a; j++) {
    nowa += bb;
  }
  int newb = b % a;
  nowb = nowa + bb;
  a -= newb;
  dfs(a, newb, newc, nowa, nowb, nowc);
}
int main() {
#ifdef absi2011
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  dfs(a, b, c, "a", "b", "c");
  cout << ans << endl;
  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  long long N;
  cin >> N;

  for (int h = 1; h < 3501; h++) {

    for (int n = 1; n < 3501; n++) {

      auto upper = N * h * n;
      auto lower = 4 * h * n - N * n - N * h;

      if (upper % lower == 0 && upper / lower > 0) {
        cout << h << " " << n << " " << upper / lower << endl;
        return 0;
      }
    }
  }
}


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  long long N;
  cin >> N;

  for (int h = 1; h < 3501; h++) {

    for (int n = 1; n < 3501; n++) {

      auto upper = N * h * n;
      auto lower = 4 * h * n - N * n - N * h;
      if (lower != 0) {
        if (upper % lower == 0 && upper / lower > 0) {
          cout << h << " " << n << " " << upper / lower << endl;
          return 0;
        }
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
  int64_t N;
  cin >> N;

  for (int i = 1; i < 3501; i++) {
    for (int j = 1; j < 3501; j++) {
      int c = (N - i - j) / (4 * i * j - i * N - j * N);
      if (c * (4 * i * j - i * N - j * N) == (N - i - j)) {
        cout << i << " " << j << " " << c << endl;
        return 0;
      }
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
  int64_t N;
  cin >> N;

  for (int64_t i = 1; i < 3501; i++) {
    for (int64_t j = 1; j < 3501; j++) {
      if (4 * i * j - i * N - j * N == 0) {
        continue;
      }
      int64_t c = (N * i * j) / (4 * i * j - i * N - j * N);
      if (c * (4 * i * j - i * N - j * N) == (N * i * j) && c > 0) {
        cout << i << " " << j << " " << c << endl;
        return 0;
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;

int main() {
  long long int n;
  cin >> n;

  for (long long int i = 1; i < 3501; i++) {
    for (long long int j = 1; j < 3501; j++) {
      long long int p = n * i * j;
      long long int q = 4 * i * j - n * i - n * j;
      if (p % q == 0 && p / q > 0) {
        cout << i << " " << j << " " << p / q << endl;
        return 0;
      }
    }
  }

  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;

int main() {
  long long int n;
  cin >> n;

  for (long long int i = 1; i < 3501; i++) {
    for (long long int j = 1; j < 3501; j++) {
      long long int p = n * i * j;
      long long int q = 4 * i * j - n * i - n * j;
      if (q > 0 && p % q == 0) {
        cout << i << " " << j << " " << p / q << endl;
        return 0;
      }
    }
  }

  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n;
  cin >> n;
  for (ll i = 1; i <= 3500; i++) {
    for (ll j = 1; j <= 3500; j++) {

      if ((n * i * j) % (4 * i * j - n * (i + j)) == 0) {
        cout << i << j << (n * i * j) / (4 * i * j - n * (i + j)) << endl;
        return 0;
      }
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  int n;
  cin >> n;
  for (ll i = 1; i <= 3500; i++) {
    for (ll j = 1; j <= 3500; j++) {
      if (4 * i * j - n * (i + j) == 0)
        continue;
      if ((n * i * j) % (4 * i * j - n * (i + j)) == 0 &&
          (n * i * j) / (4 * i * j - n * (i + j)) > 0) {
        cout << i << " " << j << " " << (n * i * j) / (4 * i * j - n * (i + j))
             << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  int out = 1;
  for (int i = 1; i <= 3500 && out; i++) {
    for (int j = i; j <= 3500 && out; j++) {
      for (int k = j + 1; k <= 3500 && out; k++) {
        if (4 * i * j * k == N * j * k + N * i * k + N * i * j) {
          cout << i << " " << j << " " << k << endl;
          out--;
        }
      }
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;
  int out = 1;
  for (int i = 1; i <= 3500 && out; i++) {
    for (int j = i; j <= 3500 && out; j++) {
      if (4 * i * j - N * j - N * i > 0) {
        if (N * i * j % (4 * i * j - N * j - N * i) == 0) {
          out = 0;
          cout << i << " " << j << " "
               << N * i * j / (4 * i * j - N * j - N * i) << endl;
        }
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
// header {{{
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET (26)
#define INF INT_MAX
#define MOD (1000000007LL)
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)

using P = pair<int, int>;
using LL = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
  std::ios::sync_with_stdio(false);
  LL N;
  cin >> N;
  for (LL h = 1; h <= 3500; h++) {
    for (LL n = h; n <= 3500; n++) {
      for (LL w = n; w <= 3500; w++) {
        if (4LL * h * n * w == N * (n * w + w * h + h * n)) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Fixed submission:
// header {{{
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET (26)
#define INF INT_MAX
#define MOD (1000000007LL)
#define EPS (1e-10)
#define EQ(a, b) (abs((a) - (b)) < EPS)

using P = pair<int, int>;
using LL = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
  std::ios::sync_with_stdio(false);
  LL N;
  cin >> N;
  for (LL h = 1; h <= 3500; h++) {
    for (LL n = h; n <= 3500; n++) {
      LL hoge = 4LL * h * n - N * n - N * h;
      if (hoge <= 0)
        continue;
      if (N * h % hoge != 0)
        continue;
      LL w = N * h * n / hoge;
      if (4LL * h * n * w == N * (n * w + w * h + h * n)) {
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }
  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#define fi first
#define se second
#define pb push_back
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define L(i, u) for (int i = head[u]; i != 0; i = edge[i].nxt)
#define abs(a) ((a) > 0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;
int n, a, b;

inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = 10 * x + c - '0';
    c = getchar();
  }
  x *= f;
}
inline ll gcd(ll a, ll b) { return (!b) ? a : gcd(b, a % b); }
int main() {
  read(n);
  rep(i, 1, 3500) rep(j, 1, 3500) {
    ll x = (ll)n * i * j, y = (ll)4 * i * j - n * j - n * i;
    ll GCD = gcd(x, y);
    x /= GCD;
    y /= GCD;
    if (y == 1 && x >= 1 && x <= 3500) {
      printf("%d %d %lld", i, j, x);
      return 0;
    }
  }
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>
#define fi first
#define se second
#define pb push_back
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define L(i, u) for (int i = head[u]; i != 0; i = edge[i].nxt)
#define abs(a) ((a) > 0 ? (a) : -(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef long long ll;
typedef long double ld;
int n, a, b;

inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = 10 * x + c - '0';
    c = getchar();
  }
  x *= f;
}
inline ll gcd(ll a, ll b) { return (!b) ? a : gcd(b, a % b); }
int main() {
  read(n);
  rep(i, 1, 3500) rep(j, 1, 3500) {
    ll x = (ll)n * i * j, y = (ll)4 * i * j - n * j - n * i;
    //	ll GCD=gcd(x,y); x/=GCD; y/=GCD;
    if (x * y > 0 && x % y == 0) {
      printf("%d %d %lld", i, j, x / y);
      return 0;
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

/*
  let's try computer shogi!!!
 */

long int N;

int main() {
  cin >> N;
  if (N % 2 == 0) {
    cerr << "even" << endl;
    cout << N << " " << N << " " << N / 2 << endl;
  } else {
    for (long int i = 1; i < 3501; ++i) {
      for (long int j = 1; j < 3501; ++j) {
        for (long int k = 1; k < 3501; ++k) {
          if (i * j * k * 4 == N * ((i * j) + (j * k) + (k * i))) {
            cout << i << " " << j << " " << k << endl;
            break;
          }
        }
      }
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

/*
  let's try computer shogi!!!
 */

long int N;

int main() {
  cin >> N;
  if (N % 2 == 0) {
    cerr << "even" << endl;
    cout << N << " " << N << " " << N / 2 << endl;
  } else {
    for (int i = 1; i < 3500; ++i) {
      for (int j = 1; j < 3500; ++j) {
        if (4 * i * j - N * (i + j) <= 0) {
          continue;
        }
        if ((N * i * j) % (4 * i * j - N * (i + j)) == 0) {
          cout << i << " " << j << " "
               << (N * i * j) / (4 * i * j - N * (i + j)) << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;

  if (~n & 1) {
    cout << n << " " << n << " " << n / 2;
  } else {
    for (int h = 1; h <= 3500; ++h) {
      for (int w = 1; w <= 3500; ++w) {
        long long prod = n * 1LL * h * w;
        long long sum = 4LL * h * w - n * 1LL * w - n * 1LL * h;
        if (sum < 0)
          continue;
        if (prod % sum == 0) {
          int k = prod / sum;
          cout << h << " " << w << " " << k;
          return 0;
        }
      }
    }
  }

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;

  if (~n & 1) {
    cout << n << " " << n << " " << n / 2;
  } else {
    for (int h = 1; h <= 3500; ++h) {
      for (int w = 1; w <= 3500; ++w) {
        long long prod = n * 1LL * h * w;
        long long sum = 4LL * h * w - n * 1LL * w - n * 1LL * h;
        if (sum <= 0)
          continue;
        if (prod % sum == 0) {
          int k = prod / sum;
          cout << h << " " << w << " " << k;
          return 0;
        }
      }
    }
  }

  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

ll N;
int h, w, n;

int main() {

  cin >> N;
  n = N;

  for (ll x = 1; x <= 3500; x++) {
    for (ll y = 1; y <= 3500; y++) {
      ll up = n * x * y;
      ll down = 4 * x * y - n * y - n * x;
      if (up % down == 0 && up / down > 0) {
        cout << x << " " << y << " " << up / down << endl;
        return 0;
      }
    }
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double

using namespace std;

ll N;
int h, w, n;

int main() {

  cin >> N;
  n = N;

  for (ll x = 1; x <= 3500; x++) {
    for (ll y = 1; y <= 3500; y++) {
      ll up = n * x * y;
      ll down = 4 * x * y - n * y - n * x;
      if (down != 0 && up % down == 0 && up / down > 0) {
        cout << x << " " << y << " " << up / down << endl;
        return 0;
      }
    }
  }

  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):


#include <algorithm>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

int main() {

  ll N;
  cin >> N;

  for (int i = 1; i <= 3500; i++) {
    for (int j = 1; j <= 3500; j++) {
      ll bunsi = N * i * j;
      ll bunbo = 4 * i * j - N * j - N * i;

      if (bunsi % bunbo == 0) {
        ll c = bunsi / bunbo;

        if (4 * i * j * c == (N * j * c + N * i * c + N * i * j)) {
          cout << i << " " << j << " " << c << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}


Fixed submission:


#include <algorithm>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

int main() {

  ll N;
  cin >> N;

  for (int i = 1; i <= 3500; i++) {
    for (int j = 1; j <= 3500; j++) {
      ll bunsi = N * i * j;
      ll bunbo = 4 * i * j - N * j - N * i;

      if (bunbo <= 0)
        continue;

      if (bunsi % bunbo == 0) {
        ll c = bunsi / bunbo;

        if (4 * i * j * c == (N * j * c + N * i * c + N * i * j)) {
          cout << i << " " << j << " " << c << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
// #define _GLIBCXX_DEBUG

signed main() {
  int N;
  cin >> N;

  if (N % 2 == 0) {
    cout << N << " " << N << " " << N / 2 << endl;
    return 0;
  }
  if (N == 3) {
    cout << 2 << " " << 2 << " " << 3 << endl;
    return 0;
  }
  int h = 1, w = 1;
  while (true) {
    h++;
    if (N * (h + w) == 3 * h * w) {
      cout << h << " " << N << " " << w << endl;
      return 0;
    }
    w++;
    if (N * (h + w) == 3 * h * w) {
      cout << h << " " << N << " " << w << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
// #define _GLIBCXX_DEBUG

signed main() {
  int N;
  cin >> N;

  if (N % 2 == 0) {
    cout << N << " " << N << " " << N / 2 << endl;
    return 0;
  }
  if (N == 3) {
    cout << 2 << " " << 2 << " " << 3 << endl;
    return 0;
  }

  for (int h = (int)(N / 4) + 1; h < 3501; h++)
    for (int n = h; n < 3501; n++)
      for (int w = n; w < 3501; w++) {
        if (N * (h * n + n * w + w * h) == 4 * h * n * w) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  long long n = 0;
  cin >> n;
  for (long long i = 1; i <= 3500; i++) {
    for (long long j = 1; j <= 3500; j++) {
      double k = n * i * j / (4 * i * j - n * i - n * j);
      if (k == (long long)k && k > 0) {
        cout << i << " " << j << " " << (long long)k << endl;
        return 0;
      }
    }
  }
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  long long n = 0;
  cin >> n;
  for (long long i = 1; i <= 3500; i++) {
    for (long long j = 1; j <= 3500; j++) {
      if (4 * i * j - n * i - n * j == 0)
        continue;
      double k = n * i * j / (double)(4 * i * j - n * i - n * j);
      if (k == (long long)k && k > 0) {
        cout << i << " " << j << " " << (long long)k << endl;
        return 0;
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
using ll = long long;
using namespace std;
int main() {
  ll n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n << " " << n << " " << n / 2 << endl;
    return 0;
  }
  for (ll i = 1; i <= 3500; i++) {
    for (ll j = 1; j <= 3500; j++) {
      ll bunsi = n * i * j;
      ll bunbo = (4LL * i * j) - (n * i) - (n * j);
      if (bunsi % bunbo == 0 && bunsi / bunbo > 0) {
        cout << i << " " << j << " " << bunsi / bunbo;
        return 0;
      }
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
using ll = long long;
using namespace std;
int main() {
  ll n;
  cin >> n;
  if (n % 2 == 0) {
    cout << n << " " << n << " " << n / 2 << endl;
    return 0;
  }
  for (ll i = 1; i <= 3500; i++) {
    for (ll j = 1; j <= 3500; j++) {
      ll bunsi = n * i * j;
      ll bunbo = (4LL * i * j) - (n * i) - (n * j);
      if (bunbo == 0)
        continue;
      if (bunsi % bunbo == 0 && bunsi / bunbo > 0) {
        cout << i << " " << j << " " << bunsi / bunbo;
        return 0;
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  for (ll i = 1; i < 4000; i++) {
    for (ll j = 1; j < 4000; j++) {
      ll k = N * i * j / (4 * i * j - N * i - N * j);
      if (k > 0) {
        cout << i << " " << j << " " << k << '\n';
        return 0;
      }
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  for (ll i = 1; i < 4000; i++) {
    for (ll j = 1; j < 4000; j++) {
      ll a = N * i * j;
      ll b = 4 * i * j - N * (i + j);
      if (b > 0 && a % b == 0) {
        cout << i << " " << j << " " << a / b << '\n';
        return 0;
      }
    }
  }
  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll N;
  cin >> N;
  for (ll h = 1; h < 3501; h++) {
    for (ll n = 1; n < 3501; n++) {
      if (N * n * h % (4 * n * h - N * (h + n)) == 0 and
          4 * h * n > N * (n + h)) {
        cout << h << " " << n << " " << N * n * h / (4 * n * h - N * (h + n))
             << endl;
        return 0;
      }
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll N;
  cin >> N;
  for (ll h = 1; h < 3501; h++) {
    for (ll n = 1; n < 3501; n++) {
      ll a = N * n * h;
      ll b = 4 * h * n - N * (n + h);
      if (b > 0 and a % b == 0) {
        cout << h << " " << n << " " << a / b << endl;
        return 0;
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
long long n, a, b, c, d, e, f;
int main() {
  cin >> n;
  for (b = 1; a <= 3500; a++)
    for (a = 1; b <= 3500; b++) {
      long long x = n * a * b;
      c = 4 * a * b - b * n - a * n;
      if (c <= 0)
        continue;
      if (x > c && x % c == 0) {
        c = x / c;
        cout << a << " " << b << " " << c << endl;
        return 0;
      }
    }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
long long n, a, b, c, d, e, f;
int main() {
  cin >> n;
  for (a = 1; a <= 3500; a++)
    for (b = 1; b <= 3500; b++) {
      long long x = n * a * b;
      c = 4 * a * b - b * n - a * n;
      if (c <= 0)
        continue;
      if (x > c && x % c == 0) {
        c = x / c;
        cout << a << " " << b << " " << c << endl;
        return 0;
      }
    }
  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for (auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for (auto i = n; i != k; i--)
#define all(x, r) (x), (x) + (r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template <class T> using V = vector<T>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  if (N % 2 == 0) {
    cout << N << " " << N << " " << N / 2 << endl;
    return 0;
  }

  REP(h, 1, 3501) {
    REP(n, 1, 3501) {
      int w = N * h * n / (4 * h * n - (n + h) * N);
      if (w > 0 && (h * n + n * w + w * h) * N == 4 * h * n * w) {
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }

  return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for (auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for (auto i = n; i != k; i--)
#define all(x, r) (x), (x) + (r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int, int>;
using Tiii = tuple<int, int, int>;
template <class T> using V = vector<T>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  if (N % 2 == 0) {
    cout << N << " " << N << " " << N / 2 << endl;
    return 0;
  }

  REP(h, 1, 3501) {
    REP(n, 1, 3501) {
      if (4 * h * n - (n + h) * N == 0)
        continue;
      ll w = N * h * n / (4 * h * n - (n + h) * N);
      if (w > 0 && (h * n + n * w + w * h) * N == 4 * h * n * w) {
        cout << h << " " << n << " " << w << endl;
        return 0;
      }
    }
  }

  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <typename T> T _gcd(T a, T b) { return b ? _gcd(b, a % b) : a; }

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

void f(ll n) {
  for (ll q = 1; q <= 3500; q++) {
    for (int p = q; p <= 3500; p++) {
      ll s = n * p * q;
      ll t = 4 * p * q - n * (p + q);

      if (t < 0)
        t *= -1;

      if (s % t == 0) {
        cout << p << " " << q << " " << s / t << endl;
        return;
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n;
  cin >> n;

  f(n);
}

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <typename T> T _gcd(T a, T b) { return b ? _gcd(b, a % b) : a; }

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

void f(ll n) {
  for (ll q = 1; q <= 3500; q++) {
    for (int p = q; p <= 3500; p++) {
      ll s = n * p * q;
      ll t = 4 * p * q - n * (p + q);

      if (t <= 0)
        continue;

      if (s % t == 0) {
        cout << p << " " << q << " " << s / t << endl;
        return;
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n;
  cin >> n;

  f(n);
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
int mod = 1e9 + 7;
typedef long long ll;

int main() {
  long long N;
  cin >> N;

  for (long long h = 1; h <= 3500; h++) {
    for (long long w = 1; w <= 3500; w++) {
      long long n = (N * h * w) / ((4 * h - N) * w - w * h);
      long double n_ = (N * h * w) / ((4 * h - N) * w - w * h);
      if (n == n_ && n > 0) {
        printf("%ld %ld %ld\n", h, w, n);
        return 0;
      }
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i++)
int mod = 1e9 + 7;
typedef long long ll;

int main() {
  long long N;
  cin >> N;

  for (long long h = 1; h <= 3500; h++) {
    for (long long w = 1; w <= 3500; w++) {
      long long n = (N * h * w) / ((4 * h - N) * w - N * h);
      if (((4 * h - N) * w - N * h) > 0 &&
          (N * h * w) % ((4 * h - N) * w - N * h) == 0) {
        printf("%ld %ld %ld\n", h, w, n);
        return 0;
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n, x)                                                             \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template <class T> using V = vector<T>;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const ll INF = 1e18;

int main() {
  ll N;
  cin >> N;
  ll w, ww, www;
  for (ll n = 1; n <= 3500; n++) {
    for (ll h = 1; h <= 3500; h++) {
      ll z = 4 * n * h - n * N - h * N;
      if (z <= 0)
        continue;
      ll x = __gcd(z, n);
      ll y = n / x;
      z /= x;
      ll a = __gcd(z, h);
      ll b = h / a;
      z /= a;
      ll c = __gcd(z, N);
      ll d = N / c;
      z /= c;
      if (z == 1) {
        w = d * b * y;
        ww = h;
        www = n;
        break;
      }
    }
  }
  cout << w << ' ' << ww << ' ' << www << endl;
}
// ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算の際にオーバーフローに注意せよ！(適切にmodをとれ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
*/

Fixed submission:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n, x)                                                             \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template <class T> using V = vector<T>;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const ll INF = 1e18;

int main() {
  ll N;
  cin >> N;
  ll w, ww, www;
  for (ll n = 1; n <= 3500; n++) {
    for (ll h = 1; h <= 3500; h++) {
      ll z = 4 * n * h - n * N - h * N;
      if (z <= 0)
        continue;
      ll a = N * h * n;
      if (a % z == 0) {
        w = a / z;
        ww = h;
        www = n;
        break;
      }
    }
  }
  cout << w << ' ' << ww << ' ' << www << endl;
}
// ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算の際にオーバーフローに注意せよ！(適切にmodをとれ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
*/
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define rrep(i, m, n) for (lli i = m - 1; i >= n; i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(), N.end()), N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K, L, N, S) vector<L> K(N, S)
#define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S))
#define TV(K, L, N, M, R, S)                                                   \
  vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S)))
#define pint pair<lli, lli>
#define paf(L, R) pair<L, R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a) a.begin(), a.end()
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A, B, C, D, E, F, N, M, K, L, R, X, Y, Z, H, W, sum = 0, num = 0,
                                                      flag = 0;
  string S, T;
  cin >> N;
  rep(i, 1, 3501) if (!flag)
      rep(j, 1, 3501) if ((N * i * j) % (4 * i * j - N * (i + j)) == 0) {
    cout << i << " " << j << " " << (N * i * j) / (4 * i * j - N * (i + j))
         << endl;
    flag = 1;
    break;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define rrep(i, m, n) for (lli i = m - 1; i >= n; i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(), N.end()), N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(), n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K, L, N, S) vector<L> K(N, S)
#define DV(K, L, N, M, S) vector<vector<L>> K(N, vector<L>(M, S))
#define TV(K, L, N, M, R, S)                                                   \
  vector<vector<vector<L>>> K(N, vector<vector<L>>(M, vector<L>(R, S)))
#define pint pair<lli, lli>
#define paf(L, R) pair<L, R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a) a.begin(), a.end()
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A, B, C, D, E, F, N, M, K, L, R, X, Y, Z, H, W, sum = 0, num = 0,
                                                      flag = 0;
  string S, T;
  cin >> N;
  rep(i, 1, 3501) if (!flag)
      rep(j, 1, 3501) if (4 * i * j - N * (i + j) > 0 &&
                          (N * i * j) % (4 * i * j - N * (i + j)) == 0) {
    cout << i << " " << j << " " << (N * i * j) / (4 * i * j - N * (i + j))
         << endl;
    flag = 1;
    break;
  }
}
Problem p03583 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int a, h, n, w;
  cin >> a;
  h = a / 4 + 1;
  for (n = h;; ++n)
    if (4 * h * n - a * n - a * h != 0 &&
        a * h * n % (4 * h * n - a * n - a * h) == 0) {
      w = a * h * n / (4 * h * n - a * n - a * h);
      if (w > 0)
        break;
    }
  cout << h << " " << n << " " << w;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int a, h, n, w;
  cin >> a;
  for (h = 1; h <= 4500; ++h)
    for (n = 1; n <= 4500; ++n)
      if (4 * h * n - a * (n + h) &&
          a * h * n % (4 * h * n - a * (n + h)) == 0) {
        w = a * h * n / (4 * h * n - a * (n + h));
        if (w > 0) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
  return 0;
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
// ↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n) n.begin(), n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long> dij;
struct edge {
  long long to, cost;
};
vector<vector<edge>> G;

long long mod_pow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % MOD;
    }
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

void addedge(int from, int to, int cost) {
  G[from].push_back({to, cost});
  G[to].push_back({from, cost});
}

// ↑template↑

int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= 3500; ++i) {
    for (long long j = 1; j <= 3500; ++j) {
      long long mon = 4 * i * j - n * i - n * j;
      if ((n * i * j) % mon == 0 && mon > 0) {
        cout << i << " " << j << " " << (n * i * j) / mon << endl;
        return 0;
      }
    }
  }
}

Fixed submission:
// ↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n) n.begin(), n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long> dij;
struct edge {
  long long to, cost;
};
vector<vector<edge>> G;

long long mod_pow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % MOD;
    }
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

void addedge(int from, int to, int cost) {
  G[from].push_back({to, cost});
  G[to].push_back({from, cost});
}

// ↑template↑

int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= 3500; i++) {
    for (long long j = 1; j <= 3500; j++) {
      long long k = 4 * i * j - n * j - n * i;
      long long l = i * j * n;
      if (k > 0 && l % k == 0) {
        cout << i << " " << j << " " << l / k << endl;
        return 0;
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;

  for (int h = 1; h <= 3500; h++) {
    for (int n = 1; n <= 3500; n++) {
      if ((N * h * n) % (4 * h * n - N * n - N * h) == 0) {
        int w = (N * h * n) / (4 * h * n - N * n - N * h);
        if (w > 0) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin >> N;

  for (int h = 1; h <= 3500; h++) {
    for (int n = 1; n <= 3500; n++) {
      if (4 * h * n - N * n - N * h == 0)
        continue;
      if ((N * h * n) % (4 * h * n - N * n - N * h) == 0) {
        int w = (N * h * n) / (4 * h * n - N * n - N * h);
        if (w > 0) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using Graph = vector<vector<pair<int, int>>>;

const ll INF = 1001001001;

int main() {
  ll N;
  cin >> N;
  ll h;
  for (ll n = 1; n <= 3500; n++) {
    for (ll w = n; w <= 3500; w++) {
      if (n * w * N % (4 * n * w - N * w - N * n) == 0) {
        ll tmp = (4 * n * w - N * w - N * n);
        ll top = n * w * N;
        if (tmp > 0 && top > 0 && top % tmp == 0)
          h = top / tmp;
        if (h > 0) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using Graph = vector<vector<pair<int, int>>>;

const ll INF = 1001001001;

int main() {
  ll N;
  cin >> N;
  ll h;
  for (ll n = 1; n <= 3500; n++) {
    for (ll w = n; w <= 3500; w++) {
      ll tmp = (4 * n * w - N * w - N * n);
      ll top = n * w * N;
      if (tmp > 0 && top > 0 && top % tmp == 0) {
        h = top / tmp;
        if (h > 0) {
          cout << h << " " << n << " " << w << endl;
          return 0;
        }
      }
    }
  }
}
Problem p03583 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr << #v << " = " << v << '\n'
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int, int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(), s.end()
int main(void) {
  ll n;
  cin >> n;
  if (!(n & 1))
    return cout << (n) << ' ' << (n) << ' ' << (n / 2) << '\n', 0;
  else {
    for (ll i = 1; i <= 4000; ++i)
      for (ll j = 1; j <= 4000; ++j) {
        ll A = (4 * i * j - n * (i + j));
        ll B = n * i * j;
        if (!(B % A)) {
          ll C = (B / A);
          if (1 <= C && C <= 3500)
            return cout << i << ' ' << j << ' ' << C << '\n', 0;
        }
      }
  }
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr << #v << " = " << v << '\n'
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int, int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(), s.end()
int main(void) {
  ll n;
  cin >> n;
  if (!(n & 1))
    return cout << (n) << ' ' << (n) << ' ' << (n / 2) << '\n', 0;
  else {
    for (ll i = 1; i <= 4000; ++i)
      for (ll j = 1; j <= 4000; ++j) {
        ll A = (4 * i * j - n * (i + j));
        ll B = n * i * j;
        if (A != 0 && !(B % A)) {
          ll C = (B / A);
          if (1 <= C && C <= 3500)
            return cout << i << ' ' << j << ' ' << C << '\n', 0;
        }
      }
  }
  return 0;
}