alexjercan/bugnet huggingface dataset:
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 y = n / b;
  if (n < b) {
    cout << (a * n / b) - a * (n / b) << "\\n";
    return 0;
  }
  n = b * y - 1;
  cout << (a * n / b) - a * (n / b) << "\\n";
  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;
  int c = n;
  if (n < b) {
    cout << (a * n / b) - a * (n / b) << "\\n";
    return 0;
  }
  while (1) {
    if (c % b == 0) {
      break;
    }
    --c;
  }
  n = c - 1;
  cout << (a * n / b) - a * (n / b) << "\\n";
  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 = min(b - 1, n);
  int ans = int(a * x / b) - a * int(x / b);
  // // 全探索
  // ll ans = 0;
  // for(ll x = 0; x <= n; ++x) {
  //     ll fst = a * x / b;
  //     ll scd = x / b;
  //     scd *= a;
  //     ll flr = fst - scd;
  //     ans = max(ans, flr);
  // }
  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 ans = 0;
  for (ll x = 0; x <= n; ++x) {
    ll fst = a * x / b;
    ll scd = x / b;
    scd *= a;
    ll flr = fst - scd;
    ans = max(ans, flr);
  }
  cout << ans << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  ll prev = 0;
  int flag = 0;
  for (ll x = 1; x < n + 1; x++) {
    prev = ans;
    ans = floor(a * x / b) - (a * floor(x / b));
    if (ans != 0)
      flag = 1;
    else if (flag == 1) {
      cout << prev << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  if (b == 1) {
    cout << ans << endl;
    return 0;
  }
  for (ll x = b - 1; x <= n; x += b) {
    ans = max(ans, (a * x) / b - a * (x / b));
  }
  ans = max(ans, (a * n) / b - a * (n / b));
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  for (ll x = b - 1; x <= n; x += b) {
    ans = max(ans, (a * x) / b - a * (x / b));
  }
  ans = max(ans, (a * n) / b - a * (n / b));
  cout << ans << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t A, B, N;
  cin >> A >> B >> N;
  int64_t max_val = (A * min(B - 1, N)) / B;
  cout << max_val << endl;

  return 0;
}


Error: TLE

Fixed submission:

/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t A, B, N;
  cin >> A >> B >> N;
  int64_t max_val = INT64_MIN;
  for (int64_t x = 0; x < B && x <= N; ++x) {
    const int64_t val = (A * x) / B - A * (x / B);
    if (val > max_val) {
      max_val = val;
    }
  }
  cout << max_val << endl;

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

#include "math.h"
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <typeinfo>
#include <vector>
using namespace std;

// 　Floor Function

int main() {
  long long int a, b, n, hoge = 0, mae, usiro;
  cin >> a >> b >> n;
  /*for (long long int i = 1; i<= b && i <= n; i++) {
          mae = ((a * i) / b);
          usiro = (a * (i / b));
          if (hoge <(mae-usiro) ) {
                  hoge = (mae - usiro);
          }
  } */
  if (b > n) {
    mae = ((a * n) / b);
    usiro = (a * (n / b));
    hoge = (mae - usiro);
  } else {
    mae = ((a * (b - 1)) / b);
    usiro = (a * ((b - 1) / b));
    hoge = (mae - usiro);
  }
  cout << hoge << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include "math.h"
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <typeinfo>
#include <vector>
using namespace std;

// 　Floor Function

int main() {

  long long int a, b, n, hoge = 0, mae, usiro;
  cin >> a >> b >> n;
  for (long long int i = 1; i <= b && i <= n; i++) {
    mae = ((a * i) / b);
    usiro = (a * (i / b));
    if (hoge < (mae - usiro)) {
      hoge = (mae - usiro);
    }
  }
  cout << hoge << endl;

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

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 5;
const double pi = acos(-1.0);
const ll mod = 1e9 + 7;
int main() {

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 5;
const double pi = acos(-1.0);
const ll mod = 1e9 + 7;
int main() {

  ll a, b, n, ans = -inf, temp, flag, cnt;
  cin >> a >> b >> n;
  for (int i = 1; i <= n; i++) {
    temp = ans;
    cnt = floor(a * i / b) - a * floor(i / b);
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
int main(void) {

  long long int a, b, n, maxx = 0, x, f;
  cin >> a >> b >> n;
  long long int hope_x = b - 1;
  if (hope_x <= n)
    x = hope_x;
  else
    x = n;
  // for(int i=1;i<=x;i++){
  // f=(a*i)/b-a*(i/b);
  // maxx=max(maxx,f);
  //}
  cout << (a * x) / b - a * (x / b);
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
int main(void) {

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

#include <bits/stdc++.h>
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;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll INF = 1 << 25;
int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  // ll X = -1*INF;
  // for (int i=0;i<=N;i++) {
  //     ll Y = (ll)(A*i/B)-(ll)A*(i/B);
  //     // cout << i << " " << Y << endl;
  //     chmax(X, Y);
  // }
  // cout << X << endl;
  ll Z = min(B - 1, N);
  cout << (ll)(A * Z / B) - (ll)A * (Z / B) << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
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;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
ll INF = 1 << 25;
int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  ll X = -1 * INF;
  for (int i = 0; i <= N; i++) {
    ll Y = (ll)(A * i / B) - (ll)A * (i / B);
    chmax(X, Y);
  }
  cout << X << 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 deb(x) cerr << #x << ": " << x << '\\n';
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main() {
  ios;
  ll A, B, N;
  cin >> A >> B >> N;
  ll ans = 0, max = min(B - 1, N);
  ans = ((A * max) / B) - (A * (max / 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 rep1(i, n) for (int i = 1; i <= n; i++)
#define deb(x) cerr << #x << ": " << x << '\\n';
#define ios                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main() {
  ios;
  ll A, B, N;
  cin >> A >> B >> N;
  ll ans = 0, best = 0;
  rep1(x, 1e8 + 9e7) {
    if (x > N)
      break;
    ans = ((A * x) / B) - (A * (x / B));
    best = max(best, ans);
  }
  cout << best;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // Your code
  ll a, b, n;
  cin >> a >> b >> n;
  ll ind = min(b - 1, n);
  cout << floor(a * ind / b);
  return 0;
}

Error: TLE

Fixed submission:

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // Your code
  ll a, b, n;
  cin >> a >> b >> n;
  ll max_val = 0;
  for (ll i = 0; i <= n; i++) {
    max_val = max(max_val, (ll)(floor(a * i / b) - a * floor(i / b)));
  }
  cout << max_val;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>

using namespace std;

const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;

/*
ll modpow(ll a, ll n,int md) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % md;
        a = a * a % md;
        n >>= 1;
    }
    return res;
}
*/

// const int N=200005;
ll A, B, N, maxxx, buff;
int main() {
  if (B <= N) {
    maxxx = 0;
    cin >> A >> B >> N;
    ll x = ((ll)(N / B) * B) - 1;
    maxxx = ((ll)((A * x) / B)) - (A * ((ll)(x / B)));
    buff = ((ll)((A * N) / B)) - (A * ((ll)(N / B)));
    if (maxxx < buff)
      maxxx = buff;
    printf("%lld\\n", maxxx);
  } else {
    maxxx = 0;
    cin >> A >> B >> N;
    maxxx = ((ll)((A * N) / B)) - (A * ((ll)(N / B)));
    printf("%lld\\n", maxxx);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>

using namespace std;

const int maxn = 2e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long ll;

/*
ll modpow(ll a, ll n,int md) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % md;
        a = a * a % md;
        n >>= 1;
    }
    return res;
}
*/

// const int N=200005;
ll A, B, N, maxxx, buff;
int main() {
  maxxx = 0;
  cin >> A >> B >> N;
  for (ll x = 1; x <= N; x++) {
    buff = ((ll)((A * x) / B)) - (A * ((ll)(x / B)));
    if (maxxx < buff)
      maxxx = buff;
  }
  printf("%lld\\n", maxxx);
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int a, b, n;
  cin >> a >> b >> n;
  int x = n;
  while ((x / b) >= 1) {
    x--;
  }
  int ans = floor((a * x) / b);
  cout << ans << "\\n";
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using ll = long long;
#define print(n) cout << n << endl

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

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

  ll x = min(b - 1, n);
  print(floor(a * x / b) - a * floor(x / b));
  return 0;
}

Error: TLE

Fixed submission:

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

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i > 0; i--)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl

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

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

  ll culc, ans = 0;
  rep(x, n) {
    culc = floor(a * (x + 1) / b) - a * floor((x + 1) / b);
    if (culc > ans)
      ans = culc;
  }
  print(ans);
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  long long f = 0;
  if (n < b)
    f = (a * n) / b - a * (n / b);
  if (n == b)
    f = (a * (n - 1)) / b - a * ((n - 1) / b);
  if (n > b)
    f = (a * (n - 1 - n % b)) / b - a * ((n - 1 - n % b) / b);

  cout << f << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  long long a, b, n;
  cin >> a >> b >> n;
  long long f = 0;
  if (n < b)
    f = (a * n) / b - a * (n / b);
  if (n == b)
    f = (a * (n - 1)) / b - a * ((n - 1) / b);
  if (n > b)
    for (long long i = 0; i <= n % b; i++) {
      long long t = (a * (n - i)) / b - a * ((n - i) / b);
      if (t > f)
        f = t;
    }
  cout << f << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll << 60;

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

int main() {
  int a;
  long double b, n;
  cin >> a >> b >> n;
  long double a_b = a / b;
  ll x = min(n, b - 1);
  ll f_a = floor(a_b * (x)) - a * floor((x) / b);

  out(f_a);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll << 60;

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

int main() {
  int a;
  long double b, n;
  cin >> a >> b >> n;
  ll max_f = 0;
  long double a_b = a / b;
  ll g, l;
  if (n <= b)
    g = 0, l = n;
  else
    g = b, l = g;
  for (ll i = g; i <= n; i++) {
    // ll f = (1-2*a)*floor(i)+floor(i+a_b)-a*b;
    ll f = floor(a_b * i) - a * floor(i / b);
    // out(f);
    if (max_f < f)
      max_f = f;
  }
  out(max_f);
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x)                                                              \\
  t ipt;                                                                       \\
  cin >> ipt;                                                                  \\
  x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

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

  double ans = 0.0;

  if (n < b) {
    MSG(floor(((double)a * n / (double)b) - a * floor((double)n / b)))
  } else {
    MSG(floor(((double)a * (b - 1) / (double)b) -
              a * floor((double)(b - 1) / b)))
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x)                                                              \\
  t ipt;                                                                       \\
  cin >> ipt;                                                                  \\
  x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

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

  double ans = 0.0;
  for (ll x = 1; x <= min(n, b); ++x) {
    ans =
        max(floor(((double)a * x / (double)b) - a * floor((double)x / b)), ans);
  }

  MSG(ans)
}
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 z = min(B - 1, N);
  long long ans = A * z / B;

  cout << ans << 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 ans = 0;
  for (int i = 0; i <= N; i++) {
    long long temp = 0;
    temp = A * i / B - A * (i / B);
    if (temp >= ans) {
      ans = temp;
    }
  }

  cout << ans << 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 counter = 0;
  counter = ((A * N) / B) - A * (N / B);
  long long i = N - (N % B) - 1;
  counter = max(counter, ((A * i) / B) - A * (i / B));
  cout << counter << 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 counter = 0;
  counter = ((A * N) / B) - A * (N / B);
  long long i = N;
  for (i; i > 0; i--) {
    if (i % B == 0) {
      i--;
      break;
    } else
      continue;
  }
  counter = max(counter, ((A * i) / B) - A * (i / B));
  cout << counter << endl;

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

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO                                                                 \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO                                                                 \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

int main() {
  fastIO;
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  ll y;
  for (ll i = 1; i <= min(n, (ll)1e8); i++) {
    ans = max(ans, (a * i) / b - a * (i / b));
    y = min(n, (b / i));
    ans = max(ans, (a * y) / b - a * (y / b));
  }
  if (a <= n)
    ans = max(ans, (a * a) / b - a * (a / b));
  cout << ans << "\\n";
  return 0;
}