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

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long sum=0//计数器,n,x;
    cin>>n>>x;//输入
    long long a[n+1];
    cin>>a[1];//处理第一个单独超限。
    if(a[1]>x)
        {
        sum+=a[1]-x;//增加吃的量
        a[1]=x;//a[i]>=x,要吃的最少，即是a[i]=x;
        }
    for(int i=2;i<=n;i++)
        {
        cin>>a[i];//输入
        if(a[i]+a[i-1]>x)//照例处理
            {
            sum+=a[i]+a[i-1]-x;
            a[i]=x-a[i-1];
            }
        }
    cout<<sum;//输出
    return 0;//养成好习惯
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: expected ',' or ';' before 'cin'
    6 |     cin>>n>>x;//输入
      |     ^~~
a.cc:7:17: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |     long long a[n+1];
      |                 ^
      |                 yn
a.cc:8:10: error: 'a' was not declared in this scope
    8 |     cin>>a[1];//处理第一个单独超限。
      |          ^
a.cc:9:13: error: 'x' was not declared in this scope
    9 |     if(a[1]>x)
      |             ^
a.cc:17:24: error: 'x' was not declared in this scope
   17 |         if(a[i]+a[i-1]>x)//照例处理
      |                        ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int N;
ll x, A[100005];
ll ans;

