Problem p02696 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

// #include <bits/stdc++.h>
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, i0, n) for (int(i) = (i0); (i) < (n); (i)++)
#define FORR(i, i0, n) for (int(i) = (n)-1; (i) >= (i0); (i)--)
#define SORT(x) sort(x.begin(), x.end())
#define SORTR(x) sort(x.begin(), x.end(), greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int, int> P;
using namespace std;
using ll = long long;

ll f(ll a, ll b, ll x) {
  ll e1 = (a * x);
  e1 /= b;
  ll e2 = (x / b);
  e2 *= a;
  return e1 - e2;
}
int main() {

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

  if (n < b) {
    cout << f(a, b, n);
  } else {
    cout << f(a, b, b - 1);
  }
}

//
//
// int main(){
//    int n,m,q;
//    cin >> n >> m >> q;
//
//    vector<tuple<int,int,int,int>> x(q);
//    rep(i,q){
//        int a,b,c,d;
//        cin >> a >> b >> c >> d;
//        x[i] = {-d,a-1,b-1,c};
//    }
//
//    SORT(x);
//    vector<int> A(n,-1);
//
//    ll ans = 0;
//    rep(i,q){
//        cout << get<0>(x[i]) << endl;
//
//    }
//
//}


Error: 1

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

// #include <bits/stdc++.h>
#define maxs(x, y) x = max(x, y)
#define mins(x, y) x = min(x, y)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, i0, n) for (int(i) = (i0); (i) < (n); (i)++)
#define FORR(i, i0, n) for (int(i) = (n)-1; (i) >= (i0); (i)--)
#define SORT(x) sort(x.begin(), x.end())
#define SORTR(x) sort(x.begin(), x.end(), greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int, int> P;
using namespace std;
using ll = long long;

ll f(ll a, ll b, ll x) {
  ll e1 = (a * x);
  e1 /= b;
  ll e2 = (x / b);
  e2 *= a;
  return e1 - e2;
}
int main() {

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

  if (n < b) {
    cout << "a";
    return 1;
  } else {
    cout << "n";
  }
}

//
//
// int main(){
//    int n,m,q;
//    cin >> n >> m >> q;
//
//    vector<tuple<int,int,int,int>> x(q);
//    rep(i,q){
//        int a,b,c,d;
//        cin >> a >> b >> c >> d;
//        x[i] = {-d,a-1,b-1,c};
//    }
//
//    SORT(x);
//    vector<int> A(n,-1);
//
//    ll ans = 0;
//    rep(i,q){
//        cout << get<0>(x[i]) << endl;
//
//    }
//
//}