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

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update> pbds;
#define int long long
#define inf 1e9
#define mod 1000000007

void solve() {
  int A, B, N;
  cin >> A >> B >> N;

  int ans = 0;
  int low = 1, high = N;
  while (low <= high) {
    int mid = (low + high) / 2;
    int exp = ((A * mid) / B) - (A * (mid / B));

    if (ans <= exp) {
      low = mid + 1;
    } else {
      high = mid - 1;
    }
    ans = max(ans, exp);
  }
  cout << ans;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update> pbds;
#define int long long
#define inf 1e9
#define mod 1000000007

void solve() {
  int A, B, N;
  cin >> A >> B >> N;

  int ans = 0;
  int low = 1, high = N;
  while (low <= high) {
    int mid = (low + high) / 2;
    int exp = ((A * mid) / B) - A * (mid / B);

    if (ans <= exp) {
      low = mid + 1;
    } else {
      low = mid - 1;
    }
    ans = max(ans, exp);
  }
  cout << ans;
}

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 100000000000
#define MOD 100000007 // 10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  ll x = n;
  if (n >= b - 1)
    x = b - 1;
  ll ans = a * x / b - a * (x / b);
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 100000000000
#define MOD 100000007 // 10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  ll ans = 0LL;
  ll tmp;
  for (i = n; i >= n / b; i--) {
    tmp = floor((a * i) / b) - a * (floor(i / b));
    ans = max(ans, tmp);
  }

  cout << ans << endl;

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

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

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int main() {
  long a, b, c, d, x = 0;
  cin >> a >> b >> c;
  d = c;
  if (b < c)
    d = b;
  for (long i = 0; i <= d; i++)
    if (floor(a * i / b) - a * floor(i / b) > x)
      x = floor(a * i / b) - a * floor(i / b);
  cout << x << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {

  long long int a, b, n;
  cin >> a >> b >> n;
  n = min(n, b - 1);
  cout << (floor)(a * n / b) - a * (floor)(n / b);

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
int int_floor(double x) {
  int i = (int)x;
  return i - (i > x);
}
using namespace std;

int main() {
  ios ::sync_with_stdio(0);
  long long int a, b, n;
  cin >> a >> b >> n;
  long long int x, c[n], j = 0;

  for (long long int i = 1; i <= n; i++) {
    x = (long long int)(a * i / b % 1000000007) -
        a * (long long int)(i / b % 1000000007);
    c[j] = x;
    j++;
  }
  sort(c, c + j);
  // reverse(c,c+j);
  cout << c[j - 1];
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long int ans = 0;
  long int a, b, n, x;
  cin >> a >> b >> n;

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

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  long int ans = 0;
  long int a, b, n, x;
  cin >> a >> b >> n;

  if (n < b) {
    x = n;
  } else if (n == b) {
    x = b - 1;
  } else {
    x = b;
    while (n > (x + b))
      x += b;
    x--;
  }
  ans = ((a * x) / b) - a * (x / b);

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

#include <bits/stdc++.h>
using namespace std;
template <class T> struct rge {
  T b, e;
};
template <class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  template <class T> debug &operator<<(T x) {
    cerr << boolalpha << x;
    return *this;
  }
  template <class B, class C> debug &operator<<(pair<B, C> x) {
    return *this << "(" << x.first << ", " << x.second << ")";
  }
  template <class T> debug &operator<<(rge<T> x) {
    *this << "[";
    for (auto it = x.b; it != x.e; it++) {
      *this << ", " + 2 * (it == x.b) << *it;
    }
    return *this << "]";
  }
  template <class T> debug &operator<<(vector<T> x) {
    return *this << range(x.begin(), x.end());
  }
#else
  template <class T> debug &operator<<(const T &) { return *this; }
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;
ll a, b, n;

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

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

  cin >> a >> b >> n;
  ll x = b * (n / b) - 1;
  cout << max(f(n), f(x)) << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
template <class T> struct rge {
  T b, e;
};
template <class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  template <class T> debug &operator<<(T x) {
    cerr << boolalpha << x;
    return *this;
  }
  template <class B, class C> debug &operator<<(pair<B, C> x) {
    return *this << "(" << x.first << ", " << x.second << ")";
  }
  template <class T> debug &operator<<(rge<T> x) {
    *this << "[";
    for (auto it = x.b; it != x.e; it++) {
      *this << ", " + 2 * (it == x.b) << *it;
    }
    return *this << "]";
  }
  template <class T> debug &operator<<(vector<T> x) {
    return *this << range(x.begin(), x.end());
  }
#else
  template <class T> debug &operator<<(const T &) { return *this; }
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;
ll a, b, n;

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

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

  cin >> a >> b >> n;
  ll ans = 0;
  for (ll x = 0; x <= n;) {
    ll lo = x, hi = n;
    while (lo < hi) {
      ll mid = lo + (hi - lo + 1) / 2;
      if ((a * x) / b == (a * mid) / b) {
        lo = mid;
      } else {
        hi = mid - 1;
      }
    }
    //$ debug() nav(x);
    ans = max(ans, f(x));
    x = lo + 1;
  }

  cout << ans << endl;
}
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 FOR(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define MOD 1000000007

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T> void print(T &x) { printf("%d\\n", x); }

int main() {
  ll A, B, N;
  scanf("%lld %lld %lld", &A, &B, &N);
  // printf("A=%d, B=%d, N=%d\\n", A, B, N);
  double t;
  ll x;
  ll tmp1, tmp2;
  ll ans;

  if (N < B) {
    x = N;
  } else {
    x = B - 1;
  }
  t = (double)x / B;
  tmp1 = A * t;
  tmp2 = t;
  tmp2 *= A;
  ans = tmp1 - tmp2;
  // printf("%lld, %lld, %lld, %lf\\n", A, B, N, t);
  // printf("%lld, %lld, %lld\\n", tmp1, tmp2, ans);
  print(ans);
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
#define MOD 1000000007

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T> void print(T &x) { printf("%d\\n", x); }

int main() {
  ll A, B, N;
  scanf("%lld %lld %lld", &A, &B, &N);
  // printf("A=%d, B=%d, N=%d\\n", A, B, N);
  ll ans = -10;
  double t;
  ll tmp1, tmp2 = -1;
  ll fl;
  ll x = 0;
  while (1) {
    if (x + B - 1 > N) {
      t = (double)N / B;
      tmp1 = A * t;
      tmp2++;
      ;
      fl = tmp1 - A * tmp2;
      if (ans < fl) {
        ans = fl;
      }
      break;
    } else {
      x = x + B - 1;
      t = (double)x / B;
      tmp1 = A * t;
      tmp2++;
      ;
      fl = tmp1 - A * tmp2;
      if (ans < fl) {
        ans = fl;
      }
    }
  }
  printf("%lld", ans);
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

#define ll long long
#define sq(a) (a) * (a)
#define caset                                                                  \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define get1(a)                                                                \\
  ll int a;                                                                    \\
  cin >> a;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define line '\\n'

#define vi(v) vector<int> v;
#define all(v) v.begin(), v.end()

// #define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
// #ifndef ONLINE_JUDGE   freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout); 	#endif

int main() {
  //	fast;
  long long int val, mx = 0, n, a, b;
  cin >> a >> b >> n;
  if (b <= n)
    cout << floor(a * (b - 1) / b);
  else {
    cout << floor(a * n / b);
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <vector>
using namespace std;

#define ll long long
#define sq(a) (a) * (a)
#define caset                                                                  \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define get1(a)                                                                \\
  ll int a;                                                                    \\
  cin >> a;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define line '\\n'

#define vi(v) vector<int> v;
#define all(v) v.begin(), v.end()

// #define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
// #ifndef ONLINE_JUDGE   freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout); 	#endif

int main() {
  //	fast;
  long long int val, mx = 0, n, a, b;
  cin >> a >> b >> n;
  for (int i = 1; i <= n; i++) {
    val = floor(a * i / b) - a * floor(i / b);
    mx = max(mx, val);
  }
  cout << mx;

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

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, n, ans, temp;
  cin >> a >> b >> n;
  ans = -1;
  if (n >= b - 1) {
    temp = a * (b - 1) / b - a * ((b - 1) / b);
  } else {
    temp = a * (n) / b - a * ((n) / b);
  }
  ans = temp;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b, n, ans, temp;
  cin >> a >> b >> n;
  ans = -1;
  for (int i = 0; i <= n; i++) {
    temp = a * i / b - a * (i / b);
    ans = max(ans, temp);
  }
  cout << ans << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  unsigned long long A, B, N, first, second, max = 0;
  cin >> A >> B >> N;

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

  cout << max << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  unsigned long long A, B, N, first, second, current, max = 0;
  cin >> A >> B >> N;

  if (N < B) {
    max = A * N / B;
  } else {
    for (unsigned long long i = 1; i <= N / B; ++i) {
      first = A * (B * i - 1) / B;
      second = (B * i - 1) / B;
      current = first - A * second;

      if (current > max) {
        max = current;
      }
    }
  }

  cout << max << endl;

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

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

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

  long a = min(B - 1, N);

  long b = (A * a) / B;

  cout << b << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int gausux(double x) {
  int ans = x;
  return ans;
}

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

  int max = 0;

  for (long int i = 1; i <= N; i++) {
    int ansi;
    int c1 = gausux(A * i / B);
    int c2 = gausux(i / B);
    ansi = c1 - A * c2;

    if (ansi > max) {
      max = ansi;
    }
  }
  cout << max << endl;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll a, b, c, x;
  cin >> a >> b >> c;
  x = min(b - 1, c);
  cout << floor(a * x / b) - a * floor(x / b) << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define speed                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define int long long

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int cnt[N];

int32_t main() {
  speed;
  int a, b, n;
  cin >> a >> b >> n;
  int mx = (a * n) / b - a * (n / b);
  for (int x = 1; x <= min(100000000ll, n); x++) {
    mx = max(mx, (a * x) / b - a * (x / b));
  }
  for (int x = n; x >= max(1ll, n - 100000000ll); x--) {
    mx = max(mx, (a * x) / b - a * (x / b));
  }
  cout << mx;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-04-30(Thu)
   note
**********************************************************************/

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

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

Error: TLE

Fixed submission:

/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-04-30(Thu)
   note
**********************************************************************/

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

int main() {
  int a, b;
  int64_t n;
  cin >> a >> b >> n;
  int x;
  int max = 0;
  // int number = floor(a*x/b) - a*floor(x/b);
  for (int64_t i = 1LL; i <= n; i++) {
    // int number = floor(a*i/b) - a*floor(i/b);
    int number = a * i / b - a * (i / b);
    if (number >= max) {
      max = number;
    }
  }

  cout << max << 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, t, k, k1;
  cin >> a >> b >> n;
  if (b > n) {
    cout << (a * n) / b;
  } else {
    cout << (a * (b - 1)) / b;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, n, t, k, k1;
  cin >> a >> b >> n;
  if (b > n) {
    cout << (a * n) / b;
  } else {
    t = b - 1;
    k = ((a * t) / b) - (a * (t / b));
    while (1) {
      t++;
      if (t > n) {
        break;
      }
      k1 = ((a * t) / b) - (a * (t / b));
      if (k > k1) {
        break;
      } else if (k1 > k) {
        k = k1;
      }
    }
    cout << k;
  }
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <vector>
#define _USE_MATH_DEFINES
#include <algorithm>
#include <math.h>
#include <memory>
#include <string>
#define Rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int &a, int &b) {
  int temp = a;
  a = b;
  b = temp;
  return;
}
int ncr(int n, int r) {
  int a = 1;
  Rep(i, r) a = (a * (n - i)) / (i + 1);
  return a;
}
int npr(int n, int r) {
  int a = 1;
  Rep(i, r) a *= n - i;
  return a;
}
int mod(int a, int b) { return a % b; }

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

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
#define _USE_MATH_DEFINES
#include <algorithm>
#include <math.h>
#include <memory>
#include <string>
#define Rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
void swap(int &a, int &b) {
  int temp = a;
  a = b;
  b = temp;
  return;
}
int ncr(int n, int r) {
  int a = 1;
  Rep(i, r) a = (a * (n - i)) / (i + 1);
  return a;
}
int npr(int n, int r) {
  int a = 1;
  Rep(i, r) a *= n - i;
  return a;
}
int mod(int a, int b) { return a % b; }

int main() {
  long double a, b, x, n;
  std::cin >> a >> b >> n;
  ll ans = 0;
  for (long double i = 0; i <= n; i++) {
    long double k = i / b;
    ll h = k;
    k = k - h;
    h = k * a;
    if (h > ans) {
      ans = h;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  long long int A, B, N;
  cin >> A >> B >> N;
  long long int i;
  long long int f = 0;
  long long int f_max = 0;

  if (B == 1) {
    f_max = 0;
  } else if (B > N) {
    f_max = floor(A * N / B) - A * floor(N / B);
  } else {
    f_max = A - 1 - floor(A / B);
  }

  cout << f_max << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  long long int A, B, N;
  cin >> A >> B >> N;
  long long int i;
  long long int f = 0;
  long long int f_max = 0;

  if (B > N) {
    f_max = floor(A * N / B) - A * floor(N / B);
  } else {
    for (i = B - 1; i <= N; i = i + B) {
      f = floor(A * i / B) - A * floor(i / B);
      if (f > f_max) {
        f_max = f;
      }
    }
  }

  cout << f_max << endl;

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

#include <iostream>
#include <vector>

int main() {
  int64_t A, B, N;
  std::cin >> A >> B >> N;

  auto maxX = std::min(B - 1, N);
  std::cout << (A * maxX / B) - A * (maxX / B) << std::endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

int main() {
  int64_t A, B, N;
  std::cin >> A >> B >> N;

  int64_t max = 0;
  for (auto i = 0; i <= N; ++i) {
    auto score = (A * i / B) - A * (i / B);
    // std::cout << score << std::endl;

    if (max < score)
      max = score;
  }

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
long long A, B, N;
int main(void) {
  cin >> A >> B >> N;

  vector<int> keep;
  int zeroCount = 0;
  long long m = min(N, B - 1);
  int max = floor((A * m) / B) - A * floor(m / B);
  cout << max << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
long long A, B, N;
int main(void) {
  cin >> A >> B >> N;

  vector<int> keep;
  int max = 0;
  int prev = -1;
  int zeroCount = 0;
  for (long long x = 0; x <= min(N, B - 1); x++) {
    int val = floor((A * x) / B) - A * floor(x / B);
    if (val > max)
      max = val;
  }
  cout << max << endl;
  return 0;
}
Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

// AtCoder Beginners Contest 165
// D - Floor Function

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  unsigned long A, B, N, i, m, value0, value1;

  cin >> A >> B >> N;

  if (A < 1 && 1000000 < A) {
    cout << "Aは条件を満たしていません!\\n";
    return 0;
  }

  if (B < 1 && 1000000000000 < B) {
    cout << "Bは条件を満たしていません!\\n";
    return 0;
  }

  if (N < 1 && 1000000000000 < N) {
    cout << "Nは条件を満たしていません!\\n";
    return 0;
  }

  /*
  m = 1;
  value0 = floor(A*m/B) - A*floor(m/B);
  for (i = 2; i <= B-1; i++) {
      value1 = floor(A*i/B) - A*floor(i/B);
      if (value1 > value0) {
          value0 = value1;
      }
  }
  */
  if (B - 1 < N)
    value0 = floor(A * (B - 1) / B) - A * floor((B - 1) / B);
  else
    value0 = floor(A * N / B) - A * floor(N / B);
  cout << value0 << '\\n';
}


Error: TLE

Fixed submission:

// AtCoder Beginners Contest 165
// D - Floor Function

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  unsigned long A, B, N, i, value0, value1;

  cin >> A >> B >> N;

  value0 = floor(A * 1 / B) - A * floor(1 / B);
  for (i = 1; i <= N; i++) {
    value1 = floor(A * i / B) - A * floor(i / B);
    if (value1 > value0) {
      value0 = value1;
    }
  }
  cout << value0 << '\\n';
}