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

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
vector<int> ve(3006, 0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#else
// online submission
#endif
  long long int a, b, c;
  cin >> a >> b >> c;
  ll mx = 0, ans = 0;
  for (int x = b / a; x <= min(b, c); x++) {
    ll t = floor((double)(a * x / b)) - a * floor((double)(x / b));
    mx = max(t, mx);
  }
  cout << mx;
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
vector<int> ve(3006, 0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#else
// online submission
#endif
  long long int a, b, c;
  cin >> a >> b >> c;
  ll mx = 0, ans = 0;
  ll x = min(b - 1, c);
  ll t = floor((double)(a * x / b)) - a * floor((double)(x / b));
  cout << t;
}
Problem p02696 (C++)

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

int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  long long ans = -1;
  for (long long i = 0; i < n + 1; i++) {
    ans = max(ans, a * i / b - (i / b) * a);
  }
  cout << ans << endl;
}


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

int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  long long ans = -1;
  if (n < b - 1) {
    ans = a * n / b;
  } else {
    ans = a * (b - 1) / b;
  }
  cout << ans << endl;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main() {
  unsigned long long a, b;
  long long max = -9999999;
  unsigned long long n;
  int h;
  cin >> a >> b >> n;
  for (int i = 0; i <= n / b; i++) {
    h = i;
  }
  for (int i = 0; i < h; i++) {
    if (max < floor(a * ((b - 1) + i * b) / b) - a * i)
      max = floor(a * ((b - 1) + i * b) / b) - a * i;
  }
  if (max < floor(a * n / b) - floor(n / b) * a)
    max = floor(a * n / b) - floor(n / b) * a;
  cout << max;
}


Fixed submission:
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main() {
  unsigned long long a, b;
  long long max = -9999999;
  unsigned long long n;
  int h;
  cin >> a >> b >> n;
  for (int i = 0; i <= n / b; i++) {
    h = i;
  }
  if (h > 0) {
    for (int i = 0; i < 1; i++) {
      if (max < floor(a * ((b - 1) + i * b) / b) - a * i)
        max = floor(a * ((b - 1) + i * b) / b) - a * i;
    }
  }
  if (max < floor(a * n / b) - floor(n / b) * a)
    max = floor(a * n / b) - floor(n / b) * a;
  cout << max;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
// #define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  ll y = min(a, n);
  for (ll i = n; i >= y - 100; i--) {
    if (i < 0)
      break;
    ll x = floor(a * i / b) - a * floor(i / b);
    ans = max(ans, x);
  }
  print(ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
// #define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
  cout << head;
  if (sizeof...(tail) != 0)
    cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = n;
  if (x >= b - 1)
    x = b - 1;
  ll ans = a * x / b - a * (x / b);
  print(ans);
  return 0;
}
Problem p02696 (C++)

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;

  ll max = 0;
  ll x;
  if (n >= b) {
    x = b - 1;
  } else {
    x = n;
  }
  while (x <= n) {
    ll Ax = a * x;
    ll value = Ax / b - a * (x / b);
    if (value > max) {
      max = value;
    }
    x += b;
  }

  cout << max << endl;

  return 0;
}

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;

  ll max = 0;
  ll x;
  if (n >= b) {
    x = b - 1;
  } else {
    x = n;
  }
  while (x <= n) {
    ll Ax = a * x;
    ll value = Ax / b - a * (x / b);
    if (value > max) {
      max = value;
    }
    break;
  }

  cout << max << endl;

  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;

int main()

