criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn= 1e5 +10;
int n;
ll c,mx,x[maxn],v[maxn],a[maxn],b[maxn];
int main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>v[i];
		a[i]=a[i-1]+x[i-1]-x[i]+v[i];
	}
	x[n+1]=c;
	for(ll i=n;i>=1;i--)b[i]=b[i+1]+x[i]-x[i+1]+v[i];
	for(int i=2;i<=n;i++)a[i]=max(a[i],a[i-1]);
	for(int i=n-1;i>=1;i--)b[i]=max([b[i],b[i+1]]);
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,a[i]),mx=max(mx,b[i]);
		mx=max(mx,a[i]-x[i]+b[i+1]);
		mx=max(mx,b[i]-(c-x[i])+a[i-1]);
	}
	printf("%lld\n",mx);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:42: warning: capture of variable 'b' with non-automatic storage duration
   18 |         for(int i=n-1;i>=1;i--)b[i]=max([b[i],b[i+1]]);
      |                                          ^
a.cc:6:33: note: 'll b [100010]' declared here
    6 | ll c,mx,x[maxn],v[maxn],a[maxn],b[maxn];
      |                                 ^
a.cc:18:43: error: expected ',' before '[' token
   18 |         for(int i=n-1;i>=1;i--)b[i]=max([b[i],b[i+1]]);
      |                                           ^
      |                                           ,
a.cc:18:43: error: expected identifier before '[' token
a.cc:18:46: error: expected ']' before ',' token
   18 |         for(int i=n-1;i>=1;i--)b[i]=max([b[i],b[i+1]]);
      |                                              ^
      |                                              ]
a.cc: In lambda function:
a.cc:18:46: error: expected '{' before ',' token
a.cc: In function 'int main()':
a.cc:18:53: error: expected ')' before ']' token
   18 |         for(int i=n-1;i>=1;i--)b[i]=max([b[i],b[i+1]]);
      |                                        ~            ^
      |                                                     )
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long FINF=-1000000000000000000ll;
struct Pair{
	long long x,v;
}s[100010];
long long n,c/*,dp[100010][2],f[100010][2]*/,ans,a,b,sum[100010],rsum[100010],k,sz,tot,ms[100010],rms[100010];
int main(){
	scanf("%lld%lld",&n,&c);
	s[0].x=0;
	s[n+1].x=c;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&s[i].x,&s[i].v);
		sum[i]=sum[i-1]+s[i].v-s[i].x+s[i-1].x;
		ms[i]=max(sum[i],ms[i-1]);
	}
	ms[n+1]=FINF;
	for(int i=n;i>=1;i--){
		rsum[i]=rsum[i-1]+s[i].v-s[i+1].x+s[i].x;
		rms[i]=max(rms[i+1],rsum[i]);
	}
	ans=max(0ll,max(ms[n],rms[1]));
	for(int i=1;i<=n;i++){
		ans=max(ans,ms[i]-s[i].x+rms[i+1]);
		ans=max(ans,rms[i]-(c-s[i].x)+ms[i-1]);
	}
	printf("%lld",ans);
	return 0;
}v

Compiler output:
a.cc:29:2: error: 'v' does not name a type
   29 | }v
      |  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll	long long
int n;
ll c,mx,x[100010],v[100010],a[100010,b[100010];
int main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>v[i];
		a[i]=a[i-1]+x[i-1]-x[i]+v[i];
	}
	x[n+1]=c;
	for(ll i=n;i>=1;i--)
	b[i]=b[i+1]+x[i]-x[i+1]+v[i];
	for(int i=2;i<=n;i++)a[i]=max(b[i],b[i+1]);
	for(int i=n-1;i>=1;i--)
	b[i]=max([b[i],b[i+1]]);
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,a[i]),mx=max(mx,b[i]);
		mx=max(mx,a[i]-x[i]+b[i+1]);
		mx=max(mx,b[i]-(c-x[i])+a[i-1]);
	}
	printf("%lld\n",mx);
	return 0;
}

Compiler output:
a.cc:5:37: error: expected ']' before ',' token
    5 | ll c,mx,x[100010],v[100010],a[100010,b[100010];
      |                                     ^
      |                                     ]
a.cc: In function 'int main()':
a.cc:12:17: error: 'a' was not declared in this scope
   12 |                 a[i]=a[i-1]+x[i-1]-x[i]+v[i];
      |                 ^
a.cc:17:30: error: 'a' was not declared in this scope
   17 |         for(int i=2;i<=n;i++)a[i]=max(b[i],b[i+1]);
      |                              ^
a.cc:19:19: warning: capture of variable 'b' with non-automatic storage duration
   19 |         b[i]=max([b[i],b[i+1]]);
      |                   ^
a.cc:5:38: note: 'long long int b [100010]' declared here
    5 | ll c,mx,x[100010],v[100010],a[100010,b[100010];
      |                                      ^
a.cc:19:20: error: expected ',' before '[' token
   19 |         b[i]=max([b[i],b[i+1]]);
      |                    ^
      |                    ,
a.cc:19:20: error: expected identifier before '[' token
a.cc:19:23: error: expected ']' before ',' token
   19 |         b[i]=max([b[i],b[i+1]]);
      |                       ^
      |                       ]
a.cc: In lambda function:
a.cc:19:23: error: expected '{' before ',' token
a.cc: In function 'int main()':
a.cc:19:30: error: expected ')' before ']' token
   19 |         b[i]=max([b[i],b[i+1]]);
      |                 ~            ^
      |                              )
a.cc:22:27: error: 'a' was not declared in this scope
   22 |                 mx=max(mx,a[i]),mx=max(mx,b[i]);
      |                           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll	long long
const int maxn=100010;
int n;
ll c,mx,x[maxn],v[maxn],a[maxn],b[maxn];
int main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>v[i];
		a[i]=a[i-1]+x[i-1]-x[i]+v[i];
	}
	x[n+1]=c;
	for(ll i=n;i>=1;i--)
	b[i]=b[i+1]+x[i]-x[i+1]+v[i];
	for(int i=2;i<=n;i++)a[i]=max(b[i],b[i+1]);
	for(int i=n-1;i>=1;i--)
	b[i]=max([b[i],b[i+1]]);
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,a[i]),mx=max(mx,b[i]);
		mx=max(mx,a[i]-x[i]+b[i+1]);
		mx=max(mx,b[i]-(c-x[i])+a[i-1]);
	}
	printf("%lld\n",mx);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:19: warning: capture of variable 'b' with non-automatic storage duration
   20 |         b[i]=max([b[i],b[i+1]]);
      |                   ^
