Language: C++

#include <bits/stdc++.h>	
using namespace std;
#define int long long
#define rep(i,n) for(int i=0,i<(n),i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)

vector<int> w,u;

int fillvector(vector<int> a,vector<int> b){
	w.assign(n+1,0);
	u.assign(n+1,0);
	rep(i,n)w[i+1]=w[i]+b[i];
	u[0]=w[1]-a[0];
	for(int i=0;i<n;i++){
		u[i+1]=max(u[i],w[i+1]-a[i]);
	}	
}

}
	
}

signed main(){
	int n,c;cin>>n>>c;
	vector<int>x(n,0);
	vector<int>v(n,0);
	rep(i,n) cin>>x[i]>>v[i];
	fillvector(x,v);
	int ans=0;
	rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-x[i]));
	vector<int>y(n,0);
	rep(i,n)y[i]=c-x[n-1-i];
	reverse(begin(v),end(v));
	fillvector(y,v);
	rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-y[i]));
	cout<<ans<<endl;


}


Compiler output:
a.cc: In function 'long long int fillvector(std::vector<long long int>, std::vector<long long int>)':
a.cc:10:18: error: 'n' was not declared in this scope
   10 |         w.assign(n+1,0);
      |                  ^
a.cc:4:31: error: expected ';' before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:12:9: note: in expansion of macro 'rep'
   12 |         rep(i,n)w[i+1]=w[i]+b[i];
      |         ^~~
a.cc:4:31: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:12:9: note: in expansion of macro 'rep'
   12 |         rep(i,n)w[i+1]=w[i]+b[i];
      |         ^~~
a.cc:4:39: error: expected ';' before ')' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                                       ^
a.cc:12:9: note: in expansion of macro 'rep'
   12 |         rep(i,n)w[i+1]=w[i]+b[i];
      |         ^~~
a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
a.cc: At global scope:
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
a.cc:21:1: error: expected declaration before '}' token
   21 | }
      | ^
a.cc: In function 'int main()':
a.cc:4:31: error: expected ';' before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:27:9: note: in expansion of macro 'rep'
   27 |         rep(i,n) cin>>x[i]>>v[i];
      |         ^~~
a.cc:4:31: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:27:9: note: in expansion of macro 'rep'
   27 |         rep(i,n) cin>>x[i]>>v[i];
      |         ^~~
a.cc:4:39: error: expected ';' before ')' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                                       ^
a.cc:27:9: note: in expansion of macro 'rep'
   27 |         rep(i,n) cin>>x[i]>>v[i];
      |         ^~~
a.cc:4:31: error: expected ';' before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:30:9: note: in expansion of macro 'rep'
   30 |         rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-x[i]));
      |         ^~~
a.cc:4:31: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:30:9: note: in expansion of macro 'rep'
   30 |         rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-x[i]));
      |         ^~~
a.cc:4:39: error: expected ';' before ')' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                                       ^
a.cc:30:9: note: in expansion of macro 'rep'
   30 |         rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-x[i]));
      |         ^~~
a.cc:4:31: error: expected ';' before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:32:9: note: in expansion of macro 'rep'
   32 |         rep(i,n)y[i]=c-x[n-1-i];
      |         ^~~
a.cc:4:31: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:32:9: note: in expansion of macro 'rep'
   32 |         rep(i,n)y[i]=c-x[n-1-i];
      |         ^~~
a.cc:4:39: error: expected ';' before ')' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                                       ^
a.cc:32:9: note: in expansion of macro 'rep'
   32 |         rep(i,n)y[i]=c-x[n-1-i];
      |         ^~~
a.cc:4:31: error: expected ';' before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:35:9: note: in expansion of macro 'rep'
   35 |         rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-y[i]));
      |         ^~~
a.cc:4:31: error: expected primary-expression before '<' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                               ^
a.cc:35:9: note: in expansion of macro 'rep'
   35 |         rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-y[i]));
      |         ^~~
a.cc:4:39: error: expected ';' before ')' token
    4 | #define rep(i,n) for(int i=0,i<(n),i++)
      |                                       ^
a.cc:35:9: note: in expansion of macro 'rep'
   35 |         rep(i,n)ans=max(ans,w[n]-w[i]-2*(c-y[i]));
      |         ^~~