func_code_string: #include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   template <class T>   inline T biton(T n, T pos) {     return n | ((T)1 << pos);   }   template <class T>   inline T bitoff(T n, T pos) {     return n & ~((T)1 << pos);   }   template <class T>   inline T ison(T n, T pos) {     return (bool)(n & ((T)1 << pos));   }   template <class T>   inline T gcd(T a, T b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   template <typename T>   string NumberToString(T Number) {     ostringstream second;     second << Number;     return second.str();   }   inline int nxt() {     int aaa;     scanf( %d , &aaa);     return aaa;   }   inline long long int lxt() {     long long int aaa;     scanf( %lld , &aaa);     return aaa;   }   inline double dxt() {     double aaa;     scanf( %lf , &aaa);     return aaa;   }   template <class T>   inline T bigmod(T p, T e, T m) {     T ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % m;       p = (p * p) % m;     }     return (T)ret;   }   int ar[1000010];   long long F(long long int limit, long long int a, long long int b) {     if (limit < a) return 1LL;     long long int sum = 1LL;     long long int x = 0;     while (true) {       if (x + a > limit) break;       long long int temp = (limit - x) / a;       sum += temp;       long long int r = (a * temp) + x;       if (r - b < 0) break;       temp = (r + b - 1) / b;       temp--;       sum += temp;       r -= temp * b;       x = r;       if (x % a == 0) break;     }     return sum;   }   long long int get(long long int st, long long int len) {     long long int sum = (len * len + len) / 2LL;     sum *= st;     return sum;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n, a, b;     cin >> n >> a >> b;     long long limit = min(a + b - 2, n);     long long sum = 0;     for (long long i = 0; i <= limit; i++) {       sum += F(i, a, b);     }     limit++;     long long int gc = gcd(a, b);     while (limit <= n) {       if (limit % gc == 0) break;       sum += (limit / gc) + 1;       limit++;     }     long long int upperLimit = n;     while (upperLimit >= limit) {       sum += (upperLimit / gc) + 1;       if (upperLimit % gc == 0) break;       upperLimit--;     }     if (upperLimit > limit) {       long long int diff = (upperLimit - limit);       sum += diff;       diff /= gc;       long long int chunk = limit * diff + get(gc, diff - 1);       sum += chunk;     }     cout << sum << endl;     return 0;   }   