a.cc:6:33: note: 'long long int b [100010]' declared here
    6 | ll c,mx,x[maxn],v[maxn],a[maxn],b[maxn];
      |                                 ^
a.cc:20:20: error: expected ',' before '[' token
   20 |         b[i]=max([b[i],b[i+1]]);
      |                    ^
      |                    ,
a.cc:20:20: error: expected identifier before '[' token
a.cc:20:23: error: expected ']' before ',' token
   20 |         b[i]=max([b[i],b[i+1]]);
      |                       ^
      |                       ]
a.cc: In lambda function:
a.cc:20:23: error: expected '{' before ',' token
a.cc: In function 'int main()':
a.cc:20:30: error: expected ')' before ']' token
   20 |         b[i]=max([b[i],b[i+1]]);
      |                 ~            ^
      |                              )
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll	long long
const int maxn=1e5+10;
int n;
ll c,mx,x[maxn],v[maxn],a[maxn],b[maxn];
int main()
{
	cin>>n>>c;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>v[i];
		a[i]=a[i-1]+x[i-1]-x[i]+v[i];
	}
	x[n+1]=c;
	for(ll i=n;i>=1;i--)
	b[i]=b[i+1]+x[i]-x[i+1]+v[i];
	for(int i=2;i<=n;i++)a[i]=max(b[i],b[i+1]);
	for(int i=n-1;i>=1;i--)
	b[i]=max([b[i],b[i+1]]);
	for(int i=1;i<=n;i++)
	{
		mx=max(mx,a[i]),mx=max(mx,b[i]);
		mx=max(mx,a[i]-x[i]+b[i+1]);
		mx=max(mx,b[i]-(c-x[i])+a[i-1]);
	}
	printf("%lld\n",mx);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:19: warning: capture of variable 'b' with non-automatic storage duration
   20 |         b[i]=max([b[i],b[i+1]]);
      |                   ^
a.cc:6:33: note: 'long long int b [100010]' declared here
    6 | ll c,mx,x[maxn],v[maxn],a[maxn],b[maxn];
      |                                 ^
a.cc:20:20: error: expected ',' before '[' token
   20 |         b[i]=max([b[i],b[i+1]]);
      |                    ^
      |                    ,
a.cc:20:20: error: expected identifier before '[' token
a.cc:20:23: error: expected ']' before ',' token
   20 |         b[i]=max([b[i],b[i+1]]);
      |                       ^
      |                       ]
