Problem p02754 (C++)

Buggy submission (status: Runtime Error):
// #pragma warning(disable:4996)
// #include <Windows.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
// #include <boost/multiprecision/cpp_int.hpp>
#include <bitset>
#include <complex>
#include <cstdio>
#include <list>
// #include <stdio.h>

//< in.txt > out.txt
using namespace std;
// std::ios::sync_with_stdio(false);
// std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
// typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

template <class T> inline void chmin(T &a, T b) { a = min(a, b); }

template <class T> inline void chmax(T &a, T b) { a = max(a, b); }

void input();
void solve();

void daminput();

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  input();
  // daminput();
  solve();
  return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

int N, A, B;

void input() { cin >> N >> A >> B; }

void daminput() {}

void solve() {
  LL ans = (N / (A + B)) * A;
  N -= (N / (A + B)) * (A + B);
  ans += min(A, N);
  cout << ans << "\n";
}

Fixed submission:
// #pragma warning(disable:4996)
// #include <Windows.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
// #include <boost/multiprecision/cpp_int.hpp>
#include <bitset>
#include <complex>
#include <cstdio>
#include <list>
// #include <stdio.h>

//< in.txt > out.txt
using namespace std;
// std::ios::sync_with_stdio(false);
// std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
// typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

template <class T> inline void chmin(T &a, T b) { a = min(a, b); }

template <class T> inline void chmax(T &a, T b) { a = max(a, b); }

void input();
void solve();

void daminput();

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  input();
  // daminput();
  solve();
  return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

LL N, A, B;

void input() { cin >> N >> A >> B; }

void daminput() {}

void solve() {
  LL ans = (N / (A + B)) * A;
  N -= (N / (A + B)) * (A + B);
  ans += min(A, N);
  cout << ans << "\n";
}