alexjercan/bugnet huggingface dataset:
Problem p02696 (C++) — buggy submission, verdict: 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 x = B - 1;
  x = min(x, N);
  long long result = floor(A * x / B) - A * floor(x / B);
  cout << result;
}


Error: TLE

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 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;
}
Problem p02696 (C++) — buggy submission, verdict: 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 x = min(B - 1, N);
  ll diff = A * x / B - A * (x / B);
  cout << diff << endl;
}


Error: TLE

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 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;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long A, B, N;
  cin >> A >> B >> N;

  if (N / B == 0) {
    double xBarB = (double)N / B;
    cout << floor((double)A * N / B) << endl;
  } else {
    double xBarB = (double)(B - 1) / B;
    cout << floor(A * xBarB) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long A, B, N;
  cin >> A >> B >> N;
  int max = 0;
  for (int x = 0; x < N + 1; x++) {
    double xBarB = (double)x / B;
    int calc = floor(A * xBarB) - A * floor(xBarB);
    if (max > calc)
      break;
    else
      max = calc;
  }
  cout << max << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_d() {
  ull n, a, b;
  cin >> a >> b >> n;

  ull ans = 0;

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

  cout << ans << "\\n";
}

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

  solve_abc_d();

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define rep2(i, m, n) for (ll i = m; i < (ll)(n); i++)
#define rrep(i, n, m) for (ll i = n; i >= (ll)(m); i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_d() {
  ull n, a, b;
  cin >> a >> b >> n;

  ull ans = 0;

  if (n < b) {
    rep1(x, n) { ans = max(ans, a * x / b - a * (x / b)); }
  } else {
    rep1(x, b) { ans = max(ans, a * x / b - a * (x / b)); }
  }

  cout << ans << "\\n";
}

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

  solve_abc_d();

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