a.cc: In lambda function:
a.cc:20:23: error: expected '{' before ',' token
a.cc: In function 'int main()':
a.cc:20:30: error: expected ')' before ']' token
   20 |         b[i]=max([b[i],b[i+1]]);
      |                 ~            ^
      |                              )
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long FINF=-1000000000000000000ll;
struct Pair{
	long long x,v;
}s[100010];
long long n,c/*,dp[100010][2],f[100010][2]*/,ans,a,b,sum[100010],k,sz,tot;
Pair q[100010];
int main(){
	scanf("%lld%lld",&n,&c);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&s[i].x,&s[i].v);
		//f[i][0]=f[i][1]=FINF;
		
	}
	//f[0][0]=f[0][1]=0;
	s[n+1].x=c;
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+s[i].v;
	}
	k=0;
	q[0]=-233;
	for(int i=0;i<=n;i++){
		k=sum[i]-s[i].x;
		if(q[sz].v<k){
			q[++sz].x=i;
			q[ sz ].v=k;
		}
	}
	for(int i=n;i>=1;i--){
		if(q[sz].x==i)sz--;
		tot+=s[i].v-(s[i+1].x-s[i].x);
		ans=max(ans,max(tot-(c-s[i].x)+q[sz].v,tot));
	}
	k=0;
	sz=0;
	q[0]=-233;
	for(int i=n;i>=1;i--){
		k=(sum[n]-sum[i-1])-(c-s[i].x);
		if(q[sz].v<k){
			q[++sz].x=i;
			q[ sz ].v=k;
		}
	}
	tot=0;
	for(int i=1;i<=n;i++){
		if(q[sz].x==i)sz--;
		tot+=s[i].v-(s[i].x-s[i-1].x);
		ans=max(ans,max(tot-s[i].x+q[sz].v,tot));
	}
	printf("%lld",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:15: error: no match for 'operator=' (operand types are 'Pair' and 'int')
   22 |         q[0]=-233;
      |               ^~~
a.cc:4:8: note: candidate: 'constexpr Pair& Pair::operator=(const Pair&)'
    4 | struct Pair{
      |        ^~~~
a.cc:4:8: note:   no known conversion for argument 1 from 'int' to 'const Pair&'
a.cc:4:8: note: candidate: 'constexpr Pair& Pair::operator=(Pair&&)'
a.cc:4:8: note:   no known conversion for argument 1 from 'int' to 'Pair&&'
a.cc:37:15: error: no match for 'operator=' (operand types are 'Pair' and 'int')
   37 |         q[0]=-233;
      |               ^~~
a.cc:4:8: note: candidate: 'constexpr Pair& Pair::operator=(const Pair&)'
    4 | struct Pair{
      |        ^~~~
a.cc:4:8: note:   no known conversion for argument 1 from 'int' to 'const Pair&'
a.cc:4:8: note: candidate: 'constexpr Pair& Pair::operator=(Pair&&)'
a.cc:4:8: note:   no known conversion for argument 1 from 'int' to 'Pair&&'
Language: C++

#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=1e5+9;
LL c,ans,n;
LL x[maxn],v[maxn];
struct node{
	LL CW,AC,CW_back,AC_back;
}f[maxn];
LL read(){
	LL x=0;bool f=0;char c=getchar();
	while (c<'0'||c>'9'){if (c=='-') f=1;c=getchar();}
	while (c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return f?-x:x;
}
int main(){
	n=read(),c=read();
	for (int i=1;i<=n;++i) x[i]=read(),v[i]=read();
	f[1].AC=v[1]-x[1];f[1].AC_back=f[1].AC-x[1];
	for (int i=2;i<=n;++i) f[i].AC=f[i-1].AC+v[i]-(x[i]-x[i-1]),f[i].AC_back=f[i].AC-x[i];
	for (int i=2;i<=n;++i) f[i].AC=max(f[i-1].AC,f[i].AC),f[i].AC_back=max(f[i-1].AC_back,f[i].AC_back);
	f[n].CW=v[n]-(c-x[n]);f[n].CW_back=f[n].CW-(c-x[n]);
	for (int i=n-1;i>=1;--i) f[i].CW=f[i+1].CW+v[i]-(x[i+1]-x[i]),f[i].CW_back=f[i].CW-(c-x[i]);
	for (int i=n-1;i>=1;--i) f[i].CW=max(f[i+1].CW,f[i].CW),f[i].CW_back=max(f[i+1].CW_back,f[i].CW_back);
	ans=max(0,max(f[n].AC,f[1].CW));
	for (int i=1;i<n;++i){
		ans=max(ans,f[i].AC_back+f[i+1].CW);
		ans=max(ans,f[i].AC+f[i+1].CW_back);
	}
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:16: error: no matching function for call to 'max(int, const long long int&)'
   25 |         ans=max(0,max(f[n].AC,f[1].CW));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/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:   template argument deduction/substitution failed:
a.cc:25:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   25 |         ans=max(0,max(f[n].AC,f[1].CW));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/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, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/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:   candidate expects 1 argument, 2 provided
/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:   template argument deduction/substitution failed:
a.cc:25:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |         ans=max(0,max(f[n].AC,f[1].CW));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~
Language: C

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i=0; (i) < int(n); ++(i))

int main(void){

	int n, c;
	cin >> n >> c;
	int x, v, point=0;
	vector<ll> sum;
	rep(i, n){
		cin >> x >> v;
		if(i == 0){
			sum.push_back(v-x);
		}else{
			sum.push_back(sum.back()+v-x+point);
		}
		point = x;
	}

	ll ans = *max_element(sum.begin(), sum.end());
	cout << ans << endl;

	return 0;
}


Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int n,c;
struct shousi{
	int x,v;
}f[100005];
int main()
{
//	scanf("%d %d",&n,&c);
//	for (int i=1;i<=n;i++)
//		scanf("%d %d",&f[i].x,&f[i].v);
//	sort(f+1,f+n+1,cmp);
//	
cout<<191<<endl;
	return 0;
}


Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
char ch;
bool fl;
inline void read(int &a){
    for(fl=0,ch=getchar();ch<'0'||ch>'9';ch=getchar()) fl^=(ch=='-');
    for(a=0;ch>='0'&&ch<='9';ch=getchar())a=(a<<3)+(a<<1)+(ch^'0');
    if(fl)a=-a;
}
const int N=1e5+10;
int c[N];
int n,i,d,l,r,L,R;
ll Ans;
inline void Ins(int i){ for(;i<=n+1;i+=i&(-i))c[i]++;}
inline int Qry(int i){ int Ans=0;for(;i;i-=i&(-i))Ans+=c[i];return Ans;}
struct Po{
    ll v;
    int id;
    bool operator <(const Po &a)const{ return v<a.v;}
}S[N],Pre[N];
int GetL(int l,int r,ll V){
    while(l<r){
        int mid=(l+r)>>1;
        if(S[mid].v>=V)r=mid;
        else l=mid+1;
    }
    return l;
}
int GetR(int l,int r,ll V){
    while(l<r){
        int mid=((l+r)>>1)+1;
        if(S[mid].v<=V)l=mid;
        else r=mid-1;
    }
    return l;
}
int main(){
    read(n);read(L);read(R);
    for(i=1;i<=n;i++){
        read(d);
        Pre[i].v=Pre[i-1].v+d;
    }
    for(i=0;i<=n;i++)S[i].v=Pre[i].v,S[i].id=i;
    sort(S,S+n+1);
    for(i=0;i<=n;i++)Pre[S[i].id].id=i;
    Ins(Pre[0].id+1);
    for(i=1;i<=n;i++){
        r=GetR(0,n,Pre[i].v-L);if(S[0].v>(Pre[i].v-L))r=-1;
        l=GetL(0,n,Pre[i].v-R);if(S[n].v<(Pre[i].v-R))l=n+1;
        if(l<=r) Ans+=Qry(r+1)-Qry(l);
        Ins(Pre[i].id+1);
    }
    printf("%lld",Ans);
    return 0;
}

Compiler output:
a.cc: In function 'void read(int&)':
a.cc:8:17: error: 'getchar' was not declared in this scope
    8 |     for(fl=0,ch=getchar();ch<'0'||ch>'9';ch=getchar()) fl^=(ch=='-');
      |                 ^~~~~~~
a.cc:3:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <algorithm>
  +++ |+#include <cstdio>
    3 | using namespace std;
a.cc:9:33: error: 'getchar' was not declared in this scope
    9 |     for(a=0;ch>='0'&&ch<='9';ch=getchar())a=(a<<3)+(a<<1)+(ch^'0');
      |                                 ^~~~~~~
a.cc:9:33: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
a.cc: In function 'int main()':
a.cc:55:5: error: 'printf' was not declared in this scope
   55 |     printf("%lld",Ans);
      |     ^~~~~~
a.cc:55:5: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
Language: C++

#include<bits/stdc++.h>
#define maxn 100886
using namespace std;
int n;
long long c; 
int w[maxn], v[maxn], top = 0;
long long  a[maxn];
long long  maxx = -199999999;
inline long long read() {
	long long  x = 0, y = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') y = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 1) + (x << 3) + ch - '0';
		ch = getchar();
	}
	return x * y;
}
int main() {
	n = read(), c = read();
	for(int i = 1; i <= n; ++i) {
		int ww, vv;
		ww = read(), vv = read();
		if(ww > cc) continue;
		w[++top] = ww, v[top] = vv;
	}
	for(int i = 1; i <= top; ++i) {
		if(i == 1) {
			a[i] = 0 - w[i] + v[i];
		}
		a[i] = a[i - 1] + v[i] - (w[i] - w[i - 1]);
		maxx = max(a[i], maxx);
	}
	cout << maxx <<'\n';
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:25: error: 'cc' was not declared in this scope; did you mean 'c'?
   27 |                 if(ww > cc) continue;
      |                         ^~
      |                         c
Language: C

#include <stdio.h>
#define MAX(x,y) x>y?x:y
typedef long long long int ll;

ll N,C,x[100002],v[100002];

ll Solve(){
	ll lg=0,tem=0;
        ll max[100001];
        max[0]=0;
	for(ll i=0;i<N;i++)
	{
		lg+=v[i+1]+x[i]-x[i+1];
		max[i+1]=MAX(max[i],lg);
                //printf("f(%lld)=%lld\n",i+1,max[i+1]);
	}
	ll ans=max[N];
	for(ll i=N;i>1;i--)
	{
		tem+=v[i]+x[i]-x[i+1];
		ans=MAX(tem+x[i]-C+max[i-1],ans);
	}
        //printf("ans: %lld\n",ans);
	return ans;
}

int main(){
	scanf("%llld %llld",&N,&C);
	for(ll i=0;i<N;i++) scanf("%llld %llld",&x[i+1],&v[i+1]);
	x[N+1]=C;
        x[0]=0;
	ll Ans1=Solve();
	for(ll i=1;i<=N;i++) x[i]=C-x[i];
        for(ll i=1;i<=N/2;i++) {
            ll t=x[i];
            x[i]=x[N+1-i];
            x[N+1-i]=t;
            t=v[i];
            v[i]=v[N+1-i];
            v[N+1-i]=t;
        }
       /*for(ll i=1;i<=N;i++) printf("x[%lld]=%lld\n",i,x[i]);
        for(ll i=1;i<=N;i++) printf("v[%lld]=%lld\n",i,v[i]);*/
	ll Ans2=Solve();
	printf("%llld",MAX(Ans1,Ans2));
	return 0;
}


Compiler output:
main.c:3:19: error: 'long long long' is too long for GCC
    3 | typedef long long long int ll;
      |                   ^~~~
Language: C++

#include<iostream>
#include<cstdlib>

using namespace std;

int N;

void eraser(int *x,int *v,int address){
		
		int temp = address + i;
	
	for(int i = 0;i < N - address;i++){
		
		x[temp] = x[temp + 1];
		v[temp] = v[temp + 1];
	
	}
	
	
	N -= 1;
	
}	

int main(void){
	
	int C;
	
	int *x;
	int *v;
	
	int min_add = 0;
	int loca = 0;
	int after_sum = 0;
	int sum = 0;
	
	cin >> N >> C;
	
	x = new int[N];
	v = new int[N];
	
	for(int i = 0;i < N;i++){
		
		cin >> x[i] >> v[i];
		
	}
	
	
	for(int i = 0;i < N;i++){
		
		if(x[i] > (C / 2))
			x[i] = x[i] - C;
	}
	
	min_add = abs(x[0]) < abs(x[N - 1]) ? 0 : N - 1;
	
	after_sum = v[min_add] - abs(x[min_add]);
	
	if(after_sum < sum){
		
		cout << sum;
		
		return 0;
		
	}
	
	sum = after_sum;
			
	for(int i = 0;i < N;i++){
		
		int compare1,compare2;
		
		loca = x[min_add];
		
		int plus = (min_add + 1) > N - 1 ? 0 : min_add + 1;
		int minus = (min_add - 1) < 0 ? N - 1 : min_add - 1;
		
		sum = after_sum;
		
		compare1 = v[plus] - abs(x[plus] - loca);
		compare2 = v[minus] - abs(x[minus] - loca);
		
		if(compare1 < compare2){
			
			after_sum += compare2;
			
			eraser(x,v,minus);
			min_add = minus;
			
			
		}else{
			
			after_sum += compare1;
			
			eraser(x,v,plus);
			min_add = plus;
			
		}		
		
		
		if(sum > after_sum){
			
			break;
			
		}
		
	}
	
	cout << sum;
	
	return 0;
	
	}

Compiler output:
a.cc: In function 'void eraser(int*, int*, int)':
a.cc:10:38: error: 'i' was not declared in this scope
   10 |                 int temp = address + i;
      |                                      ^
Language: C++

#include <iostream>
using namespace std;
__int64_t N, C;
int main() {
  cin >> N >> C;
  __int64_t x[N+2],v[N+2],OA[N+2],rOA[N+2],OB[N+2],rOB[N+2],sum,out;
  OA[0]=rOA[0]=OB[0]=rOB[0]=sum=out=0;
  for (int i=0; i<N; i++) {
    cin >> x[i] >> v[i];
    sum += v[i];
    OA[i+1] = max(OA[i],sum-x[i]);
    rOA[i+1] = max(rOA[i],sum-2*x[i]);
  }
  sum = 0;
  for (int i=0; i<N; i++) {
    int n = N-1-i;
    sum += v[n];
    OB[i+1] = max(OB[i],sum-C+x[n]);
    rOB[i+1] = max(rOB[i],sum-2*(C-x[n]));
    out = max(out, max(OA[n]+rOB[i],OB[i]+rOA[n]));
  }
  cout << max(out, max(OA[0]+rOB[N],OB[N]+rOA[0])));
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:51: error: expected ';' before ')' token
   22 |   cout << max(out, max(OA[0]+rOB[N],OB[N]+rOA[0])));
      |                                                   ^
      |                                                   ;
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
using ll = long long;

int n;
ll C;
ll ans = 0;
const int maxn = 1e5 + 10;
const ll oo = 0x3f3f3f3f3f3f3f3f;

struct Point{
    ll x;
    int v;
};

Point p[maxn];
ll sum[maxn];

bool cmp(Point p1 , Point p2){
    return p1.x < p2.x;
}

void solve(){
    //sort(p + 1 , p + n + 1 , cmp); 
    sum[0] = 0;
    ll cur = 0 , mx = 0; 
    for(int i = 1 ; i <= n ; ++ i){
	cur += p[i].v - (p[i].x - p[i - 1].x);
	if(cur > mx) mx = cur;
	sum[i] = mx;
    }
    ans = max(ans , sum[n]);
    ll now = 0;
    for(int i = n ; i >= 1 ; -- i){
        now += p[i].v;
        ans = max(ans , (sum[i - 1] + now) - 2 * (C - p[i].x));
    } 
}

int main(){
    ios::sync_with_stdio(0);
    cin >> n >> C;	
    for(int i = 1 ; i <= n ; ++ i)
	cin >> p[i].x >> p[i].v;
    solve();
    for(int i = 1 ; i <= n ; ++ i)
	p[i].x = C - p[i].x;
	swap(p[i], p[n-i+1]);
    solve();
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:16: error: 'i' was not declared in this scope
   52 |         swap(p[i], p[n-i+1]);
      |                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<ll> Vec;
typedef vector<Vec> DVec;
typedef vector<DVec> TVec;
typedef priority_queue<P, vector<P>, greater<P>> PQ;

#define fi                first
#define se                second
#define pb                push_back
#define INF               LLONG_MAX/3
#define MOD               1000000007
#define bcnt              __builtin_popcount
#define all(x)            (x).begin(),(x).end()
#define srt(x)            sort(all(x))
#define rvs(x)            reverse(all(x))
#define uni(x)            x.erase(unique(all(x)),x.end())
#define ub(x,y)           (upper_bound(all(x),y)-x.begin())
#define lb(x,y)           (lower_bound(all(x),y)-x.begin())
#define rep(i,n)          repl(i,0,n-1)
#define mkp(x,y)          make_pair(x,y)
#define mmax(x,y)         (x>y?x:y)
#define mmin(x,y)         (x<y?x:y)
#define maxch(x,y)        x=mmax(x,y)
#define minch(x,y)        x=mmin(x,y)
#define exist(x,y)        (find(all(x),y)!=x.end())
#define each(itr,v)       for(auto itr:v)
#define repl(i,a,b)       for(ll i=(ll)(a);i<=(ll)(b);i++)
#define dvec(n1,n2,i)     DVec(n1,Vec(n2,i))
#define tvec(n1,n2,n3,i)  TVec(n1,dvec(n2,n3,i))


int main(){
  cin.sync_with_stdio(false);
  ll n,m,w,h,r,l;
  ll mv=0,c,suma=0,sumb=0;
  cin >> n >> c;
  Vec v(n+2,0),x(n+2,0),rv(n+1),0,lv(n+1,0),frv(n,0),dnum(n,0);
  x[0]=0;
  x[n+1]=c;
  repl(i,1,n) cin >> x[i] >> v[i];
  rv[0]=0;
  lv[0]=0;
  frv[0]=0;
  dnum[0]=0;
  repl(i,1,n){
    suma+=v[i];
    sumb+=v[n+1-i];
    rv[i]=suma-x[i];
    if(rv[i]>frv[i-1]){
      frv[i]=rv[i];
      dnum[i]=i;
    }
    else{
      frv[i]=frv[i-1];
      dnum[i]=dnum[i-1];
    }
    lv[i]=max(lv[i-1],sumb-c+x[n+1-i]);
  }
  rep(i,n+1)mv=mmax(mv,lv[i]+frv[n-i]-mmin(c-x[n+1-i],x[dnum[n-i]]));
  cout << mv << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:33: error: expected unqualified-id before numeric constant
   42 |   Vec v(n+2,0),x(n+2,0),rv(n+1),0,lv(n+1,0),frv(n,0),dnum(n,0);
      |                                 ^
a.cc:47:3: error: 'lv' was not declared in this scope; did you mean 'rv'?
   47 |   lv[0]=0;
      |   ^~
      |   rv
a.cc:48:3: error: 'frv' was not declared in this scope; did you mean 'rv'?
   48 |   frv[0]=0;
      |   ^~~
      |   rv
a.cc:49:3: error: 'dnum' was not declared in this scope; did you mean 'enum'?
   49 |   dnum[0]=0;
      |   ^~~~
      |   enum
Language: C++

15 10000000000
400000000 1000000000
800000000 1000000000
1900000000 1000000000
2400000000 1000000000
2900000000 1000000000
3300000000 1000000000
3700000000 1000000000
3800000000 1000000000
4000000000 1000000000
4100000000 1000000000
5200000000 1000000000
6600000000 1000000000
8000000000 1000000000
9300000000 1000000000
9700000000 1000000000


Compiler output:
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 15 10000000000
      | ^~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

ll N, C;
vector<ll> v, x;
vector<ll> l, r;
vector<ll> rmax, lmax;
ll res = 0;

ll mymax(ll a, ll b)
{
  if (a > b)
  {
    return a;
  }
  else
  {
    return b;
  }
}

ll mymin(ll a, ll b)
{
  if (a < b)
  {
    return a;
  }
  else
  {
    return b;
  }
}

int main()
{
  cin >> N >> C;
  v = vector<ll>(N);
  x = vector<ll>(N);
  l = vector<ll>(N);
  r = vector<ll>(N);
  rmax = vector<ll>(N);
  lmax = vector<ll>(N);

  for (int i = 0; i < N; i++)
  {
    cin >> x[i] >> v[i];
  }
  for (int i = 0; i < N; i++)
  {
    r[i] = (i == 0 ? 0 : r[i - 1]) + v[i] - (x[i] - (i == 0 ? 0 : x[i - 1]));
  }
  for (int i = N - 1; i >= 0; i--)
  {
    if (i == N - 1)
    {
      i[i] = v[i] - (C - x[i]);
    }
    else
    {
      l[i] = v[i] + l[i + 1] - (x[i + 1] - x[i]);
    }
    if (i == N - 1)
    {
      lmax[i] = i;
      continue;
    }
    if (l[lmax[i + 1]] <= l[i])
    {
      lmax[i] = i;
    }
    else
    {
      lmax[i] = lmax[i + 1];
    }
  }

  //iで方向転換
  for (int i = 0; i < N; i++)
  {
    ll temp = 0;
    temp += r[i];
    res = mymax(res, temp);
    if (i != N - 1)
    {
      res = mymax(res, l[lmax[i + 1]]);
      temp += l[lmax[i + 1]];
      res = mymax(res, temp - mymin(x[i], (C - x[lmax[i + 1]])));
    }
    else
    {
      res = mymax(res, l[0]);
    }
  }

  cout << res << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:8: error: invalid types 'int[int]' for array subscript
   60 |       i[i] = v[i] - (C - x[i]);
      |        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

using ll = long long int;

const ll MAX_N = (int)1e5 + 5;

struct dist_cal {ll dist, cal;};

ll n, c;
vector<dist_cal> xv;
vector<dist_cal> xv_rev;

ll ans;

ll solve(vector<dist_cal> dsv) {
  /****************************************************/
  ll score_a[MAX_N];
  ll score_b[MAX_N];
  ll score_g[MAX_N];

  ll tmp_a = 0;
  for (int i = 0; i < dsv.size(); ++i) {
    tmp_a += dsv[i].cal;
    score_a[i] = tmp_a - dsv[i].dist;
  }

  ll tmp_b = 0;
  for (int i = n - 1; i >= 0; --i) {
    tmp_b += dsv[i].cal;
    score_b[i] = tmp_b - (c - dsv[i].dist);
  }

  score_g[0] = 0;
  for (int i = 1; i < dsv.size(); ++i) {
    score_g[i] = max(score_g[i - 1], score_a[i - 1]);
  }

  // ll last_max = score_g[n - 1];
  for (int i = n - 1; i >= 0; --i) {
    ll cur_score = score_b[i] - (c - dsv[i].dist) + score_g[i];
    last_max = max(last_max, cur_score);
  }
  /****************************************************/

  return last_max;
}

int main(void) {
  // Here your code !
	scanf("%lld %lld", &n, &c);
	for (ll i = 0; i < n; ++i) {
    ll x, v;
    scanf("%lld %lld", &x, &v);
    dist_cal tmp;
    tmp.dist = x;
    tmp.cal = v;
    xv.push_back(tmp);
  }

  for (int i = 0; i < xv.size(); ++i) {
    dist_cal tmp;
    tmp.dist = c - xv[i].dist;
    tmp.cal = xv[i].cal;
    xv_rev.push_back(tmp);
  }

  sort(xv.begin(), xv.end(), [](dist_cal a, dist_cal b) { return a.dist < b.dist; });
  sort(xv_rev.begin(), xv_rev.end(), [](dist_cal a, dist_cal b) { return a.dist < b.dist; });

  ans = max(solve(xv), solve(xv_rev));
  ans = max(ans, (ll)0);

  printf("%lld\n", ans);

	return 0;
}

Compiler output:
a.cc: In function 'll solve(std::vector<dist_cal>)':
a.cc:42:5: error: 'last_max' was not declared in this scope
   42 |     last_max = max(last_max, cur_score);
      |     ^~~~~~~~
a.cc:46:10: error: 'last_max' was not declared in this scope
   46 |   return last_max;
      |          ^~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int calc_max_cal(const vector<pair<long long int, long long int>>& sushi){
  long long int sum_sushi_cal = 0;
  long long int max_cal = 0;
  for (auto& s : sushi) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first);
  }
  return max_cal;
}
int main() {
  int N;
  long long int C;
  cin >> N >> C;

  vector<pair<long long int, long long int>> sushi_forward;
  vector<pair<long long int, long long int>> sushi_backward;
  sushi_forward.reserve(N);
  sushi_backward.reserve(N);
  for (int ii = 0; ii<N; ii++) {
    long long int x;
    long long int v;
    cin >> x >> v;
    sushi_forward.push_back(make_pair(x, v));
    sushi_backward.push_back(make_pair(C-x, v));
  }
  
  sort(sushi_forward.begin(), sushi_forward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  sort(sushi_backward.begin(), sushi_backward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  long long int max_cal_forward = calc_max_cal(sushi_forward);
  long long int max_cal_backward = calc_max_cal(sushi_backward);
  
  long long int max_cal = max(max_cal_forward, max_cal_backward);
  long long int sum_sushi_cal = 0;
  for (auto& s : sushi_forward) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_backward);
  }
  sum_sushi_cal = 0;
  for (auto& s : sushi_backward) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_forward);
  }
  
  long long int current_pos = 0;
  long long int cal_all_sushi = 0;
  long long int max_distance = 0;
  for (auto& s : sushi_forward) {
    max_distance = max(max_distance, s.firts - current_pos);
    cal_all_sushi += s.second;
    current_pos = s.firts;
  }
  max_distance = max(max_distance, N - current_pos);
  max_cal = min(max_cal, cal_all_sushi - max_distance);
  
  cout << max_cal;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:40: error: 'struct std::pair<long long int, long long int>' has no member named 'firts'; did you mean 'first'?
   56 |     max_distance = max(max_distance, s.firts - current_pos);
      |                                        ^~~~~
      |                                        first
a.cc:58:21: error: 'struct std::pair<long long int, long long int>' has no member named 'firts'; did you mean 'first'?
   58 |     current_pos = s.firts;
      |                     ^~~~~
      |                     first
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int calc_max_cal(const vector<pair<long long int, long long int>>& sushi){
  long long int sum_sushi_cal = 0;
  long long int max_cal = 0;
  for (auto& s : sushi) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first);
  }
  return max_cal;
}
int main() {
  int N;
  long long int C;
  cin >> N >> C;

  vector<pair<long long int, long long int>> sushi_forward;
  vector<pair<long long int, long long int>> sushi_backward;
  sushi_forward.reserve(N);
  sushi_backward.reserve(N);
  for (int ii = 0; ii<N; ii++) {
    long long int x;
    long long int v;
    cin >> x >> v;
    sushi_forward.push_back(make_pair(x, v));
    sushi_backward.push_back(make_pair(C-x, v));
  }
  
  sort(sushi_forward.begin(), sushi_forward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  sort(sushi_backward.begin(), sushi_backward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  long long int max_cal_forward = calc_max_cal(sushi_forward);
  long long int max_cal_backward = calc_max_cal(sushi_backward);
  
  long long int max_cal = max(max_cal_forward, max_cal_backward);
  long long int sum_sushi_cal = 0;
  for (auto& s : sushi_forward) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_backward);
  }
  sum_sushi_cal = 0;
  for (auto& s : sushi_backward) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_forward);
  }
  
  long long int current_pos = 0;
  long long int cal_all_sushi = 0;
  for (auto& s : sushi_forward) {
    max_distance = max(max_distance, s.firts - current_pos);
    cal_all_sushi += s.second;
    current_pos = s.firts;
  }
  max_distance = max(max_distance, N - current_pos);
  max_cal = min(max_cal, cal_all_sushi - max_distance);
  
  cout << max_cal;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:5: error: 'max_distance' was not declared in this scope
   55 |     max_distance = max(max_distance, s.firts - current_pos);
      |     ^~~~~~~~~~~~
