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

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

using namespace std;

int n, m;
vector<int> veca;

int main() {
  cin >> n >> m;
  for (int i = 1; i < sqrt(m); i++) {
    if (m % i == 0) {
      if ((m / (m / i)) >= n)
        veca.push_back(m / i);
      if ((m / i) >= n)
        veca.push_back(i);
    }
  }
  sort(veca.begin(), veca.end());
  cout << veca[veca.size() - 1] << endl;
}


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

using namespace std;

int n, m;
vector<int> veca;

int main() {
  cin >> n >> m;
  for (int i = 1; i <= sqrt(m); i++) {
    if (m % i == 0) {
      if ((m / (m / i)) >= n)
        veca.push_back(m / i);
      if ((m / i) >= n)
        veca.push_back(i);
    }
  }
  sort(veca.begin(), veca.end());
  cout << veca[veca.size() - 1] << endl;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  if (m % n == 0) {
    cout << m / n << endl;
    return 0;
  }
  ll ans = 1;
  for (ll i = n; i <= m; i++) {
    if (m % i == 0)
      ans = max(ans, m / i);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main() {
  ll n, m;
  cin >> n >> m;
  if (m % n == 0) {
    cout << m / n << endl;
    return 0;
  }
  ll ans = 1;
  for (ll i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      if (i >= n)
        ans = max(ans, m / i);
      if (m / i >= n)
        ans = max(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, rept) for (int i = 0; i < (ll)rept; ++i)
typedef long long ll;
using namespace std;

int main() {

  ll n = 0, m = 0;
  cin >> n >> m;

  if (n == 1) {
    cout << m << endl;
    return 0;
  }

  if (m % n == 0) {
    cout << m / n << endl;
    return 0;
  }

  for (ll i = m / 2; i >= 1; i--) {
    if (m % i == 0 && m / i >= n) {
      cout << i << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rep(i, rept) for (int i = 0; i < (ll)rept; ++i)
typedef long long ll;
using namespace std;

int main() {

  ll n = 0, m = 0;
  cin >> n >> m;

  if (n == 1) {
    cout << m << endl;
    return 0;
  }

  if (m % n == 0) {
    cout << m / n << endl;
    return 0;
  }

  for (ll i = 100000000; i >= 1; i--) {
    if (m % i == 0 && m / i >= n) {
      cout << i << endl;
      return 0;
    }
  }
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
// using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(), (obj).end()
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double, ll> &firstElof,
                 const pair<double, ll> &secondElof) {
  return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double, ll> &firstElof,
                       const pair<double, ll> &secondElof) {
  return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge { // グラフに使うヤツ
  ll from, to, cost;
};

typedef vector<vector<edge>> G;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}

int main() {
  ll n, m;
  cin >> n >> m;
  for (ll i = m; i >= 1; i--) {
    if (m % i == 0 and m / i >= n) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
// using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(), (obj).end()
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 long long INF = 1LL << 60;
bool pairCompare(const pair<double, ll> &firstElof,
                 const pair<double, ll> &secondElof) {
  return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double, ll> &firstElof,
                       const pair<double, ll> &secondElof) {
  return firstElof.second < secondElof.second;
}
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge { // グラフに使うヤツ
  ll from, to, cost;
};

typedef vector<vector<edge>> G;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return (b);
  else
    return (gcd(b, a % b));
}

int main() {
  ll n, m;
  cin >> n >> m;
  for (ll i = m / n; i >= 1; i--) {
    if (m % i == 0 and m / i >= n) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

// ループマクロ
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; 0 <= i; i--)

// 入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x)                                                              \
  for (auto &ele : (x))                                                        \
  cin >> ele
#define VECOUT(x)                                                              \
  for (auto &ele : (x))                                                        \
    cout << ele << " ";                                                        \
  cout << endl;

// その他
#define ALL(obj) (obj).begin(), (obj).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int, V, greater<int>>
int main(void) {

  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  for (ll i = m; 1 <= i; i--) {
    if (m % i == 0 && m / i >= n) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

// ループマクロ
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; 0 <= i; i--)

// 入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x)                                                              \
  for (auto &ele : (x))                                                        \
  cin >> ele
#define VECOUT(x)                                                              \
  for (auto &ele : (x))                                                        \
    cout << ele << " ";                                                        \
  cout << endl;

// その他
#define ALL(obj) (obj).begin(), (obj).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int, V, greater<int>>
int main(void) {

  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, m;
  cin >> n >> m;
  for (ll i = m / n + 1; 1 <= i; i--) {
    if (m % i == 0 && m / i >= n) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int isprime(int x) {
  for (int p = 2; p * p <= x; p++)
    if (x % p == 0)
      return 0;
  return 1;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  if (isprime(M)) {
    printf("%d\n", 1);
    return 1;
  }
  for (int n = N;; n++) {
    if (M % n == 0) {
      printf("%d\n", M / n);
      break;
    }
  }
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int isprime(int x) {
  for (int p = 2; p * p <= x; p++)
    if (x % p == 0)
      return 0;
  return 1;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  if (isprime(M)) {
    printf("%d\n", 1);
    return 0;
  }
  for (int n = N;; n++) {
    if (M % n == 0) {
      printf("%d\n", M / n);
      break;
    }
  }
}
Problem p03241 (C++)

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

int main() {
  int n, m, ans;
  scanf("%d%d", &n, &m);
  for (int i = 1; m / i >= n; i++)
    if (m % i == 0)
      ans = i;
  printf("%d\n", ans);
}

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

int main() {
  int n, m, ans;
  scanf("%d%d", &n, &m);
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      if (i < n) {
        if (m / i >= n)
          ans = i;
      } else {
        ans = m / i;
        break;
      }
    }
  }
  printf("%d\n", ans);
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int max = 0;
  if (m % n == 0) {
    cout << m / n << endl;
    return 0;
  }
  for (int i = 1; i <= m; i++)
    if (m % i == 0 && m / i >= n && i > max)
      max = i;
  cout << max << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int max = 0;
  if (m % n == 0) {
    cout << m / n << endl;
    return 0;
  }
  for (int i = 1; i <= m / 2; i++)
    if (m % i == 0 && m / i >= n && i > max)
      max = i;
  cout << max << endl;
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i <= 1000000000; i++) {
    if (m % i == 0 && m / i >= n) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if (n == 1) {
    cout << m << endl;
    return 0;
  }
  for (int i = 1; i <= m / n; i++) {
    if (m % i == 0 && m / i >= n) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int ma = 1;
  for (int i = 1; i <= m / n + 1; i++) {
    if (m % i == 0 && m / i >= n && i > ma)
      ma = i;
  }
  cout << ma << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << m;
    return 0;
  }
  int ma = 1;
  for (int i = 1; i <= m / n + 1; i++) {
    if (m % i == 0 && m / i >= n && i > ma)
      ma = i;
  }
  cout << ma << endl;
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <string>
#include <type_traits>
#include <vector>
#define int long long
#define ll long long
#define mod 1000000007
#define inf 1e17
#define rep(i, j, n) for (int i = j; i < n; i++)
#define P pair<int, int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z = 0;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
} // ここから始めよう
signed main() {
  int a, b;
  cin >> a >> b;
  for (int i = b; i > 0; i--) {
    if (b % i == 0 && a * i <= b) {
      cout << i << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <string>
#include <type_traits>
#include <vector>
#define int long long
#define ll long long
#define mod 1000000007
#define inf 1e17
#define rep(i, j, n) for (int i = j; i < n; i++)
#define P pair<int, int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
int z = 0;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
} // ここから始めよう
signed main() {
  int a, b;
  cin >> a >> b;
  vector<int> v;
  for (int i = 1; i * i <= b; i++) {
    if (b % i == 0) {
      v.ps(i);
      v.ps(b / i);
    }
  }
  sort(v.begin(), v.end(), greater<int>());
  for (auto x : v) {
    if (a * x <= b) {
      cout << x << endl;
      return 0;
    }
  }
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

template <class T> T gcd(T x, T y) {
  // 最小公倍数を求める
  if (y == 0)
    return x;
  gcd(y, x % y);
}

template <class T> T lcm(T x, T y) {
  // 最大公約数を求める
  T GCD = gcd(x, y);
  T ans = x / GCD * y;
  return ans;
}

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

  int N, M;
  cin >> N >> M;

  int ans = 0;
  REP(i, M / N) {
    if (M % (i + 1) == 0) {
      ans = i + 1;
    }
  }

  std::cout << ans << '\n';

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
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;
}

template <class T> T gcd(T x, T y) {
  // 最小公倍数を求める
  if (y == 0)
    return x;
  gcd(y, x % y);
}

template <class T> T lcm(T x, T y) {
  // 最大公約数を求める
  T GCD = gcd(x, y);
  T ans = x / GCD * y;
  return ans;
}

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

  int N, M;
  cin >> N >> M;

  int ans = 0;
  if (N == 1) {
    std::cout << M << '\n';
    return 0;
  }
  REP(i, M / N) {
    if (M % (i + 1) == 0) {
      ans = i + 1;
    }
  }

  std::cout << ans << '\n';

  return 0;
}
Problem p03241 (C++)

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

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;
}

#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define lrep(i, cc, n) for (long long i = cc; i < n; ++i)
#define sqrep(i, cc, n) for (long long i = cc; i * i <= n; ++i)
#define rrep(i, cc, n) for (long i = cc; i > n; --i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9 = 1000000000;
const ll mod = 1000000007;

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> p;
  ll m2 = m;
  for (ll i = 0; i * i <= m; i++) {
    if (m % i == 0) {
      p.push_back(i);
      if (m != i * i)
        p.push_back(m / i);
    }
  }
  sort(p.begin(), p.end(), greater<ll>());
  rep(i, 0, p.size()) {
    if (p[i] * n <= m) {
      cout << p[i] << endl;
      return 0;
    }
  }
}

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

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;
}

#define rep(i, cc, n) for (int i = cc; i < n; ++i)
#define lrep(i, cc, n) for (long long i = cc; i < n; ++i)
#define sqrep(i, cc, n) for (long long i = cc; i * i <= n; ++i)
#define rrep(i, cc, n) for (long i = cc; i > n; --i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9 = 1000000000;
const ll mod = 1000000007;

ll gcd(ll x, ll y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> p;
  for (ll i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      p.push_back(i);
      if (m != i * i)
        p.push_back(m / i);
    }
  }
  sort(p.begin(), p.end(), greater<ll>());
  rep(i, 0, p.size()) {
    if (p[i] * n <= m) {
      cout << p[i] << endl;
      return 0;
    }
  }
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
// priority_queue<llint> q;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int n, m;

void solve() {
  cin >> n >> m;
  int ans;
  if (n > m)
    ans = 0;
  else {
    for (int i = 1; i <= m / n; i++) {
      if (m % i == 0)
        ans = i;
    }
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
// priority_queue<llint> q;

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int n, m;

void solve() {
  cin >> n >> m;
  int ans = 1;
  for (int i = 1; i * i <= m; i++) {
    if (m % i != 0)
      continue;
    if (i <= m / n)
      ans = max(i, ans);
    if (m / i <= m / n)
      ans = max(m / i, ans);
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int maxMOD = 1;
  for (int mod = 2; mod <= m; mod++) {
    int x = m - mod * (n - 1);
    if (x >= mod) {
      if (x % mod == 0)
        maxMOD = mod;
    } else
      break;
  }
  printf("%d\n", maxMOD);
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int maxMOD = 1;
  if (n == 1) {
    cout << m << endl;
    return 0;
  }
  for (int mod = 2; mod <= m; mod++) {
    int x = m - mod * (n - 1);
    if (x >= mod) {
      if (x % mod == 0)
        maxMOD = mod;
    } else
      break;
  }
  printf("%d\n", maxMOD);
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef long long int ll;

#define repi(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) repi(i, 0, a)
#define rrep(i, a) for (int i = a - 1; i >= 0; i--)

ll llmax(ll a, ll b) { return a > b ? a : b; }

int main() {
  ll N, M;
  cin >> N >> M;

  ll ans = 1;
  ll n = 1;
  while (n * n <= M) {
    if (M % n == 0) {
      if (n <= M / N)
        ans = llmax(ans, n);
      if (M / n <= M / N)
        ans = llmax(ans, M / n);
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <vector>

using namespace std;
typedef long long int ll;

#define repi(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) repi(i, 0, a)
#define rrep(i, a) for (int i = a - 1; i >= 0; i--)

ll llmax(ll a, ll b) { return a > b ? a : b; }

int main() {
  ll N, M;
  cin >> N >> M;

  ll ans = 1;
  ll n = 1;
  while (n * n <= M) {
    if (M % n == 0) {
      if (n <= M / N)
        ans = llmax(ans, n);
      if (M / n <= M / N)
        ans = llmax(ans, M / n);
    }
    n++;
  }
  cout << ans << endl;
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;

int main() {

  int N, M;
  cin >> N >> M;

  int max;

  for (int i = M; i > 0; i--) {
    if (M % i == 0 && M / i >= N) {
      max = i;
      break;
    }
  }

  cout << max << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {

  int N, M;
  cin >> N >> M;

  int max;

  for (int i = M / N + 1; i > 0; i--) {
    if (M % i == 0 && M / i >= N) {
      max = i;
      break;
    }
  }

  cout << max << endl;

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9 : (int)1e18)
#define EPS 0.0000000001
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
template <typename Head, typename Value>
auto vectors(const Head &head, const Value &v) {
  return vector<Value>(head, v);
}
template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) {
  auto inner = vectors(tail...);
  return vector<decltype(inner)>(x, inner);
}
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pii>;
int W, H;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool valid(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); }
void YN(bool f) { cout << (f ? "YES" : "NO"); }
void yn(bool f) { cout << (f ? "yes" : "no"); }
void YeNo(bool f) { cout << (f ? "Yes" : "No"); }
signed main() {
  int n, m;
  cin >> n >> m;
  int ans = -1;
  for (int i = 1; i * n <= m; ++i) {
    int q = (m - i * n);
    if (q % i == 0)
      cmax(ans, i);
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9 : (int)1e18)
#define EPS 0.0000000001
template <class T, class S> void cmin(T &a, const S &b) {
  if (a > b)
    a = b;
}
template <class T, class S> void cmax(T &a, const S &b) {
  if (a < b)
    a = b;
}
template <typename Head, typename Value>
auto vectors(const Head &head, const Value &v) {
  return vector<Value>(head, v);
}
template <typename Head, typename... Tail> auto vectors(Head x, Tail... tail) {
  auto inner = vectors(tail...);
  return vector<decltype(inner)>(x, inner);
}
using ld = long double;
using pii = pair<int, int>;
using piii = pair<int, pii>;
int W, H;
int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
bool valid(int x, int y) { return (0 <= x && x < W) && (0 <= y && y < H); }
void YN(bool f) { cout << (f ? "YES" : "NO"); }
void yn(bool f) { cout << (f ? "yes" : "no"); }
void YeNo(bool f) { cout << (f ? "Yes" : "No"); }
signed main() {
  int n, m;
  cin >> n >> m;
  int ans = 1;
  if (m % n == 0) {
    cout << m / n << endl;
    return 0;
  }
  for (int i = 2; i * n <= m; ++i) {
    if ((m - n * i) % i == 0)
      ans = i;
  }
  cout << ans << endl;
}
Problem p03241 (C++)

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

int main() {
  unsigned int N, M;
  cin >> N >> M;

  for (unsigned int i = N; i <= M; i++) {
    if (M % i == 0) {
      cout << M / i << endl;
      return 0;
    }
  }
}


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

int main() {
  unsigned int N, M;
  cin >> N >> M;

  if (M % 2 != 0) {
    if (N % 2 == 0) {
      N++;
    }
    for (unsigned int i = N; i <= M; i = i + 2) {
      if (M % i == 0) {
        cout << M / i << endl;
        return 0;
      }
    }
  } else {
    for (unsigned int i = N; i <= M; i++) {
      if (M % i == 0) {
        cout << M / i << endl;
        return 0;
      }
    }
  }
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
/* Author - Ankur Kumar Singh
    IDE :- Offine Linux
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
/* variable type :- */
#define ll long long int
#define ld long double
#define I ll
#define mod 1000000007
/* map */
#define abc pair<ll, ll>
map<pair<abc, abc>, ll> pqr;
map<pair<ll, ll>, ll> xyz;
/* vector */
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define mp make_pair
#define ac accumulate
vector<pair<ll, string>> a1;
vector<pair<ll, string>> a2;
vector<pair<ll, string>> a3;
vector<pair<ll, string>> a4;
vector<pair<ll, string>> a5;
vector<pair<ll, string>> a6;
vector<pair<ll, string>> a7;
vector<pair<pair<ll, ll>, ll>> b;
ll cnt;
ll X[121], Y[121];

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output2.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string n;
  cin >> n;
  for (ll i = 0; i < n.size(); i++) {
    if (n[i] == '1')
      n[i] = '9';
    else
      n[i] = '1';
  }
  cout << n;
}

Fixed submission:
/* Author - Ankur Kumar Singh
    IDE :- Offine Linux
 ---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
/* variable type :- */
/* variable type :- */
#define ll long long int
#define ld long double
#define I ll
#define mod 1000000007
/* map */
#define abc pair<ll, ll>
map<pair<abc, abc>, ll> pqr;
map<pair<ll, ll>, ll> xyz;
/* vector */
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define mp make_pair
#define ac accumulate
vector<pair<ll, string>> a1;
vector<pair<ll, string>> a2;
vector<pair<ll, string>> a3;
vector<pair<ll, string>> a4;
vector<pair<ll, string>> a5;
vector<pair<ll, string>> a6;
vector<pair<ll, string>> a7;
vector<pair<pair<ll, ll>, ll>> b;
ll cnt;
ll X[121], Y[121];

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string n;
  cin >> n;
  for (ll i = 0; i < n.size(); i++) {
    if (n[i] == '1')
      n[i] = '9';
    else
      n[i] = '1';
  }
  cout << n;
}
Problem p03242 (Python)

Buggy submission (status: Runtime Error):
n = input()
ans = ""

for i in range(n):
    if n[i] == 1:
        ans += "9"
    else:
        ans += "1"
print(int(ans))


Fixed submission:
n = input()
ans = ""

for i in range(len(n)):
    if n[i] == "1":
        ans += "9"
    else:
        ans += "1"
print(int(ans))
Problem p03242 (C++)

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

int main() {
  string N;
  for (int i = 0; i < 3; i++) {
    if (N.at(i) == '1')
      cout << 9;
    else
      cout << 1;
  }
  cout << endl;
}


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

int main() {
  string N;
  cin >> N;
  for (int i = 0; i < 3; i++) {
    if (N.at(i) == '1')
      cout << 9;
    else
      cout << 1;
  }
  cout << endl;
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int a;
  cin >> a;
  cout << 1110 - a;
  return 1110 - a;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int a;
  cin >> a;
  cout << 1110 - a;
  return 0;
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '1') {
      s.at(i) = '9';
      continue;
    } else if (s.at(i) == '9') {
      s.at(i) = '1';
      continue;
    }
  }
  cout << s << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '1') {
      s.at(i) = '9';
      continue;
    } else if (s.at(i) == '9') {
      s.at(i) = '1';
      continue;
    }
  }
  cout << s << endl;
}
Problem p03242 (C++)

Buggy submission (status: Time Limit Exceeded):
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main() {
  char c;

  while (cin >> c, c != '\n') {
    if (c == '1')
      cout << '9';
    else
      cout << '1';
  }
  cout << endl;
  return 0;
}


Fixed submission:
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main() {
  char c;

  while (cin >> c) {
    if (c == '1')
      cout << '9';
    else
      cout << '1';
  }
  cout << endl;
  return 0;
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
// Devarshi

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (i = 0; i < n; i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it, x) for (auto it : x)
#define PI 3.14159265
#define sync                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 1000001;

int main() {

  sync

#ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

  string s;
  cin >> s;
  // cout<<s<<endl;
  forn(i, s.size()) {
    if (s[i] == '1')
      s[i] = '9';
    else
      s[i] = '1';
  }
  cout << s;
  return 0;
}


Fixed submission:
// Devarshi

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (i = 0; i < n; i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it, x) for (auto it : x)
#define PI 3.14159265
#define sync                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 1000001;

int main() {

  sync

      string s;
  cin >> s;
  // cout<<s<<endl;
  forn(i, s.size()) {
    if (s[i] == '1')
      s[i] = '9';
    else
      s[i] = '1';
  }
  cout << s;
  return 0;
}
Problem p03242 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
for i in n:
    if i == 1:
        i = 9
    elif i == 9:
        i = 1
print(n)


Fixed submission:
n = int(input())
print(1110 - n)
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define F first
#define S second
#define endl "\n"
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define re0(i, a) for (int i = 0; i < (a); i++)
using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 7 + 1e9;
const int inf = 1e9;
const int N = 0;
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.in", "r", stdin);
#endif // ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  re0(i, s.size()) cout << ((s[i] == '1') ? 9 : 1);
  cout << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define F first
#define S second
#define endl "\n"
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define re0(i, a) for (int i = 0; i < (a); i++)
using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 7 + 1e9;
const int inf = 1e9;
const int N = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  re0(i, s.size()) cout << ((s[i] == '1') ? 9 : 1);
  cout << endl;
}
Problem p03242 (C++)

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

int main() {
  vector<char> a;
  for (int i = 0; i < 3; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < 3; i++) {
    if (a.at(i) == '1') {
      cout << '9';
    } else {
      cout << '1';
    }
  }
  cout << endl;
  return 0;
}

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

int main() {
  vector<char> a(3);
  for (int i = 0; i < 3; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < 3; i++) {
    if (a.at(i) == '1') {
      cout << '9';
    } else {
      cout << '1';
    }
  }
  cout << endl;
  return 0;
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '1') {
      s.at(i) = '9';
    } else {
      s.at(i) = '1';
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  cout << 1110 - n << endl;
}
Problem p03242 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/*
    TITLE:
*/

//=================================================
int N;
//=================================================
void input() { cin >> N; }

//=================================================
void solve() {
  int ans = 0;
  for (int i = 0; N; ++i) {
    int m = N % 10;
    if (m == 1) {
      m = 9;
    } else if (m == 9) {
      m = 1;
    }
    ans += 10 * i + m;
  }
  cout << ans << endl;
}
//=================================================
signed main() {
  input();
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/*
    TITLE:
*/

//=================================================
int N;
//=================================================
void input() { cin >> N; }

//=================================================
void solve() {
  int ans = 0;
  for (int i = 0; N; ++i) {
    int m = N % 10;
    if (m == 1) {
      m = 9;
    } else if (m == 9) {
      m = 1;
    }
    ans += pow(10, i) * m;
    N /= 10;
  }
  cout << ans << endl;
}
//=================================================
signed main() {
  input();
  solve();
  return 0;
}
Problem p03242 (C++)

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

int main() {
  int n, i = 1, ans = 0;
  cin >> n;
  while (n) {
    int a = n % 10;
    if (a == 1)
      ans += 9 * i;
    if (a == 9)
      ans += i;
    i *= 10;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n, i = 1, ans = 0;
  cin >> n;
  while (n) {
    int a = n % 10;
    n /= 10;
    if (a == 1)
      ans += 9 * i;
    if (a == 9)
      ans += i;
    i *= 10;
  }
  cout << ans << endl;
  return 0;
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main(void) {

  int n;

  scanf("%d", n);

  printf("%d\n", 1110 - n);

  return 0;
}

Fixed submission:
#include <stdio.h>

int main(void) {

  int n;

  scanf("%d", &n);

  printf("%d\n", 1110 - n);

  return 0;
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define test()                                                                 \
  ull t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define pb push_back
#define mkp make_pair
#define nl cout << endl
#define MOD 1000000007
#define loop(i, start, end) for (ull i = start; i < end; i++)
#define N 100001
#define oa(a, n)                                                               \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i] << " ";                                                       \
  nl
#define ov(a)                                                                  \
  for (int i = 0; i < a.size(); i++)                                           \
    cout << a[i] << " ";                                                       \
  nl
int main() {
  fastio();
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif

  string s;
  cin >> s;
  loop(i, 0, s.size()) {
    if (s[i] == '9')
      s[i] = '1';
    else if (s[i] == '1')
      s[i] = '9';
  }
  cout << s << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define test()                                                                 \
  ull t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define pb push_back
#define mkp make_pair
#define nl cout << endl
#define MOD 1000000007
#define loop(i, start, end) for (ull i = start; i < end; i++)
#define N 100001
#define oa(a, n)                                                               \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i] << " ";                                                       \
  nl
#define ov(a)                                                                  \
  for (int i = 0; i < a.size(); i++)                                           \
    cout << a[i] << " ";                                                       \
  nl
int main() {
  fastio();
  string s;
  cin >> s;
  loop(i, 0, s.size()) {
    if (s[i] == '9')
      s[i] = '1';
    else if (s[i] == '1')
      s[i] = '9';
  }
  cout << s << endl;

  return 0;
}
Problem p03242 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  while (n != 0) {
    if (n % 10 == 1)
      v.push_back(9);

    else if (n % 10 == 9)
      v.push_back(1);

    else
      v.push_back(n % 10);
  }

  int i, s = v.size();
  for (i = s - 1; i >= 0; --i)
    printf("%d", v[i]);
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  while (n != 0) {
    if (n % 10 == 1)
      v.push_back(9);

    else if (n % 10 == 9)
      v.push_back(1);

    else
      v.push_back(n % 10);

    n /= 10;
  }

  int i, s = v.size();
  for (i = s - 1; i >= 0; --i)
    printf("%d", v[i]);
}
Problem p03242 (Python)

Buggy submission (status: Runtime Error):
num = input()
x = [int(i) for i in num]
for i in range(len(x)):
    if x[i] == 1:
        x[i] = "9"
    else:
        x[i] = "1"
mojiretu = ",".join(x)
print(int(mojiretu))


Fixed submission:
num = input()
x = [int(i) for i in num]
for i in range(len(x)):
    if x[i] == 1:
        x[i] = "9"
    else:
        x[i] = "1"
mojiretu = "".join(x)
print(int(mojiretu))
Problem p03242 (C++)

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

int main() {
  string s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '9')
      s.at(i) = '1';
    else
      s.at(i) = '9';
  }
  cout << s.at(0) << s.at(1) << s.at(2) << endl;
}


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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == '9')
      s.at(i) = '1';
    else
      s.at(i) = '9';
  }
  cout << s.at(0) << s.at(1) << s.at(2) << endl;
}
Problem p03242 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A;
  if (A.at(0) == '1') {
    A.at(0) = '9';
  } else {
    A.at(0) = '1';
  }
  if (A.at(1) == '1') {
    A.at(1) = '9';
  } else {
    A.at(1) = '1';
  }
  if (A.at(2) == '1') {
    A.at(2) = '9';
  } else {
    A.at(2) = '1';
  }
  cout << A << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A;
  cin >> A;
  if (A.at(0) == '1') {
    A.at(0) = '9';
  } else {
    A.at(0) = '1';
  }
  if (A.at(1) == '1') {
    A.at(1) = '9';
  } else {
    A.at(1) = '1';
  }
  if (A.at(2) == '1') {
    A.at(2) = '9';
  } else {
    A.at(2) = '1';
  }
  cout << A << endl;
}
Problem p03243 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod = 1000000007;
const ll inf = LONG_LONG_MAX;
ll dx4[4] = {1, 0, -1, 0};
ll dy4[4] = {0, -1, 0, 1};
ll dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
ll dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};

bool ok(ll a) {
  string s = to_string(a);
  if (s[0] == s[1] && s[1] == s[2])
    return 1;
  else
    0;
}

int main() {

  ll n;
  cin >> n;

  while (!ok(n))
    n++;

  cout << n << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod = 1000000007;
const ll inf = LONG_LONG_MAX;
ll dx4[4] = {1, 0, -1, 0};
ll dy4[4] = {0, -1, 0, 1};
ll dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
ll dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};

bool ok(ll a) {
  string s = to_string(a);
  if (s[0] == s[1] && s[1] == s[2])
    return 1;
  else
    return 0;
}

int main() {

  ll n;
  cin >> n;

  while (!ok(n))
    n++;

  cout << n << endl;
}