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

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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define REP2(i, d, n) for (int i = (d); i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define CLR(a) memset((a), 0, sizeof(a))
#define MCLR(a) memset((a), -1, sizeof(a))
#define RANGE(x, y, maxX, maxY)                                                \
  (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int, int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1};

void solve(long long N, long long M) {
  LL ans = 1LL;
  for (LL i = 1; i * N <= M; i++) {
    if ((M - (i * N)) % i == 0) {
      ans = i;
    }
  }

  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define REP2(i, d, n) for (int i = (d); i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define CLR(a) memset((a), 0, sizeof(a))
#define MCLR(a) memset((a), -1, sizeof(a))
#define RANGE(x, y, maxX, maxY)                                                \
  (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int, int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[] = {1, 0, -1, 0}, DY[] = {0, -1, 0, 1};

void solve(long long N, long long M) {
  if (N == 1) {
    cout << M << endl;
    return;
  }
  LL ans = 1LL;
  for (LL i = 1; i * N <= M; i++) {
    if ((M - (i * N)) % i == 0) {
      ans = i;
    }
  }

  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  solve(N, M);
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

typedef long long ll;

int main(void) {
  ll N, M;
  cin >> N >> M;
  ll ans;
  for (ll d = M; d > 0; d++) {
    if (M % d == 0) {
      if (M / d >= N) {
        ans = d;
        cout << ans << endl;
        return 0;
      }
    }
  }
}


Fixed submission:
#include <iostream>

using namespace std;

typedef long long ll;

int main(void) {
  ll N, M;
  cin >> N >> M;
  ll ans;
  for (ll d = M / N; d > 0; d--) {
    if (M % d == 0) {
      if (M / d >= N) {
        ans = d;
        cout << ans << endl;
        return 0;
      }
    }
  }
}
Problem p03241 (C++)

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

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

int N, M;

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

  cin >> N >> M;

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

  return 0;
}


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

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

int N, M;

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

  cin >> N >> M;

  for (int i = N; i <= M; i++) {
    if (M % i == 0) {
      cout << M / i << endl;
      break;
    }
    if (i * 2 > M) {
      cout << 1 << endl;
      break;
    }
  }

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  int max = 0;
  for (int i = 1; i <= b / a; i++) {
    if (b % i == 0 && i >= max) {
      max = i;
    }
  }
  printf("%d", max);
  return 0;
}


Fixed submission:
#include <stdio.h>
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  int max = 0;
  if (a == 1 && b == 1000000000) {
    printf("1000000000");
    return 0;
  }
  for (int i = 1; i <= b / a; i++) {
    if (b % i == 0 && i >= max) {
      max = i;
    }
  }
  printf("%d", max);
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
typedef pair<int, int> P;

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

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define sort(A) sort(A.begin(), A.end())
#define reverse(A) reverse(A.begin(), A.end())
typedef long long ll;
typedef pair<int, int> P;

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

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

int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  for (int i = 1; i <= M / N; i++) {
    if ((M - N * i) % i == 0)
      ans = i;
  }
  cout << ans << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  if (N == 1)
    ans = M;
  else {
    for (int i = 1; i <= M / N; i++) {
      if ((M - N * i) % i == 0)
        ans = i;
    }
  }
  cout << ans << endl;
}
Problem p03241 (C++)

Buggy submission (status: Runtime Error):

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

using ll = long long;

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

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

  vector<int> res;
  for (int i = 2; i * i <= M; ++i) {
    if (M % i == 0) {
      res.push_back(i);
      if (i != M / i)
        res.push_back(M / i);
    }
  }

  sort(res.begin(), res.end());
  auto it = lower_bound(res.begin(), res.end(), N);

  cout << M / *it << '\n';

  return 0;
}


Fixed submission:

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

using ll = long long;

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

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

  vector<int> res;
  for (int i = 2; i * i <= M; ++i) {
    if (M % i == 0) {
      res.push_back(i);
      if (i != M / i)
        res.push_back(M / i);
    }
  }
  res.push_back(1);
  res.push_back(M);

  sort(res.begin(), res.end());
  auto it = lower_bound(res.begin(), res.end(), N);

  cout << M / *it << '\n';

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iostream"
#include "map"
#include "queue"
#include "set"
#include "stack"
#include "string"
#include "tuple"
#include "unordered_map"
#include "vector"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n, i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int, int>
typedef long long ll;
using namespace std;

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


Fixed submission:
#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iostream"
#include "map"
#include "queue"
#include "set"
#include "stack"
#include "string"
#include "tuple"
#include "unordered_map"
#include "vector"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n, i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intinf 1000000000
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int, int>
typedef long long ll;
using namespace std;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define REPS(i, n) for (ll(i) = 1; (i) <= (n); (i)++)
#define RREP(i, n) for (ll(i) = (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for (ll(i) = (n); (i) > 0; (i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

template <class T> inline void chmin(T &a, T b) {
  if (a > b) {
    a = b;
  }
}

template <class T> inline void chmax(T &a, T b) {
  if (a < b) {
    a = b;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  ll N, M;
  cin >> N >> M;
  ll gcm = 0;
  for (ll i = N;; i++) {
    if (M < i)
      break;
    if (M % i == 0) {
      chmax(gcm, M / i);
      break;
    }
  }
  cout << gcm << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define REPS(i, n) for (ll(i) = 1; (i) <= (n); (i)++)
#define RREP(i, n) for (ll(i) = (n - 1); (i) >= 0; (i)--)
#define RREPS(i, n) for (ll(i) = (n); (i) > 0; (i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

template <class T> inline void chmin(T &a, T b) {
  if (a > b) {
    a = b;
  }
}

template <class T> inline void chmax(T &a, T b) {
  if (a < b) {
    a = b;
  }
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  ll N, M;
  cin >> N >> M;
  ll gcm = 0;
  if (N <= 10) {
    for (ll i = N;; i++) {
      if (M < i)
        break;
      if (M % i == 0) {
        chmax(gcm, M / i);
        break;
      }
    }
  } else {
    for (ll i = 1;; i++) {
      ll test = M - i * (N - 1);
      if (test <= 0)
        break;
      if (test < i)
        break;
      if (test % i == 0) {
        chmax(gcm, i);
      }
    }
  }
  cout << gcm << "\n";
}
Problem p03241 (C++)

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int ans = (N == 1 ? M : 1);
  for (int i = 0; i <= M / 2; i++) {
    if (M % i == 0 && (long long)i * N <= M && ans < i)
      ans = i;
  }
  cout << ans << endl;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  int ans = (N == 1 ? M : 1);
  for (int i = 2; i <= M / 2; i++) {
    if (M % i == 0 and (long long) i * N <= M and ans < i)
      ans = i;
  }
  cout << ans << endl;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


Fixed submission:
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int n, m;
  scanf("%d %d\n", &n, &m);
  int max = 1;
  for (int i = (m / n); i >= 1; i--) {
    if (m % i == 0) {

      max = i;
      break;
    }
  }
  printf("%d\n", max);
}
Problem p03241 (C++)

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

using namespace std;

#define lli long long int
#define REP(i, s, l) for (lli i = s; i < l; i++)
#define DEBUG 0
#define INF (1LL << 50)
#define MOD 1000000007

vector<lli> divisorList(lli num) {
  vector<lli> v;

  for (lli i = 1; i * i <= num; i++) {
    if (num % i == 0) {
      v.push_back(i);
      v.push_back(num / i);
    }
  }
  sort(v.begin(), v.end());
  return v;
}

signed main() {

  lli n, m;
  cin >> n >> m;

  lli ans = 0;
  vector<lli> v = divisorList(m);
  for (lli i = 0; i <= v.size(); i++) {
    if (m / v[i] < n)
      break;
    if (m % v[i] == 0) {
      ans = max(ans, v[i]);
    }
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i, s, l) for (lli i = s; i < l; i++)
#define DEBUG 0
#define INF (1LL << 50)
#define MOD 1000000007

vector<lli> divisorList(lli num) {
  vector<lli> v;

  for (lli i = 1; i * i <= num; i++) {
    if (num % i == 0) {
      v.push_back(i);
      v.push_back(num / i);
    }
  }
  sort(v.begin(), v.end());
  return v;
}

signed main() {

  lli n, m;
  cin >> n >> m;

  lli ans = 0;
  vector<lli> v = divisorList(m);
  for (lli i = 0; i < v.size(); i++) {
    if (m / v[i] < n)
      break;
    if (m % v[i] == 0) {
      ans = max(ans, v[i]);
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03241 (C++)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
  fastio() {
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    cin.tie(0);
  }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

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


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
  fastio() {
    ios::sync_with_stdio(false);
    cout << setprecision(10) << fixed;
    cin.tie(0);
  }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m, k, ans;

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

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  for (i = m; i; i--)
    if (!(m % i) && m / i >= n) {
      printf("%d\n", i);
      return 0;
    }
}

Fixed submission:
#include <cstdio>
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  for (i = m / n; i; i--)
    if (!(m % i) && m / i >= n) {
      printf("%d\n", i);
      return 0;
    }
}
Problem p03241 (C++)

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

int main() {
  int N, M, lim;
  cin >> N >> M;
  lim = M / N;
  int num = 0;
  vector<int> yakusu(M);
  for (int i = 0; i < sqrt(M); i++) {
    if (M % (i + 1) == 0) {
      yakusu[num] = i + 1;
      num++;
      yakusu[num] = M / (i + 1);
      num++;
    }
  }
  int max = -1;
  for (int i = 0; i < yakusu.size(); i++) {
    if (yakusu[i] <= lim) {
      if (max < yakusu[i])
        max = yakusu[i];
    }
  }
  cout << max << endl;
}


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

int main() {
  int N, M, lim;
  cin >> N >> M;
  lim = M / N;
  int num = 0;
  vector<int> yakusu(1000000);
  for (int i = 0; i < sqrt(M); i++) {
    if (M % (i + 1) == 0) {
      yakusu[num] = i + 1;
      num++;
      yakusu[num] = M / (i + 1);
      num++;
    }
  }
  int max = -1;
  for (int i = 0; i < yakusu.size(); i++) {
    if (yakusu[i] <= lim) {
      if (max < yakusu[i])
        max = yakusu[i];
    }
  }
  cout << max << endl;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
#define REP(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  if (M % N == 0)
    cout << M / N << endl;
  else {
    for (int i = sqrt(M / N); i <= M / N; i++) {
      ans = max(ans, GCD(i, M - (N - 1) * i));
    }
    cout << ans << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < int(a); ++i)
#define REP(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int main() {
  int N, M;
  cin >> N >> M;
  int ans = 0;
  if (M % N == 0)
    cout << M / N << endl;
  else {
    for (int i = 1; i <= M / N; i++) {
      if (M % i == 0)
        ans = i;
    }
    cout << ans << endl;
  }
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>

using namespace std;

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

  int ans = 1;
  for (int i = 1; i <= (int)M / N; i++)
    ans = (M % i == 0) ? i : ans;
  cout << ans << endl;
}


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

using namespace std;

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

  int ans = 1;
  if (N == 1) {
    cout << M << endl;
    return 0;
  }

  for (int i = 1; i <= (int)M / N; i++)
    ans = (M % i == 0) ? i : ans;
  cout << ans << endl;
}
Problem p03241 (C++)

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

int main() {
  long N, M, p = 0;
  cin >> N >> M;
  p = M;
  while (true) {
    if (M % p == 0 && p * N <= M) {
      p = p + 10000000;
      break;
    }
    p = p - 10000000;
  }

  for (int i = p; i > 0; i--) {
    if (M % i == 0 && i * N <= M) {
      cout << i;
      break;
    }
  }
}


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

int main() {
  long N, M, p = 0;
  cin >> N >> M;
  p = M;
  while (true) {
    if (p * N <= M) {
      p = p + 10000000;
      break;
    }
    p = p - 10000000;
  }

  for (int i = p; i > 0; i--) {
    if (M % i == 0 && i * N <= M) {
      cout << i;
      break;
    }
  }
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
//
//  abc112d.cpp
//
//
//  Created by Yoshida Satoshi on 2018/10/22.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int N, M;

  cin >> N >> M;

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

  return 0;
}


Fixed submission:
//
//  abc112d.cpp
//
//
//  Created by Yoshida Satoshi on 2018/10/22.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int N, M;

  cin >> N >> M;

  for (int i = N; i <= M; i++) {
    if (M % i == 0) {
      cout << M / i << endl;
      break;
    }
    if (i > M / 2) {
      cout << 1 << endl;
      break;
    }
  }

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define REP(i, limit) for (int i = 0; i < limit; ++i)
#define LINT long long

int main() {
  int N, M;
  cin >> N >> M;
  int k = M / N;
  int ans = 1;
  int work;
  for (int i = 2; i < k + 1; ++i) {
    if ((M - N * i) % i == 0)
      ans = i;
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define REP(i, limit) for (int i = 0; i < limit; ++i)
#define LINT long long

int main() {
  int N, M;
  cin >> N >> M;
  int k = M / N;
  int ans = 1;
  int work;
  if (N == 1) {
    cout << M << endl;
    return 0;
  }
  for (int i = 2; i < k + 1; ++i) {
    if ((M - N * i) % i == 0)
      ans = i;
  }
  cout << ans << endl;

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Runtime Error):
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = a; i < b; i++)
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) cout << (f ? "Yes" : "No") << endl
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl

using namespace std;

const int mod = 1e9 + 7;

void run();

void init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
}

signed main() {
  init();
  run();
  return 0;
}

void run() {
  int n, m;
  cin >> n >> m;
  vi d;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      d.pb(i);
      d.pb(m / i);
    }
  }
  sort(all(d));
  int ans;
  for (int i = 0; d[i] <= m / n; i++) {
    ans = d[i];
  }
  cout << ans << endl;
}