a.cc:55:40: error: 'struct std::pair<long long int, long long int>' has no member named 'firts'; did you mean 'first'?
   55 |     max_distance = max(max_distance, s.firts - current_pos);
      |                                        ^~~~~
      |                                        first
a.cc:57:21: error: 'struct std::pair<long long int, long long int>' has no member named 'firts'; did you mean 'first'?
   57 |     current_pos = s.firts;
      |                     ^~~~~
      |                     first
a.cc:59:3: error: 'max_distance' was not declared in this scope
   59 |   max_distance = max(max_distance, N - current_pos);
      |   ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
	int N;
	long long C;
	cin >> N >> C;
	long long cum = 0;
	long long cum_maxi = 0;
	long long cum_maxj = 0;
	long long x0 = 0;
	long long x[N+2];
	long v[N+2];
	for(int i=1; i<=N; ++i){
		cin >> x[i] >> v[i];
	}
	x[0] = 0;
	x[N+1] = C;
	v[0] = 0;
	v[N+1] = 0;
	long i_max = 0;
	long j_max = N+1;
	
	long i = 0;
	long long vi = 0;
	
	
	while(x[i] <= C/2){
		vi += v[i];
		cum = vi - x[i];
		i_max = (cum_maxi <= cum) && x[i] > x[i_max] ? i : i_max; 
		cum_maxi = max(cum,cum_maxi);
		i++;
	}
	long long cum_max = cum_maxi;
	while(x[i] <= C){
		vi += v[i];
		cum = vi - x[i];
		cum_max = max(cum,cum_max);
		i++;
	}
	i = N+1;
	vi = 0;
	while(C-x[i] <= C/2){
		vi += v[i];
		cum = vi - (C-x[i]);
		j_max = (cum_maxj <= cum) && x[i] < x[j_max] ? i : j_max; 
		cum_maxj = max(cum,cum_maxj);
		i--;
	}
	cum_max = max(cum_maxj,cum_max)
	while(C-x[i] <= C){
		vi += v[i];
		cum = vi - (C-x[i]);
		cum_max = max(cum,cum_max);
		i--;
	}
	
		
	cout << max((cum_maxi+cum_maxj) - min(x[i_max],C-x[j_max]),cum_max) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:40: error: expected ';' before 'while'
   51 |         cum_max = max(cum_maxj,cum_max)
      |                                        ^
      |                                        ;
   52 |         while(C-x[i] <= C){
      |         ~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int calc_max_cal(const vector<pair<long long int, long long int>>& sushi){
  long long int sum_sushi_cal = 0;
  long long int max_cal = 0;
  for (auto& s : sushi) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first);
  }
  return max_cal;
}
int main() {
  int N;
  long long int C;
  cin >> N >> C;

  vector<pair<long long int, long long int>> sushi_forward;
  vector<pair<long long int, long long int>> sushi_backward;
  sushi_forward.reserve(N);
  sushi_backward.reserve(N);
  for (int ii = 0; ii<N; ii++) {
    long long int x;
    long long int v;
    cin >> x >> v;
    sushi_forward.push_back(make_pair(x, v));
    sushi_backward.push_back(make_pair(C-x, v));
  }
  
  sort(sushi_forward.begin(), sushi_forward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  sort(sushi_backward.begin(), sushi_backward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  long long int max_cal_forward = calc_max_cal(sushi_forward);
  long long int max_cal_backward = calc_max_cal(sushi_backward);
  
  long long int max_cal = max(max_cal_forward, max_cal_backward);
  long long int sum_sushi_cal = 0;
  for (auto& s : sushi_forward) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_backward);
  }
  sum_sushi_cal = 0;
  for (auto& s : sushi_backword) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_forward);
  }
  
  cout << max_cal;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:18: error: 'sushi_backword' was not declared in this scope; did you mean 'sushi_backward'?
   47 |   for (auto& s : sushi_backword) {
      |                  ^~~~~~~~~~~~~~
      |                  sushi_backward
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int calc_max_cal(const vector<pair<long long int, long long int>>& sushi){
  long long int sum_sushi_cal = 0;
  long long int max_cal = 0;
  for (auto& s : sushi) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first);
  }
  return max_cal;
}
int main() {
  int N;
  long long int C;
  cin >> N >> C;

  vector<pair<long long int, long long int>> sushi_forward;
  vector<pair<long long int, long long int>> sushi_backward;
  sushi_forward.reserve(N);
  sushi_backward.reserve(N);
  for (int ii = 0; ii<N; ii++) {
    long long int x;
    long long int v;
    cin >> x >> v;
    sushi_forward.push_back(make_pair(x, v));
    sushi_backward.push_back(make_pair(C-x, v));
  }
  
  sort(sushi_forward.begin(), sushi_forward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  sort(sushi_backward.begin(), sushi_backward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  long long int max_cal_forward = calc_max_cal(sushi_forward);
  long long int max_cal_backward = calc_max_cal(sushi_backward);
  
  long long int max_cal = max(max_cal_forward, max_cal_backword);
  long long int sum_sushi_cal = 0;
  for (auto& s : sushi_forward) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_backword);
  }
  sum_sushi_cal = 0;
  for (auto& s : sushi_backword) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_forward);
  }
  
  cout << max_cal;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:48: error: 'max_cal_backword' was not declared in this scope; did you mean 'max_cal_backward'?
   40 |   long long int max_cal = max(max_cal_forward, max_cal_backword);
      |                                                ^~~~~~~~~~~~~~~~
      |                                                max_cal_backward
