alexjercan/bugnet huggingface dataset:
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define ll long long
#define endl "\\n"
#define ss string
using namespace std;
/*ll  mod(ll  a,ll  b)
{
  if(a>b)
    return (a-b);
  else
    return (b-a);
}
double distance(ll  x1, ll  y1, ll  x2, ll  y2)
{

    return sqrt(pow(x2 - x1, 2) +
                pow(y2 - y1, 2) * 1.0);
}*/

int main() {
  /*ll t;
  cin>>t;
  while(t--)
  {
    ll n,q;
    cin>>n>>q;
    ss s;
    cin>>s;
    ss s2=s;
    ss s3=s;
    ll arr[q];
    for(int i=0;i<q;i++)
    {
      cin>>arr[i];
    }
    for(ll i=0;i<q;i++)
    {

      ss s1;
      for(ll j=0;j<s.size();)
      {
        if(count(s1.begin(),s1.end(),s[j])<=arr[i])
       {
         s1.push_back(s[j]);
         s.erase(s.begin()+j);
       }
       cout<<s1<<" "<<s<<endl;

      }
      cout<<s1<<endl;
      cout<<s.size()<<endl;
        s1.clear();
       s2=s3;
       s=s3;
    }*/
  unsigned ll a, b, n, x, mini = LONG_LONG_MAX, v;
  cin >> a >> b >> n;
  if (b - 1 >= n)
    x = n;
  else {
    x = b - 1;
  }
  cout << (a * x) / b << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#define ll long long
#define endl "\\n"
#define ss string
using namespace std;
/*ll  mod(ll  a,ll  b)
{
  if(a>b)
    return (a-b);
  else
    return (b-a);
}
double distance(ll  x1, ll  y1, ll  x2, ll  y2)
{

    return sqrt(pow(x2 - x1, 2) +
                pow(y2 - y1, 2) * 1.0);
}*/

int main() {
  /*ll t;
  cin>>t;
  while(t--)
  {
    ll n,q;
    cin>>n>>q;
    ss s;
    cin>>s;
    ss s2=s;
    ss s3=s;
    ll arr[q];
    for(int i=0;i<q;i++)
    {
      cin>>arr[i];
    }
    for(ll i=0;i<q;i++)
    {

      ss s1;
      for(ll j=0;j<s.size();)
      {
        if(count(s1.begin(),s1.end(),s[j])<=arr[i])
       {
         s1.push_back(s[j]);
         s.erase(s.begin()+j);
       }
       cout<<s1<<" "<<s<<endl;

      }
      cout<<s1<<endl;
      cout<<s.size()<<endl;
        s1.clear();
       s2=s3;
       s=s3;
    }*/
  unsigned ll a, b, n, x, maxi = 0;
  cin >> a >> b >> n;
  for (x = 0; x <= n; x++) {
    maxi =
        max(maxi, (long long int)((a * x) / b) - a * ((long long int)(x / b)));
  }
  cout << maxi;

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

#include <bits/stdc++.h>

#define endl '\\n'
#define fi first
#define se second
#define MOD(n, k) ((((n) % (k)) + (k)) % (k))
#define forn(i, n) for (int i = 0; i < n; i++)
#define forr(i, a, b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll a, b, x, n, res;

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

  cin >> a >> b >> n;

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

  cout << (a * x) / b - a * (x / b) << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define endl '\\n'
#define fi first
#define se second
#define MOD(n, k) ((((n) % (k)) + (k)) % (k))
#define forn(i, n) for (int i = 0; i < n; i++)
#define forr(i, a, b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll a, b, x, n, res;

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

  cin >> a >> b >> n;

  for (int x = max(1ll, n - int(2e6)); x <= n; x++) {
    res = max(res, (a * x) / b - a * (x / b));
  }
  cout << res << 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 < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7, INF = 1e9;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  cout << a * min(n, b - 1) / b << endl;
  system("pause");
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7, INF = 1e9;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = (ll)(floor(a * n) / b) - (ll)(a * floor(n / b));
  for (ll i = n; i >= b - 1; i--) {
    if (i > n)
      break;
    ans = max(ans, (ll)(floor(a * i) / b) - (ll)(a * floor(i / b)));
  }
  cout << ans << endl;
  system("pause");
}
Problem p02696 (C++) — buggy submission, verdict: Runtime Error

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

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

Error: 0

Fixed submission:

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

int main() {
  int a, b, n;
  cin >> a >> b >> n;
  vector<double> fl(n);
  for (int x = 1; x <= n; x++) {
    fl[x - 1] = floor(((double)(a) * (double)(x)) / (double)(b)) -
                (double)(a) * (double)((x / b));
  }
  cout << *max_element(fl.begin(), fl.end()) << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const long long INF = -10000000000;

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

  if (b == 1)
    cout << 0 << endl;
  else {
    long long res = INF;
    for (long long i = 0; i <= n / b; i++) {
      if (((i + 1) * b - 1) <= n) {
        long long x = (a * ((i + 1) * b - 1)) / b - a * i;
        res = max(res, x);
      } else if (i == n / b) {
        long long y = (a * n) / b - a * (n / b);
        res = max(res, y);
      }
    }

    cout << res << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

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

const long long INF = -10000000000;

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

  long long res = INF;
  for (int i = 0; i <= n; i++) {
    long long x = (a * i) / b - a * (i / b);
    res = max(res, x);
  }

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

#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repa(i, s, n) for (int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i, a, b) for (int i = a; i >= b; i--)

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

  int x = min(b - 1, n);
  cout << (a * x) / b - a * (x / b) << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repa(i, s, n) for (int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i, a, b) for (int i = a; i >= b; i--)

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

  int ans = 0;
  repa(i, 1, 1000000000) {
    int tmp = floor(a * i / b) - a * floor(i / b);
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <ciso646>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

// 解説ac

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <ciso646>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int a;
  ll b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  rep(i, n + 1) {
    ll rr = a * (i % b) - (a * i % b);
    ans = max(rr, ans);
  }
  cout << ans / b;
}
Problem p02696 (C++) — buggy submission, verdict: Runtime Error

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

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

  long long ans = (a * n / b) - a * (n / b);
  if (b - 1 <= n) {
    ans = max(ans, (a * (b - 1) / b) - a * ((b - 1) / b));
  }
  cout << ans << endl;
}

Error: 0

Fixed submission:

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

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

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

  for (long long int i = 0; i <= n / (b - 1); i++) {
    long long sum1 = (a * ((b - 1) * i)) / b;
    long long sum2 = a * (((b - 1) * i) / b);
    ans = max(ans, sum1 - sum2);
  }
  cout << ans << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

long long A, B, N;

long long dif(long long x) {
  long long a = A * x;
  a /= B;
  long long b = x / B;
  b *= A;
  return a - b;
}

long long bi(long long mi, long long ma, long long target) {
  if (ma - mi == 1 || ma - mi == 0) {
    return dif(ma);
  }

  long long mid = (ma + mi) / 2;
  long long midValue = dif(mid);
  if (midValue >= target) {
    return bi(mi, mid, target);
  } else {
    return bi(mid, ma, target);
  }
}

int main() {
  cin >> A >> B >> N;
  long long valueN = dif(N);
  long long x = N / B;
  x *= B;
  x -= 1;
  if (x < 0) {
    x = 0;
  }
  long long valueLastEdge = dif(x);
  long long target = max(valueN, valueLastEdge);
  cout << bi(0, min(N, B - 1), target);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

long long A, B, N;

long long dif(long long x) {
  long long a = A * x;
  a /= B;
  long long b = x / B;
  b *= A;
  return a - b;
}

long long bi(long long mi, long long ma, long long target) {
  if (ma - mi == 1) {
    return dif(ma);
  }

  long long mid = (ma + mi) / 2;
  long long midValue = dif(mid);
  if (midValue >= target) {
    return bi(mi, mid, target);
  } else {
    return bi(mid, ma, target);
  }
}

int main() {
  cin >> A >> B >> N;
  long long valueN = dif(N);
  long long x = N / B;
  x *= B;
  x -= 1;
  if (x < 0) {
    x = 0;
  }
  long long valueLastEdge = dif(x);
  long long target = max(valueN, valueLastEdge);
  cout << bi(0, min(N, B - 1), target);
}
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)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = acos(-1);
const int INF = numeric_limits<int>::max();

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

  ll maxans = 0;

  if (b > n) {
    maxans = (a * n) / b - a * (n / b);
  }

  else {
    maxans = (a * (b - 1)) / b - a * ((b - 1) / b);
  }

  cout << maxans << 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)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = acos(-1);
const int INF = numeric_limits<int>::max();

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

  int maxans = 0;

  for (int i = 1; i <= n; ++i) {
    int tmp = (a * i) / b - a * (i / b);
    maxans = max(maxans, tmp);
  }

  cout << maxans << endl;

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

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

long long A, B, N;

int main() {
  cin >> A >> B >> N;
  long long MR = 0;

  long long i = min(B - 1, N);
  MR = (A * i) / B - A * (i / B);

  cout << MR << endl;
}


Error: TLE

Fixed submission:

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

long long A, B, N;

int main() {
  cin >> A >> B >> N;
  long long MR = 0;
  int Y = std::floor(std::sqrt(N));
  int C = 1;

  for (long long i = 1; i <= N; i += Y) {
    MR = std::max(((A * i) / B - A * (i / B)), MR);
    C = i;
  }
  for (long long i = C + 1; i <= N; i++) {
    MR = std::max(((A * i) / B - A * (i / B)), MR);
  }

  cout << MR << 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++)
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;
}


