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

#include<math.h>
#include<stdlib.h>
#include<string.h>
using namespace std;

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

  cin >> a >> b >> c >> x >> y;

  int total;

  if(((a+b)/2 > c) && (min(a,b) < c)){
    if(x < y){
      total = x*2*c + (y-x)*b;
      cout << 1 << endl;
    }
    else{
      total = y*2*c + (x-y)*a;
      cout << 2 << endl;
    }
  }
  else if(((a+b)/2 <= c) && (min(a,b) < c)){
    total = a*x + b*y;
    cout << 3 << endl;
  }
  else{
    total = max(x,y)*2*c;
  }
  cout << total << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'cin' was not declared in this scope
    9 |   cin >> a >> b >> c >> x >> y;
      |   ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include<string.h>
  +++ |+#include <iostream>
    4 | using namespace std;
a.cc:16:7: error: 'cout' was not declared in this scope
   16 |       cout << 1 << endl;
      |       ^~~~
a.cc:16:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:16:20: error: 'endl' was not declared in this scope
   16 |       cout << 1 << endl;
      |                    ^~~~
a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    3 | #include<string.h>
  +++ |+#include <ostream>
    4 | using namespace std;
a.cc:20:7: error: 'cout' was not declared in this scope
   20 |       cout << 2 << endl;
      |       ^~~~
a.cc:20:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:20: error: 'endl' was not declared in this scope
   20 |       cout << 2 << endl;
      |                    ^~~~
a.cc:20:20: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:25:5: error: 'cout' was not declared in this scope
   25 |     cout << 3 << endl;
      |     ^~~~
a.cc:25:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:25:18: error: 'endl' was not declared in this scope
   25 |     cout << 3 << endl;
      |                  ^~~~
a.cc:25:18: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:30:3: error: 'cout' was not declared in this scope
   30 |   cout << total << endl;
      |   ^~~~
a.cc:30:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:20: error: 'endl' was not declared in this scope
   30 |   cout << total << endl;
      |                    ^~~~
a.cc:30:20: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
Language: C++

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

int GetMinimum(int A, int B, int C, int X, int Y){
    int maxnab = max(2*X, 2*Y);
    int minsum = INT_MAX;
    for(int nab=0; nab<=maxnab; nab+=2){
        int na = X - nab/2;
        int nb = Y - nab/2;
        if (na<0) na=0;
        if (nb<0) nb=0;
        int sum = A * na + B * nb + C * nab;
        if(sum < minsum) minsum = sum;
    }
    return minsum;
}

int main()
{
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    auto n = GetMinimum(A,B,C,X,Y);
    cout << n << endl;
    return 0;
}

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

#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

int main(){

  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;

  int ans_ab = a * x + b * y;
  int ans_abc = (x > y)?( 2 * c * y + a * (x-y)):(2 * c * x + b * (y-x));
  int ans_c = (x>y)?c * x:c*y;

  cout<<min(ans_ab,ans_abc,ans_c)<<endl;

  return 0;
}


Compiler output:
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: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:17:12:   required from here
   17 |   cout<<min(ans_ab,ans_abc,ans_c)<<endl;
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main3
{
    
    public static void main(String[] args) throws IOException
    {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
        String s = r.readLine();
        String[] sl = s.split("[\\s]+");
        int a = Integer.parseInt(sl[0]);
        int b = Integer.parseInt(sl[1]);
        int ab = Integer.parseInt(sl[2]);
        int x = Integer.parseInt(sl[3]);
        int y = Integer.parseInt(sl[4]);
        
        int apb = Math.min(a + b, 2 * ab);
        int sum = 0;
        int v = Math.min(x, y);
        sum += v * apb;
        x -= v;
        y -= v;
        if(x == 0)
        {
            sum += Math.min(y * b, 2 * y * ab);
        }
        else
        {
            sum += Math.min(x * a, 2 * x * ab);
        }
        System.out.println(sum);
    }
    
}


Compiler output:
Main.java:6: error: class Main3 is public, should be declared in a file named Main3.java
public class Main3
       ^
1 error
Language: C++

#include <iostream>

using namespace std;

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (y < x) {
        swap(x, y);
        swap(a, b);
    }
    int pa = c * x * 2 + b * (y - x), pb = a * x + b * y, pc = c * y * 2;
    cout << min({pa, pb, pc}) << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:16: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   13 |     cout << min({pa, pb, pc}) << endl;
      |             ~~~^~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
Language: C

#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) (((a)+(b)-1)/(b))
#define all(x) x.begin(), x.end()
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define dbg(msg, var) cerr << msg << " " << var << endl;

using namespace std;

const int MAX = 100010;
const int MOD = 123456789;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// End Template //

ll dp1[100010], dp2[100010];

