Language: C++

#include <iostream>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

using namespace std;

int n;
ll c;
vll val, pos;

typedef pair<int, ll> P;
vector<P> toleft, toright;

void init()
{
	cin >> n >> c;

	val.resize(n + 1, 0);
	pos.resize(n + 1, 0);
	REP1C(i, n) { cin >> pos[i] >> val[i]; }

	toleft.resize(n + 1);
	toright.resize(n + 1);
	toright[0] = toleft[0] = P(0, 0);
}

int main()
{
	init();
	ll best, tmp;

	best = tmp = 0;
	REP1C(i, n)
	{
		tmp += val[i];
		if (chmax(best, tmp - pos[i]))
			toright[i] = P(i, best);
		else
			toright[i] = toright[i - 1];
	}

	best = tmp = 0;
	for (int i = n; i >= 1; --i)
	{
		tmp += val[i];
		if (chmax(best, tmp - 2 * (c - pos[i])))
			toleft[i] = P(i, best);
		else
		{
			if (i == n)
				toleft[i] = P(0, 0);
			else
				toleft[i] = toleft[i + 1];
		}
	}

	ll ans = 0;
	REP1C(i, n)
	{
		chmax(ans, toright[i].second);
		if (toright[i].first != n)
			chmax(ans, toright[i].second + toleft[toright[i].first + 1].second);
	}

	best = tmp = 0;
	REP1C(i, n)
	{
		tmp += val[i];
		if (chmax(best, tmp - 2 * pos[i]))
			toright[i] = P(i, best);
		else
			toright[i] = toright[i - 1];
	}

	best = tmp = 0;
	for (int i = n; i >= 1; --i)
	{
		tmp += val[i];
		if (chmax(best, tmp - (c - pos[i])))
			toleft[i] = P(i, best);
		else
		{
			if (i == n)
				toleft[i] = P(0, 0);
			else
				toleft[i] = toleft[i + 1];
		}
	}

	REP1C(i, n)
	{
		chmax(ans, toleft[i].second);
		if (toleft[i].first != 0)
			chmax(ans, toleft[i].second + toright[toleft[i].first - 1].second);
	}

	cout << ans << endl;
}


Compiler output:
a.cc:14:1: error: 'll' does not name a type
   14 | ll c;
      | ^~
a.cc:15:1: error: 'vll' does not name a type
   15 | vll val, pos;
      | ^~~
a.cc:17:19: error: 'll' was not declared in this scope
   17 | typedef pair<int, ll> P;
      |                   ^~
a.cc:17:21: error: template argument 2 is invalid
   17 | typedef pair<int, ll> P;
      |                     ^
a.cc: In function 'void init()':
a.cc:22:21: error: 'c' was not declared in this scope
   22 |         cin >> n >> c;
      |                     ^
a.cc:24:9: error: 'val' was not declared in this scope
   24 |         val.resize(n + 1, 0);
      |         ^~~
a.cc:25:9: error: 'pos' was not declared in this scope
   25 |         pos.resize(n + 1, 0);
      |         ^~~
a.cc:30:40: error: expression list treated as compound expression in functional cast [-fpermissive]
   30 |         toright[0] = toleft[0] = P(0, 0);
      |                                        ^
a.cc: In function 'int main()':
a.cc:36:9: error: 'll' was not declared in this scope
   36 |         ll best, tmp;
      |         ^~
a.cc:38:9: error: 'best' was not declared in this scope
   38 |         best = tmp = 0;
      |         ^~~~
a.cc:38:16: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   38 |         best = tmp = 0;
      |                ^~~
      |                tm
a.cc:41:24: error: 'val' was not declared in this scope
   41 |                 tmp += val[i];
      |                        ^~~
a.cc:42:39: error: 'pos' was not declared in this scope
   42 |                 if (chmax(best, tmp - pos[i]))
      |                                       ^~~
a.cc:42:21: error: 'chmax' was not declared in this scope
   42 |                 if (chmax(best, tmp - pos[i]))
      |                     ^~~~~
a.cc:43:47: error: expression list treated as compound expression in functional cast [-fpermissive]
   43 |                         toright[i] = P(i, best);
      |                                               ^
a.cc:51:24: error: 'val' was not declared in this scope
   51 |                 tmp += val[i];
      |                        ^~~
a.cc:52:44: error: 'c' was not declared in this scope
   52 |                 if (chmax(best, tmp - 2 * (c - pos[i])))
      |                                            ^