{
  ll a, b, n;
  cin >> a >> b >> n;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = -1e18;

  n = min(n, b - 1);
  for (int i = 0; i <= n; i++) {
    ans = max(ans, (a * i) / b - a * (i / b));
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;

int main()

{
  ll a, b, n;
  cin >> a >> b >> n;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = -1e18;

  n = min(n, b - 1);

  ans = max(ans, (a * n) / b - a * (n / b));

  cout << ans << endl;
  return 0;
}
Problem p02696 (C++)

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

// using namespace std;
using std::cin, std::cout, std::endl, std::string;
using ll = long long;

#define rep(countName, left, right, up)                                        \
  for (auto countName = left; countName < right; countName += up)
#define REP(countName, end)                                                    \
  for (auto countName = 0; countName < end; countName++)
#define rev(countName, right, left, down)                                      \
  for (auto countName = right; countName >= left; countName -= down)
#define REV(countName, end)                                                    \
  for (auto countName = end; countName >= 0; countName--)

auto solve1(ll a, ll b, ll n) {
  ll ans = 0;
  rep(x, 0, n + 1, b - 1) { ans = std::max(ans, ((a * x) / b) - a * (x / b)); }
  ans = std::max(ans, ((a * n) / b) - a * (n / b));
  return ans;
}

int main(void) {
  ll a, b, n;
  cin >> a >> b >> n;
  cout << solve1(a, b, n) << endl;

  return 0;
}


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

// using namespace std;
using std::cin, std::cout, std::endl, std::string;
using ll = long long;

#define rep(countName, left, right, up)                                        \
  for (auto countName = left; countName < right; countName += up)
#define REP(countName, end)                                                    \
  for (auto countName = 0; countName < end; countName++)
#define rev(countName, right, left, down)                                      \
  for (auto countName = right; countName >= left; countName -= down)
#define REV(countName, end)                                                    \
  for (auto countName = end; countName >= 0; countName--)

auto solve1(ll a, ll b, ll n) {
  auto min = std::min(b - 1, n);
  return ((a * min) / b) - a * (min / b);
}

int main(void) {
  ll a, b, n;
  cin >> a >> b >> n;
  cout << solve1(a, b, n) << endl;

  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

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

  ll a, b, n;
  cin >> a >> b >> n;

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ll tmp = floor(a * i / b) - a * floor(i / b);
    chmax(ans, tmp);
  }

  cout << ans << '\n';
  return 0;
}


Fixed submission:
#include <cmath>
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

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

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

  ll a, b, n;
  cin >> a >> b >> n;

  ll x;
  if (n < b - 1)
    x = n;
  else
    x = b - 1;

  ll ans = floor(a * (x % b) / b);

  cout << ans << '\n';
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef long double ld;
const ll INF = (ll)1e18;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD 1000000007
#define print(a)                                                               \
  ;                                                                            \
  for (auto x : a)                                                             \
    cout << x << " ";                                                          \
  cout << "\n";
#define mset(a)                                                                \
  ;                                                                            \
  memset(a, 0, sizeof(a));

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll a, b, n;
  cin >> a >> b >> n;
  ll Max = -INF;
  for (ll i = 1; i <= n; i++) {
    ll d1 = (ll)((ld)(a * i) / b);
    ll d2 = (ll)i / b;
    Max = max(Max, d1 - a * d2);
  }
  cout << Max << "\n";
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef long double ld;
const ll INF = (ll)1e18;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF ll(1e18)
#define MOD 1000000007
#define print(a)                                                               \
  ;                                                                            \
  for (auto x : a)                                                             \
    cout << x << " ";                                                          \
  cout << "\n";
#define mset(a)                                                                \
  ;                                                                            \
  memset(a, 0, sizeof(a));

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll a, b, n;
  cin >> a >> b >> n;
  ll j = min(b - 1, n);
  cout << a * j / b - a * (j / b) << "\n";
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
// I'm a f*cking looser
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define asc(A) sort(A.begin(), A.end())
#define dsc(A) sort(A.begin(), A.end(), greater<ll>())
#define input(A, N)                                                            \
  for (ll i = 0; i < N; i++)                                                   \
    cin >> A[i];
int main() {
  fasino
#ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
#endif
      ll a,
      b, n;
  cin >> a >> b >> n;
  ll maxi = INT32_MIN;
  for (int i = 1; i <= min(b, n); i++) {
    // ll i=b;
    ll m = floor(double(a * i) / b) - (a * floor(double(i) / b));
    maxi = max(maxi, m);
  }
  cout << maxi;
  return 0;
}

Fixed submission:
// I'm a f*cking looser
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);
#define asc(A) sort(A.begin(), A.end())
#define dsc(A) sort(A.begin(), A.end(), greater<ll>())
#define input(A, N)                                                            \
  for (ll i = 0; i < N; i++)                                                   \
    cin >> A[i];