int main()
{sws;

    ll n, c, x, v;
    cin >> n >> c;

    vector<pair<ll, ll>> vet;
    for(int i=0;i<n;i++){
        cin >> x >> v;
        vet.pb({x, v});
    }

    ll ans = 0;

    ll best=0, now=0, lst=0;
    for(int i=0;i<n;i++){
        x = vet[i].ff;
        v = vet[i].ss;
        now+=v-(x-lst);
        lst=x;
        dp1[i] = best = max(best, now);
    }

    ans = max(ans, best);

    best=0; now=0; lst=c;
    for(int i=n-1;i>=0;i--){
        x = vet[i].ff;
        v = vet[i].ss;
        now+=v-(lst-x);
        lst = x;
        dp2[n-i-1] = best = max(best, now);
    }

    ans = max(ans, best);

    // for(int i=0;i<n;i++)
    //     cout << dp1[i] << " ";
    // cout << endl;

    // for(int i=0;i<n;i++)
    //     cout << dp2[i] << " ";
    // cout << endl;

    ll sum=0;
    for(int i=0;i<n-1;i++){
        x = vet[i].ff;
        v = vet[i].ss;
        sum+=v;
        ans = max(ans, sum-2*x + dp2[n-1-i - 1]);
    }


    sum=0;
    for(int i=0;i<n-1;i++){
        x = vet[n-1-i].ff;
        v = vet[n-1-i].ss;
        sum+=v;
        ans = max(ans, sum-2*(c-x) + dp1[n-1-i - 1]);
    }

    cout << ans << endl;

    return 0;
}

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

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int N; cin >> N;
    ll C; cin >> C;
    vector<ll> x(N);
    vector<ll> v(N);
    vector<ll> xr(N);
    vector<ll> vr(N);
    rep(i, N){
        cin >> x[i] >> v[i];
    }
    rep(i, N){
        xr[i] = C - x[N-1-i];
        vr[i] = v[N-1-i];
    }

    vector<ll> vtotal(N+1);
    vector<ll> vrtotal(N+1);
    rep(i, N){
        vtotal[i+1] = vtotal[i] + v[i];
        vrtotal[i+1] = vrtotal[i] + vr[i];
    }

    vector<ll> f(N+1);
    rep(i, N){
        f[i+1] = vtotal[i+1] - x[i];
    }
    vector<int> fmax(N+1);
    ll now = 0;
    int nownum = 0;
    for (int i = 1; i <= N; i++){
        if(f[i] > now){
            now = f[i];
            nownum = i;
        }
        fmax[i] = nownum;
    }

    ll ans = 0;
    rep(i, N+1){
        ll now = f[fmax[N-i]];
        if(i == 0){
            ans = max(ans, now);
            //cout << i << " " << now << endl;
            continue;
        }
        if(i == N){
            ll now2 = vrtortal[i] - xr[i-1];
            ans = max(ans, now2);
            continue;
        }
        //cout << i << " " << now;
        ll now2 = now - x[fmax[N-i]-1];
        now2 += vrtotal[i];
        now2 -= xr[i-1];
        ll now3 = now2 + x[fmax[N-i]-1] - xr[i-1];
        //cout << " " << now2 << " " << now3 << endl;
        now = max(now, now2);
        now = max(now, now3);
        ans = max(ans, now);
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:23: error: 'vrtortal' was not declared in this scope; did you mean 'vrtotal'?
   53 |             ll now2 = vrtortal[i] - xr[i-1];
      |                       ^~~~~~~~
      |                       vrtotal
Language: C++

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007



n, c = LI()
clock_pos = []
value = []
for pos, v in LIR(n):
    clock_pos += [pos]
    value += [v]

r1 = 0
r2 = 0
A1 = [0]
A2 = [0]
for i in range(n):
    r1 += value[i]
    r2 += value[-i - 1]
    A1 += [max(A1[i], r1 - clock_pos[i])]
    A2 += [max(A2[i], r2 - (c - clock_pos[-i-1]))]

ans = 0
for j in range(n-1):
    ans = max(ans, A1[j+1] + A2[n - j - 1] - clock_pos[j], A2[j+1] + A1[n - j - 1] - (c - clock_pos[-j-1]))

print(ans)

Compiler output:
a.cc:22:62: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   22 | def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
      |                                                              ^~~~~~~
a.cc:23:61: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   23 | def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
      |                                                             ^~~~~~~
a.cc:1:1: error: 'from' does not name a type
    1 | from collections import defaultdict, deque, Counter
      | ^~~~
Language: C++

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  ll c;
  cin >> n >> c;
  vector<ll> s(n+1, 0), f(n+1, 0), v(n), x(n+1, 0), g(n+1, 0), select(n+1,0);
  s[0] = 0;
  for(int i=0; i<n; i++){
    cin >> x[i+1] >> v[i];
    s[i+1] = s[i] + v[i];
    f[i+1] = max(s[i+1]-x[i+1], f[i]);
    if(f[i+1]!=f[i]) select[i+1] = i+1;
    else select[i+1] = select[i];
    g[i+1] = max(f[i+1], g[i]);
  }
  ll ans = amx(0, s[n]-c);
  for(int i=1; i<=n; i++){
    ll tmp = s[n] - s[i-1] - c + x[i];
    tmp += g[i-1];
    tmp -= min(c-x[i], x[select[i-1]]);
    ans = max(tmp, ans);
  }
  ans = max(ans, g[n]);
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:12: error: 'amx' was not declared in this scope
   23 |   ll ans = amx(0, s[n]-c);
      |            ^~~
Language: C++

#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  ll n,c;cin>>n>>c;
  vll x(n),v(n),y1(n+1,0),y2(n+1,0),z1(n+1,0),z2(n+1,0),sum1(n+1,0),sum2(n+1,0);
  rep(i,0,n){
    cin>>x[i]>>v[i];
  }
  rep(i,0,n){
    sum1[i+1]=sum1[i]+v[i];
    y1[i+1]=max(y1[i],sum1[i+1]-x[i]);
    z1[i+1]=max(z1[i],sum1[i+1]-2*x[i]);
  }
  drep(i,n-1,0){
    sum2[i]=sum2[i+1]+v[i];
    y2[i]=max(y2[i+1],sum2[i]-(c-x[i]));
    z2[i]=max(z2[i+1],sum2[i]-2*(c-x[i]));
  }
  ll ans=0;
  //片方固定
  rep(i,0,n1){
    ans=max(ans,max(y1[i]+z2[i],y2[i]+z1[i]));
  }
  cout<<ans<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:11: error: 'n1' was not declared in this scope; did you mean 'z1'?
   35 |   rep(i,0,n1){
      |           ^~
a.cc:12:36: note: in definition of macro 'rep'
   12 | #define rep(i,a,b) for(ll i=(a);i<(b);++i)
      |                                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    ll N, C; cin >> N >> C;
    vector<pair<ll, ll>> P(N);
    for(int i = 0; i < N; i++){
        ll x, v; cin >> x >> v;
        P[i] = make_pair(x, v);
    }
    int l=0, r=N-1;
    ll ptr = 0;
    ll Max=0;
    ll SUM = 0;
    ll foot = 0;
    int flag = 2;
    //cout << l << " " << r << " " << SUM <<"  " << foot << endl;
    while(l <= r){
        ll fl = min(abs(P[l].first-ptr), C - abs(P[l].first-ptr));
        ll fr = min(abs(P[r].first-ptr), C - abs(P[r].first-ptr));
        ll lv = P[l].second;
        ll rv = P[r].second;
        if(SUM+lv-fl-foot < SUM+rv-fr-foot){ // flag = 0;
            SUM += rv;
            if(flag == 1) foot = min(foot+fr, 2*(C-

Compiler output:
a.cc: In function 'int main()':
a.cc:27:52: error: expected primary-expression at end of input
   27 |             if(flag == 1) foot = min(foot+fr, 2*(C-
      |                                                    ^
a.cc:27:52: error: expected ')' at end of input
   27 |             if(flag == 1) foot = min(foot+fr, 2*(C-
      |                                                 ~  ^
      |                                                    )
a.cc:27:52: error: expected '}' at end of input
a.cc:25:44: note: to match this '{'
   25 |         if(SUM+lv-fl-foot < SUM+rv-fr-foot){ // flag = 0;
      |                                            ^
a.cc:27:52: error: expected '}' at end of input
   27 |             if(flag == 1) foot = min(foot+fr, 2*(C-
      |                                                    ^
a.cc:20:18: note: to match this '{'
   20 |     while(l <= r){
      |                  ^
a.cc:27:52: error: expected '}' at end of input
   27 |             if(flag == 1) foot = min(foot+fr, 2*(C-
      |                                                    ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

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


int main() {
  long long N,C;
  cin >> N >> C;
  vector<long long> x(N+2,0),v(N+2,0);
  for(int i=1;i<=N;i++){
    cin >> x[i] >> v[i];
  }
  x[N+1]=C;
  long long ans=0;
  long long a=0,k=0,b=0,l=0;
  for(long long i=1;i<=N;i++){
    k +=v[i]-x[i]+x[i-1];//v[1]-x[1],v[1]+v[2]-x[2]+x[1]-x[1],...
    a=maxll(a,k);
    //時計回り
  }
  //cout << a << endl;
  for(long long i=N;i>=0;i--){
    l +=v[i]-x[i+1]+x[i];//v[N]-x[N+1]+x[N],v[N]+v[N-1]-x[N+1]+x[N-1],...
    b=maxll(b,l);
    //反時計回り
  }
  //cout << b << endl;
  long long c=0,d=0,e=0,f=0,g=0,h=0,p=0,q=0,m=0;
  while(x[m]<=C/2){
    m++;
  }
  //cout << m-1 << endl;
  //x[m-1]までがC/2以下
    
  for(long long i=1;i<m;i++){
    e +=v[i]-2*x[i]+2*x[i-1];
    c=maxll(c,e);
  }
  //cout << c << endl;
  //原点まで戻ってくる
  for(long long i=N;i>=m;i--){
    f +=v[i]-x[i+1]+x[i];
    d=max(d,f);
  }
  //cout << d << endl;
  //戻ってきた後の移動
    for(long long i=1;i<m;i++){
    p +=v[i]-x[i]+x[i-1];
    g=maxll(g,p);
  }
  //cout << g << endl;
  //戻ってきた後の移動
  for(long long i=N;i>=m;i--){
    q +=v[i]-2*x[i+1]+2*x[i];
    h=max(h,q);
  }
  //cout << h << endl;
  //原点まで戻ってくる
  //cout << c+d << endl;
  //cout << g+h << endl;
  ans=maxll(maxll(a,b),maxll(c+d,g+h));
  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'maxll' was not declared in this scope
   17 |     a=maxll(a,k);
      |       ^~~~~
a.cc:23:7: error: 'maxll' was not declared in this scope
   23 |     b=maxll(b,l);
      |       ^~~~~
a.cc:36:7: error: 'maxll' was not declared in this scope
   36 |     c=maxll(c,e);
      |       ^~~~~
a.cc:48:7: error: 'maxll' was not declared in this scope
   48 |     g=maxll(g,p);
      |       ^~~~~
a.cc:60:13: error: 'maxll' was not declared in this scope
   60 |   ans=maxll(maxll(a,b),maxll(c+d,g+h));
      |             ^~~~~
a.cc:60:7: error: 'maxll' was not declared in this scope
   60 |   ans=maxll(maxll(a,b),maxll(c+d,g+h));
      |       ^~~~~
Language: C++

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

long long maxll(long long n,long long m){
  if(n>m)
    return n;
  else
    return m;
}

int main() {
  long long N,C;
  cin >> N >> C;
  vector<long long> x(N+2,0),v(N+2,0);
  for(int i=1;i<=N;i++){
    cin >> x[i] >> v[i];
  }
  x[N+1]=C;
  long long ans=0;
  long long a=0,k=0,b=0,l=0;
  for(int i=1;i<=N;i++){
    k +=v[i]-x[i]+x[i-1];
    a=maxll(a,k);
  }
  //cout << a << endl;
  for(int i=N;i>=0;i--){
    l +=v[i]-x[i+1]+x[i];
    b=maxll(b,l);
  }
  //cout << b << endl;
  long long c=0,d=0,e=0,f=0,g=0,h=0,p=0,q=0;
  int m=0;
  while(x[m]<C+/2){
    m++;
  }
  //cout << m-1 << endl;
    
  for(int i=1;i<m;i++){
    e +=v[i]-2*x[i]+2*x[i-1];
    c=maxll(c,e);
  }
  //cout << c << endl;
  for(int i=N;i>=m;i--){
    f +=v[i]-x[i+1]+x[i];
    d=max(d,f);
  }
  //cout << d << endl;
    for(int i=1;i<m;i++){
    p +=v[i]-x[i]+x[i-1];
    g=maxll(g,p);
  }
  //cout << g << endl;
  for(int i=N;i>=m;i--){
    q +=v[i]-2*x[i+1]+2*x[i];
    h=max(h,q);
  }
  //cout << h << endl;
  cout << c+d << endl;
  cout << g+h << endl;
  cout << maxll(maxll(a,b),maxll(c+d,g+h)) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:16: error: expected primary-expression before '/' token
   33 |   while(x[m]<C+/2){
      |                ^
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,c;
  cin>>n>>c;
  vll x(n),v(n);
  rep(i,n){
    cin>>x[i]>>v[i];
  }
  ll ans=0;
  ll cu=0;
  ll k=0;
  ll j=0;
  ll ii=0;
  rep(i,n){
    cu+=v[i];
    cu-=x[i];
    ans=max(ans,cu);
    cu+=x[i];
    if(x[i]=<c/2){
    j=cu;
    j-=2*x[i];
    if(k<j){
      ii=i;
      k=j;
    }
    }
  }
  cu=k;
  for(int i=n-1;i>ii;i--){
    cu+=v[i];
    cu-=c-x[i];
    ans=max(ans,cu);
    cu+=c-x[i];
  }
  k=0;
  cu=0;
  for(int i=n-1;i>=0;i--){
    cu+=v[i];
    cu-=c-x[i];
    ans=max(ans,cu);
    cu+=c-x[i];
    if(x[i]>=c-c/2){
    j=cu;
    j-=2*(c-x[i]);
    if(k<j){
      k=j;
      ii=i;
    }
    }
  }
  cu=k;
  for(int i=0;i<ii;i++){
    cu+=v[i];
    cu-=x[i];
    ans=max(ans,cu);
    cu+=x[i];
  }
  COUT(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:13: error: expected primary-expression before '<' token
   59 |     if(x[i]=<c/2){
      |             ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int n;
ll c;
vector<p> x;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>c;
    for (int i = 0; i < n; i++)
    {
        ll tempx, tempv;
        cin >> tempx>>tempv;
        x.push_back(make_pair(tempx,tempv));
    }
    vector<ll> sumr, suml;
    sumr.push_back(0);
    suml.push_back(0);
    ll backsumr=0;
    ll backsuml=0;
    ll iter_lmax=-1;
    ll iter_rmax=-1;
    ll ans=0;
    for(int i=0;i<n;i++){
        sumr.push_back(sumr[i]+x[i].second);
        if(sumr[i+1]-2*x[i].first>backsumr&&c=>2*x[i].first){
            backsumr=sumr[i+1]-2*x[i].first;
            iter_rmax=i;
        }
        ans=max(ans,sumr[i+1]-x[i].first);
    }
    //cout << ans << "\n";
    for(int i=0;i<n;i++){
        suml.push_back(suml[i]+x[n-1-i].second);
        if(suml[i+1]-2*(c-x[n-1-i].first)>backsuml&&c>=2*(c-x[n-1-i].first)){
            backsuml=suml[i+1]-2*(c-x[n-1-i].first);
            iter_lmax=n-1-i;
        }
        ans=max(ans,suml[i+1]-(c-x[n-1-i].first));
    }
    //cout << ans << "\n";
    //cout << iter_rmax << "\n";
    if(iter_rmax!=-1){
        for(int i=0;i<n-iter_rmax-1;i++){
            ans=max(ans,backsumr+suml[i+1]-(c-x[n-1-i].first));
        }
    }
    //cout << ans << "\n";
    //cout << iter_lmax << "\n";
    if(iter_lmax!=-1){
        for(int i=0;i<iter_lmax;i++){
            //cout<<backsuml+sumr[i+1]-x[i].first<<"\n";
            ans=max(ans,backsuml+sumr[i+1]-x[i].first);
        }
    }
    cout << ans << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:47: error: expected primary-expression before '>' token
   70 |         if(sumr[i+1]-2*x[i].first>backsumr&&c=>2*x[i].first){
      |                                               ^
Language: C++

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

int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    
    int n,i;
    long long c;
    
    cin>>n;
    cin>>c;
    
	long long j,k;
	map<long long ,long long>mp;
	mp[0]=0;
	for(i=1;i<=n;i++)
	{
	    cin>>j>>k;
	    mp[j]=k;
	}
	
	long long a[n+1],b[n+1],ax[n+1],bx[n+1];
	ax[0]=0;
	bx[n]=0;
	
	j=0;k=0;
	i=0;
	for(auto d:mp)
	{
	    j=j+d.second;
	    k=max(k,j-d.first);
	    
	    a[i]=k;
	    if(i!=0)
	    {
	        if(a[i]!=a[i-1])
	        ax[i]=d.first;
	        else
	        ax[i]=ax[i-1];
	    }
	    
//	    cout<<i<<" : "<<a[i]<<endl;
	
	    i++;
	}
	
	j=0;v=0;i=n;
    mp[c]=0;
//    cout<<endl;
	for(auto d=mp.rbegin();d!=mp.rend();d++)
	{
	    if(d->first != 0)
	    {
	        j=j+d->second;
	        v=max(v,j-c+d->first);
	        b[i]=v;
	        if(i!=n)
	        {
	            if(b[i]!=b[i+1])
	            bx[i]=c-d->first;
	            else
	            bx[i]=bx[i+1];
	        }
//	        cout<<i<<" : "<<b[i]<<endl;
	    
	        i--;
	    }
	    
	}
	v=0;
//	cout<<endl;
	for(i=0;i<=n;i++)
	{
	    v=max(v,a[i]+b[i]-min(ax[i],bx[i]));
	    
//	    cout<<i<<" : "<<v<<endl;
	}
	
	cout<<v;
	return 0;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:13: error: 'v' was not declared in this scope
   51 |         j=0;v=0;i=n;
      |             ^
Language: C++

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

int visited[10000];
int dis[10000];
int nut[10000];
int n,c;
int maxi=0;
void maxinut(int curr,int nut){
  for(int i=0; i<n; i++){
    if(visited[i]==1)continue;
    visited[i]=1;
    if(nut[i]-dist[i]+curr > maxi)maxi=nut[i]-dist[i]+curr;
    maxinut(dist[i],nut[i]-dist[i]+curr);
    visited[i]=0;
  }
}
int main(){
  cin >> n >> c;
  int dis[n];
  int nut[n];
  memset(visited,0,sizeof(visited));
  for(int i=0; i<n; i++){
    cin >> dis[i] >> nut[i];
  }
  maxinut(0,0);
  cout maxi;
}

Compiler output:
a.cc: In function 'void maxinut(int, int)':
a.cc:13:11: error: invalid types 'int[int]' for array subscript
   13 |     if(nut[i]-dist[i]+curr > maxi)maxi=nut[i]-dist[i]+curr;
      |           ^
a.cc:13:15: error: 'dist' was not declared in this scope; did you mean 'dis'?
   13 |     if(nut[i]-dist[i]+curr > maxi)maxi=nut[i]-dist[i]+curr;
      |               ^~~~
      |               dis
a.cc:13:43: error: invalid types 'int[int]' for array subscript
   13 |     if(nut[i]-dist[i]+curr > maxi)maxi=nut[i]-dist[i]+curr;
      |                                           ^
a.cc:14:13: error: 'dist' was not declared in this scope; did you mean 'dis'?
   14 |     maxinut(dist[i],nut[i]-dist[i]+curr);
      |             ^~~~
      |             dis
a.cc:14:24: error: invalid types 'int[int]' for array subscript
   14 |     maxinut(dist[i],nut[i]-dist[i]+curr);
      |                        ^
a.cc: In function 'int main()':
a.cc:27:7: error: expected ';' before 'maxi'
   27 |   cout maxi;
      |       ^~~~~
      |       ;
Language: C++

#include <stdio.h>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using lli = long long int;

std::vector<lli> S, T;
std::vector<lli> SB, TB;
std::vector<lli> X;

int main(void){
    int n; lli C;
    scanf("%d%lld", &n, &C);
    S.resize(n+1), T.resize(n+1), X.resize(n+2);
    X[0] = 0, X[n+1] = C; S[0] = 0; T[0] = 0;
    FOReq(i, 1, n){ scanf("%lld%lld", &X[i], &S[i]); T[n-i+1] = S[i];}

    REP(i, n){ S[i+1] += S[i]; T[i+1] += T[i];}
    SB.resize(n); TB.resize(n);
    FOReq(i, 0, n){
        SB[i] = S[i] - 2 * X[i];
        TB[i] = T[i] - 2 * (C - X[n-i+1]);
    }
    REP(i, n){
        if(SB[i] > SB[i+1]) SB[i+1] = SB[i];
        if(TB[i] > TB[i+1]) TB[i+1] = TB[i];
    }
    lli res = -1;
    FOReq(i, 0, n){
        chmax(res, S[i] - X[i] + TB[n-i]);
        chmax(res, T[i] - (C - X[n-i+1]) + SB[n-i]);
    }
    printf("%lld\n", res);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'chmax' was not declared in this scope
   33 |         chmax(res, S[i] - X[i] + TB[n-i]);
      |         ^~~~~
Language: C++

#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,int> P;
typedef pair<ll,ll> p;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
static const int MAX_SIZE = 1 << 17; //segment tree のサイズ。この実装では2べきにする必要がある。 2^17 ≒ 1.3 * 10^5

int main(){
  int N;
  ll C,x[110000],v[110000],T[110000],H[110000],temp=0;
  cin>>N>>C;
  for(int i=1;i<=N;i++){
      cin>>x[i]>>v[i];
  }
  x[N+1]=C; v[N+1]=0;
  x[0]=0; v[0]=0;
  for(int i=0;i<=N+1;i++){
      temp+=v[i];
      if(i==0) T[i]=v[i]-x[i];
      else T[i]=max(T[i-1],temp-x[i]);
  }
  temp=0;

  for(int i=N+1;i>=0;i--){
      temp+=v[i];
      if(i==N+1) H[i]=v[i]-(C-x[i]);
      else H[i]=max(H[i+1],v[i]-(C-x[i]));
  }
  ll ans=0;
  ans=max(ans,H[0],T[N+1]);
  cout<<ans<<endl;
  return 0;
  temp=0;
  for(int i=0;i<=N;i++){
      temp+=v[i];
      ans=max(ans,temp-x[i]*2+H[i+1]);
  }
  temp=0;
  for(int i=N+1;i>=1;i--){
      temp+=v[i];
      ans=max(ans,temp-(C-x[i])*2+T[i-1]);
  }
  cout<<ans<<endl;


}



Compiler output:
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:2:
/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:46:10:   required from here
   46 |   ans=max(ans,H[0],T[N+1]);
      |       ~~~^~~~~~~~~~~~~~~~~
/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<hoge>
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, C;
	int ans = 0;
	vector<int> x, sum1, sum2, v;
	
	cin>>N>>C;
	
	x.resize(N);
	v.resize(N);
	sum1.resize(N+1);
	sum2.resize(N+1);
	
	for(int i = 0; i < N; i++){
		cin>>x[i]>>v[i];
	}
	
	for(int i = 0, sum = 0; i < N; i++){
		sum += v[i];
		
		sum1[i+1] = max(0ll,sum - x[i] * 2);
	}
	
	for(int i = 0, sum = 0; i < N; i++){
		sum += v[N-i+1];
		
		sum2[i+1] = max(0ll,sum - (C - x[i]) * 2);
	}
	
	for(int i = 0, sum = 0; i < N; i++){
		int j = N - i - 1;
		sum += v[j];
		
		ans = max(sum + sum1[j] - (C - x[j]), ans);
	}
	
	for(int i = 0, sum = 0; i < N; i++){
		int j = N - i - 1;
		sum += v[i];
		
		ans = max(sum + sum2[j] - x[i], ans);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

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

long long INF = LONG_LONG_MAX / 3;
const int N = (int) 1e5 + 5;

int n;
long long c;
long long x[N], v[N];
long long dp[N][2];
// 0: clockwise
// 1: counter - clockwise

void maximize(long long &a, long long b) {
	if (a < b) a = b;
}

void minimize(long long &a, long long b) {
	if (a > b) a = b;
}

int main() {
	scanf("%d %lld", &n, &c);
	for (int i = 1; i <= n; i++) scanf("%lld %lld", &x[i], &v[i]);
	long long ans = -INF;
	long long temp = 0;
	for (int i = 1; i <= n; i++) {
		temp += v[i];
		temp -= (x[i] - x[i - 1]);
		maximize(ans, temp);
	}
	temp = 0;
	x[n + 1] = c;
	for (int i = n; i >= 1; i--) {
		temp += v[i];
		temp -= (x[i + 1] - x[i]);
		maximize(ans, temp);
	}
	temp = 0;
	dp[n + 1][1] = -INF;
	for (int i = n; i >= 1; i--) {
		temp += v[i];
		temp -= (x[i + 1] - x[i]);
		maximize(dp[i][1], dp[i + 1][1]);
		maximize(dp[i][1], temp);
	}
	temp = 0;
	dp[0][0] = -INF;
	for (int i = 1; i <= n; i++) {
		temp += v[i];
		temp -= (x[i] - x[i - 1]);
		maximize(dp[i][0], dp[i - 1][0]);
		maximize(dp[i][0], temp);
	}
	for (int i = 1; i <= n; i++) maximize(ans, dp[i][0] + dp[i + 1][1] - x[i]);
	for (int i = n; i >= 1; i--) maximize(ans, dp[i][1] + dp[i - 1][0] - (c - x[i]));
	maximize(ans, 0);
	printf("%lld", ans);
	return 0;
}

Compiler output:
a.cc:5:17: error: 'LONG_LONG_MAX' was not declared in this scope
    5 | long long INF = LONG_LONG_MAX / 3;
      |                 ^~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N, C;
    cin >> N >> C;
    vector<long long> x(N + 2), v(N + 2);
    for(long long i = 1; i <= N; i++) {
        cin >> x[i] >> v[i];
    }
    x[0] = 0;
    x[N + 1] = C;
    long long cal = 0;
    vector<vector<long long>> dp(2, vector<long long>(N + 1, 0));
    for(long long i = 1; i <= N; i++) {
        cal += v[i] - x[i] - x[i - 1];
        dp[0][i] = max(dp[0][i - 1], cal);
    }
    cal = 0;
    //左回り
    for(long long i = N; i >= 1; i++) {
        cal += v[i] - x[i + 1] + x[i];
        dp[1][i] = max(dp[1][i + 1], cal);
    }
    long long res = 0;
    for(long long i = 0; i <= N; i++) {
        cal = dp[0][i] + dp[1][i + 1] - x[i];
        res = max(cal, res);
        cal = dp[0][i] + dp[1][i + 1] + x[i + 1] - C;
        res = max(cal, res);
    }
    cout << maxcal << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:13: error: 'maxcal' was not declared in this scope
   60 |     cout << maxcal << endl;
      |             ^~~~~~
Language: C++

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

vector<int> w,u;

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

}
	
}

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


}


Compiler output:
a.cc: In function 'long long int fillvector(std::vector<long long int>, std::vector<long long int>)':
a.cc:10:18: error: 'n' was not declared in this scope
   10 |         w.assign(n+1,0);
      |                  ^
a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type]
   17 | }
      | ^
a.cc: At global scope:
a.cc:19:1: error: expected declaration before '}' token
   19 | }
      | ^
a.cc:21:1: error: expected declaration before '}' token
   21 | }
      | ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include <vector>
#include <queue>
#include <map>
#include <stack>

using namespace std;

typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)

int const N_MAX = 100000;

int N;
ll C;
ll xs[N_MAX + 1], vs[N_MAX + 1];
ll ls[N_MAX + 1], rs[N_MAX + 1];
ll gs[N_MAX + 1];
int g_idx[N_MAX + 1];
ll g_dist[N_MAX + 1];

int main() {
  scanf("%d %lld", &N, &C);
  xs[0] = 0;
  vs[0] = 0;
  FOR(i, 1, N + 1) {
    scanf("%lld %lld", &xs[i], &vs[i]);
  }

  FOR(i, 1, N + 1) {
    ls[i] = ls[i - 1] + vs[i];
    rs[i] = rs[i - 1] + vs[N - i + 1];
  }

  FOR(i, 1, N + 1) {
    ll g = gs[i - 1];
    ll dist = C - xs[N - i + 1];
    ll cal = rs[i] - dist;
    if (g >= cal) {
      gs[i] = g;
      g_dist[i] = g_dist[i - 1];
    } else {
      gs[i] = cal;
      g_dist[i] = dist;
    }
  }

  ll max_cal = 0;
  rep(i, N + 1) {
    ll l = ls[i];
    ll l_dist = xs[i];
    ll l_cal = l - l_dist;

    // int j = N - i;
    // ll r_cal = gs[j];
    // ll r_dist = g_dist[j];
    rep(j, N - i + 1) {
      ll r = rs[j];
      ll r_dist = C - xs[N - i + 1];
      if (r_dist == C) r_dist = 0;

      ll cal = l_cal + r_cal - min(l_dist, r_dist);
      max_cal = max(max_cal, cal);
    }
  }
  printf("%lld\n", max_cal);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:24: error: 'r_cal' was not declared in this scope; did you mean 'l_cal'?
   69 |       ll cal = l_cal + r_cal - min(l_dist, r_dist);
      |                        ^~~~~
      |                        l_cal
Language: C++

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//do {
//    print(v);
//  } while (std::next_permutation(v.begin(), v.end()));


int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N, C;
	cin >> N >> C;
	VI x(N);
	VI v(N);
	VI rsum(N);
	VI lsum(N);
	VI misum(N,0);
	VI hisum(N,0);
	int migi = LLINF * -1, hidari = LLINF * -1;
	
	REP(i, N) {
		cin >> x[i] >> v[i];
		rsum[i] = v[i]-x[i];//right only

		if (i != 0)
			rsum[i] += rsum[i - 1]+x[i-1];


		if (C / 2 > x[i])
			migi = max(migi, rsum[i]);

		//cout << rsum[i] << endl;

	}
	int j = 0;
	for (int i = N - 1; i >= 0; i--) {

		lsum[j] = v[i] - (C - x[i]);
		if(j!=0)
			lsum[j]+=lsum[j-1];
		if (i != N - 1)
			lsum[i] += x[i + 1];

		if (C / 2 < x[i]) 
			hidari = max(hidari, lsum[j]);
		j++;
	}
	int A = 0, B = 0;
	int i = 0;

	while (x[i] < C / 2) {
		A = max(A, rsum[i] - x[i] + hidari);
		i++;
	}
	j = 0;
	i = N - 1;
	while(x[i]>C/2){
		B = max(B, lsum[j] - x[i] + migi);
		i--;
		j++;
	}
	rSORT(rsum);
	rSORT(lsum);
	A = max(A, B);
	int ans = max(rsum[0], lsum[0]);
	//cout << rsum[0] << " " << lsum[0] << endl;
	cout << max(A, ans) << endl;


	return 0;
}



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

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <random>
using namespace std;
#define Would
#define you

long long a, b, k[100005], l[100005], mon, ans;
int main() {
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		cin >> k[i] >> l[i];
		if (i) { l[i] += l[i - 1]; }
	}
	mon = k[a - 1];
	for (int i = 0; i < a; ++i) {
		long long mmon = max(l[i] - k[i], mon - l[i] - (b - k[i]));
		ans = max(ans, mmon);
	}
	cout << max(ans,0) << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:20: error: no matching function for call to 'max(long long int&, int)'
   29 |         cout << max(ans,0) << endl;
      |                 ~~~^~~~~~~
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:   template argument deduction/substitution failed:
a.cc:29:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |         cout << max(ans,0) << endl;
      |                 ~~~^~~~~~~
/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,
                 from a.cc:2:
/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:29:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |         cout << max(ans,0) << endl;
      |                 ~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>

#define lint long long

using namespace std;

//解説見た

int main() {
    int N;
    lint C;
    cin >> N >> C;
    
    vector<lint> x(N + 2), v(N), list(N + 2), ilist(N + 2);
    
    x[0] = 0; x[N + 1] = C;
    for(int i = 0; i < N; ++i){
        cin >> x[i + 1] >> v[i];
    }
    
    
    list[0] = 0; ilist[N + 1] = 0;
    for(int i = 1; i <= N; ++i){
        list[i] = list[i - 1] + v[i - 1];
        ilist[N - i + 1] = ilist[N - i + 2] + v[N - i];
    }
    
    vector<lint> f1(N + 1), f2(N + 1), g1(N + 1), g2(N + 1);
    g1[0] = 0; g2[0] = 0; f1[0] = 0; f2[0] = 0;

    for(int i = 1; i < N + 1; ++i){
        f1[i] = list[i] - x[i];
        g1[i] = max(f1[i], g1[i - 1]);
        
        f2[i] = list[i] - 2 * x[i];
        g2[i] = max(f2[i], g2[i - 1]);
    }
    
    lint ans = 0;
    for(int B = 1; B <= N + 1; ++B){
        lint cal1 = g2[B - 1] + ilist[B] - (C - x[B]);
        lint cal2 = g1[B - 1] + ilist[B] - 2 * (C - x[B]);
        ans = max(ans, max(cal1, cal2));
    }
    
    cout << ans << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:46:25: error: expected '}' at end of input
   46 |     cout << ans << endl;
      |                         ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using int128 = __int128;
using cint = cpp_int;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ull MAX = ULONG_MAX;
#define endl '\n'
#define space ' '
#define def inline auto
#define func inline constexpr ll
#define run __attribute__((constructor)) def _
#define all(v) begin(v), end(v)

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << endl;                                                          \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define each(i, a) for (auto &&i : a)
#define rep(i, n) inc(i, 0, n - 1)

// Stream
#define input(a) scanf("%lld", &(a))
#define output(a) printf("%lld\n", (a))
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

// Math
func gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
func lcm(ll a, ll b) { return a * b / gcd(a, b); }

#define M 100000
ll N, C, X, Y, A[M], B[M], P[M], Q[M];
signed main() {
    cin >> N >> C;
    rep(i, N) {
        cin >> A[i] >> B[i];
    }
    P[0] = B[0] - A[0];
    Q[N - 1] = B[N - 1] - (C - A[N - 1]);
    inc(i, 1, N - 1)
        P[i] = B[i] - (A[i] - A[i - 1])
    dec(i, N - 2, 0)
        Q[i] = B[i] - (C - (A[i + 1] - A[i]));
    inc(i, 1, N - 1) P[i] += P[i - 1];
    dec(i, N - 2, 0) Q[i] += Q[i - 1];
    cout << max(*max_element(P, P + N), *max_element(Q, Q + N)) << endl;
}

// for compilation: g++ -O3 -o _ _.cpp -std=c++17

Compiler output:
a.cc:2:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
    2 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>

#define N 4

int main(void){
int i,xm=0,cm=0;
int v[N+1]={};

printf(" N C\n");
for(i=1;i<=N;i++)
scanf("%d %d",&x[i],&v[i]);

for(i=1;i<=N;i++){
cm+=v[i];
xm+=x[i];
}
printf("%d\n",cm-xm);

return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:16: error: 'x' undeclared (first use in this function)
   11 | scanf("%d %d",&x[i],&v[i]);
      |                ^
main.c:11:16: note: each undeclared identifier is reported only once for each function it appears in