Language: C++

#include<bits/stdc++.h>

using namespace std;

#define int (__int128)

const int MAXN = 1e8 + 28;

const int INF = 9e20 + 118;

int dp[MAXN];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x, d;
    long long nn, xx, dd;
    cin >> nn >> xx >> dd;
    n = nn;
    d = dd;
    x = xx;
    for (int i = 0; i < MAXN; ++i)
    {
        dp[i] = -INF;
    }
    if (d < 0)
    {
        d = -d;
        x = -x;
    }
    if (d == 0)
    {
        if (x == 0)
        {
            cout << 1 << endl;
            return 0;
        }
        cout << (long long)n + 1 << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 0; i <= n; ++i)
    {
        int l = (i * (i - 1)) / 2ll;
        int r = i * (n - 1) - l + 1;
        int st = i * x + l * d;
        int en = i * x + r * d;
        int ind = ((i * x) % d + d) % d;
        if (dp[ind] > st)
        {
            st = dp[ind];
        }
        if (dp[ind] < en)
        {
            dp[ind] = en;
        }
        if (en > st)
        {
            ans += (en - st) / d;
        }
    }
    cout << (long long)ans << endl;
    return 0;
}


Compiler output:
a.cc:5:14: error: expected unqualified-id before '__int128'
    5 | #define int (__int128)
      |              ^~~~~~~~
a.cc:7:7: note: in expansion of macro 'int'
    7 | const int MAXN = 1e8 + 28;
      |       ^~~
a.cc:5:14: error: expected ')' before '__int128'
    5 | #define int (__int128)
      |             ~^~~~~~~~
a.cc:7:7: note: in expansion of macro 'int'
    7 | const int MAXN = 1e8 + 28;
      |       ^~~
a.cc:5:14: error: expected unqualified-id before '__int128'
    5 | #define int (__int128)
      |              ^~~~~~~~
a.cc:9:7: note: in expansion of macro 'int'
    9 | const int INF = 9e20 + 118;
      |       ^~~
a.cc:5:14: error: expected ')' before '__int128'
    5 | #define int (__int128)
      |             ~^~~~~~~~
a.cc:9:7: note: in expansion of macro 'int'
    9 | const int INF = 9e20 + 118;
      |       ^~~
a.cc:5:14: error: expected unqualified-id before '__int128'
    5 | #define int (__int128)
      |              ^~~~~~~~
a.cc:11:1: note: in expansion of macro 'int'
   11 | int dp[MAXN];
      | ^~~
a.cc:5:14: error: expected ')' before '__int128'
    5 | #define int (__int128)
      |             ~^~~~~~~~
a.cc:11:1: note: in expansion of macro 'int'
   11 | int dp[MAXN];
      | ^~~
a.cc: In function 'int32_t main()':
a.cc:17:9: error: 'n' was not declared in this scope; did you mean 'yn'?
   17 |     int n, x, d;
      |         ^
      |         yn
a.cc:17:12: error: 'x' was not declared in this scope
   17 |     int n, x, d;
      |            ^
a.cc:17:15: error: 'd' was not declared in this scope
   17 |     int n, x, d;
      |               ^
a.cc:23:14: error: 'i' was not declared in this scope
   23 |     for (int i = 0; i < MAXN; ++i)
      |              ^
a.cc:23:25: error: 'MAXN' was not declared in this scope
   23 |     for (int i = 0; i < MAXN; ++i)
      |                         ^~~~
a.cc:25:9: error: 'dp' was not declared in this scope; did you mean 'dd'?
   25 |         dp[i] = -INF;
      |         ^~
      |         dd
a.cc:25:18: error: 'INF' was not declared in this scope
   25 |         dp[i] = -INF;
      |                  ^~~
a.cc:42:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |     int ans = 0;
      |         ^~~
      |         abs
a.cc:43:14: error: 'i' was not declared in this scope
   43 |     for (int i = 0; i <= n; ++i)
      |              ^
a.cc:45:13: error: 'l' was not declared in this scope
   45 |         int l = (i * (i - 1)) / 2ll;
      |             ^
a.cc:46:13: error: 'r' was not declared in this scope
   46 |         int r = i * (n - 1) - l + 1;
      |             ^
a.cc:47:13: error: 'st' was not declared in this scope; did you mean 'std'?
   47 |         int st = i * x + l * d;
      |             ^~
      |             std
a.cc:48:13: error: 'en' was not declared in this scope; did you mean 'nn'?
   48 |         int en = i * x + r * d;
      |             ^~
      |             nn
a.cc:49:13: error: 'ind' was not declared in this scope; did you mean 'int'?
   49 |         int ind = ((i * x) % d + d) % d;
      |             ^~~
      |             int
a.cc:50:13: error: 'dp' was not declared in this scope; did you mean 'dd'?
   50 |         if (dp[ind] > st)
      |             ^~
      |             dd
a.cc:54:13: error: 'dp' was not declared in this scope; did you mean 'dd'?
   54 |         if (dp[ind] < en)
      |             ^~
      |             dd