Language: C++

#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0
#define all(v) begin(v),end(v)
#define inf 1LL<<55

#define NORMAL 0
#define REVERSE 1

lli dp[2][100010];

int main() {
    ll N, C;
    cin >> N >> C;

    vector<ll> x(N + 2), v(N + 2);
    for (ll i = 1; i <= N; i++) {
        cin >> x[i] >> v[i];
    }
    x[0] = 0;
    x[N + 1] = C;

    ll cal = 0;
    vector<vector<ll>> dp(2, vector<ll>(100010, 0));

    for (ll i = 1; i <= N; i++) {
        cal -= x[i] - x[i - 1];
        cal += v[i];
        dp[0][i] = max(dp[0][i - 1], cal);
        // ここでそれまでのカロリーの最大値をメモ
    }

    cal = 0;
    for (ll i = N; i >= 1; i--) {
        cal -= x[i + 1] - x[i];
        cal += v[i];
        dp[1][i] = max(dp[1][i + 1], cal);
    }

    ll maxcal = 0;
    for (ll i = 0; i <= N; i++) {
        // 時計回り
        cal = dp[0][i] + dp[1][i + 1] - x[i];
        maxcal = max(maxcal, cal);

        // 反時計回り
        cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
        maxcal = max(maxcal, cal);
    }

    cout << maxcal << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'll' was not declared in this scope; did you mean 'lli'?
   18 |     ll N, C;
      |     ^~
      |     lli
a.cc:19:12: error: 'N' was not declared in this scope
   19 |     cin >> N >> C;
      |            ^
a.cc:19:17: error: 'C' was not declared in this scope
   19 |     cin >> N >> C;
      |                 ^
a.cc:21:14: error: template argument 2 is invalid
   21 |     vector<ll> x(N + 2), v(N + 2);
      |              ^
a.cc:22:12: error: expected ';' before 'i'
   22 |     for (ll i = 1; i <= N; i++) {
      |            ^~
      |            ;
a.cc:22:20: error: 'i' was not declared in this scope
   22 |     for (ll i = 1; i <= N; i++) {
      |                    ^
a.cc:25:6: error: invalid types 'int[int]' for array subscript
   25 |     x[0] = 0;
      |      ^
a.cc:28:7: error: expected ';' before 'cal'
   28 |     ll cal = 0;
      |       ^~~~
      |       ;
a.cc:29:19: error: template argument 2 is invalid
   29 |     vector<vector<ll>> dp(2, vector<ll>(100010, 0));
      |                   ^~
a.cc:29:21: error: template argument 1 is invalid
   29 |     vector<vector<ll>> dp(2, vector<ll>(100010, 0));
      |                     ^~
a.cc:29:21: error: template argument 2 is invalid
a.cc:29:39: error: template argument 2 is invalid
   29 |     vector<vector<ll>> dp(2, vector<ll>(100010, 0));
      |                                       ^
a.cc:29:51: error: expression list treated as compound expression in initializer [-fpermissive]
   29 |     vector<vector<ll>> dp(2, vector<ll>(100010, 0));
      |                                                   ^
a.cc:31:12: error: expected ';' before 'i'
   31 |     for (ll i = 1; i <= N; i++) {
      |            ^~
      |            ;
a.cc:31:20: error: 'i' was not declared in this scope
   31 |     for (ll i = 1; i <= N; i++) {
      |                    ^
a.cc:32:9: error: 'cal' was not declared in this scope
   32 |         cal -= x[i] - x[i - 1];
      |         ^~~
a.cc:34:11: error: invalid types 'int[int]' for array subscript
   34 |         dp[0][i] = max(dp[0][i - 1], cal);
      |           ^
a.cc:34:26: error: invalid types 'int[int]' for array subscript
   34 |         dp[0][i] = max(dp[0][i - 1], cal);
      |                          ^
a.cc:38:5: error: 'cal' was not declared in this scope
   38 |     cal = 0;
      |     ^~~
a.cc:39:12: error: expected ';' before 'i'
   39 |     for (ll i = N; i >= 1; i--) {
      |            ^~
      |            ;
a.cc:39:20: error: 'i' was not declared in this scope
   39 |     for (ll i = N; i >= 1; i--) {
      |                    ^
a.cc:42:11: error: invalid types 'int[int]' for array subscript
   42 |         dp[1][i] = max(dp[1][i + 1], cal);
      |           ^
a.cc:42:26: error: invalid types 'int[int]' for array subscript
   42 |         dp[1][i] = max(dp[1][i + 1], cal);
      |                          ^
a.cc:45:7: error: expected ';' before 'maxcal'
   45 |     ll maxcal = 0;
      |       ^~~~~~~
      |       ;
a.cc:46:12: error: expected ';' before 'i'
   46 |     for (ll i = 0; i <= N; i++) {
      |            ^~
      |            ;
a.cc:46:20: error: 'i' was not declared in this scope
   46 |     for (ll i = 0; i <= N; i++) {
      |                    ^
a.cc:48:17: error: invalid types 'int[int]' for array subscript
   48 |         cal = dp[0][i] + dp[1][i + 1] - x[i];
      |                 ^
a.cc:48:28: error: invalid types 'int[int]' for array subscript
   48 |         cal = dp[0][i] + dp[1][i + 1] - x[i];
      |                            ^
a.cc:49:9: error: 'maxcal' was not declared in this scope
   49 |         maxcal = max(maxcal, cal);
      |         ^~~~~~
a.cc:52:17: error: invalid types 'int[int]' for array subscript
   52 |         cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
      |                 ^
a.cc:52:28: error: invalid types 'int[int]' for array subscript
   52 |         cal = dp[0][i] + dp[1][i + 1] - C + x[i + 1];
      |                            ^
a.cc:56:13: error: 'maxcal' was not declared in this scope
   56 |     cout << maxcal << endl;
      |             ^~~~~~