Fixed submission:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, a, b) for (int i = a; i < b; i++)
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int, int>
#define vp vector<pair<int, int>>
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a, 0, sizeof(a))
#define inf (1ll << 60)
#define Yes(f) cout << (f ? "Yes" : "No") << endl
#define yes(f) cout << (f ? "yes" : "no") << endl
#define YES(f) cout << (f ? "YES" : "NO") << endl

using namespace std;

const int mod = 1e9 + 7;

void run();

void init() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(12);
}

signed main() {
  init();
  run();
  return 0;
}

void run() {
  int n, m;
  cin >> n >> m;
  vi d;
  for (int i = 1; i * i <= m; i++) {
    if (m % i == 0) {
      d.pb(i);
      d.pb(m / i);
    }
  }
  sort(all(d));
  int ans = 1;
  for (int i = 0; i < d.size() && d[i] <= m / n; i++) {
    ans = d[i];
  }
  cout << ans << endl;
}
Problem p03241 (C++)

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = M; i > 0; i--) {
    if (M % i == 0 and M / i >= N) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = M / N; i > 0; 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>
#define INF (1 << 30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

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

/*

123 を 10 個の数で分ける
123 / 3 = 41
41 を 10 個の数でわけられる。

x を y 個の数でわけられるか？
→ x >= y なら OK


N M
i ∈ [2, ?]
        if( M を i で割れる )
                s = M を i で割る
                if( s を N でわけられるか？ ){
                        i で OK
                }

123 / 3
        s = 123/3
        s == 41
        41 を 10 でわけられます

M/i >= N
1/i >= N/M
i <= M/N


*/

Fixed submission:
#include <bits/stdc++.h>
#define INF (1 << 30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

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

/*

123 を 10 個の数で分ける
123 / 3 = 41
41 を 10 個の数でわけられる。

x を y 個の数でわけられるか？
→ x >= y なら OK


N M
i ∈ [2, ?]
        if( M を i で割れる )
                s = M を i で割る
                if( s を N でわけられるか？ ){
                        i で OK
                }

123 / 3
        s = 123/3
        s == 41
        41 を 10 でわけられます

M/i >= N
1/i >= N/M
i <= M/N


*/
Problem p03241 (C++)

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define REP(i, n) for (ll i = 1; i < n; i++)
#define PER(i, n) for (ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 62) - 1;
ll ceil(const ll &a, const ll &b) { return ((a) + (b)-1) / b; }
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() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i <= m / n; i++) {
    if (m % i == 0)
      ans = i;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define per(i, n) for (ll i = n - 1; i >= 0; i--)
#define REP(i, n) for (ll i = 1; i < n; i++)
#define PER(i, n) for (ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 62) - 1;
ll ceil(const ll &a, const ll &b) { return ((a) + (b)-1) / b; }
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() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i * i <= m; i++) {
    if (m % i != 0)
      continue;
    if (i >= n)
      chmax(ans, m / i);
    if (m / i >= n)
      chmax(ans, i);
  }
  cout << ans << endl;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <vector>

