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

#include<cstdio>

#define Fast register
#define int long long
inline int Min(const int&x,const int&y){return x<y?x:y;}
inline void chkMin(int&x,const int&y){x>y&&(x=y);}
#undef int

int main(){
	#define int long long
	Fast int A,B,C,X,Y;
	scanf(" %lld %lld %lld %lld %lld",&A,&B,&C,&X,&Y);
	C<<=1;
	Fast int Ans=A*X+B*Y;
	if(X<Y)chkMin(Ans,C*X+B*(Y-X));
	if(X>Y)chkMin(Ans,C*Y+A*(X-Y));
	return(printf("%lld",Min(Ans,C*Max(X,Y))),0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |         Fast int A,B,C,X,Y;
      |                  ^
a.cc:11:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |         Fast int A,B,C,X,Y;
      |                    ^
a.cc:11:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |         Fast int A,B,C,X,Y;
      |                      ^
a.cc:11:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |         Fast int A,B,C,X,Y;
      |                        ^
a.cc:11:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   11 |         Fast int A,B,C,X,Y;
      |                          ^
a.cc:14:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   14 |         Fast int Ans=A*X+B*Y;
      |                  ^~~
a.cc:17:40: error: 'Max' was not declared in this scope
   17 |         return(printf("%lld",Min(Ans,C*Max(X,Y))),0);
      |                                        ^~~
Language: C++

#include <iostream>
using namespace std;

int main()
{
    int a, b, c, x, y;
    long ans = 0;
    cin >> a >> b >> c >> x >> y;
    vector<long> v;
    if(c >= (a+b)/2){
        ans = a*x + b*y;
    }else{
        long t = 2*c*(max(x,y));
        if(x > y){
            ans = 2*c*y + (x-y)*a;
        }else{
            ans = 2*c*x + (y-x)*b;
        }
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<long> v;
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:9:12: error: expected primary-expression before 'long'
    9 |     vector<long> v;
      |            ^~~~
Language: C++

#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

int main() {
	ll A, B, C;
	ll X, Y;
	ll ans = 10000000000000;
	cin >> A >> B >> C >> X >> Y;
	int N = 2 * max(X, Y);
	rep(N) {
		mini((ll)ans, i * 2 * C + max((ll)0, (X - i)*A) + max((ll)0, (Y - i)*B));
	}
	say(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:65:22: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'll' {aka 'long long int'}
   65 |                 mini((ll)ans, i * 2 * C + max((ll)0, (X - i)*A) + max((ll)0, (Y - i)*B));
      |                      ^~~~~~~
a.cc:54:14: note:   initializing argument 1 of 'void mini(T&, T) [with T = long long int]'
   54 | void mini(T &a, T b) {
      |           ~~~^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

#define int ll

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;


    int Min = INF;

    rep3(ai, 5000) {

        rep3(bi, 5000) {
            int ci = max(x - ai, y - bi) *2;
            if (ai > x || bi > y || ci < 0) continue;
            int cost = a * ai + b * bi + ci*c;
            Min = min(Min, cost);
        }
    }

    cout << Min << endl;

    return 0;
}

Compiler output:
a.cc:31:13: error: '::main' must return 'int'
   31 | #define int ll
      |             ^~
a.cc:33:1: note: in expansion of macro 'int'
   33 | int main() {
      | ^~~
Language: C++

// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"


/*

#include<bits/stdc++.h>
/*
*/

using namespace std;

typedef pair<long long int, vector<long long int>> PLVL;


class combination{
public:

//Nの最大値がわかれば代入する
	combination(long long int combinationThreshold = 1e7){
		( *this ).combinationThreshold = combinationThreshold + 2;
	}

	//a^p % mod
	long long int powmod(long long int A, long long int P, long long int M = LLONG_MAX){
		long long int ans = 1;
		long long int mul = A;
		for( ; P > 0; P >>= 1, mul = ( mul*mul ) % M ){
			if( ( P & 1 ) == 1 ) ans = ( ans*mul ) % M;
		}
		return ans;
	}

	//nCk mod m
	long long int cb(long long int N, long long int K, long long int M = LLONG_MAX){
		if( N < combinationThreshold ){// 事前計算O(N)、答えるのはO(1)
			if( inv.size() == 0 ){
				inv = vector<long long int>(combinationThreshold);
				inv[1] = 1;
				for( long long int i = 2; i < combinationThreshold; i++ ){
					inv[i] = M - ( M / i )*inv[M%i] % M;
				}
				fact = vector<long long int>(combinationThreshold);
				fact[0] = 1;
				revFact = vector<long long int>
					(combinationThreshold);
				revFact[0] = 1;
				for( long long int i = 1; i < combinationThreshold; i++ ){
					fact[i] = ( fact[i - 1] * i ) % M;
					revFact[i] = ( revFact[i - 1] * inv[i] ) % M;
				}
			}
			return ( ( ( fact[N] * revFact[K] ) % M )*revFact[N - K] ) % M;
		} else{
			return cbOnce(N, K, M);
		}
	}

	//一回だけなら最速 O(K + log(M))
	long long int cbOnce(long long int N, long long int K, long long int M = LLONG_MAX){
		if( K > N / 2 ) return cbOnce(N, N - K, M);
		long long int ans = 1;
		long long int div = 1;
		for( long long int i = 0; i < K; i++ ){
			ans *= N - i;
			ans %= M;
			div *= i + 1;
			div %= M;
		}
		ans *= powmod(div, M - 2, M);
		return ans % M;
	}

private:
	vector<vector<long long int>>C;//3000以下の答え
	vector<long long int>fact;//階乗
	vector<long long int>revFact;//階乗の逆元
	vector<long long int>inv;//mod pでの逆元

	long long int combinationThreshold;//Nの最大値がわかれば入れる。
};

int main(){
	long long int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	long long int m = min(X, Y);
	long long int ans = C * 2 * m + ( X - m )*A + ( Y - m )*B;

	long long int ma = max(X, Y);
	ans = min(ans, ma*C * 2);

	cout << min(ans, A * X + B * Y) << endl;

}


Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

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

int main() {
    int a,b,c,x,y; cin >> a >> b >> c >> x >> y;
    int res = 0;
    int allc = INT_MAX;
    if ((a + b) / 2 > c) {
        if (x > y) {
            res += c * y * 2;
            res += (x - y) * a;
            allc = c * x * 2;
        } else {
            res += c * x * 2;
            res += (y - x) * b;
            allc = c * y * 2;
        }
    } else {
        res += a * x;
        res += b * y;
    }
    cout << min(res, allc) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: 'INT_MAX' was not declared in this scope
   10 |     int allc = INT_MAX;
      |                ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <algorithm>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

a,b,c,x,y = map(int, input().split())
def hoge(n):
    nx = max(0, x-n)
    ny = max(0, y-n)
    return 2*n*c + nx*a+ny*b

ans = 10**10

for i in range(10**4):
    ans = min(ans, hoge(i))

print(ans)

Compiler output:
a.cc:1:1: error: 'a' does not name a type
    1 | a,b,c,x,y = map(int, input().split())
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

long long main() {
    long long a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if (2*c < a + b) {
        long long q = min(x,y);
        x-=q;
        y-=q;
        cout << q * c * 2 + x * a + y * b;
    } else
        cout << x * a + y * b;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: Java

import java.io.*;
import java.util.*;

public class C implements Runnable{
	public static void main (String[] args) {new Thread(null, new C(), "_cf", 1 << 28).start();}

	public void run() {
		DeoxysS fs = new DeoxysS();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		int A = fs.nextInt();
		int B = fs.nextInt();
		int C = fs.nextInt();
		int x = fs.nextInt();
		int y = fs.nextInt();
		
		long min = (long)1e18;
		for(int AB = 0; AB <= 200000; AB += 2) {
			long tres = (long)AB * C;
			long tx = x - (AB / 2);
			long ty = y - (AB / 2);
			tres += Math.max(0, tx) * A;
			tres += Math.max(0, ty) * B;
			min = Math.min(min, tres);
		}
		out.println(min);

		out.close();
	}
	
	class DeoxysS {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public DeoxysS() {
			in = new BufferedInputStream(System.in, BS);
		}

		public DeoxysS(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

}

Compiler output:
Main.java:4: error: class C is public, should be declared in a file named C.java
public class C implements Runnable{
       ^
1 error
Language: C++

#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())tmp=tmp*10+c-'0';
    return tmp*f;
}
inline power(ll a,ll b)
{
	ll tmp=1;
	for(;b;b>>=1){if(b&1)tmp=tmp*a%mod; a=a*a%mod;}
	return tmp;
}
using namespace std;
int main()
{
	ll a=read(),b=read(),c=read(),x=read(),y=read();
	if(2*c<a+b){
		if(x>y)printf("%lld\n",y*2*c+(x-y)*a);
		else printf("%lld\n",x*2*c+(y-x)*b);
	}
	else printf("%lld\n",a*x+b*y);
	return 0;
}

Compiler output:
a.cc:23:8: error: ISO C++ forbids declaration of 'power' with no type [-fpermissive]
   23 | inline power(ll a,ll b)
      |        ^~~~~
Language: C++

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

const int N = 100005;

long long x[N], c[N], cc[N], cmx[N], ccmx[N], v[N];

int main() {
	int n; long long C;
	cin >> n >> C;
	for (int i = 1; i <= n; i++)cin >> x[i] >> y[i];
	for (int i = 1; i <= n; i++) {
		c[i] = c[i - 1] + v[i] - (x[i] - x[i - 1]);
		cmx[i] = max(cmx[i - 1], c[i]);
	}
	x[n + 1] = C;
	for (int i = n; i >= 1; i--) {
		cc[n - i + 1] = cc[n - i] + v[i] - (x[i + 1] - x[i]);
		ccmx[n - i + 1] = max(ccmx[n - i + 1], cc[n - i + 1]);
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = max(ans, c[i] - x[i] + ccmx[n - i]);
		ans = max(ans, cc[i] - (C - x[n - i + 1]) + cmx[n - i]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:52: error: 'y' was not declared in this scope
   12 |         for (int i = 1; i <= n; i++)cin >> x[i] >> y[i];
      |                                                    ^
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    long C = sc.nextLong();
    long[] x = new long[n];
    long[] v = new long[n];
    long ans = 0;
    
    for(int i=0; i<N; i++){
      x[i] = sc.nextLong();
      v[i] = sc.nextLong();
    }
    
    long sum1 = 0;
    long sum2 = 0;
    long[] a = new long[n+1];
    long[] b= new long[n+1];
    
    for(int i=0; i<N; i++){
      sum1 += v[i];
      a[i+1] =  sum1 - x[i];
      a[i+1] = Math.max(a[i], a[i+1]);
      sum2 += v[N-i-1];
      b[i+1] = sum2 - (C - x[N-i-1]);
      b[i+1] = Math.max(b[i], b[i+1]);
    }
    
    for(int i=0; i<N; i++){
      long a1 = Math.max(a[i+1], b[i+1] - x[i] + b[N-i-1]);
      long a2 = Math.max(b[i+1], b[i+1] - (c-x[N-i-1]) + a[N-i-1]);
      ans = Math.max(a1, a2);
    }
    System.out.println(ans);
  }
}


Compiler output:
Main.java:9: error: cannot find symbol
    long[] x = new long[n];
                        ^
  symbol:   variable n
  location: class Main
Main.java:10: error: cannot find symbol
    long[] v = new long[n];
                        ^
  symbol:   variable n
  location: class Main
Main.java:20: error: cannot find symbol
    long[] a = new long[n+1];
                        ^
  symbol:   variable n
  location: class Main
Main.java:21: error: cannot find symbol
    long[] b= new long[n+1];
                       ^
  symbol:   variable n
  location: class Main
Main.java:34: error: cannot find symbol
      long a2 = Math.max(b[i+1], b[i+1] - (c-x[N-i-1]) + a[N-i-1]);
                                           ^
  symbol:   variable c
  location: class Main
5 errors
Language: C++

#include <iostream>
using namespace std;

int main() {
    long long n, c;
    cin >> n >> c;
    long long x[n], v[n], dp[n + 1], result = 0;
    dp[0] = 0;
    for (long long i = 0; cin >> x[i] >> v[i]; i++) {
    }
    for (long long i = 0, sum = 0; i < n; i++) {
        sum += v[i];
        dp[i + 1] = max(dp[i], sum - x[i]);
    }
    for (long long i = n - 1, sum = 0; i > 0; i--) {
        sum += v[i];
        result = max({result, sum - 2 * (c - x[i]) + dp[i], dp[i]});
    }
    dp[n] = 0;
    for (long long i = n - 1, sum = 0; i >= 0; i--) {
        sum += v[i];
        dp[i] = max(dp[i + 1], sum - c + x[i]);
    }
    for (long long i = 0, sum = 0; i < n; i++) {
        sum += v[i];
        result = max({result, sum - 2 * x[i] + dp[i + 1], dp[i + 1]});
    }
    cout << result;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   17 |         result = max({result, sum - 2 * (c - x[i]) + dp[i], dp[i]});
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: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:   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
a.cc:26:21: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   26 |         result = max({result, sum - 2 * x[i] + dp[i + 1], dp[i + 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:   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
Language: C++

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


int main()
{
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, 0, n)
        cin >> x[i] >> v[i];

    vector<ll> cumsum(n + 1), cumsum_rev(n + 1);
    cumsum[0] = cumsum_rev[0] = 0;
    rep(i, 0, n)
    {
        cumsum[i + 1] = cumsum[i] + v[i];
        cumsum_rev[i + 1] = cumsum_rev[i] + v[n - i - 1];
    }

    vector<ll> back(n + 1), back_rev(n + 1);
    back[0] = back_rev[0] = 0;
    rep(i, 0, n) 
    {
        back[i + 1] = max(back[i], cumsum[i + 1] - x[i] * 2);
        back_rev[i + 1] = max(back_rev[i], cumsum_rev[i + 1] - (c - x[n - i - 1]) * 2);
    }

    ans = max(cumsum[n] - x[n - 1], cumsum_rev[n] - (c - x[0]));
    ans = max(0LL, ans);
    rep(i, 0, n - 1)
    {
        ll cand1 = cumsum[i + 1] + back_rev[n - i - 1] - x[i];
        ll cand2 = cumsum_rev[i + 1] + back[n - i - 1] - (c - x[n - 1 - i]);
        ans = max(ans, cand1);
        ans = max(ans, cand2);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |     ans = max(cumsum[n] - x[n - 1], cumsum_rev[n] - (c - x[0]));
      |     ^~~
      |     abs
Language: C++

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


int main()
{
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, 0, n)
        cin >> x[i] >> v[i];

    vector<ll> cumsum(n + 1), cumsum_rev(n + 1);
    cumsum[0] = cumsum_rev[0] = 0;
    rep(i, 0, n)
    {
        cumsum[i + 1] = cumsum[i] + v[i];
        cumsum_rev[i + 1] = cumsum_rev[i] + v[n - i - 1];
    }

    vector<ll> back(n + 1), back_rev(n + 1);
    back[0] = back_rev[0] = 0;
    rep(i, 0, n) 
    {
        back[i + 1] = max(back[i], cumsum[i + 1] - x[i] * 2);
        back_rev[i + 1] = max(back_rev[i], cumsum_rev[i + 1] - (c - x[n - i - 1]) * 2);
    }

    ans = max(cumsum[n] - x[n - 1], cumsum_rev[n] - (c - x[0]));
    ans = max(0, ans);
    rep(i, 0, n - 1)
    {
        ll cand1 = cumsum[i + 1] + back_rev[n - i - 1] - x[i];
        ll cand2 = cumsum_rev[i + 1] + back[n - i - 1] - (c - x[n - 1 - i]);
        ans = max(ans, cand1);
        ans = max(ans, cand2);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |     ans = max(cumsum[n] - x[n - 1], cumsum_rev[n] - (c - x[0]));
      |     ^~~
      |     abs
Language: C++

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


int main()
{
    ll n, c;
    cin >> n >> c;
    vector<ll> x(n), v(n);
    rep(i, 0, n)
        cin >> x[i] >> v[i];

    vector<ll> cumsum(n + 1), cumsum_rev(n + 1);
    cumsum[0] = cumsum_rev[0] = 0;
    rep(i, 0, n)
    {
        cumsum[i + 1] = cumsum[i] + v[i];
        cumsum_rev[i + 1] = cumsum_rev[i] + v[n - i - 1];
    }

    vector<ll> back(n + 1), back_rev(n + 1);
    back[0] = back_rev[0] = 0;
    rep(i, 0, n) 
    {
        back[i + 1] = max(back[i], cumsum[i + 1] - x[i] * 2);
        back_rev[i + 1] = max(back_rev[i], cumsum_rev[i + 1] - (c - x[n - i - 1]) * 2);
    }

    ll ans = 0;
    ans = max(cumsum[n] - x[n - 1]], cumsum_rev[n] - (c - x[0]));
    rep(i, 0, n - 1)
    {
        ll cand1 = cumsum[i + 1] + back_rev[n - i - 1] - x[i];
        ll cand2 = cumsum_rev[i + 1] + back[n - i - 1] - (c - x[n - 1 - i]);
        ans = max(ans, cand1);
        ans = max(ans, cand2);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:35: error: expected ')' before ']' token
   33 |     ans = max(cumsum[n] - x[n - 1]], cumsum_rev[n] - (c - x[0]));
      |              ~                    ^
      |                                   )
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--)

signed main(){
	int n,c;cin>>n>>c;
	vector<int> x(n),v(n),s(n+1,0),a(n+1,0),b(n+1,0);
	rep(i,n)cin>>x[i]>>v[i];
	rep(i,n){
	s[i+1]=s[i]+v[i];
	a[i+1]=max(a[i],s[i]-2*x[i]);
	b[i+1]=max(b[i],s[i]-x[i]);
	}
	int ans=b[n],a0=0,b0=0;
	for(int i=n-1;i>=1;i++){
		a0=max(a0,s[n]-s[i]+2*(c-x[i]));
		b0=max(b0,s[n]-s[i]+(c-x[i]));
		ans=max(ans,a[i-1]+b0,b[i-1]+a0);
	}
	cout<<ans<<endl;

}


Compiler output:
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: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:20:10:   required from here
   20 |                 ans=max(ans,a[i-1]+b0,b[i-1]+a0);
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
//using lint=long long int;
int n;
int c;
vector<int> x,v;
vector<int>f,g;

int inf=1e18;

void fill_vector(vector<int>a,vector<int>b){
	f.resize(n+1,0);g.resize(n+1,0);
	for(int i=0;i<n;i++){
		f[i+1]=f[i]+b[i];
	}
	for(int i=0;i<n;i++){
		g[i+1]=max(g[i],f[i+1]-a[i]);
	}
}


signed main(){
	cin>>n>>c;
	x.resize(n);
	v.resize(n);
	for(int i=0;i<n;i++){
		cin>>x[i]>>v[i];
	}

	fill_vector(x,v);
//	for(auto&& u:f)cerr<<u<<endl;
//	for(auto&& u:g)cerr<<u<<endl;
//	cerr<<endl;

	int ans=max(g[n],f[n]-min(c-x[0],x[n-1]));
		cerr<<ans<<endl;
	for(int i=0;i<n-1;i++){
		int y=g[i+1]+f[n]-f[i+1]-2*(c-x[i+1]);
		ans=max(ans,y);
	//	cerr<<y<<" "<<ans<<endl;
	}
  	cout<<endl;
	reverse(begin(x),end(x));
	reverse(begin(v),end(v));

	fill_vector(x,v);
	ans=max(ans,g[n]));

	for(int i=0;i<n-1;i++){
		int y=g[i+1]+f[n]-f[i+1]-2*(c-x[i+1]);
		ans=max(ans,y);
	//	cerr<<y<<" "<<ans<<endl;
	}
	cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:26: error: expected ';' before ')' token
   48 |         ans=max(ans,g[n]));
      |                          ^
      |                          ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
//using lint=long long int;
int n;
int c;
vector<int> x,v;
vector<int>f,g;

int inf=1e18;

void fill_vector(vector<int>a,vector<int>b){
	f.resize(n+1,0);g.resize(n+1,0);
	for(int i=0;i<n;i++){
		f[i+1]=f[i]+b[i];
	}
	for(int i=0;i<n;i++){
		g[i+1]=max(g[i],f[i+1]-a[i]);
	}
}


signed main(){
	cin>>n>>c;
	x.resize(n);
	v.resize(n);
	for(int i=0;i<n;i++){
		cin>>x[i]>>v[i];
	}

	fill_vector(x,v);
//	for(auto&& u:f)cerr<<u<<endl;
//	for(auto&& u:g)cerr<<u<<endl;
//	cerr<<endl;

	int ans=max(g[n],f[n]-min(c-x[0],x[n-1]));
		cerr<<ans<<endl;
	for(int i=0;i<n-1;i++){
		int y=g[i+1]+f[n]-f[i+1]-2*(c-x[i+1]);
		ans=max(ans,y);
	//	cerr<<y<<" "<<ans<<endl;
	}
  	cout<<endl;
	reverse(begin(x),end(x));
	reverse(begin(v),end(v));

	fill_vector(x,v);
	int ans=max(ans,g[n]));

	for(int i=0;i<n-1;i++){
		int y=g[i+1]+f[n]-f[i+1]-2*(c-x[i+1]);
		ans=max(ans,y);
	//	cerr<<y<<" "<<ans<<endl;
	}
	cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:13: error: redeclaration of 'long long int ans'
   48 |         int ans=max(ans,g[n]));
      |             ^~~
a.cc:36:13: note: 'long long int ans' previously declared here
   36 |         int ans=max(g[n],f[n]-min(c-x[0],x[n-1]));
      |             ^~~
Language: C++

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

int n,c;
vector<int> x,v;
vector<int>f,g;

int inf=1e18;

void fill_vector(vector<int>a,vector<int>b){
	f.resize(n+1,0);g.resize(n+1,0);
	for(int i=0;i<n;i++){
		f[i+1]=f[i]+b[i];
	}
	int tmp=-inf;
	for(int i=0;i<n;i++){
		g[i+1]=max(g[i],f[i+1]-a[i]);
	}
}


int main(){
	cin>>n>>c;
	x.resize(n);
	v.resize(n);
	for(int i=0;i<n;i++){
		cin>>x[i]>>v[i];
	}

	fill_vector(x,v);
	int ans=f[n]-min({2*(c-x[0]),2*(c-x[n-1]),c});

	for(int i=0;i<n-1;i++){
		ans=max(ans,g[i+1]+f[n]-f[i+1]-2*(c-x[i+1]));
	}
	reverse(begin(x),end(x));
	reverse(begin(v),end(v));

	fill_vector(x,v);
	for(int i=0;i<n-1;i++){
		ans=max(ans,g[i+1]+f[n]-f[i+1]-2*(c-x[i+1]));
	}
	cout<<ans<<endl;

}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

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

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 2e5 + 5;

ll A[N],X[N],M[N],n,k,i,p,a,x,ans;

int main(){
    scanf("%lld%lld",&n,&k);
    for(i=1;i<=n;i++){
        scanf("%lld%lld",&x,&a);
        X[i] = x;
        A[i] = a;
    }

    p = 0;
    for(i=1;i<n;i++){
        p += A[i];
        M[n-i] = p - X[i]*2;
    }

    for(i=n-1; i ;i--) M[i] = max(M[i] , M[i+1]);

    p = 0;
    for(i=n; i ;i--){
        p += A[i];
        ans = max(ans , p + X[i]-k + M[n-i+1]);
    }
    //////
    p = 0;
    for(i=n; i>1 ;i--){
        p += A[i];
        M[i-1] = p - (k-X[i])*2;
    }

    for(i=n-1; i ;i--) M[i] = max(M[i] , M[i+1]);

    p = 0;
    for(i=1;i<=n;i++){
        p += A[i];
        ans = max(ans , p - X[i] + M[i]);
    }

    cout << ans;
    return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:53:14: error: expected '}' at end of input
   53 |     return 0;
      |              ^
a.cc:16:11: note: to match this '{'
   16 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

#define int ll

int main () {
  cin.tie(0);
  cout << setprecision(10);

  ll n, c; cin >> n >> c;
  vll x(n), v(n);
  REP(i, n) {
    cin >> x[i] >> v[i];
  }

  // clockwise go
  vll sr(n);
  sr[0] = v[0] - x[0];
  FOR(i, 1, n) {
    sr[i] = sr[i-1] + v[i] - (x[i] - x[i-1]);
  }
  
  vll sl(n);
  sl[0] = v[n-1] - (c - x[n-1]);
  RFOR(i, 1, n) {
    sl[i] = sl[i-1] + v[n-i-1] - (x[n-i-1] - x[n-i-2]);
  }

  vll ma1r(n);
  ma1r[0] = sr[0];
  FOR(i, 1, n) {
    ma1r[i] = max(ma1r[i-1], sr[i]);
  }

  vll ma1l(n);
  ma1l[0] = sl[0];
  FOR(i, 1, n) {
    ma1l[i] = max(ma1l[i-1], sl[i]);
  }

  vll ma2r(n);
  ma2r[0] = sr[0] - x[0];
  FOR(i, 1, n) {
    ma2r[i] = max(ma2r[i-1], sr[i] - x[i]);
  }

  vll ma2l(n);
  ma2l[0] = sl[0] - (c - x[n-1]);
  FOR(i, 1, n) {
    ma2l[i] = max(ma2l[i-1], sl[i] - (c - x[n-i-1]));
  }


  // printv(sr);
  // printv(sl);
  // printv(ma1r);
  // printv(ma1l);
  // printv(ma2r);
  // printv(ma2l);

  ll ans = max(0ll, max(ma1r[n-1], ma1l[n-1]));
  FOR(i, 0, n-1) {
    // cout << i << ":" << ans << endl;
    ans = max(ans, max(max(0ll, ma1r[i]) + max(0ll, ma2l[n-2-i]), max(0ll, ma2r[i]) + max(0ll, ma1l[n-2-i])));
  }
  cout << ans << endl;
}


Compiler output:
a.cc:38:13: error: '::main' must return 'int'
   38 | #define int ll
      |             ^~
a.cc:40:1: note: in expansion of macro 'int'
   40 | int main () {
      | ^~~
Language: C++

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

using namespace std;
int main() {
  long long n, c;
  vector<long long> x, v, index;
  vector<long long> l(1, 0), r(1, 0);
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    int xi, vi;
    cin >> xi >> vi;
    x.push_back(xi);
    v.push_back(vi);
    index.push_back(i);
  }
  sort(index.begin(), index.end(), [&](int i, int j) -> int {
    return x[i] < x[j];
  });
  // clockwise
  for (int j = 0; j < n; j++) {
    int i = index[j];
    int dx = x[i] - (j ? x[index[j-1]] : 0);
    l.push_back(l.back() - dx + v[i]);
  }
  // anticlockwise
  for (int j = n; j--;) {
    int i = index[j];
    int dx = c - x[i] - (j < n - 1 ? c - x[index[j+1] : c);
    r.push_back(r.back() - dx + v[i]);
  }
  long long ans = max(*max_element(l.begin(), l.end()), *max_element(r.begin(), r.end()));
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:54: error: expected ']' before ':' token
   31 |     int dx = c - x[i] - (j < n - 1 ? c - x[index[j+1] : c);
      |                                                      ^~
      |                                                      ]
Language: C++

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

using namespace std;
int main() {
  long long n, c;
  vector<long long> x, v, index;
  vector<long long> l(1, 0), r(1, 0);
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    int xi, vi;
    cin >> xi >> vi;
    x.push_back(xi);
    v.push_back(vi);
    index.push_back(i);
  }
  sort(index.begin(), index.end(), [&](int i, int j) -> int {
    return x[i] < x[j];
  });
  // clockwise
  for (int j = 0; j < n; j++) {
    int i = index[j];
    l.push_back(l.back() - x[i] + v[i]);
  }
  // anticlockwise
  for (int j = n; j--;) {
    int i = index[j];
    r.push_back(r.back() - (c - x[i]) + v[i]);
  }
  long long ans = max(*max_element(l.begin(), l.end()), *max_element(r.begin(), r.end()))
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:3: error: expected ',' or ';' before 'cout'
   33 |   cout << ans << endl;
      |   ^~~~
Language: C++

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

using namespace std;
int main() {
  long long n, c
  vector<long long> x, v, index;
  vector<long long> l(1, 0), r(1, 0);
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    int xi, vi;
    cin >> xi >> vi;
    x.push_back(xi);
    v.push_back(vi);
    index.push_back(i);
  }
  sort(index.begin(), index.end(), [&](int i, int j) -> int {
    return x[i] < x[j];
  });
  // clockwise
  for (int j = 0; j < n; j++) {
    int i = index[j];
    l.push_back(l.back() - x[i] + v[i]);
  }
  // anticlockwise
  for (int j = n; j--;) {
    int i = index[j];
    r.push_back(r.back() - (c - x[i]) + v[i]);
  }
  long long ans = max(*max_element(l.begin(), l.end()), *max_element(r.begin(), r.end()))
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected initializer before 'vector'
    9 |   vector<long long> x, v, index;
      |   ^~~~~~
a.cc:11:15: error: 'c' was not declared in this scope
   11 |   cin >> n >> c;
      |               ^
a.cc:15:5: error: 'x' was not declared in this scope; did you mean 'xi'?
   15 |     x.push_back(xi);
      |     ^
      |     xi
a.cc:16:5: error: 'v' was not declared in this scope; did you mean 'vi'?
   16 |     v.push_back(vi);
      |     ^
      |     vi
a.cc:17:5: error: 'index' was not declared in this scope
   17 |     index.push_back(i);
      |     ^~~~~
a.cc:19:8: error: 'index' was not declared in this scope
   19 |   sort(index.begin(), index.end(), [&](int i, int j) -> int {
      |        ^~~~~
a.cc: In lambda function:
a.cc:20:12: error: 'x' was not declared in this scope
   20 |     return x[i] < x[j];
      |            ^
a.cc: In function 'int main()':
a.cc:25:28: error: 'x' was not declared in this scope
   25 |     l.push_back(l.back() - x[i] + v[i]);
      |                            ^
a.cc:25:35: error: 'v' was not declared in this scope
   25 |     l.push_back(l.back() - x[i] + v[i]);
      |                                   ^
a.cc:30:33: error: 'x' was not declared in this scope
   30 |     r.push_back(r.back() - (c - x[i]) + v[i]);
      |                                 ^
a.cc:30:41: error: 'v' was not declared in this scope
   30 |     r.push_back(r.back() - (c - x[i]) + v[i]);
      |                                         ^
a.cc:33:3: error: expected ',' or ';' before 'cout'
   33 |   cout << ans << endl;
      |   ^~~~
Language: C++

#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n, c);
	vector< int > x(n), v(n);
	vector< int > sm(n + 1, 0), rev(n, 0), rev_sm(n + 1, 0), rev_ans(n + 1, 0);
	REP(i, n) {
		cin >> x[i] >> v[i];
	}
	
	auto solve = [&]() {
		sm[0] = v[0];
		REP(i, n) {
			sm[i] = sm[i - 1] + v[i]; // 累積和
		}

		rev_sm[n - 1] = v[n - 1];
		RREP(i, n - 2) {
			rev_sm[i] = rev_sm[i + 1] + v[i]; // 逆回りの時の累積和
		}

		REP(i, n) {
			rev[i] = c - x[i];           // 逆回りの時のi番目のsushiまでのdistance
		}

		// 逆回りの時の最適解
		rev_ans[n - 1] = rev_sm[n - 1] - rev[n - 1];
		RREP(i, n - 2) {
			rev_ans[i] = rev_sm[i] - rev[i];
			rev_ans[i] = max(rev_ans[i], rev_ans[i + 1]);
		}

		int ans = 0;
		// 右端固定
		REP(i, n) {
			int tmp_sm = sm[i] - 2 * x[i];
			ans = max(ans, tmp_sm);

			if (i < n - 1) tmp_sm += rev_sm[i + 1]; // 最後まで言ったら取れない
			ans = max(ans, tmp_sm);
		}

		return ans;
	}
	
	int ans = solve();

	reverse(ALL(v));
	REP(i, n) x[i] = c - x[i];
	reverse(ALL(x));

	ans = max(ans, solve());
	OUT(ans)BR;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:13: error: expected ',' or ';' before 'int64'
   12 | #define int int64
      |             ^~~~~
a.cc:78:9: note: in expansion of macro 'int'
   78 |         int ans = solve();
      |         ^~~
a.cc:84:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   84 |         ans = max(ans, solve());
      |         ^~~
      |         abs
Language: C++

#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n, c);
	vector< int > x(n), v(n);
	vector< int > sm(n + 1, 0), rev(n, 0), rev_sm(n + 1, 0), rev_ans(n + 1, 0);
	REP(i, n) {
		cin >> x[i] >> v[i];
	}
	
	auto solve = [&]() {
		sm[0] = v[0];
		REP(i, n) {
			sm[i] = sm[i - 1] + v[i]; // 累積和
		}

		rev_sm[n - 1] = v[n - 1];
		RREP(i, n - 2) {
			rev_sm[i] = rev_sm[i + 1] + v[i]; // 逆回りの時の累積和
		}

		REP(i, n) {
			rev[i] = c - x[i];           // 逆回りの時のi番目のsushiまでのdistance
		}

		// 逆回りの時の最適解
		rev_ans[n - 1] = rev_sm[n - 1] - y[n - 1];
		RREP(i, n - 2) {
			rev_ans[i] = rev_sm[i] - rev[i];
			rev_ans[i] = max(rev_ans[i], rev_ans[i + 1]);
		}

		int ans = 0;
		// 右端固定
		REP(i, n) {
			int tmp_sm = sm[i] - 2 * x[i];
			ans = max(ans, tmp_sm);

			if (i < n - 1) tmp_sm += rev_sm[i + 1]; // 最後まで言ったら取れない
			ans = max(ans, tmp_sm);
		}

		return ans;
	}
	
	int ans = solve();

	reverse(ALL(v));
	REP(i, n) x[i] = c - x[i];
	reverse(ALL(x));

	ans = max(ans, solve());
	OUT(ans)BR;
  
  return 0;
}


Compiler output:
a.cc: In lambda function:
a.cc:59:50: error: 'y' was not declared in this scope
   59 |                 rev_ans[n - 1] = rev_sm[n - 1] - y[n - 1];
      |                                                  ^
a.cc: In function 'int main()':
a.cc:12:13: error: expected ',' or ';' before 'int64'
   12 | #define int int64
      |             ^~~~~
a.cc:78:9: note: in expansion of macro 'int'
   78 |         int ans = solve();
      |         ^~~
a.cc:84:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   84 |         ans = max(ans, solve());
      |         ^~~
      |         abs
Language: C++

#define loop(i, s, e) for(ll i = s;i < e;i++)

#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <map>
#include <cmath>
#include "vector2d.cpp"

using namespace std;
using namespace libcgl;
typedef long long signed ll;

long long n,c,v[100000],x[100000],s[2][100000],d[2][100000],ss[2][100000],dd[2][100000];

long long xx(int i) {
    if(i == 0) return 0;
    if(i < 0) return c-x[n+i+1];
    return x[i];
}


long long vv(int i) {
    if(i == 0) return 0;
    if(i < 0) return v[n+i+1];
    return v[i];
}

int main() {
    cin >> n >> c;
    loop(i,1,n+1) { cin >> x[i] >> v[i]; }

    loop(i,1,n+1) {
        s[0][i] = s[0][i-1] + vv(i) - (xx(i) - xx(i-1));
        d[0][i] = d[0][i-1] + vv(-i) - (xx(-i) - xx(-i+1));
        ss[0][i] = max(ss[0][i-1],s[0][i]);
        dd[0][i] = max(dd[0][i-1],d[0][i]);
        s[1][i] = s[1][i-1] + vv(i) - 2 * (xx(i) - xx(i-1));
        d[1][i] = d[1][i-1] + vv(-i) - 2 * (xx(-i) - xx(-i+1));
        ss[1][i] = max(ss[1][i-1],s[1][i]);
        dd[1][i] = max(dd[1][i-1],d[1][i]);
    }

    ll res = 0;
    loop(i,0,n+1) {
        res = max(res,max(ss[1][i] + dd[0][n-i],ss[0][i] + dd[1][n-i]));
    }
    cout << res << endl;
}



Compiler output:
a.cc:13:10: fatal error: vector2d.cpp: No such file or directory
   13 | #include "vector2d.cpp"
      |          ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
 
typedef long long ll;
ll n,c,s,ans;
int main(){
  ll i;
  cin>>N>>c;
ll x[N],cal[N],mx[N+1]={0},mx2[N+1]={0};

  for(i=0;i<N;i++){
    scanf("%lld %lld",&x[i],&cal[i]);
  }  
  for(i=N-1;i>=0;i--){
    s+=cal[i];
    mx[i] = max(mx[i+1],s-(c-x[i]));
    mx2[i] = max(mx2[i+1],s-(c-x[i])*2);
  }
  ans = max(mx[0],mx2[0]);
  s=0;
  for(i=0;i<N;i++){
    s+=cal[i];
    ans = max(ans, s-x[i]*2 + mx[i+1]);
    ans = max(ans, s-x[i] + mx2[i+1]);
  }
    cout << ans;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:8: error: 'N' was not declared in this scope
    9 |   cin>>N>>c;
      |        ^
a.cc:13:24: error: 'x' was not declared in this scope
   13 |     scanf("%lld %lld",&x[i],&cal[i]);
      |                        ^
a.cc:13:30: error: 'cal' was not declared in this scope
   13 |     scanf("%lld %lld",&x[i],&cal[i]);
      |                              ^~~
a.cc:16:8: error: 'cal' was not declared in this scope
   16 |     s+=cal[i];
      |        ^~~
a.cc:17:5: error: 'mx' was not declared in this scope
   17 |     mx[i] = max(mx[i+1],s-(c-x[i]));
      |     ^~
a.cc:17:30: error: 'x' was not declared in this scope
   17 |     mx[i] = max(mx[i+1],s-(c-x[i]));
      |                              ^
a.cc:18:5: error: 'mx2' was not declared in this scope
   18 |     mx2[i] = max(mx2[i+1],s-(c-x[i])*2);
      |     ^~~
a.cc:20:13: error: 'mx' was not declared in this scope
   20 |   ans = max(mx[0],mx2[0]);
      |             ^~
a.cc:20:19: error: 'mx2' was not declared in this scope
   20 |   ans = max(mx[0],mx2[0]);
      |                   ^~~
a.cc:23:8: error: 'cal' was not declared in this scope
   23 |     s+=cal[i];
      |        ^~~
a.cc:24:22: error: 'x' was not declared in this scope
   24 |     ans = max(ans, s-x[i]*2 + mx[i+1]);
      |                      ^
Language: C++

#include<iostream>
#include<cmath>
using namespace std;

int main(){
  int i,N,C;//num,circle
  cin>>N>>C;
  int x[N],cal[N];//x:distance

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

  int mx[N+1]={0};
  int mx2[N+1]={0};
  int ans,s;
  
  //clockwise
  for(i=N-1;i>=0;i--){
    s+=cal[i];//consumed calories
    mx[i] = max(mx[i+1],s-(c-x[i]));//c-x[i]: used calories
    mx2[i] = max(mx2[i+1],s-(c-x[i])*2);//return first point
  }
  ans = max(mx[0],mx2[0]);
  s=0;//initialize calories

  //anticlockwise
  for(i=0;i<N;i++){
    s+=cal[i];
    ans = max(ans,s-a[i]*2 + mx[i+1]);//return first point 
    ans = max(ans,s-a[i] + mx2[i+1]);
  }

  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:28: error: 'c' was not declared in this scope
   21 |     mx[i] = max(mx[i+1],s-(c-x[i]));//c-x[i]: used calories
      |                            ^
a.cc:30:21: error: 'a' was not declared in this scope
   30 |     ans = max(ans,s-a[i]*2 + mx[i+1]);//return first point
      |                     ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int x[100'000];
int v[100'000];

int max(int a, int b){ return a < b? b: a; }

int main(){
	int n, c;
	cin >> n >> c;

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

	int max = -1;
	for(int j = n; j >= 0; --j){
		int cal = 0;
		int nowX = 0;
		int d = 0;
		// ちょっと反時計回り
		for(int i = 0; i <= j; ++i){
			int localD = c - x[i];
			cal += v[i] - localD + nowX;
			max = max(max, cal);
			nowX = localD;
			d += localD;
		}
		// 初期位置に戻る
		cal -= d;
		nowX = 0;
		// 時計回り
		for(int i = 0; i < n-j; ++i){
			cal += v[i] - x[i] + nowX;
			max = max(max, cal);
			nowX = x[i];
		}
	}

	cout << max << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:34: error: 'max' cannot be used as a function
   28 |                         max = max(max, cal);
      |                               ~~~^~~~~~~~~~
a.cc:38:34: error: 'max' cannot be used as a function
   38 |                         max = max(max, cal);
      |                               ~~~^~~~~~~~~~
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int x[100'000];
int v[100'000];

int main(){
	int n, c;
	cin >> n >> c;

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

	int max = -1;
	for(int j = n; j >= 0; --j){
		int cal = 0;
		int nowX = 0;
		int d = 0;
		// ちょっと反時計回り
		for(int i = 0; i <= j; ++i){
			int localD = c - x[i];
			cal += v[i] - localD + nowX;
			max = max(max, cal);
			nowX = localD;
			d += localD;
		}
		// 初期位置に戻る
		cal -= d;
		nowX = 0;
		// 時計回り
		for(int i = 0; i < n-j; ++i){
			cal += v[i] - x[i] + nowX;
			max = max(max, cal);
			nowX = x[i];
		}
	}

	cout << max << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:34: error: 'max' cannot be used as a function
   26 |                         max = max(max, cal);
      |                               ~~~^~~~~~~~~~
a.cc:36:34: error: 'max' cannot be used as a function
   36 |                         max = max(max, cal);
      |                               ~~~^~~~~~~~~~