Language: C++

/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  int64 c; cin >> c;
  
  vector<int64_t> x(n), v(n);
  rep(i, n) cin >> x[i] >> v[i];

  int64 ans = -INF64;

  // clockwise
  int64 sum1 = 0;
  int64 get1[101010] = {};
  int64 mx1[101010] = {};
  for (int i = 0; i < n; ++i) {
    sum1 += v[i];
    get1[i] = sum1 - x[i];
  }

  int64 m1 = -INF64;
  for (int i = 0; i < n; ++i) {
    mx1[i] = max(m1, get1[i]);
    chmax(m1, get1[i]);
  }

  //counterclockwise
  int64 sum2 = 0;
  int64 get2[101010] = {};
  int64 mx2[101010] = {};
  for (int i = n - 1; i >= 0; --i) {
    sum2 += v[i];
    get2[i] = sum2 - (c - x[i]);
  }

  int64 m2 = -INF64;
  for (int i = n - 1; i >= 0; --i) {
    mx2[i] = max(m2, get2[i]);
    chmax(m2, get2[i]);
  }

  ans = max({mx1[n - 1], mx2[0], 0LL});

  // A : right, B : left
  // fix A
  for (int i = 0; i <= n - 2; ++i) {
    chmax(ans, get1[i] + mx2[i + 1] - x[i]);
  }

  // fix B
  for (int i = n - 1; i >= 1; --i) {
    chmax(ans, get2[i] + mx1[i - 1] - c + x[i]);
  }

  print(ans);

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:101:12: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
  101 |   ans = max({mx1[n - 1], mx2[0], 0LL});
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:24:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   template argument deduction/substitution failed:
a.cc:101:12: note:   deduced conflicting types for parameter '_Tp' ('long int' and 'long long int')
  101 |   ans = max({mx1[n - 1], mx2[0], 0LL});
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   candidate expects 2 arguments, 1 provided