template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD = 1000000007;
// const int MOD=998244353;
const int INTMAX = 1001001000;
const ll LLMAX = 1010010010010010000;

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

  ll N, M;
  cin >> N >> M;

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

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <queue>
#include <set>
#include <vector>

template <typename T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD = 1000000007;
// const int MOD=998244353;
const int INTMAX = 1001001000;
const ll LLMAX = 1010010010010010000;

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

  ll N, M;
  cin >> N >> M;

  if (N == 1) {
    cout << M << endl;
    return 0;
  }

  for (ll i = 1; i <= sqrt(M); i++) {
    if (M % i == 0 && i >= N) {
      cout << M / i << endl;
      return 0;
    }
  }
  for (ll i = sqrt(M); i >= 1; i--) {
    if (M % i == 0 && M / i >= N) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}
Problem p03241 (C++)

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

using namespace std;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

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

  int mx = M / N;
  int rem = M % N;

  while (rem) {
    mx--;
    rem = M - N * mx;
    rem %= mx;
  }

  cout << mx << "\n";

  return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

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

  int mx = M / N;
  int rem = M % N;
  rem %= mx;

  while (rem) {
    mx--;
    rem = M - N * mx;
    rem %= mx;
  }

  cout << mx << "\n";

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main() {
  ll n, m;
  cin >> n >> m;
  ll mx = 1;
  for (ll i = m - 1; i >= 2; i--) {
    if ((i % 2 == 0 && m % 2 != 0)) {
      continue;
    }
    ll u = m - i * (n - 1);
    if (u <= 0) {
      continue;
    }
    if (u % i == 0) {
      mx = i;
      break;
    }
  }
  cout << mx << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int main() {
  ll n, m;
  cin >> n >> m;
  ll mx = 1;
  for (ll i = m - 2 * (n - 1); i >= 2; i--) {
    if ((i % 2 == 0 && m % 2 != 0)) {
      continue;
    }
    ll u = m - i * (n - 1);
    if (u <= 0) {
      continue;
    }
    if (u % i == 0) {
      mx = i;
      break;
    }
  }
  cout << mx << endl;
}
Problem p03241 (C++)

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

int main() {
  long long int n, m;
  cin >> n >> m;
  for (long long int i = m; i > 0; i--) {
    if (m % i == 0 && (m / i) >= n) {
      cout << i;
      break;
    }
  }
  return 0;
}


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

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

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

int main() {
  int n, m;
  cin >> n >> m;

  int yakusu_count = 1;
  vector<long long> yakusu(m);
  yakusu.at(0) = m;
  int current = 1;

  for (int i = m / 2; i > 0; i--) {
    if (m % i == 0) {
      yakusu.at(current) = i;
      current++;
      yakusu_count++;
    }
  }

  bool flag = 0;

  rep(i, yakusu_count) {
    if (m >= n * yakusu.at(i)) {
      cout << yakusu.at(i) << endl;
      flag = 1;
      break;
    }
  }

  if (flag == 0)
    cout << 1 << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;

  int yakusu_count = 1;
  vector<long long> yakusu(1000000);
  yakusu.at(0) = m;
  int current = 1;

  for (int i = m / 2; i > 0; i--) {
    if (m % i == 0) {
      yakusu.at(current) = i;
      current++;
      yakusu_count++;
    }
  }

  bool flag = 0;

  rep(i, yakusu_count) {
    if (m >= n * yakusu.at(i)) {
      cout << yakusu.at(i) << endl;
      flag = 1;
      break;
    }
  }

  if (flag == 0)
    cout << 1 << endl;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#define INF 1e9
#define EPS 1e-9
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define REPR(i, n) for (ll i = (n)-1; i >= 0; --i)
#define REPR1(i, n) for (ll i = (n); i > 0; --i)
#define REPC(i, obj) for (auto i : obj)
#define R_UP(a, b) (((a) + (b)-1) / (b))
#define ALL(obj) (obj).begin(), (obj).end()
#define SETP cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template <typename T = ll> inline T in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int n = in(), m = in();
  REPR1(i, m) {
    if (m % i == 0 && i * n <= m) {
      cout << i << endl;
      return 0;
    }
  }
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#define INF 1e9
#define EPS 1e-9
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define REPR(i, n) for (ll i = (n)-1; i >= 0; --i)
#define REPR1(i, n) for (ll i = (n); i > 0; --i)
#define REPC(i, obj) for (auto i : obj)
#define R_UP(a, b) (((a) + (b)-1) / (b))
#define ALL(obj) (obj).begin(), (obj).end()
#define SETP cout << fixed << setprecision(8)
using namespace std;
using ll = long long;
template <typename T = ll> inline T in() {
  T x;
  cin >> x;
  return x;
}

signed main() {
  int n = in(), m = in();
  REPR1(i, m / n) {
    if (m % i == 0 && i * n <= m) {
      cout << i << endl;
      return 0;
    }
  }
}
Problem p03241 (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++)
typedef long long int ll;

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> div(0);
  for (int i = 1; i <= m; i++)
    if (m % i == 0)
      div.emplace_back(i), div.emplace_back(m / i);
  sort(div.begin(), div.end());

  int res = 0;
  for (auto x : div)
    if (m / x >= n)
      res = x;
  cout << res << endl;

  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> div(0);
  for (int i = 1; i * i <= m; i++)
    if (m % i == 0)
      div.emplace_back(i), div.emplace_back(m / i);
  sort(div.begin(), div.end());

  int res = 0;
  for (auto x : div)
    if (m / x >= n)
      res = x;
  cout << res << endl;

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <set>
#include <string.h>
#include <vector>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, ans;
  cin >> N >> M;
  for (int i = 1; i <= M / N; i++) {
    if (M % i == 0)
      ans = i;
  }

  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <random>
#include <set>
#include <string.h>
#include <vector>

using namespace std;

const int MOD = 1000000007;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, ans;
  cin >> N >> M;
  for (int i = 1; i * i <= M; i++) {
    if (M % i == 0) {
      int j = M / i;
      if (i <= M / N) {
        ans = max(ans, i);
      }
      if (j <= M / N) {
        ans = max(ans, j);
      }
    }
  }

  cout << ans << endl;
}
Problem p03241 (C++)

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

int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 1;
  for (long long i = 2; i * n <= m; i++) {
    if ((m - i * n) % i == 0)
      ans = i;
  }
  cout << ans << endl;
}

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

