alexjercan/bugnet huggingface dataset:
Problem p02696 (C++) — buggy submission, verdict: Runtime Error

// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \\t" << x.second << '\\n'

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int modinv(int a, int m) {
  int b = m, u = 1, v = 0;
  while (b) {
    int t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a % b, y, x);
  y -= a / b * x;
  return d;
}

int a, b, n;

signed main() {
  cin >> a >> b >> n;

  int res = 0;

  if (b > n) {
    cout << (a * n) / b - a * (n / b) << endl;
    return 0;
  }
  if (b != 1) {
    int i = n / (b - 1);
    res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res);
    i--;
    res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res);
  } else {
    res = 0;
  }
  cout << res << endl;
  return 0;
}

Error: 0

Fixed submission:

// @prefix atcoder
// @description atcoder template

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

// typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \\t" << x.second << '\\n'

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int modinv(int a, int m) {
  int b = m, u = 1, v = 0;
  while (b) {
    int t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

long long extGCD(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extGCD(b, a % b, y, x);
  y -= a / b * x;
  return d;
}

int a, b, n;

signed main() {
  cin >> a >> b >> n;

  int res = 0;

  if (b > n) {
    cout << (a * n) / b - a * (n / b) << endl;
    return 0;
  }
  int i = n / (b - 1);
  res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res);
  i--;
  res = max((a * (i * (b - 1))) / b - a * ((b * i - 1) / b), res);
  cout << res << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, 0, n)

int main() {
  ll A, B, N;
  ll maxval = numeric_limits<ll>::min(), val;
  cin >> A >> B >> N;

  if (B <= N) {
    val = (A * (B - 1)) / B;
  } else {
    val = ((A * N) / B) - (A * (N / B));
  }
  cout << val << endl;
  /*
  for (ll x = B - 1; x <= N; x += B) {
          val = ((A * x) / B) - (A * (x / B));
          maxval = max(maxval, val);
  }

  val = ((A * N) / B) - (A * (N / B));
  maxval = max(maxval, val);

  cout << maxval << endl;
  */
  return 0;
}

Error: TLE

Fixed submission:

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

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, 0, n)