Error: TLE

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;
  for (long long i = 0; i < n + 1; i++) {
    ans = max(ans, a * i / b - (i / b) * a);
  }
  cout << ans << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

long long a, b, n;

long long eval(long long x) { return a * x / b - a * (x / b); }

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

Error: -8

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

long long a, b, n;

long long eval(long long x) { return a * x / b - a * (x / b); }

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

#include <cstdio>
#include <iostream>
using namespace std;
typedef long long LL;
int main() {
  LL a, b, n, d;
  scanf("%lld%lld%lld", &a, &b, &n);
  if (n < b)
    d = n;
  else
    d = b - 1;
  printf("%lld\\n", a * d / b);
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
  LL a, b, n;
  scanf("%lld%lld%lld", &a, &b, &n);
  LL m = -1e9;
  LL x;
  for (LL i = 1; i <= n; i++) {
    x = floor(a * i / b) - a * floor(i / b);
    if (x > m)
      m = x;
  }
  cout << m << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

// abc165-D//

// #include <math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <iostream>
#include <stdio.h>
#include <vector>
// #include <string.h>
using namespace std;

int main() {
  long a, b, n;
  cin >> a >> b >> n;
  long ans = 0;
  if (n < b - 1)
    ans = (long)(a * n / b);
  else
    ans = (long)(a * (b - 1) / b);

  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

// #include <math.h>
#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
// #include <string.h>
using namespace std;

int main(void) {
  int A;
  long B, N;
  cin >> A >> B >> N;
  long max = 0;
  for (long i = 1; i < N + 1; i++) {
    long x = A * i / B;
    long y = i / B;
    long z = x - A * y;
    if (z > max)
      max = z;
  }
  cout << max << 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;
  cin >> a >> b >> n;
  long long ans = 0;
  long long l = (a * n / b);
  long long r = a * (n / b);
  long long tmp = n / b;
  long long amari = n % b;
  l = (a * (n - 1)) / b;
  r = a * ((n - 1) / b);
  ans = l - r;

  l = (a * (min(b - 1, n)) / b);
  r = a * (min(n, (b - 1)) / b);
  ans = max(ans, l - r);
  l = (a * n) / b;
  r = a * (n / b);
  ans = max(ans, l - r);
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int a;
  long long b, n;
  cin >> a >> b >> n;
  long long ans = 0;
  long long i = n;
  for (; i > n - b; i--) {
    long long l = (a * i) / b;
    long long r = a * (i / b);
    long long tmp = l - r;
    if (tmp > ans)
      ans = tmp;
  }
  cout << ans;
}
Problem p02696 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  // os << '{';
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, x, ans = 0, count = 0;
  cin >> a >> b >> n;
  cout << a * min(n, b - 1) / b << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  // os << '{';
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, x, ans = 0, count = 0;
  cin >> a >> b >> n;
  set<lli> g;
  vector<lli> f(n + 1);
  cout << a * min(n, b - 1) / b << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */

#include <algorithm>
#include <bits/stdc++.h>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define INF (int)(1e9 + 10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))

int main() {
  int a;
  ll b, n;
  cin >> a >> b >> n;
  int ans = 0;
  ll i;
  ll j = 1;
  if (b == 1) {
    cout << 0 << endl;
    return 0;
  }
  while (1) {
    i = b * j - 1;
    if (i > n) {
      i = n;
      ll c = floor(a * i / b) - a * floor(i / b);
      if (c > ans) {
        ans = c;
      }
      break;
    }
    ll c = floor(a * i / b) - a * floor(i / b);
    if (c > ans) {
      ans = c;
    }
    j++;
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */

#include <algorithm>
#include <bits/stdc++.h>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define MOD (long long int)(1e9 + 7)
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define REP(i, n) for (int i = n - 1; i >= 0; i--)
#define REPS(i, n) for (int i = n; i > 0; i--)
#define INF (int)(1e9 + 10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a) < (b)) ? (b) : (a))
#define chmin(a, b) a = (((a) > (b)) ? (b) : (a))

int main() {
  int a;
  ll b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  ll i;
  ll j = 1;
  while (1) {
    i = b * j - 1;
    if (i > n) {
      i = n;
      ll c = floor(a * i / b) - a * floor(i / b);
      if (c > ans) {
        ans = c;
      }
      break;
    }
    ll c = floor(a * i / b) - a * floor(i / b);
    if (c > ans) {
      ans = c;
    }
    j++;
  }
  cout << ans << endl;
  return 0;
}