int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 1;
  if (n == 1) {
    cout << m << endl;
    return 0;
  }
  for (long long i = 2; i * n <= m; i++) {
    if ((m - i * n) % 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() {
  int n, m;
  cin >> n >> m;
  int kotae = 1;
  for (int i = m / n + 1; i >= 2; --i) {
    int tmp = kotae;
    if (m % i == 0)
      kotae = max(kotae, i);
    if (m / kotae < n) {
      kotae = tmp;
      break;
    }
  }
  cout << kotae << 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 << endl;
    return 0;
  }
  int kotae = 1;
  for (int i = m / n + 1; i >= 2; --i) {
    int tmp = kotae;
    if (m % i == 0)
      kotae = max(kotae, i);
    if (m / kotae < n) {
      kotae = tmp;
      break;
    }
  }
  cout << kotae << endl;
  return 0;
}
Problem p03241 (C++)

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

typedef long long ll;

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

  ll ans;
  for (int i = M; i > 0; i--) {
    if (M % i == 0 && i * N <= M) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

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

typedef long long ll;

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

  ll ans;
  for (int i = M / N; i > 0; i--) {
    if (M % i == 0 && i * N <= M) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}
Problem p03241 (C++)

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long ans = 1;
  for (long long i = m / n; i > 0; i--) {
    long long a = max(m - i * n, i);
    long long b = min(m - i * n, i);
    long long cmp = gcd(a, b);
    ans = max(ans, cmp);
  }
  cout << ans << endl;
  return 0;
}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long ans = 1;
  for (long long i = m / n; i > 0; i--) {
    if ((m - i * n) % i == 0) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03241 (C++)

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

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

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
  ll N, M;
  cin >> N >> M;
  ll ans = 1;
  for (ll x = 1; x * x <= M; x++) {
    if (M % x == 0 && x * N <= M) {
      ans = max(ans, x);
    }
    ll y = N / x;
    if (M % y == 0 && y * N <= M) {
      ans = max(ans, y);
    }
  }
  cout << ans << '\n';
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
  ll N, M;
  cin >> N >> M;
  ll ans = 1;
  for (ll x = 1; x * x <= M; x++) {
    if (M % x == 0 && x * N <= M) {
      ans = max(ans, x);
    }
    ll y = M / x;
    if (M % y == 0 && y * N <= M) {
      ans = max(ans, y);
    }
  }
  cout << ans << '\n';
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <complex>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A) {
  cout << "[vector]" << endl;
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  cout << endl;
}

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

  // input
  int N, M;
  cin >> N >> M;

  vector<ll> devisorList;

  // Mの約数を求める & 答えにならないものは入れない
  ll sqrtM = sqrt(M);
  ll M_N = M / N;
  FOR(i, 1, sqrtM) {
    if (M % i == 0) {
      ll yaku0 = i;
      if (yaku0 <= M_N) {
        devisorList.push_back(yaku0);
      }

      ll yaku1 = M / i;
      if (yaku1 <= M_N) {
        devisorList.push_back(yaku1);
      }
    }
  }

  sort(ALL(devisorList));

  ll len = devisorList.size();
  p(devisorList[len - 1]);

  return 0;
}