int main() {
  fasino
#ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
#endif
      ll a,
      b, n;
  cin >> a >> b >> n;
  ll maxi = INT32_MIN;
  // for(int i=;i<min(b,n);i++){
  // ll i=b;
  maxi = floor(double(a * (min(b, n) - 1)) / b) -
         (a * floor(double(min(b, n) - 1) / b));
  ll k =
      floor(double(a * (min(b, n))) / b) - (a * floor(double(min(b, n)) / b));
  maxi = max(maxi, k);
  // if(b==1){
  //     maxi = floor(double(a*n)/b)-(a*floor(double(n))/b);
  // }
  // maxi = max(maxi,m);
  //
  // }
  cout << maxi;
  return 0;
}
Problem p02696 (C++)

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

using namespace std;

#define sp(x) cout << setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX * 0.99
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238

typedef pair<int, int> P;

signed main() {
  // ios::sync_with_stdio(false);
  // cin.tie(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  int ans = 0;
  REP(i, N + 1) { ans = max(ans, (A * i) / B - A * (i / B)); }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout << setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX * 0.99
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009
#define pi 3.141592653589793238

typedef pair<int, int> P;

signed main() {
  // ios::sync_with_stdio(false);
  // cin.tie(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long N;
  scanf("%lld", &N);
  int ans = 0;
  FOR(i, N - 10000000, N + 1) { ans = max(ans, (A * i) / B - A * (i / B)); }
  if (B >= 10000) {
    int i = B - 1;
    while (i <= N) {
      ans = max(ans, (A * i) / B - A * (i / B));
      i += B;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  long long maxn = -999999;
  for (long long i = 0; i < c / 2; i++) {
    long long k = (a * i) / b - a * (i / b);
    maxn = max(maxn, k);
  }
  for (long long i = c / 2; i <= c; i++) {
    long long k = (a * i) / b - a * (i / b);
    maxn = max(maxn, k);
  }
  cout << maxn;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  long long n = min(b - 1, x);
  cout << (a * n) / b - a * (n / b);
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
/*
 * author :Sadik Hassan
 *
 */
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define nl "\n"
#define pb push_back
#define fi first
#define se second
#define PI (acos(-1.0))
#define _SAD() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define repp(i, a, n) for (int i = a; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define SZ(s) s.size()
#define SRT(x, y) sort(x, x + y)
#define REV(a, b) reverse(a, a + b)
#define VSRT(x) sort(x.begin(), x.end())
#define VREV(x) reverse(x.begin(), x.end())
#define w(t)                                                                   \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define TSFL(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define TSFH(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;

const int N = 1e5 + 10;
const ll xy = 1e11 + 10000000;
const int INF = (int)1e9 + 5;

int main() {
  _SAD()
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 1e-18, cnt = 0;
  if (n > xy) {
    ll sap = sqrt(n);
    for (ll i = n - (sap + 999999999); i <= n; i++) {
      cnt = ((a * i) / b) - (a * (i / b));
      if (cnt < ans)
        break;
      ans = max(cnt, ans);
    }
    cout << ans << nl;
    return 0;
  }
  for (ll i = n / 2; i <= min(n, xy); i++) {
    cnt = ((a * i) / b) - (a * (i / b));
    ans = max(cnt, ans);
  }
  cout << ans << nl;
  return 0;
}


Fixed submission:
/*
 * author :Sadik Hassan
 *
 */
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define nl "\n"
#define pb push_back
#define fi first
#define se second
#define PI (acos(-1.0))
#define _SAD() ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define repp(i, a, n) for (int i = a; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define SZ(s) s.size()
#define SRT(x, y) sort(x, x + y)
#define REV(a, b) reverse(a, a + b)
#define VSRT(x) sort(x.begin(), x.end())
#define VREV(x) reverse(x.begin(), x.end())
#define w(t)                                                                   \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define TSFL(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define TSFH(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
typedef vector<int> vi;
typedef vector<ll> vii;
typedef set<int> si;
typedef set<ll> sii;

const int N = 1e5 + 10;
const ll xy = 1e11 + 10000000;
const int INF = (int)1e9 + 5;

int main() {
  _SAD()
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = min(b - 1, n);
  cout << ans * a / b << nl;
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll << 60;

ll A, B, N;

inline ll f(ll n) { return ((A * n) / B) - A * (n / B); }

int main(int argc, char **argv) {
  cin >> A >> B >> N;
  ll res{0};
  for (ll i = N / 2; i <= N; ++i) {
    res = max(res, f(i));
  }
  std::cout << res << std::endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll << 60;

ll A, B, N;

inline ll f(ll n) { return ((A * n) / B) - A * (n / B); }

int main(int argc, char **argv) {
  cin >> A >> B >> N;
  std::cout << f(min(N, B - 1)) << std::endl;
}
Problem p02696 (C++)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)

int main() {
  long double a, b, n;
  cin >> a >> b >> n;

  ll ans = 0;
  ll tmp = 0;
  // rep(x,n+1)
  bool is_stop = 0;
  for (ll x = 0; x < n + 1; x++) {
    tmp = floor(a * (long double)x / b) - a * floor((long double)x / b);
    if (tmp >= ans)
      ans = tmp;
    if (x % (ll)b == 0) {
      if (is_stop)
        break;
      is_stop = 1;
    }
    // cout << x<< " " << tmp<< " " << a*(long double)x/b<<endl;
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for (auto &i : mp)

int main() {
  long double a, b, n;
  cin >> a >> b >> n;

  ll ans = 0;
  ll tmp = 0;
  // rep(x,n+1)
  bool is_stop = 0;
  // for (ll x = 0; x < n+1; x++){
  //   tmp = floor(a*(long double)x/b) - a*floor((long double)x/b);
  //   if (tmp >= ans) ans = tmp;
  //   if(x%(ll)b == 0){
  //     if (is_stop) break;
  //     is_stop = 1;
  //   }
  //   // cout << x<< " " << tmp<< " " << a*(long double)x/b<<endl;
  // }
  if (n >= b) {
    ans = floor(a * (b - 1.0) / b) - a * floor((b - 1.0) / b);
  } else {
    ans = floor(a * n / b) - a * floor(n / b);
  }
  cout << ans << endl;
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  long long A, B, N, max = 0;
  cin >> A >> B >> N;
  for (long long x = N; x >= 0; x -= 1) {
    long long Ax = A * x;
    long long res = Ax / B - A * (x / B);
    if (res > max)
      max = res;
  }
  cout << max << endl;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  long long A, B, N, max = 0;
  cin >> A >> B >> N;

  long long x = 0;

  if (N >= B)
    x = B - 1;
  else
    x = N;

  long long res = (A * x) / B;

  cout << res << endl;
}
Problem p02696 (C++)

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

const ll INF = 1001001001;

const double PI = 3.141592653;

const ll MOD = 1000000007; // 大きい素数

// 提出のときに言語がc＋＋似合っていることを確認する

// 絶対値の関数
int z(int a, int b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll sum = 0;
  for (ll i = 1; i <= n; i++) {
    sum = max(sum, (a * i) / b - a * (i / b));
  }
  cout << sum << endl;

  return 0;
}


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

const ll INF = 1001001001;

const double PI = 3.141592653;

const ll MOD = 1000000007; // 大きい素数

// 提出のときに言語がc＋＋似合っていることを確認する

// 絶対値の関数
int z(int a, int b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll l = min(n, b - 1);
  ll sum = (a * l) / b;
  cout << sum << endl;

  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef double db;
const ll mod = 998244353;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

const int N = 1e5 + 50;
ll s[N];
ll a[N];
int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (b > n) {
    cout << floor((1ll) * a * n / b);
  } else {
    ll ans = 0;
    for (int i = b - 1; i <= n; i += b) {
      ans = max(ans, (ll)(floor((1ll) * a * i / b) - a * floor(i / b)));
    }
    ans = max(ans, (ll)(floor((1ll) * a * n / b) - a * floor(n / b)));
    cout << ans;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
typedef double db;
const ll mod = 998244353;
ll powmod(ll a, ll b) {
  ll res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

const int N = 1e5 + 50;
ll s[N];
ll a[N];
int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (b > n) {
    cout << floor((1ll) * a * n / b);
  } else {

    cout << floor((1ll) * a * (b - 1) / b);
  }
  return 0;
}
Problem p02696 (C++)

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

using namespace std;

int main() {
  long long a, b, n, mx = 0;
  cin >> a >> b >> n;
  for (int i = 1; i * b - 1 <= n; i++) {
    long long t = i * b - 1;
    mx = max(mx, (a * t / b) - a * (t / b));
  }
  long long t = n;
  mx = max(mx, (a * t / b) - a * (t / b));
  cout << mx << endl;
}


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

using namespace std;

int main() {
  long long a, b, n, mx = 0;
  cin >> a >> b >> n;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i * b - 1 <= n; i++) {
    long long t = i * b - 1;
    mx = max(mx, (a * t / b) - a * (t / b));
  }
  long long t = n;
  mx = max(mx, (a * t / b) - a * (t / b));
  cout << mx << endl;
}
Problem p02696 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  vector<ull> ans(n);
  for (ll i = 0; i < n; i++) {
    ans[i] = (a * (i + 1)) / b - a * ((i + 1) / b);
  }
  sort(ans.rbegin(), ans.rend());
  cout << ans[0] << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(n, b - 1);
  cout << (a * (x)) / b - a * ((x) / b) << endl;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long INT;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
  INT a, b, n, ans = 0;
  cin >> a >> b >> n;

  for (int i = 0; i <= b && i <= n; i++) {
    ans = max(ans, (a * i) / b - (i / b) * a);
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long INT;
double PI = 3.14159265;
using namespace std;
using Graph = vector<vector<int>>;
using Field = vector<string>;
using DGraph = vector<vector<pair<int, int>>>;

const long long INF = 1LL << 60;
//---//

int main() {
  INT a, b, n, ans = 0;
  cin >> a >> b >> n;

  if (b - 1 <= n)
    n = max(n % b, b - 1);
  else
    n = n % b;

  ans = (a * n) / b - (n / b) * a;

  cout << ans << endl;

  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long long int a, b, n, i, max = 0, temp = 0;
  cin >> a >> b >> n;
  for (i = 1; ((i <= n) && (i <= b)); i++) {
    temp = floor(a * i / b) - a * floor(i / b);
    if (temp > max)
      max = temp;
    if (temp < max)
      break;
  }
  cout << max << endl;
  return 0;
}


Fixed submission:
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long long int a, b, n, i, max = 0, temp = 0;
  cin >> a >> b >> n;
  if (b - 1 <= n)
    max = floor((b - 1) * a / b) - a * floor((b - 1) / b);
  else
    max = floor(n * a / b) - a * floor(n / b);
  cout << max << endl;
  return 0;
}
Problem p02696 (C++)

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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
  lld A, B, N;
  cin >> A >> B >> N;
  lld maxv = -1;
  lld nowx = N / 2;
  while (true) {
    if (nowx > N) {
      cout << maxv << endl;
      exit(0);
    }
    lld left = (A * nowx / B);
    lld right = A * (nowx / B);
    // cout << left << " " << right << endl;
    maxv = max(maxv, left - right);
    nowx = min(((left + 1) * B / A) + 1, (right + 1) * B);
    // cout << ((left + 1) * B / A) + 1 << " " << (right + 1) * B << endl;
    // cout << nowx << endl;
  }
}

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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
  lld A, B, N;
  cin >> A >> B >> N;
  lld maxv = -1;
  lld nowx = max(0LL, N - 10 * B);
  while (true) {
    if (nowx > N) {
      cout << maxv << endl;
      exit(0);
    }
    lld left = (A * nowx / B);
    lld right = A * (nowx / B);
    // cout << left << " " << right << endl;
    maxv = max(maxv, left - right);
    nowx = min(((left + 1) * B / A) + 1, (right + 1) * B);
    // cout << ((left + 1) * B / A) + 1 << " " << (right + 1) * B << endl;
    // cout << nowx << endl;
  }
}
Problem p02696 (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++)
using ll = long long;
using P = pair<ll, ll>;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll sum = 0, ans = 0;
  for (int i = 0; i <= n; i++) {
    sum = (a * i) / b - a * (i / b);
    ans = max(sum, ans);
  }
  cout << ans << endl;
}

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  if (n < b) {
    cout << a * n / b << endl;
    return 0;
  } else {
    ans = (a * n) / b - a * (n / b);
    ans = max(ans, ((a * b) / b - a));
    ans = max(ans, ((a * (b - 1)) / b));
  }
  cout << ans << endl;
}
Problem p02696 (C++)

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

int main(int argc, const char *argv[]) {
  long long int a, b, n, c;
  c = 0;
  std::cin >> a >> b >> n;
  if (b > n) {
    std::cout << a * n / b - a * (n / b) << std::endl;
  } else {
    for (int i = 1; i * b - 1 < n; i++) {
      c = i * b - 1;
    }
    std::cout << a * c / b - a * (c / b) << std::endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>

int main(int argc, const char *argv[]) {
  long long int a, b, n, c;
  c = 0;
  std::cin >> a >> b >> n;
  if (b > n) {
    std::cout << a * n / b - a * (n / b) << std::endl;
  } else {
    c = (n / b) * b - 1;
    std::cout << a * c / b - a * (c / b) << std::endl;
  }
  return 0;
}
Problem p02696 (C++)

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  for (ll i = 1; i <= min(n, b); i++) {
    ll tmp = (a * i) / b - a * (i / b);
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  cout << a * min(b - 1, n) / b << endl;
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
int main() {
  ll A, B, N, x = 1, M = 0, c = 1;
  scanf("%lld%lld%lld", &A, &B, &N);

  if (B == 1) {
    puts("0");
    return 0;
  }
  if (N < 100000) {
    while (x <= N) {
      M = max(M, A * x / B - A * (x / B));
      x++;
    }
  } else {
    c = max((N - 10000000) / B, 0ll);
    while ((x = B * c - 1) <= N) {
      M = max(M, A * x / B - A * (x / B));
      c++;
    }
    x -= B;
    while (x <= N) {
      M = max(M, A * x / B - A * (x / B));
      x++;
    }
  }
  printf("%lld\n", M);
  return 0;
}


Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (auto i = a; i < b; i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const ll mod = 1000000007;
int main() {
  ll A, B, N, x = 1, M = 0, c = 1;
  scanf("%lld%lld%lld", &A, &B, &N);

  if (B == 1) {
    puts("0");
    return 0;
  }
  if (N < 100000) {
    while (x <= N) {
      M = max(M, A * x / B - A * (x / B));
      x++;
    }
  } else {
    c = max((N - 10000000) / B, 0ll);
    while ((x = B * c - 1) <= N) {
      M = max(M, A * x / B - A * (x / B));
      c++;
    }
    x = max(N - 100000, 0ll);
    while (x <= N) {
      M = max(M, A * x / B - A * (x / B));
      x++;
    }
  }
  printf("%lld\n", M);
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a, b, n;
  cin >> a >> b >> n;
  int64_t x, maxi = 0;
  for (x = 0; x <= n; x++) {
    int64_t p = x / b;
    int64_t ans = a * x / b - a * p;
    maxi = max(ans, maxi);
  }
  cout << maxi;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a, b, n;
  cin >> a >> b >> n;
  int64_t x, maxi = 0;
  int64_t p = min(b - 1, n);
  int64_t q = p / b;
  int64_t ans = a * p / b - a * q;
  cout << ans;
}
Problem p02696 (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;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  rep(i, min(b, n + 1)) { ans = max(ans, (i * a / b) - a * (i / b)); }
  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;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  if (n >= b) {
    cout << ((b - 1) * a / b) - a * ((b - 1) / b);
  }
  if (n < b) {
    cout << n * a / b - a * (n / b);
  }
}
Problem p02696 (C++)

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

const long INF = 1L << 60;

int main() {
  long a, b, n;
  scanf("%ld%ld%ld", &a, &b, &n);
  long ans = -INF;
  for (int i = n / 2; i <= n; i++)
    ans = max(ans, (long)(floor(a * i / b) - a * floor(i / b)));
  printf("%ld\n", ans);
}


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

const long INF = 1L << 60;

int main() {
  long a, b, n;
  scanf("%ld%ld%ld", &a, &b, &n);
  if (b - 1 >= n)
    printf("%ld\n", (long)(floor(a * n / b) - a * floor(n / b)));
  else
    printf("%ld\n", (long)(floor(a * (b - 1) / b) - a * floor((b - 1) / b)));
}
Problem p02696 (C++)

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

using namespace std;

int main(void) {

  long long A;
  long long B, N;
  cin >> A >> B >> N;

  long long max = 0;

  for (long long x = 0; x <= B && x <= N; x++) {
    long long p = (A * x) / B - A * (x / B);
    if (p > max) {
      max = p;
    }
  }

  cout << max << endl;
}


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

using namespace std;

int main(void) {

  long long A;
  long long B, N;
  cin >> A >> B >> N;

  long long max = 0;

  if (N < B) {
    max = (A * N) / B - A * (N / B);
  } else {
    max = (A * (B - 1)) / B - A * ((B - 1) / B);
  }

  cout << max << endl;
}
Problem p02696 (C++)

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

// D - Floor Function
int main() {
  long long A, B, N;
  cin >> A >> B >> N;

  long long result = -1;
  for (int x = 0; x <= N; x++) {
    long long tmp = floor(A * x / B) - A * floor(x / B);
    if (result > 0 && tmp == 0)
      break;
    result = max(result, tmp);
  }
  cout << result;
}


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

// D - Floor Function
int main() {
  long long A, B, N;
  cin >> A >> B >> N;

  long long x = B - 1;
  x = min(x, N);
  long long result = floor(A * x / B) - A * floor(x / B);
  cout << result;
}
Problem p02696 (C++)

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

#define FOR(i, a, b) for (ll i = a; (i) < (b); ++(i))
#define RFOR(i, a, b) for (ll i = a; (i) >= (b); --(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define UNIQ(v)                                                                \
  sort(ALL(v));                                                                \
  v.erase(unique(ALL(v)), v.end())
#define BIT(n) (1LL << (n))
#define DEBUG(a) cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9 + 7;
// const ll inf = 1e15;
// const ll mod = 1e9+7;

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

int main() {
  ll A, B, N;
  cin >> A >> B >> N;

  // int mx = 0;
  // if (N < B) {
  //     mx = floor(A*N/B) - A*floor(N/B);
  // } else {
  //     REP(i, B) {
  //         int diff = floor(A*i/B) - A*floor(i/B);
  //         mx = max(mx, diff);
  //     }
  // }

  ll mx = 0;
  for (ll i = 0; i < B && i <= N; ++i) {
    ll diff = A * i / B - A * (i / B);
    mx = max(mx, diff);
  }
  cout << mx << endl;
}


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

#define FOR(i, a, b) for (ll i = a; (i) < (b); ++(i))
#define RFOR(i, a, b) for (ll i = a; (i) >= (b); --(i))
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define UNIQ(v)                                                                \
  sort(ALL(v));                                                                \
  v.erase(unique(ALL(v)), v.end())
#define BIT(n) (1LL << (n))
#define DEBUG(a) cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9 + 7;
// const ll inf = 1e15;
// const ll mod = 1e9+7;

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

int main() {
  ll A, B, N;
  cin >> A >> B >> N;

  // int mx = 0;
  // if (N < B) {
  //     mx = floor(A*N/B) - A*floor(N/B);
  // } else {
  //     REP(i, B) {
  //         int diff = floor(A*i/B) - A*floor(i/B);
  //         mx = max(mx, diff);
  //     }
  // }

  ll x = min(B - 1, N);
  ll diff = A * x / B - A * (x / B);
  cout << diff << endl;
}
Problem p02696 (C++)

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

#define ll long long

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  if (n < b) {
    cout << (a * n) / b << endl;
  } else {
    ll ans = 0;
    ll x = b - 1;
    while (x < n) {
      ll temp = (a * x) / b - a * (x / b);
      if (temp > ans)
        ans = temp;
      x += b;
    }
    cout << ans << endl;
  }
}

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

#define ll long long

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = (n / b) * b - 1;
  if (x == -1)
    cout << (a * n) / b;
  else
    cout << (a * x) / b - a * (x / b);
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  long long ans;
  ans = 0;
  for (int i = 0; i <= n; i++) {
    long long f;
    f = a * i / b - a * (i / b);
    ans = max(ans, f);
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  long long ans;
  ans = 0;
  if (n >= b) {
    ans = (b - 1) * a / b;
  } else {
    ans = n * a / b;
  }
  cout << ans << endl;
}
Problem p02696 (C++)

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

using namespace std;

void C(void) {
  long long n, m, q;
  long long i, j, k;
  long long temp_a, temp_b, temp_c, temp_d;
  vector<long long> a, b, c, d;

  cin >> n >> m >> q;

  for (i = 0; i < q; i++) {
    cin >> temp_a, temp_b, temp_c, temp_d;
    a.push_back(temp_a);
    b.push_back(temp_b);
    c.push_back(temp_c);
    d.push_back(temp_d);
  }
}

int main(void) {
  long long n, m, q;
  long long i, j, k;
  long long a, b;
  long long max = 0;

  cin >> a >> b >> n;

  for (i = 0; i <= n; i++) {
    m = floor((a * i) / double(b)) - a * floor(i / double(b));
    if (max < m) {
      max = m;
    }
  }

  cout << max << endl;

  return 0;
}


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

using namespace std;

void C(void) {
  long long n, m, q;
  long long i, j, k;
  long long temp_a, temp_b, temp_c, temp_d;
  vector<long long> a, b, c, d;

  cin >> n >> m >> q;

  for (i = 0; i < q; i++) {
    cin >> temp_a, temp_b, temp_c, temp_d;
    a.push_back(temp_a);
    b.push_back(temp_b);
    c.push_back(temp_c);
    d.push_back(temp_d);
  }
}

int main(void) {
  long long n, m, q;
  long long i, j, k;
  long long a, b;
  long long max = 0;

  cin >> a >> b >> n;

  if (b > n) {
    max = floor((a * n) / double(b)) - a * floor(n / double(b));
  } else {
    max = floor((a * (b - 1)) / double(b)) - a * floor((b - 1) / double(b));
  }

  cout << max << endl;

  return 0;
}
Problem p02696 (Python)

Buggy submission (status: Time Limit Exceeded):
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    A, B, N = map(int, input().split())

    ans = 0
    for x in range(N + 1):
        res = int((A * x) // B) - A * int(x // B)
        ans = max(ans, res)
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
def main():
    import sys

    input = sys.stdin.readline

    A, B, N = map(int, input().split())

    x = min(B - 1, N)
    print((A * x) // B - A * (x // B))


if __name__ == "__main__":
    main()
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long a, b, n;
  long long ma = 0;
  cin >> a >> b >> n;
  for (long long j = n; j >= n - 100000000; j--) {
    if (j < 0) {
      break;
    }
    if (ma < (a * j) / b - a * (j / b)) {
      ma = (a * j) / b - a * (j / b);
    }
  }
  for (long long j = 0; j < 100000000; j++) {
    if (j > n) {
      break;
    }
    if (ma < (a * j) / b - a * (j / b)) {
      ma = (a * j) / b - a * (j / b);
    }
  }
  if (ma < (a * (n / 2)) / b - a * ((n / 2) / b)) {
    ma = (a * (n / 2)) / b - a * ((n / 2) / b);
  }
  cout << ma << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  long long n = min(b - 1, x);
  cout << (a * n) / b - a * (n / b) << endl;
  return 0;
}
Problem p02696 (C++)

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

long A, B, N;

long f(double x) { return floor((A * x) / B) - A * floor(x / B); }

int main() {
  cin >> A >> B >> N;
  long cnt = N > B ? B : N;
  long max = -100;
  for (long x = 1; x <= cnt; x++) {
    long now = f((double)x);
    max = max > now ? max : now;
  }
  cout << max << endl;
  return 0;
}

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

long A, B, N;

long f(double x) { return floor((A * x) / B) - A * floor(x / B); }

int main() {
  cin >> A >> B >> N;
  long min = N > B - 1 ? B - 1 : N;
  cout << f(min) << endl;
  return 0;
}
Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <climits>
#include <cmath>
#include <iostream>
typedef long long ll;
using namespace std;
int main() {
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll n;
  cin >> n;
  ll k = min(b, n);
  ll answer = INT_MIN;
  for (ll i = k; a * i >= b; i--) {
    ll medi = floor((a * i) / b) - a * (floor(i / b));
    answer = max(answer, medi);
  }
  cout << answer;
}


Fixed submission:
#include <climits>
#include <cmath>
#include <iostream>
typedef long long ll;
using namespace std;
int main() {
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll n;
  cin >> n;
  ll k = min(b - 1, n);
  ll medi = floor((a * k) / b) - a * (floor(k / b));

  cout << medi;
}