a.cc:47:18: error: 'sushi_backword' was not declared in this scope; did you mean 'sushi_backward'?
   47 |   for (auto& s : sushi_backword) {
      |                  ^~~~~~~~~~~~~~
      |                  sushi_backward
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int calc_max_cal(const vector<pair<long long int, long long int>>& sushi){
  long long int sum_sushi_cal = 0;
  long long int max_cal = 0;
  for (auto& s : sushi) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first);
  }
  return max_cal;
}
int main() {
  int N;
  long long int C;
  cin >> N >> C;

  vector<pair<long long int, long long int>> sushi;
  vector<pair<long long int, long long int>> sushi_rev;
  sushi.reserve(N);
  sushi_rev.reserve(N);
  for (int ii = 0; ii<N; ii++) {
    long long int x;
    long long int v;
    cin >> x >> v;
    sushi_forward.push_back(make_pair(x, v));
    sushi_backward.push_back(make_pair(C-x, v));
  }
  
  sort(sushi_forward.begin(), sushi_forward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  sort(sushi_backward.begin(), sushi_backward.end(),
       [](const auto& item1, const auto& item2) {return item1.first < item2.first; });
  long long int max_cal_forward = calc_max_cal(sushi_forward);
  long long int max_cal_backward = calc_max_cal(sushi_backward);
  
  long long int max_cal = max(max_cal_forward, max_cal_backword);
  long long int sum_sushi_cal = 0;
  for (auto& s : sushi_forward) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_backword);
  }
  sum_sushi_cal = 0;
  for (auto& s : sushi_backword) {
    sum_sushi_cal += s.second;
    max_cal = max(max_cal, sum_sushi_cal - s.first - s.first + max_cal_forward);
  }
  
  cout << max_cal;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'sushi_forward' was not declared in this scope
   29 |     sushi_forward.push_back(make_pair(x, v));
      |     ^~~~~~~~~~~~~