int main(void) {
    
    scanf("%d %lld", &N, &x);
    rep(i, 0, N) scanf("%lld", &A[i]);
    
    rep(i, 1, N) {
      ll t = A[i-1]+A[i];
      if (t > x) {
        ll t2 = t - x;
        A[i-1] -= max(0, t2 - A[i]);
        A[i] -= min(t2, A[i]);
        ans += t2;
      }
    }
    
    
    printf("%lld\n", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:22: error: no matching function for call to 'max(int, ll)'
   37 |         A[i-1] -= max(0, t2 - A[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:   template argument deduction/substitution failed:
a.cc:37:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   37 |         A[i-1] -= max(0, t2 - A[i]);
      |                   ~~~^~~~~~~~~~~~~~
/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:37:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |         A[i-1] -= max(0, t2 - A[i]);
      |                   ~~~^~~~~~~~~~~~~~
Language: C++

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

int main() {
  long N, X, A, B, ans = 0;
  cin >> N >> X >> A;
  while (cin >> B) {
    ans += max(0, A + B - X);
    B -= (A + B > X) ? max(B, A + B - X) : 0;
    A = B;
  }
  cout << ans << "\n"; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:15: error: no matching function for call to 'max(int, long int)'
    8 |     ans += max(0, A + B - X);
      |            ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:8:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
    8 |     ans += max(0, A + B - X);
      |            ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:8:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
    8 |     ans += max(0, A + B - X);
      |            ~~~^~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main() 
{
    int n, x;
    cin >> n >> x;
    v_int a(n);
    v_int a2(n);
    v_int b(n);
    v_int b2(n);

    irep(i, n) {
        cin >> a[i];
        b[n-i-1] = a[i];
    }

    ll a_ans = 0;
    ll b_ans = 0;

    irep(i, n-1) {
        ll sum = a[i] + a[i+1];
        if(sum > x) { 
            a_ans += (a[i]+a[i+1] - x);
            if(a[i] <= a[i+1]) {
                a[i+1] -= (sum - x);
            } else {
                a[i] -= (sum - x);
            }

            if(a[i] + a[i]
            a_ans += (a[i]+a[i+1] - x);
            a[i+1] -= (a[i]+a[i+1] - x);
        }
    }

    irep(i, n-1) {
        if(b[i] + b[i+1] > x) { 
            b_ans += (b[i]+b[i+1] - x);
            b[i+1] -= (b[i]+b[i+1] - x);
        }
    }
    cout << min(a_ans, b_ans);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:27: error: expected ';' before 'a_ans'
   62 |             if(a[i] + a[i]
      |                           ^
      |                           ;
   63 |             a_ans += (a[i]+a[i+1] - x);
      |             ~~~~~          
a.cc:64:40: error: expected ')' before ';' token
   64 |             a[i+1] -= (a[i]+a[i+1] - x);
      |                                        ^
      |                                        )
a.cc:62:15: note: to match this '('
   62 |             if(a[i] + a[i]
      |               ^
Language: C++

#include<bits/stdc++.h>
#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()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,x;
  cin>>n>>x;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n-1){
    if(a[i]+a[i+1]>x){
      ll k=a[i]+a[i+1]-x;
      if(k>=a[i+1]){
        a[i+1]-=k;
        ans+=k;
      }
      else{
        a[i+1]=0;
        k-=a[i+1];
        a[i]-=k;
        ans+=k;
      }
    }
  }
  ll anss=0;
  for(int i=n-1;i>0;i++){
    if(a[i]+a[i-1]>x){
      ll k=a[i]+a[i-1]-x;
      if(k>=a[i-1]){
        a[i-1]-=k;
        anss+=k;
      }
      else{
        a[i-1]=0;
        k-=a[i-1];
        a[i]-=k;
        anss+=k;
      }
    }
  }
  
  COUT(min(anss,ans);
}


Compiler output:
a.cc:75:2: error: unterminated argument list invoking macro "COUT"
   75 | }
      |  ^
a.cc: In function 'int main()':
a.cc:74:3: error: 'COUT' was not declared in this scope
   74 |   COUT(min(anss,ans);
      |   ^~~~
a.cc:74:7: error: expected '}' at end of input
   74 |   COUT(min(anss,ans);
      |       ^
a.cc:36:11: note: to match this '{'
   36 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K; cin>>N>>K;
  int memo; cin>>memo;
  int ans=0;
  if(memo>K){
    ans+=memo-K;
    memo=K;
  }
  rep(i,0,N){
    int X; cin>>X;
    if(X+memo>K){
      int Y=memo+X-K;
      ans+=Z;
      X-=Z;
    }
    memo=X;
  }
  cout<<ans<<endl;
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:27:12: error: 'Z' was not declared in this scope
   27 |       ans+=Z;
      |            ^
Language: C++

#include <vector>
#include <algorithm>
#include <iostream>
#include <queue>
#include <limits>
#include <math.h>
#include <map>

using namespace std;
typedef long long ll;

int main() {
  int N;
  ll x;
  scanf("%d %lld", &N, &x);
  vector<ll> a(N);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);

  ll ans = 0;
  for (int i = 0; i < N - 1; ++i) {
    if (a[i] + a[i + 1] > x) {
      ll diff = (a[i] + a[i + 1]) - x;
      ans += diff;
      a[i + 1] = max(0, a[i + 1] - diff);
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:21: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
   24 |       a[i + 1] = max(0, a[i + 1] - diff);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 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:24:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   24 |       a[i + 1] = max(0, a[i + 1] - diff);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
/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:24:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |       a[i + 1] = max(0, a[i + 1] - diff);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

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

int main()
{
  	int n, x;
  	cin>>n>>x;
  	int a[n];
  	//int sum = 0;
  	for(int i = 0; i < n; i++)
    {
      	cin>>a[i];
      	//sum += a[i];
    }
  	for(int i = 0; i < n-1; i++)
    {
        int d = x-a[i];
        if(a[i+1]-d < 0)
          continue;
        res += a[i+1]-d;
        a[i+1] = d;
    }
  	cout<<res<<"\n";
 	/*if(x == 0)
      	cout<<sum<<"\n";
  	else
    {
      	int res = 0; bool flag = true;
    	for(int i = 0; i < n-1; i++)
        {
        	if(a[i] + a[i+1] > x)
            {
              	flag = false;
              	break;
            }
        }
      	if(flag == true)
          	cout<<0<<"\n";
      	else
        {
        	for(int i = 0; i < n-1; i++)
            {
            	int d = x-a[i];
              	if(a[i+1]-d < 0)
                  	continue;
              	res += a[i+1]-d;
              	a[i+1] = d;
            }
          	cout<<res<<"\n";
        }
    }*/
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'res' was not declared in this scope
   20 |         res += a[i+1]-d;
      |         ^~~
a.cc:23:15: error: 'res' was not declared in this scope
   23 |         cout<<res<<"\n";
      |               ^~~
Language: C++

#include<bits/stdc++.h>
#define ll long long 
#define int ll
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int32_t main(){
    fast;
    int N{},x{},c{};    cin>>N>>x;
    int A[N]{}; for(int i=0;i<N;i++)    cin>>A[i];
    for(int i=1;i<N;i++){
        if(a[i]+a[i-1] > x){
        c += A[i]+A[i-1]-x;
        A[i] -= A[i]+A[i-1]-x;
    }
        
    }
    cout<<c<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:12:12: error: 'a' was not declared in this scope
   12 |         if(a[i]+a[i-1] > x){
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}
int main(){
  ll n,x,ans;cin>>n>>x;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ans=Svec(v);
  if(v[0]>x) v[0]=x;
  for(ll i=0;i<n-1;i++){
    if(v[i]+v[i+1]>x){
      v[i+1]=x-v[i];
    }
  }
  cout<<ans-Svec(v)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'i' was not declared in this scope
   12 |   rep(i,n) cin>>v[i];
      |       ^
a.cc:12:3: error: 'rep' was not declared in this scope
   12 |   rep(i,n) cin>>v[i];
      |   ^~~
Language: C++

/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
const ll MOD = 1000000000000000001;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b){
  ll r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


ll LCM(ll a,ll b){
  ll c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

vector<pair<char,ll>> runlength(string s,vector<pair<char,ll>> p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
    return p;
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
  return p;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,ans=0,pre=0,tmp;
  cin>>n>>x;
  rep(i,n){
    ll a;
    cin>>a;
    tmp=max((ll)0,pre+a-x);
    ans+=tmp;
    pre=a-tmp;
  }
  cout<<ans<<endl;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:99:11: error: 'x' was not declared in this scope
   99 |   cin>>n>>x;
      |           ^
Language: C++


using namespace std;
typedef long long ll;


int main() {
  int n;
  cin >> n;
  ll x;
  cin >> x;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin >> a.at(i);
  }
  ll ans =0;
  for(ll i=1;i<n;i++){
    if(a.at(i-1) + a.at(i) > x){
      ans += 
  
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin >> n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | 
a.cc:11:3: error: 'vector' was not declared in this scope
   11 |   vector<ll> a(n);
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | 
a.cc:11:12: error: expected primary-expression before '>' token
   11 |   vector<ll> a(n);
      |            ^
a.cc:11:14: error: 'a' was not declared in this scope
   11 |   vector<ll> a(n);
      |              ^
a.cc:20:3: error: 'cout' was not declared in this scope
   20 |   cout << ans << endl;
      |   ^~~~
a.cc:20:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:18: error: 'endl' was not declared in this scope
   20 |   cout << ans << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | 
a.cc:22:2: error: expected '}' at end of input
   22 | }
      |  ^
a.cc:16:22: note: to match this '{'
   16 |   for(ll i=1;i<n;i++){
      |                      ^
a.cc:22:2: error: expected '}' at end of input
   22 | }
      |  ^
a.cc:6:12: note: to match this '{'
    6 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
	
long long main(){
	long long n;
	long long maxc;
	cin >> n >> maxc;
	vector<long long>candies;
	for(long long i = 0;i<n;++i){
		long long temp;
		cin >>temp;
		candies.push_back(temp);
	}
	long long sum = 0;
	for(long long j = 0;j<n-1;++j){
		if(candies[j]+candies[j+1]>maxc){
		if(candies[j]>=maxc){
		sum+=candies[j+1]+candies[j]-maxc;
		candies[j+1]=0;
		}else{
			long long temp=maxc-candies[j];

			long long temp2 = candies[j+1]-temp;

			candies[j+1]=temp;
			sum+= temp2;
		}
		}
	}
	cout <<sum;
	return 0;

}


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

# include <stdio.h>
# include <math.h>
# include <stdlib.h>

int main()
{
	int a[100000], x, i, k = 0;
	scanf("%d %d", &n, &x);

	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		
		if (a[i] > x)
		{
		
			k = k + (a[i] - x);
			a[i] = x;
		}
		
	}
	
	for (i = 0; i < (n - 1); i++)
	{
		if ((a[i] + a[i + 1]) > x)
		{
			
			if (i != 0)
			{
				do
				{
					a[i] = a[i] - 1;
					k++;
				} while ((a[i] + a[i + 1]) > x);
			}
			else
			{
				do
				{
					a[i + 1]--;
					k++;
				} while ((a[i] + a[i + 1]) > x);
			}
		}
	}


	printf("%d", k);

	return 0;

}

Compiler output:
main.c: In function 'main':
main.c:8:25: error: 'n' undeclared (first use in this function)
    8 |         scanf("%d %d", &n, &x);
      |                         ^
main.c:8:25: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<bits/stdc++.h >
#include<algorithm>
#include<vector>
typedef long long ll;
#define rep(i,a,b) for(ll i=(a);i<(b);i++)
using namespace std;

ll N, x;
vector<ll> a;
int ans = 0;

int main() {
	cin >> N >> x;
	rep(i, 0, N) {
		ll t;
		cin >> t;
		a.push_back(t);
	}

	if (a[0] > x) {
		ans += a[0] - x;
		a[0] = x;
	}

	rep(i, 1, N) {
		if ((a[i - 1] + a[i]) > x) {
			ans += (a[i - 1] + a[i]) - x;
			a[i] = x - a[i - 1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

#include <iostream>
#include <vector>

using namespace std;

int main(){
  int N;
  long long int x;
  cin >> N >> x;
  vector<long long int> a(N,0LL);
  
  for(int i = 0; i < N; i++) cin >> a[i];
  
  long long int ans = 0LL;
  for(int i = 0; i < N-1; i++){
    if(a[i] + a[i+1] > x){
      if(a[i + 1] >= (a[i] + a[i+1] - x)){
        ans += (a[i] + a[i+1] - x);
        a[i+1] -= (a[i] + a[i+1] - x);
      else{
        ans += a[i+1];
        a[i+1] = 0;
        if(a[i] >= a[i] - x){
          ans += (a[i] - x);
          a[i] -= (a[i] - x);
        }
      }
    }
  }
  cout << ans;



}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:7: error: expected '}' before 'else'
   20 |       else{
      |       ^~~~
a.cc:17:42: note: to match this '{'
   17 |       if(a[i + 1] >= (a[i] + a[i+1] - x)){
      |                                          ^
Language: C++

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

int main(){
    int n; cin >> n;
    ll x; cin >> x;
    ll ans = 0;
    vector<ll> a(n);
    for(int  i = 0; i < n; i++){
        cin >> a[i];
    }
    if(a[0] > x;){
        ans += a[0] - x;
        a[0] -= a[0] - x;
    }
    for(int i = 1; i < n; i++){
        if(a[i-1] + a[i] > x){
            ans += a[i-1] + a[i] - x;
            a[i] -= a[i-1] + a[i] - x;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: expected primary-expression before ')' token
   13 |     if(a[0] > x;){
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n,x; cin >> n >> x;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    ll ans;
    REP(i,n-1) {
        ll tmp = a[i] + a[i+1];
        if (tmp > x) {
            ll eat = tmp - x;
            ans += eat;
            a[i+1] = max(a[i+1] - eat,0);
        }
    }
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: no matching function for call to 'max(ll, int)'
   26 |             a[i+1] = max(a[i+1] - eat,0);
      |                      ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:26:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |             a[i+1] = max(a[i+1] - eat,0);
      |                      ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:26:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |             a[i+1] = max(a[i+1] - eat,0);
      |                      ~~~^~~~~~~~~~~~~~~~
Language: C++

// https://atcoder.jp/contests/arc067/tasks/arc067_b
#include <bits/stdc++.h>
using namespace std;
#define int int_fast64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t, sum = 0;
    cin >> n >> x;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    REP(i, n - 1) {
        int t = v[i + 1] + v[i] - x;
        sum += max(0LL, t);
        if (i < n / 2) {
            v[i + 1] -= t;
        } else {
            v[i] -= t;
        }
    }
    cout << sum << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: no matching function for call to 'max(long long int, int_fast64_t&)'
   19 |         sum += max(0LL, t);
      |                ~~~^~~~~~~~
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:2:
/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:19:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int_fast64_t' {aka 'long int'})
   19 |         sum += max(0LL, t);
      |                ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:19:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |         sum += max(0LL, t);
      |                ~~~^~~~~~~~
Language: C++

// https://atcoder.jp/contests/arc067/tasks/arc067_b
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t, sum = 0;
    cin >> n >> x;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    REP(i, n - 1) {
        int t = v[i + 1] + v[i] - x;
        sum += max(0LL, t);
        if (i < n / 2) {
            v[i + 1] -= t;
        } else {
            v[i] -= t;
        }
    }
    cout << sum << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:19: error: no matching function for call to 'max(long long int, int64_t&)'
   19 |         sum += max(0LL, t);
      |                ~~~^~~~~~~~
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:2:
/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:19:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'})
   19 |         sum += max(0LL, t);
      |                ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:19:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |         sum += max(0LL, t);
      |                ~~~^~~~~~~~
Language: C++

// https://atcoder.jp/contests/arc067/tasks/arc067_b
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, t, sum = 0;
    cin >> n >> x;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    REP(i, n - 1) {
        sum += max(0LL, v[i + 1] + v[i] - x);
        if (i < n / 2) {
            v[i + 1] -= v[i + 1] + v[i] - x;
        } else {
            v[i] -= v[i + 1] + v[i] - x;
        }
    }
    cout << sum << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:19: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   18 |         sum += max(0LL, v[i + 1] + v[i] - x);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
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:2:
/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:18:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   18 |         sum += max(0LL, v[i + 1] + v[i] - x);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:18:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         sum += max(0LL, v[i + 1] + v[i] - x);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,x,a2,res,num;
    cin>>n>>x;
    res = 0;
    num = 0;
    cin>>a1;
    for(long long i=1;i<n;i++){
        cin>>a2;
        num = x<(a1+a2)?a1+a2-x:0;
        res += num;
        if(a2 >= num){
            a2 -= num;
        }else{
            a2 = 0
        }
        a1 = a2;
    }
    cout<<res;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:10: error: 'a1' was not declared in this scope; did you mean 'a2'?
    8 |     cin>>a1;
      |          ^~
      |          a2
a.cc:16:19: error: expected ';' before '}' token
   16 |             a2 = 0
      |                   ^
      |                   ;
   17 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n);(i)>=0;(i)--)
typedef long long lint;

int main(){
 unsigned long long int N,x,ans=0,tmp=0;
  cin >>N>>x;
 lint M[N];
 rep(i,N)cin >>M[i];
 
  repp(i,1,N){
    tmp=(M[i-1]+M[i]);
    if(tmp>x){
      ans+=tmp-x;
      M[i]-=max(tmp-x,0);
    }
    tmp=0;
  }
  cout <<ans;
}


  


Compiler output:
a.cc: In function 'int main()':
a.cc:18:16: error: no matching function for call to 'max(long long unsigned int, int)'
   18 |       M[i]-=max(tmp-x,0);
      |             ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:18:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'int')
   18 |       M[i]-=max(tmp-x,0);
      |             ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:18:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   18 |       M[i]-=max(tmp-x,0);
      |             ~~~^~~~~~~~~
Language: C++

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

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  //操作
  int ans = 0;
  if(a.at(0) > x){
    ans += a.at(0) - x;
    a.at(0) = x;
  }
  for(int i=1; i<N; i++){
    if(a.at(i-1) + a.at(i) > x){
      ans += a.at(i-1) + a.at(i) - x;
      a.at(i) = x - a.at(i-1);
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'int'
    3 | using int = long long;
      |       ^~~
Language: C++

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

int main(){
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  //操作
  int ans = 0;
  if(a.at(0) > x){
    ans += a.at(0) - x;
    a.at(0) = x;
  }
  for(int i=1; i<N; i++){
    if(a.at(i-1) + a.at(i) > x){
      ans += a.at(i-1) + a.at(i) - x;
      a.at(i) = x - a.at(i-1);
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc:3:7: error: expected nested-name-specifier before 'long'
    3 | using long long = int;
      |       ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long a,b,n,x,ans,t;
int main(){
    cin>>n>>x;
    cin>>a;
    
    for(int i=2;i<=n;i++)
    {
    	cin>>b;
    	if(a+b>x)t=a+b-x,ans+=t,
    	b=b-t,if(b<0)b=0;
    	a=b;
    	
    }
    cout<<ans;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:15: error: expected primary-expression before 'if'
   12 |         b=b-t,if(b<0)b=0;
      |               ^~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  	int n;
  	int x;
  	cin >> n;
  	int arr[n];
  	for (int i = 0; i < n; i++) {
    	cin >> arr[i];
    }
  	int answer = 0;
  	for (int i = 0; i < n; i++) {
    	if (arr[i] > x) {
        	answer = answer + (arr[i] - x);
        }
    }
  	for (int i = 0; i < n - 1; i++) {
    	if (arr[i] + arr[i + 1] > x) {
        	answer = answer + (arr[i + 1] - x < 0 ? arr[i + 1] : arr[i + 1] - x);
          	arr[i + 1] = arr[i + 1] - x; 
          	if (arr[i + 1] < 0) {
            	arr[i + 1] = 0;
            }
        }
    }
  	if (arr[ n - 2] + arr[n - 1] > x) {
    	answer = answer + (arr[n - 2] - x < 0 ? arr[i + 1] : arr[i + 1] - x);
    }
  	cout << answer << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:53: error: 'i' was not declared in this scope
   29 |         answer = answer + (arr[n - 2] - x < 0 ? arr[i + 1] : arr[i + 1] - x);
      |                                                     ^
Language: C++

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

int main(){
  ll n,x;
  cin >> n >> x;
  ll arr[n];
  ll sum;ll ans;
  for ( int i = 0 ; i < n ;i++){
  cin >> a[i];
  }
  if ( a[0] > x ) {
		ans += a[0] - x;
		a[0] = x;
	}
	sum = a[0];
	for ( int i = 1 ; i < n ; i++){
		sum += a[i];
		if (sum > x){
			ans += sum-x;
			a[i] -= sum-x;
			sum = x;
		}
		sum -= a[i-1];
	}
	cout << ans;
}
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:10: error: 'a' was not declared in this scope
   11 |   cin >> a[i];
      |          ^
a.cc:13:8: error: 'a' was not declared in this scope
   13 |   if ( a[0] > x ) {
      |        ^
a.cc:17:15: error: 'a' was not declared in this scope
   17 |         sum = a[0];
      |               ^
a.cc: At global scope:
a.cc:30:1: error: expected declaration before '}' token
   30 | }
      | ^
Language: Java

mport java.util.Scanner;
public class Main{
 
  public static void main(String[] args){
   
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int ops = 0;
    int[] candies = new int[n];
    for(int i = 0; i < n; i++){
      candies[i] = sc.nextInt(); 
    }
    for(int i = 0; i < n - 1; i++){
      int diff = (candies[i] + candies[i + 1]) - x;
      if (diff > 0){
        ops += diff;
        if (diff < candies[i + 1]){
         candies[i + 1] -= diff; 
        }
        else{
         candies[i + 1] = 0; 
        }
      }
    }
    System.out.println(ops);
    sc.close();
    
  }
  
}

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
mport java.util.Scanner;
^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5+5;
typedef long long ll;

ll a[MAX_N];

int main()
{
	ll n, x, ans = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:70: error: no matching function for call to 'max(int, ll)'
   15 |                 if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
      |                                                                   ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:15:70: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   15 |                 if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
      |                                                                   ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:15:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |                 if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
      |                                                                   ~~~^~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5+5;
typedef long long ll;

ll a[MAX_N];

int main()
{
	ll n, x, ans = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i < n; i++)
	{
		if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:70: error: no matching function for call to 'max(int, ll)'
   15 |                 if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
      |                                                                   ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:15:70: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   15 |                 if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
      |                                                                   ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:15:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |                 if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
      |                                                                   ~~~^~~~~~~~~~~~~