#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  lll ii, jj, kk;
  vector<int> ret;
  lll a, b, n, x;

  cin >> a >> b >> n;

  lll cal;
  lll ans = (1L << 63);
  ans *= -1;

  // for(ii=1;ii<=n;ii++){
  //   cal = a*ii/b - a * (ii/b);
  //   if(cal > ans){
  //     cout << "ii:" << ii << endl;
  //     ans = cal;
  //   }
  // }
  // ii = b -1;
  // ans = a*ii/b - a * (ii/b);
  //  xがb未満の場合大きい法が良い
  if (b > n) {
    ii = n;
    ans = a * ii / b - a * (ii / b);
  } else {
    ii = b - 1;
    ans = a * ii / b - a * (ii / b);
  }

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  lll ii, jj, kk;
  vector<int> ret;
  lll a, b, n;

  cin >> a >> b >> n;

  lll cal;
  lll ans = (1L << 63);
  ans *= -1;

  for (ii = 1; ii <= n; ii++) {
    cal = a * ii / b - a * (ii / b);
    if (cal > ans) {
      ans = cal;
    }
  }

  cout << ans << endl;

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define f(i, a, b) for (int i = a; i <= b; i++)
inline ll read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
#define d read()
ll a, b, n;
ll mx, num;
int main() {
  //	while(1){
  //		mx=num=0;
  //		a=d,b=d,n=d;
  //	//if(a>b)swap(a,b);
  //	f(i,1,n){
  //		ll
  //k=floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b);
  //		if(k>mx)mx=k;
  //	}
  //	f(i,1,n)
  //		if(floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b)==mx)cout<<i<<"
  //"; 	cout<<endl;
  //	}
  scanf("%lld%lld%lld", &a, &b, &n);
  if (a >= b) {
    if (b - 1 <= n)
      cout << a * (b - 1) / b - a * ((b - 1) / b);
    else
      cout << a * n / b - a * (n / b);
    return 0;
  }
  if (b - b / a <= n) {
    cout << a * (b - b / a) / b - a * ((b - b / a) / b);
    return 0;
  }
  cout << a * n / b - a * (n / b);
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define f(i, a, b) for (int i = a; i <= b; i++)
inline ll read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
#define d read()
ll a, b, n;
ll mx, num;
int main() {
  //	while(1){
  //		mx=num=0;
  //		a=d,b=d,n=d;
  //	//if(a>b)swap(a,b);
  //	f(i,1,n){
  //		ll
  //k=floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b);
  //		if(k>mx)mx=k;
  //	}
  //	f(i,1,n)
  //		if(floor((double)a*(double)i/(double)b)-a*floor((double)i/(double)b)==mx)cout<<i<<"
  //"; 	cout<<endl;
  //	}
  scanf("%lld%lld%lld", &a, &b, &n);
  if (a >= b) {
    f(i, 1, n) {
      ll x = a * i / b - a * (i / b);
      if (x > mx)
        mx = x;
    }
    cout << mx;
    return 0;
  }
  if (b - b / a <= n) {
    cout << a * (b - b / a) / b - a * ((b - b / a) / b);
    return 0;
  }
  cout << a * n / b - a * (n / b);
  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++)
const int INF = 1001001001;

int main() {
  long long int a, b, n;
  cin >> a >> b >> n;
  long long int x = min(n, b - 1);
  long long int ans = (a * x / b) - a * (x / b);
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  long long int a, b, n;
  cin >> a >> b >> n;
  int ans = 0;
  if (b < n)
    n = b;
  for (int x = 1; x <= n; x++) {
    long double x1 = a * x / b;
    long double x2 = x / b;
    int answ = floor(x1) - a * floor(x2);
    if (ans < answ)
      ans = answ;
  }

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

#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  long long k, maxn = 0, s, i, a, b, n;
  scanf("%lld %lld %lld", &a, &b, &n);
  i = b - 1;
  if (i > n) {
    i = n;
  }
  s = (a * i) / b - a * (i / b);
  printf("%lld\\n", s);
  // system("pause");
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  long long maxn = 0, s, i, a, b, n;
  scanf("%lld %lld %lld", &a, &b, &n);
  for (i = 0; i <= n; i++) {
    s = (a * i) / b - a * (i / b);
    if (s > maxn) {
      maxn = s;
    }
  }
  printf("%lld\\n", maxn);
  // system("pause");
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: 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;

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

  cout << max << endl;
}


Error: TLE

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;

  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;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#pragma warning(disable : 4996)

int main() {

  long long a, b, n;
  scanf("%lld %lld %lld", &a, &b, &n);
  long long max = 0;
  long long temp;

  max = (a * n) / b - a * (n / b);
  temp = n / b * b - 1;
  if ((a * temp) / b - a * (temp / b) > max)
    max = (a * temp) / b - a * (temp / b);

  printf("%lld", max);

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#pragma warning(disable : 4996)

int main() {

  long long a, b, n;
  scanf("%lld %lld %lld", &a, &b, &n);
  long long max = 0;
  max = (a * n) / b - a * (n / b);
  long long temp = 0;
  while (temp < n) {
    temp += b;
  }
  if (temp == n)
    temp--;
  else {
    temp -= b;
    temp--;
  }
  if ((a * temp) / b - a * (temp / b) > max)
    max = (a * temp) / b - a * (temp / b);

  printf("%lld", max);

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int)1e9 + 7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll fun(ll a, ll b, ll n, ll x) { return ((a * x) / b) - a * (x / b); }
int main() {

#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  fio;
  ll a, b, n;
  cin >> a >> b >> n;
  // set<ll> s;
  // priority_queue<ll> pq;
  /*auto it = s.end();
  it--;
  cout << *it;*/
  /*for (ll x = 0; x <= 20; x++)
          cout << fun(a, b, n, x) << endl;*/
  if (n <= b - 1)
    cout << fun(a, b, n, n) << endl;
  else if (n >= b)
    cout << max(fun(a, b, n, b - 1), fun(a, b, n, b - 2)) << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int)1e9 + 7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
ll fun(ll a, ll b, ll n, ll x) {
  return floor(float(a * x) / b) - a * floor(float(x) / b);
}
int main() {

#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  fio;
  ll a, b, n;
  cin >> a >> b >> n;
  set<ll> s;
  priority_queue<ll> pq;
  for (ll x = 0; x <= n; x++) {
    pq.push(fun(a, b, n, x));
  }
  cout << pq.top();
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  long int max = 0;
  long int x;

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

  if (B != 1) {
    for (; x <= N; x += B) {
      long int total = floor(A * x / B) - floor(x / B) * A;
      if (max < total)
        max = total;
    }
  }

  cout << max << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

/*long int F(long int l, long int r) {
    return l / r;
}*/

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

  long int max = 0;
  long int x;

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

  for (; x <= N; x += B) {
    long int total = floor(A * x / B) - floor(x / B) * A;
    if (max < total)
      max = total;
  }

  cout << max << endl;

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

#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate {
  ios_accelerate() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} CALL;

#define REP(i, n) for (int i = 0; i < n; i++)
#define RNG(i, a, b) for (int i = a; i < b; i++)
#define RBF(i, v) for (auto &i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template <typename T> inline void upsort(vector<T> &x) {
  sort(x.begin(), x.end());
}
template <typename T> inline void downsort(vector<T> &x) {
  sort(x.begin(), x.end(), greater<T>());
}
template <typename T> inline void col(T x) { cout << x << '\\n'; }
template <> inline void col(double x) {
  cout << fixed << setprecision(12) << x << '\\n';
}
#pragma endregion

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

  LL ans;
  if (n < b) {
    LL x = n;
    ans = static_cast<LL>(1.0 * a * x / b) - a * static_cast<LL>(1.0 * x / b);
  } else {
    LL x = b - 1;
    ans = static_cast<LL>(1.0 * a * x / b) - a * static_cast<LL>(1.0 * x / b);
  }

  col(ans);
  return 0;
}


Error: TLE

Fixed submission:

#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate {
  ios_accelerate() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} CALL;