a.cc:30:5: error: 'sushi_backward' was not declared in this scope
   30 |     sushi_backward.push_back(make_pair(C-x, v));
      |     ^~~~~~~~~~~~~~
a.cc:33:8: error: 'sushi_forward' was not declared in this scope
   33 |   sort(sushi_forward.begin(), sushi_forward.end(),
      |        ^~~~~~~~~~~~~
a.cc:35:8: error: 'sushi_backward' was not declared in this scope
   35 |   sort(sushi_backward.begin(), sushi_backward.end(),
      |        ^~~~~~~~~~~~~~
a.cc:40:48: error: 'max_cal_backword' was not declared in this scope; did you mean 'max_cal_backward'?
   40 |   long long int max_cal = max(max_cal_forward, max_cal_backword);
      |                                                ^~~~~~~~~~~~~~~~
      |                                                max_cal_backward
a.cc:47:18: error: 'sushi_backword' was not declared in this scope
   47 |   for (auto& s : sushi_backword) {
      |                  ^~~~~~~~~~~~~~
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] arr = sc.nextLine().split(" ");
		int n = Integer.parseInt(arr[0]);
		long c = Long.parseLong(arr[1]);
		long[] x = new long[n];
		long[] v = new long[n];
		for(int i=0 ;i<n; i++) {
			arr = sc.nextLine().split(" ");
			x[i] = Long.parseLong(arr[0]);
			v[i] = Long.parseLong(arr[1]);
		}
		sc.close();

		// table作成
		long[][] tokeiTable = new long[3][n+1];
		long[][] hanTokeiTable = new long[3][n+1];

		for(int i=0; i<3; i++)
			Arrays.fill(tokeiTable[i], 0);
		for(int i=1; i<n+1; i++) {
			tokeiTable[0][i] = tokeiTable[0][i-1] + v[i-1];
			tokeiTable[1][i] = x[i-1];
			tokeiTable[2][i] = tokeiTable[0][i] - tokeiTable[1][i];
		}
		for(int i=0; i<3; i++) {
			Arrays.fill(hanTokeiTable[i], 0);
		}
		for(int i=n-1; i>=0; i--) {
			hanTokeiTable[0][i] = hanTokeiTable[0][i+1] + v[i];
			hanTokeiTable[1][i] = c - x[i];
			hanTokeiTable[2][i] = hanTokeiTable[0][i] - hanTokeiTable[1][i];
		}
/*
		for(int i=0; i<3; i++) {
			for(int j=0; j<n+1; j++) {
				System.out.print(tokeiTable[i][j]+"\t");
			}
			System.out.println();
		}
		System.out.println();
		for(int i=0; i<3; i++) {
			for (int j=0; j<n+1; j++) {
				System.out.print(hanTokeiTable[i][j]+"\t");
			}
			System.out.println();
		}
*/
		// 計算
		long max = tokeiTable[2][0];
		for(int i=1; i<n+1; i++) {
			int tokeiMaxIndex = i;
			// hantokei計算
			int hanTokeiMaxIndex = i;
			for(int j=i+1; j<n+1; j++) {
				if(hanTokeiTable[2][hanTokeiMaxIndex]<hanTokeiTable[2][j]) {
					hanTokeiMaxIndex = j;
				}
			}
			long total = tokeiTable[2][tokeiMaxIndex] + hanTokeiTable[2][hanTokeiMaxIndex]
					- (tokeiTable[1][tokeiMaxIndex] < hanTokeiTable[1][hanTokeiMaxIndex] ? tokeiTable[1][tokeiMaxIndex] : hanTokeiTable[1][hanTokeiMaxIndex]);
			if(max<total) {
				max = total;
			}
		}

		System.out.println(max);
	}


Compiler output:
Main.java:73: error: reached end of file while parsing
	}
	 ^