a.cc:52:48: error: 'pos' was not declared in this scope
   52 |                 if (chmax(best, tmp - 2 * (c - pos[i])))
      |                                                ^~~
a.cc:52:21: error: 'chmax' was not declared in this scope
   52 |                 if (chmax(best, tmp - 2 * (c - pos[i])))
      |                     ^~~~~
a.cc:53:46: error: expression list treated as compound expression in functional cast [-fpermissive]
   53 |                         toleft[i] = P(i, best);
      |                                              ^
a.cc:57:51: error: expression list treated as compound expression in functional cast [-fpermissive]
   57 |                                 toleft[i] = P(0, 0);
      |                                                   ^
a.cc:63:11: error: expected ';' before 'ans'
   63 |         ll ans = 0;
      |           ^~~~
      |           ;
a.cc:66:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   66 |                 chmax(ans, toright[i].second);
      |                       ^~~
      |                       abs
a.cc:66:39: error: request for member 'second' in 'toright.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   66 |                 chmax(ans, toright[i].second);
      |                                       ^~~~~~
a.cc:66:17: error: 'chmax' was not declared in this scope
   66 |                 chmax(ans, toright[i].second);
      |                 ^~~~~
a.cc:67:32: error: request for member 'first' in 'toright.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   67 |                 if (toright[i].first != n)
      |                                ^~~~~
a.cc:68:47: error: request for member 'second' in 'toright.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   68 |                         chmax(ans, toright[i].second + toleft[toright[i].first + 1].second);
      |                                               ^~~~~~
a.cc:68:74: error: request for member 'first' in 'toright.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   68 |                         chmax(ans, toright[i].second + toleft[toright[i].first + 1].second);
      |                                                                          ^~~~~
a.cc:74:24: error: 'val' was not declared in this scope
   74 |                 tmp += val[i];
      |                        ^~~
a.cc:75:43: error: 'pos' was not declared in this scope
   75 |                 if (chmax(best, tmp - 2 * pos[i]))
      |                                           ^~~
a.cc:75:21: error: 'chmax' was not declared in this scope
   75 |                 if (chmax(best, tmp - 2 * pos[i]))
      |                     ^~~~~
a.cc:76:47: error: expression list treated as compound expression in functional cast [-fpermissive]
   76 |                         toright[i] = P(i, best);
      |                                               ^
a.cc:84:24: error: 'val' was not declared in this scope
   84 |                 tmp += val[i];
      |                        ^~~
a.cc:85:40: error: 'c' was not declared in this scope
   85 |                 if (chmax(best, tmp - (c - pos[i])))
      |                                        ^
a.cc:85:44: error: 'pos' was not declared in this scope
   85 |                 if (chmax(best, tmp - (c - pos[i])))
      |                                            ^~~
a.cc:85:21: error: 'chmax' was not declared in this scope
   85 |                 if (chmax(best, tmp - (c - pos[i])))
      |                     ^~~~~
a.cc:86:46: error: expression list treated as compound expression in functional cast [-fpermissive]
   86 |                         toleft[i] = P(i, best);
      |                                              ^
a.cc:90:51: error: expression list treated as compound expression in functional cast [-fpermissive]
   90 |                                 toleft[i] = P(0, 0);
      |                                                   ^
a.cc:98:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
   98 |                 chmax(ans, toleft[i].second);
      |                       ^~~
      |                       abs
a.cc:98:38: error: request for member 'second' in 'toleft.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   98 |                 chmax(ans, toleft[i].second);
      |                                      ^~~~~~
a.cc:98:17: error: 'chmax' was not declared in this scope
   98 |                 chmax(ans, toleft[i].second);
      |                 ^~~~~
a.cc:99:31: error: request for member 'first' in 'toleft.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   99 |                 if (toleft[i].first != 0)
      |                               ^~~~~
a.cc:100:46: error: request for member 'second' in 'toleft.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
  100 |                         chmax(ans, toleft[i].second + toright[toleft[i].first - 1].second);
      |                                              ^~~~~~
a.cc:100:73: error: request for member 'first' in 'toleft.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
  100 |                         chmax(ans, toleft[i].second + toright[toleft[i].first - 1].second);
      |                                                                         ^~~~~
a.cc:103:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  103 |         cout << ans << endl;
      |                 ^~~
      |                 abs