#define REP(i, n) for (int i = 0; i < n; i++)
#define RNG(i, a, b) for (int i = a; i < b; i++)
#define RBF(i, v) for (auto &i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template <typename T> inline void upsort(vector<T> &x) {
  sort(x.begin(), x.end());
}
template <typename T> inline void downsort(vector<T> &x) {
  sort(x.begin(), x.end(), greater<T>());
}
template <typename T> inline void col(T x) { cout << x << '\\n'; }
template <> inline void col(double x) {
  cout << fixed << setprecision(12) << x << '\\n';
}
#pragma endregion

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

  LL x = 1, pre = 0;
  while (x <= n) {
    LL y = static_cast<LL>(1.0 * a * x / b) - a * static_cast<LL>(1.0 * x / b);
    if (pre > y)
      break;
    pre = y;
    x++;
  }

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

// Radhe Radhe
#include <bits/stdc++.h> //157B
#define ll long long
#define fixed cout.setf(ios::fixed);
#define rep1 for (i = 0; i < n; i++)
#define Precise cout.precision(7);
using namespace std;

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h> //AC 2 may 2020
using namespace std;
int main() {
  long long x, y, a, b, n, i, ans = 0, tmp;
  cin >> a >> b >> n;
  for (i = n; i >= 1; i--) {
    x = floor((a * i) / b);
    y = floor(i / b);
    tmp = x - (a * y);
    // if(tmp<ans) break;
    ans = max(tmp, ans);
  }

  cout << ans << endl;

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <sstream> //���炵���̂Œ���
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout << s << endl
using namespace std;
typedef long long ll;
string Yes(bool b) {
  if (b) {
    return "Yes";
  } else {
    return "No";
  }
}
string YES(bool b) {
  if (b) {
    return "YES";
  } else {
    return "NO";
  }
}
//================================================

ll a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

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

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <math.h>
#include <sstream> //���炵���̂Œ���
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout << s << endl
using namespace std;
typedef long long ll;
string Yes(bool b) {
  if (b) {
    return "Yes";
  } else {
    return "No";
  }
}
string YES(bool b) {
  if (b) {
    return "YES";
  } else {
    return "NO";
  }
}
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll ans = 0;
  if (n % b == 0)
    ans = a * n / b - a * (n / b);
  for (ll i = n; i % b != 0 || i >= 0; i--) {
    if (ans < a * i / b - a * (i / b))
      ans = a * i / b - a * (i / b);
  }
  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 (int64_t i = 0; i < n; i++)

const double PI = 3.14159265358979323846;

vector<vector<int64_t>> a;
int64_t n;

void make_a(vector<int64_t> a_l, int64_t m) {
  if (a_l.size() == n - 1) {
    for (int64_t i = a_l.back(); i <= m; i++) {
      a.push_back(vector<int64_t>(a_l));
      a.back().push_back(i);
    }
  } else {
    for (int64_t i = a_l.back(); i <= m; i++) {
      auto temp = vector<int64_t>(a_l);
      temp.push_back(i);
      make_a(temp, m);
    }
  }
}

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

Error: TLE

Fixed submission:

#include "bits/stdc++.h"

using namespace std;
#define rep(i, n) for (int64_t i = 0; i < n; i++)

const double PI = 3.14159265358979323846;

int main() {
  /*int64_t n, m, q, max_pt = 0, count_c = 0, counter = 0;

  cin >> n >> m >> q;
  auto b = vector<vector<int64_t>>(q, vector<int64_t>(4, 0));
  for (int64_t i = 0; i < q; i++)
  {
          cin >> b[i][0] >> b[i][1] >> b[i][2] >> b[i][3];
  }
  auto a = vector<int64_t>(n, 1);

  for (int64_t i = 0; i < n; i++)
  {
          counter += pow(m, n);
          cout << a[i];
  }
  puts("");

  while(true)
  {
          int64_t now_pt = 0;
          for (int64_t i = 0; i < q; i++)
          {
                  if (a[b[i][1] - 1] - a[b[i][0] - 1] == b[i][2])
                  {
                          now_pt += b[i][3];
                  }
          }
          max_pt = max(now_pt, max_pt);
          count_c = counter;
          for (int64_t i = 0; i < n; i++)
          {
                  a[n - i - 1] = count_c % (int64_t)pow(m, i);
          }
          counter++;
          bool temp = true;
          for (int i = 0; i < n; i++)
          {
                  cout << a[i];
                  if (a[i] == m)
                  {
                          temp = true;
                  }
                  else
                  {
                          temp = false;
                          break;
                  }
          }
          if (temp)
          {
                  break;
          }
          puts("");*/
  //}

  int64_t a, b, c, max_s = 0, tmep;

  cin >> a >> b >> c;

  for (int i = 1; i <= c; i++) {
    tmep = floor((a * i) / b) - (a * floor(i / b));
    if (max_s < tmep) {
      max_s = tmep;
    }
  }

  cout << max_s << endl;

  return 0;
}