1 error
Language: Java

import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    long C = Long.parseLong(sc.next());

    long x[] = new long[N];
    long v[] = new long[N];

    long getCalorieForward[] = new long[N];
    long sumV = 0;
    long maxForward = -1;
    int maxIndexForward = 0;

    for (int i = 0; i < N; i++) {
      x[i] = Long.parseLong(sc.next());
      v[i] = Long.parseLong(sc.next());
      sumV += v[i];
      getCalorieForward[i] = sumV - x[i];
      if (getCalorieForward[i] > maxForward) {
        maxForward = getCalorieForward[i];
        maxIndexForward = i;
      }
    }

    long getCalorieBack[] = new long[N];
    sumV = 0;
    long maxBack = -1;
    int maxIndexBack = 0;
    for (int i = 0; i < N; i++) {
      sumV += v[N - 1 - i];
      getCalorieBack[i] = sumV - C - x[N - 1 - i];
      if (getCalorieBack[i] > maxBack) {
        maxBack = getCalorieBack[i];
        maxIndexBack = N - 1 - i;
      }
    }

    if (maxForward < 0 && maxBack < 0) {
      System.out.println(0);
    } else if (maxForward < 0) {
      System.out.println(maxBack);
    } else if (maxBack < 0) {
      System.out.println(maxForward);
    } else if (maxIndexForward < maxIndexBack) {
      System.out.println(maxForward + maxBack);
    } else {
      System.out.println(Math.max(maxForward, maxBack));
    }

  }