int main() {
  ll A, B, N;
  ll maxval = numeric_limits<ll>::min(), val;
  cin >> A >> B >> N;

  for (ll x = B - 1; x <= N; x += B) {
    val = ((A * x) / B) - (A * (x / B));
    maxval = max(maxval, val);
  }

  val = ((A * N) / B) - (A * (N / B));
  maxval = max(maxval, val);

  cout << maxval << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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


Error: TLE

Fixed submission:

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll cost = 0;
  rep(x, n + 1) cost = max(cost, ll(floor(a * x / b) - a * floor(x / b)));
  cout << cost << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  unsigned long long a, b, n;
  cin >> a >> b >> n;
  unsigned long long x = b - 1;
  if (n < x)
    x = n;
  unsigned long long s =
      (unsigned long long)(a * x / b) - a * ((unsigned long long)(x / b));
  cout << s << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  unsigned long long a, b, n;
  cin >> a >> b >> n;
  unsigned long long mx = 0;
  for (unsigned long long x = 1; x <= n; x++) {
    unsigned long long s =
        (unsigned long long)(a * x / b) - a * ((unsigned long long)(x / b));
    if (s > mx) {
      mx = s;
    }
  }
  cout << mx << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  long long b, n;
  long long ans;
  cin >> a >> b >> n;
  if (n >= b - 1)
    ans = a * (b - 1) / b;
  else
    ans = a * n / b;
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll max = 0;
  for (int i = 1; i <= n; i++) {
    ll x = a * i / b;
    ll y = i / b;
    y *= a;
    if (x - y > max) {
      max = x - y;
    }
  }
  cout << max;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= 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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll a, b, n;
ll f(ll x) { return floor(a * x / b) - a * floor(x / b); }

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

  cin >> a >> b >> n;

  cout << f(min(b - 1, n)) << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

template <class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= 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;
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x)                                                               \\
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"                       \\
       << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

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

  ll ans = 0;
  ll m = b;
  if (b > n)
    m = n;
  REP(i, m) {
    int x = i + 1;
    ll t = floor(a * x / b) - a * floor(x / b);
    ans = max(ans, t);
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  long a, b, n;
  cin >> a >> b >> n;
  long c = min(b - 1, n);
  cout << (a * c) / b - a * (c / b) << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  long a, b, n, c = 0;
  cin >> a >> b >> n;
  for (int i = 1; i <= n; i++) {
    c = max(c, ((a * i) / b) - a * (i / b));
  }
  cout << c << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll x;
  if (N >= B - 1) {
    x = B - 1;
  } else {
    x = N;
  }
  ll ans = A * (x % B) / B;
  COUT(ans);
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

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

  ll ans = -1;
  rep(i, N + 1) {
    ll a = int(A * i / B);
    ll b = A * int(i / B);
    ans = max(a - b, ans);
  }
  COUT(ans);

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll ans = 0;
  for (ll i = B - 1; i < N + 1; i += B) {
    ans = max(ans, A * i / B - A * (i / B));
    if (i > (B - 1) + B * 10000000)
      break;
  }
  ans = max(ans, (A * N) / B - A * (N / B));
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; i++)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll ans = 0;
  for (ll i = B - 1; i < N + 1; i += B) {
    ans = max(ans, A * i / B - A * (i / B));
  }
  ans = max(ans, (A * N) / B - A * (N / B));
  cout << ans << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int x = 1;
  int max = -1;
  double a, b, n;
  cin >> a >> b >> n;
  long long dif;
  dif = b - 1;
  if (n < b - 1)
    dif = n;
  max = floor(a * dif / b) - a * floor(dif / b);
  cout << max;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int x = 1;
  int max = -1;
  double a, b, n;
  cin >> a >> b >> n;
  long long dif;
  for (int i = 1; i <= n; i++) {
    dif = floor(a * i / b) - a * floor(i / b);

    if (dif > max)
      max = dif;
  }
  cout << max;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long A, B, N;
  cin >> A >> B >> N;
  long long x = min(B - 1, N);
  cout << (long long)(A * x / B) - A * (long long)(x / B) << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

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

  //  long long x = max(N, B-1);
  long long ans_max = -1;
  // cerr << (long long)((A * x) / B) << ", " << (A * (long long)(x / B)) <<
  // endl; long long ans = (long long)((A * x) / B) - (A * (long long)(x / B));
  // ans_max = max(ans, ans_max);

  for (long long x = 1; x <= B && x <= N; x++) {
    long long ans = (long long)((A * x) / B) - (A * (long long)(x / B));
    ans_max = max(ans, ans_max);
  }

  cout << ans_max << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  long long ans = 0;

  /*for (int x = 1; x <= N; x++) {
          int num = (int)(A * x / B) - A * (int)(x / B);
          int num2 =
          if (ans < num)ans = num;
  }*/

  long long x = B - 1;
  if (x >= N)
    x = N;
  long long num = (int)(A * x / B) - A * (int)(x / B);
  if (ans < num)
    ans = num;

  cout << ans;
}

Error: TLE

Fixed submission:

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

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

  long long ans = 0;

  /*for (int x = 1; x <= N; x++) {
          int num = (int)(A * x / B) - A * (int)(x / B);
          int num2 =
          if (ans < num)ans = num;
  }*/

  long long x = B - 1;
  while (x <= N) {
    long long num = (int)(A * x / B) - A * (int)(x / B);
    if (ans < num)
      ans = num;
    x += B;
  }
  long long num = (int)(A * N / B) - A * (int)(N / B);
  if (ans < num)
    ans = num;
  cout << ans;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <iostream>
#include <math.h>
using namespace std;

int main() {
  long long A, B, N, x, y, max = 0;
  cin >> A >> B >> N;
  if (B - 1 <= N) {
    x = B - 1;
    y = floor((A * x) / B) - A * floor(x / B);
    if (y > max) {
      max = y;
    }
  }
  if (floor(B / A) + 1 <= N) {
    x = floor(B / A) + 1;
    y = floor((A * x) / B) - A * floor(x / B);
    if (y > max) {
      max = y;
    }
  }
  x = N - 1;
  y = floor((A * x) / B) - A * floor(x / B);
  if (y > max) {
    max = y;
  }
  x = N;
  y = floor((A * x) / B) - A * floor(x / B);
  if (y > max) {
    max = y;
  }
  cout << max << endl;
  return 0;
}

Error: TLE

Fixed submission:


#include <iostream>
#include <math.h>
using namespace std;