Fixed submission:
#include <algorithm>
#include <complex>
#include <ctype.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout << (s) << endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A) {
  cout << "[vector]" << endl;
  for (int i = 0; i < A.size(); i++) {
    cout << A[i] << " ";
  }
  cout << endl;
}

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

  // input
  int N, M;
  cin >> N >> M;

  vector<ll> devisorList;

  // Mの約数を求める & 答えにならないものは入れない
  ll sqrtM = sqrt(M);
  ll M_N = M / N;
  FOR(i, 1, sqrtM + 1) {
    if (M % i == 0) {
      ll yaku0 = i;
      if (yaku0 <= M_N) {
        devisorList.push_back(yaku0);
      }

      ll yaku1 = M / i;
      if (yaku1 <= M_N) {
        devisorList.push_back(yaku1);
      }
    }
  }

  sort(ALL(devisorList));

  ll len = devisorList.size();
  p(devisorList[len - 1]);

  return 0;
}
Problem p03241 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()

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

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

const ll INF = 1LL << 60;

const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for (int i = 1; i * i <= m; i++) {
    if (m % i != 0)
      continue;
    if (i <= (m - 1) / (n - 1))
      chmax(ans, i);
    if (m / i <= (m - 1) / (n - 1))
      chmax(ans, m / i);
  }

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


Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()

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

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

const ll INF = 1LL << 60;

const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};

int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    std::cout << m << '\n';
    return 0;
  }
  int ans = 0;
  for (int i = 1; i * i <= m; i++) {
    if (m % i != 0)
      continue;
    if (i <= (m - 1) / (n - 1))
      chmax(ans, i);
    if (m / i <= (m - 1) / (n - 1))
      chmax(ans, m / i);
  }

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