Problem p02696 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) fo(i, 0, n)
#define pln(n) printf("%lld", n)
#define sll(n) scanf("%lld", &n)
#define ss(n) scanf("%s", n)
#define vi vector<int>
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x)                                                                 \
  { cout << #x << ": " << (x) << endl; }
#define dbg2(x, y)                                                             \
  { cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x, y, z)                                                          \
  {                                                                            \
    cout << #x << ": " << (x) << " , " << #y << ": " << (y) << " , " << #z     \
         << ": " << (z) << endl;                                               \
  }
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) for (decltype(c.begin()) it = c.begin(); it != c.end(); it++)
#define pis pair<int, string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())
#define ones(x) __builtin_popcount(x)
using namespace std;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = 0;
  ll ans = 0;
  while (x <= n) {
    ll f = floor(a * x / b) - (ll)a * floor(x / b);
    ans = max(ans, f);
    x++;
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; ++i)
#define rep(i, n) fo(i, 0, n)
#define pln(n) printf("%lld", n)
#define sll(n) scanf("%lld", &n)
#define ss(n) scanf("%s", n)
#define vi vector<int>
#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x)                                                                 \
  { cout << #x << ": " << (x) << endl; }
#define dbg2(x, y)                                                             \
  { cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x, y, z)                                                          \
  {                                                                            \
    cout << #x << ": " << (x) << " , " << #y << ": " << (y) << " , " << #z     \
         << ": " << (z) << endl;                                               \
  }
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) for (decltype(c.begin()) it = c.begin(); it != c.end(); it++)
#define pis pair<int, string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())
#define ones(x) __builtin_popcount(x)
using namespace std;

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