int main() {
  long long A, B, N, x, y, max = 0;
  cin >> A >> B >> N;
  x = 0;
  while (x <= N) {
    y = floor((A * x) / B) - A * floor(x / B);
    if (y > max) {
      max = y;
    }
    x++;
  }
  cout << max << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <map>
#define ll long long
using namespace std;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll M;
  if ((b - 1) >= n) {
    M = floor((a * (n)) / b) - a * floor((n) / b);
  } else {
    M = floor((a * (b - 1)) / b) - a * floor((b - 1) / b);
  }

  cout << M;
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <map>
#define ll long long
using namespace std;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll M = 0;
  for (int i = sqrt(n); i <= n; i++) {
    M = max(M, (ll)(floor((a * i) / b) - a * floor(i / b)));
  }
  cout << M;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
void pr() { ln; }
template <Z A, Z... B> void pr(const A &a, const B &...b) {
  cout << a << ' ';
  pr(b...);
}
template <Z A> void PR(A a, ll n) {
  rep(i, n) {
    if (i)
      cout << ' ';
    cout << a[i];
  }
  ln;
}
ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; }
const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1},
         dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
typedef pair<ll, ll> P;

void Main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(n, b - 1);
  ll ans = a * x / b - a * (x / b);
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin >>
#define Z class
#define ll long long
#define ln cout << '\\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\\n", a)
#define mem(a) memset(a, 0, sizeof(a))
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define REP(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define tr(it, c) for (iter(c) it = (c).begin(); it != (c).end(); it++)
void pr() { ln; }
template <Z A, Z... B> void pr(const A &a, const B &...b) {
  cout << a << ' ';
  pr(b...);
}
template <Z A> void PR(A a, ll n) {
  rep(i, n) {
    if (i)
      cout << ' ';
    cout << a[i];
  }
  ln;
}
ll check(ll n, ll m, ll x, ll y) { return x >= 0 && x < n && y >= 0 && y < m; }
const ll MAX = 1e9 + 7, MAXL = 1LL << 61, dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1},
         dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
typedef pair<ll, ll> P;

void Main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  rep(i, 200000000) {
    ll x = n - i;
    if (x < 0)
      break;
    ll y = a * x / b - a * (x / b);
    ans = max(ans, y);
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t a, b, n;
  cin >> a >> b >> n;
  cout << (a * min(b - 1, n)) / b << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int A;
  int64_t B, N, tmp;
  cin >> A >> B >> N;
  int64_t max1 = 0, i;
  for (i = 1; i <= N; i++) {
    tmp = (A * i) / B - A * (i / B);
    if (tmp == 0)
      continue;
    if (tmp > max1)
      max1 = tmp;
  }
  cout << max1 << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long int a, b, n;
  cin >> a >> b >> n;
  if (b > n) {
    cout << floor(a * n / b) << endl;
  } else {
    cout << floor(a * (b - 1) / b) << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  long long int a, b, n;
  cin >> a >> b >> n;
  long long int ans = -100;
  for (long long int i = 0; i <= min(b, n); i++) {
    long long int f = floor(a * i / b) - a * floor(i / b);
    if (ans < f) {
      ans = f;
    }
  }
  cout << ans;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  if (N < B) {
    cout << (ll)(A * N / B) << endl;
  } else {
    cout << (ll)(A * (B - 1) / B) << endl;
  }
  return (0);
}

Error: TLE

Fixed submission:

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

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll f = 0;
  ll tmp = 0;
  for (int i = 1; i <= N && i <= B; i++) {
    tmp = (ll)(A * i / B) - A * (ll)(i / B);
    if (tmp > f) {
      // cout << i <<" " << tmp << endl;
      f = tmp;
    }
  }

  cout << f << endl;

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

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
#define REPD(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
  int from; // 出発点
  int to;   // 到達点
  int cost; // 移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b)
    return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  ll n, a, b, ma;
  cin >> a >> b >> n;
  if (n >= b) {
    ma = b - 1;
  } else {
    ma = n;
  }
  ll ans = (a * ma) / b - a * (ma / b);
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i <= (n); i++)
#define REPD(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
  int from; // 出発点
  int to;   // 到達点
  int cost; // 移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if (a < b)
    return euclidean_gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
  ll n, a, b;
  cin >> a >> b >> n;
  ll ma = 0;
  for (ll i = n; i >= 0; i--) {
    ma = max(ma, i % b);
    if (ma == b - 1)
      break;
  }
  ll ans = (a * ma) / b - a * (ma / b);
  cout << ans << endl;
  return 0;
}