Language: C++

##include "bits/stdc++.h"

using namespace std;

#define ll  long long
#define vi  vector<int>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int inf = 99999999;
const ll linf = 1LL << 62;

ll gcd(ll a,ll b){
  if(a < b)swap(a , b);
  if(a % b == 0) return b;
  else gcd(b, a%b);
}

ll lcm(ll a,ll b){
  if(a < b)swap(a , b);
  return (a/gcd(a , b))*b;
}

  ll n,c;
  vector<pair<ll,ll> > v(100010);
  vector<ll> Asum(100010,0);
  vector<ll> Bsum(100010,0);
  vector<ll> Amax(100010,0);
  vector<ll> Amax_rep(100010,0);
  ll ans =0;

void solve(int pos){

  Asum[pos] = Asum[pos - 1] + v[pos].second;
  Bsum[n - pos + 1] = Bsum[n - pos + 2] + v[n - pos + 1)].second;

 }

int main(){

  cin >> n >>c;
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    v[i + 1] = mp(a,b);
  }

  v[n+1]= mp(c,0);

  rep(i,n)solve(i + 1);

  rep(i,n){ // compute on A of rep and nonrep
    Amax[i + 1] = max(Amax[i], Asum[i + 1] - v[i + 1].first);
    Amax_rep[i + 1] = max(Amax_rep[i], Asum[i + 1] - 2*v[i + 1].first);
  }

  rep(i,n + 1){
    int pos = n - i + 1;
    ll ans1 = Amax[pos - 1] + Bsum[pos] - 2*(c - v[pos].first); //A nonrep and B rep
    chmax(ans,ans1);
    ll ans2 = Amax_rep[pos - 1] + Bsum[pos] - (c - v[pos].first); // A rep and B nonrep
    chmax(ans,ans2);
  }

  pr(ans);

  return 0;
}


Compiler output:
a.cc:1:1: error: stray '##' in program
    1 | ##include "bits/stdc++.h"
      | ^~
a.cc:1:3: error: 'include' does not name a type
    1 | ##include "bits/stdc++.h"
      |   ^~~~~~~
a.cc: In function 'long long int gcd(long long int, long long int)':
a.cc:25:12: error: 'swap' was not declared in this scope
   25 |   if(a < b)swap(a , b);
      |            ^~~~
a.cc: In function 'long long int lcm(long long int, long long int)':
a.cc:31:12: error: 'swap' was not declared in this scope
   31 |   if(a < b)swap(a , b);
      |            ^~~~
a.cc: At global scope:
a.cc:36:3: error: 'vector' does not name a type
   36 |   vector<pair<ll,ll> > v(100010);
      |   ^~~~~~
a.cc:37:3: error: 'vector' does not name a type
   37 |   vector<ll> Asum(100010,0);
      |   ^~~~~~
a.cc:38:3: error: 'vector' does not name a type
   38 |   vector<ll> Bsum(100010,0);
      |   ^~~~~~
a.cc:39:3: error: 'vector' does not name a type
   39 |   vector<ll> Amax(100010,0);
      |   ^~~~~~
a.cc:40:3: error: 'vector' does not name a type
   40 |   vector<ll> Amax_rep(100010,0);
      |   ^~~~~~
a.cc: In function 'void solve(int)':
a.cc:45:3: error: 'Asum' was not declared in this scope
   45 |   Asum[pos] = Asum[pos - 1] + v[pos].second;
      |   ^~~~
a.cc:45:31: error: 'v' was not declared in this scope
   45 |   Asum[pos] = Asum[pos - 1] + v[pos].second;
      |                               ^
a.cc:46:3: error: 'Bsum' was not declared in this scope
   46 |   Bsum[n - pos + 1] = Bsum[n - pos + 2] + v[n - pos + 1)].second;
      |   ^~~~
a.cc:46:56: error: expected ']' before ')' token
   46 |   Bsum[n - pos + 1] = Bsum[n - pos + 2] + v[n - pos + 1)].second;
      |                                                        ^
      |                                                        ]
a.cc: In function 'int main()':
a.cc:52:3: error: 'cin' was not declared in this scope
   52 |   cin >> n >>c;
      |   ^~~
a.cc:56:5: error: 'v' was not declared in this scope
   56 |     v[i + 1] = mp(a,b);
      |     ^
a.cc:8:13: error: 'make_pair' was not declared in this scope
    8 | #define mp  make_pair
      |             ^~~~~~~~~
a.cc:56:16: note: in expansion of macro 'mp'
   56 |     v[i + 1] = mp(a,b);
      |                ^~
a.cc:59:3: error: 'v' was not declared in this scope
   59 |   v[n+1]= mp(c,0);
      |   ^
a.cc:8:13: error: 'make_pair' was not declared in this scope
    8 | #define mp  make_pair
      |             ^~~~~~~~~
a.cc:59:11: note: in expansion of macro 'mp'
   59 |   v[n+1]= mp(c,0);
      |           ^~
a.cc:64:5: error: 'Amax' was not declared in this scope
   64 |     Amax[i + 1] = max(Amax[i], Asum[i + 1] - v[i + 1].first);
      |     ^~~~
a.cc:64:32: error: 'Asum' was not declared in this scope
   64 |     Amax[i + 1] = max(Amax[i], Asum[i + 1] - v[i + 1].first);
      |                                ^~~~
a.cc:64:19: error: 'max' was not declared in this scope
   64 |     Amax[i + 1] = max(Amax[i], Asum[i + 1] - v[i + 1].first);
      |                   ^~~
a.cc:65:5: error: 'Amax_rep' was not declared in this scope
   65 |     Amax_rep[i + 1] = max(Amax_rep[i], Asum[i + 1] - 2*v[i + 1].first);
      |     ^~~~~~~~
a.cc:70:15: error: 'Amax' was not declared in this scope
   70 |     ll ans1 = Amax[pos - 1] + Bsum[pos] - 2*(c - v[pos].first); //A nonrep and B rep
      |               ^~~~
a.cc:70:31: error: 'Bsum' was not declared in this scope
   70 |     ll ans1 = Amax[pos - 1] + Bsum[pos] - 2*(c - v[pos].first); //A nonrep and B rep
      |                               ^~~~
a.cc:13:24: error: 'max' was not declared in this scope
   13 | #define chmax(x,y) x = max(x,y)
      |                        ^~~
a.cc:71:5: note: in expansion of macro 'chmax'
   71 |     chmax(ans,ans1);
      |     ^~~~~
a.cc:72:15: error: 'Amax_rep' was not declared in this scope
   72 |     ll ans2 = Amax_rep[pos - 1] + Bsum[pos] - (c - v[pos].first); // A rep and B nonrep
      |               ^~~~~~~~
a.cc:15:15: error: 'cout' was not declared in this scope
   15 | #define pr(x) cout << x << endl
      |               ^~~~
a.cc:76:3: note: in expansion of macro 'pr'
   76 |   pr(ans);
      |   ^~
a.cc:15:28: error: 'endl' was not declared in this scope; did you mean 'Endl'?
   15 | #define pr(x) cout << x << endl
      |                            ^~~~
a.cc:76:3: note: in expansion of macro 'pr'
   76 |   pr(ans);
      |   ^~
a.cc: In function 'long long int gcd(long long int, long long int)':
a.cc:27:11: warning: control reaches end of non-void function [-Wreturn-type]
   27 |   else gcd(b, a%b);
      |        ~~~^~~~~~~~