Compiler output:
Main.java:56: error: reached end of file while parsing
  }
   ^
1 error
Language: C++

#include<iostream>
using namespace std;

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

  int x[N], v[N];
  for(int i=0; i<N; ++i){
    cin >> x[i] >> v[i];
  }

 int vsum=0;
  long long left=0;
  for (int i=0; i<N, ++i){
      vsum += v[i];
      if(left < vsum-x[i]) left = vsum-x[i];
    }
  vsum =0;
  long long right=0;

for (int i=N-1; i>=0, --i){
    vsum += v[i];
    if(right < vsum-(C-x[i])) right = vsum-(C-x[i]);
  }
if (left<=0 && right <=0) cout << 0;
else if (left < right) cout << left;
else cout << right;


  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: expected ';' before ')' token
   15 |   for (int i=0; i<N, ++i){
      |                         ^
      |                         ;
a.cc:22:26: error: expected ';' before ')' token
   22 | for (int i=N-1; i>=0, --i){
      |                          ^
      |                          ;
Language: C++

#include<iostream>
using namespace std;

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

  int x[N], v[N] total[N];
  for(int i=0; i<N; ++i){
    cin >> x[i] >> v[i];
  }
  
 int vsum=0;
  long long left=0;
    for (int i=0; i<N, ++i){
      vsum += v[i];
      if(left < vsum-x[i]) left = vsum-x[i];
    }
  vsum =0;
  long long right=0;

  for (int i=N-1; i>=0, --i){
    vsum += v[i];
    if(right < vsum-(C-x[i])) right = vsum-(C-x[i]);
  }
if (left<=0 && right <=0) cout << 0;
else if (left < right) cout << left;
else cout << right;
  

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:18: error: expected initializer before 'total'
    8 |   int x[N], v[N] total[N];
      |                  ^~~~~
a.cc:10:20: error: 'v' was not declared in this scope
   10 |     cin >> x[i] >> v[i];
      |                    ^
a.cc:15:27: error: expected ';' before ')' token
   15 |     for (int i=0; i<N, ++i){
      |                           ^
      |                           ;
a.cc:16:15: error: 'v' was not declared in this scope
   16 |       vsum += v[i];
      |               ^
a.cc:22:28: error: expected ';' before ')' token
   22 |   for (int i=N-1; i>=0, --i){
      |                            ^
      |                            ;
a.cc:23:13: error: 'v' was not declared in this scope
   23 |     vsum += v[i];
      |             ^