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

#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, X;
  std::cin >> N >> X;
  std::vector<ll> A(N);
  std::vector<pair<ll, ll> > dp(N);
  for(int i=0;i<N;i++) std::cin >> A[i];

  for(int i=0;i<N;i++){
    if(i==0) dp[0] = (A[0]<=X?make_pair(0, A[0]):make_pair(A[0]-X, X));
    else dp[i] = (A[i]+dp[i-1].second<=X?make_pair(dp[i-1].first, A[i]):make_pair(dp[i-1].first+A[i]+dp[i-1].second-X, X-dp[i-1].second));
    //std::cout << dp[i].first  << " " << dp[i].second<< '\n';
  }
  std::cout << dp[N-1].first << '\n';
  return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:24:30: error: operands to '?:' have different types 'std::pair<int, long long int>' and 'std::pair<long long int, long long int>'
   24 |     if(i==0) dp[0] = (A[0]<=X?make_pair(0, A[0]):make_pair(A[0]-X, X));
a.cc:24:30: note:   and each type can be converted to the other
Language: C++

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

int main()
{
  int n,x;
  cin>>n>>x;
  vector<int> a(n);
  for(auto &i:a)
     cin>>i;
  long long int ans=0;
  for(int i=0;i<n-1;i++)
    if(a[i]+a[i+1]>x)
      {
        long long sub = a[i+1]+a[i]-x;
        ans += sub;
        a[i+1]=max(a[i+1]-sub,0);
      }
  if(a[n-1]>x)
    ans += a[n-1]-x;
  cout<<ans<<"\n";
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:19: error: no matching function for call to 'max(long long int, int)'
   17 |         a[i+1]=max(a[i+1]-sub,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:17:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   17 |         a[i+1]=max(a[i+1]-sub,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:17:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   17 |         a[i+1]=max(a[i+1]-sub,0);
      |                ~~~^~~~~~~~~~~~~~
Language: C

;;; 048 C - Boxes and Candies
(define (input n)
  (let loop ((ls ()) (n n))
    (if (zero? n) ls (loop (cons (read) ls) (- n 1)))))

(define (main arg)
  (let* ((n (read)) (x (read)) (ls (input n)))
    (let loop ((ls ls) (ans 0))
      (cond ((null? (cdr ls)) (print ans))
	    (else
	     (let ((ret 0))
	       (set! ret (max (+ (car ls) (cadr ls) (- x)) 0))
	       (dec! (car ls) (max (- ret (cadr ls)) 0))
	       (dec! (cadr ls) (min ret (cadr ls)))
	       (loop (cdr ls) (+ ret ans)))))))
  0)


Compiler output:
main.c:1:5: error: invalid digit "8" in octal constant
    1 | ;;; 048 C - Boxes and Candies
      |     ^~~
main.c:1:5: error: expected identifier or '(' before numeric constant
Language: C++

℣#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

signed main(){
  ll n,x,ans=0;cin>>n>>x;

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

  for(int i=1;i < n;i++)
  {
    if(v[i-1]+v[i]>x){
      ans+=v[i-1]+v[i]-x;
      v[i]=min(x-v[i-1],0ll);
    }
  }
  cout<<ans<<endl;
}



Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | ℣#include <bits/stdc++.h>
      |  ^
a.cc:1:1: error: '\U00002123' does not name a type
    1 | ℣#include <bits/stdc++.h>
      | ^
a.cc:12:9: error: 'pair' does not name a type
   12 | typedef pair<int,int> P;
      |         ^~~~
a.cc:13:9: error: 'pair' does not name a type
   13 | typedef pair<ll,ll> PL;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:20:16: error: 'cin' was not declared in this scope
   20 |   ll n,x,ans=0;cin>>n>>x;
      |                ^~~
a.cc:22:3: error: 'vector' was not declared in this scope
   22 |   vector<ll> v(n,0);
      |   ^~~~~~
a.cc:22:12: error: expected primary-expression before '>' token
   22 |   vector<ll> v(n,0);
      |            ^
a.cc:22:14: error: 'v' was not declared in this scope
   22 |   vector<ll> v(n,0);
      |              ^
a.cc:32:12: error: 'min' was not declared in this scope; did you mean 'main'?
   32 |       v[i]=min(x-v[i-1],0ll);
      |            ^~~
      |            main
a.cc:35:3: error: 'cout' was not declared in this scope
   35 |   cout<<ans<<endl;
      |   ^~~~
a.cc:35:14: error: 'endl' was not declared in this scope
   35 |   cout<<ans<<endl;
      |              ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n,a[100000],x,sum=0;



int main(){
	cin>>n>>x;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n-1;i++) 
	   {
	     if((a[i]+a[i+1])>x)
	   {	sum+=m;
	if(a[k+1]>=m) a[k+1]-=m;
	else{a[k+1]=0;}
	   }
	cout<<sum;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: 'm' was not declared in this scope
   13 |            {    sum+=m;
      |                      ^
a.cc:14:14: error: 'k' was not declared in this scope
   14 |         if(a[k+1]>=m) a[k+1]-=m;
      |              ^
a.cc:19:2: error: expected '}' at end of input
   19 | }
      |  ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
    ll N, x; cin >> N >> x;
    vector<ll> A(N, 0);
    for (int i = 0; i < N; i++) { cin >> A[i]; }

    ll count = 0;
    for (int i = 1; i < N; i++) {
        ll oldi = A[i];
        if (A[i - 1] + A[i] > x) {
            // count += ;
            A[i] = (x - A[i - 1]);
            count += oldi - A[i] ;
        }.
    }

    // for (auto v : A) { cout << v << " "; } cout << endl;

    cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:10: error: expected primary-expression before '.' token
   19 |         }.
      |          ^
a.cc:20:5: error: expected unqualified-id before '}' token
   20 |     }
      |     ^
Language: C++

#include<cstdio>
int main(){
  int n;
  long long x;
  scanf("%d %lld", &n, &x);
  
  long long a[100000];
  for(int i=0; i<n; i++)
    scanf("%lld", &a[i]);
  
  long long ans = 0;
  if(a[0]>x){
    ans = a[0] - x;
    a[0] -= x;
    if(x == 0){
      ans = a[0];
      a[0] = 0;
  }
  
  for(int i=0; i<(n-1); i++){
    long long sum = a[i] + a[i+1];
    if( sum > x ){
      long long diff = sum - x;
      ans += diff;
      a[i+1] -= diff;
    }
  }
  printf("%lld", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:2:11: note: to match this '{'
    2 | int main(){
      |           ^
Language: C++

#include<cstdio>
int main(){
  int n;
  long long x;
  scanf("%d %lld", &n, &x);
  
  long long a[10000000000];
  for(int i=0; i<n; i++)
    scanf("%lld", &a[i]);
  
  long long ans = 0;
  if(a[0]>x){
    ans = a[0] - x;
    a[0] -= x;
  }
  
  for(int i=0; i<(n-1); i++){
    if( a[i]+a[i+1] >= x ){
      diff = a[i+1] - x;
      ans += diff;
      a[i+1] -= diff;
    }
  }
  printf("%lld", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: 'diff' was not declared in this scope
   19 |       diff = a[i+1] - x;
      |       ^~~~
Language: C++

#include<cstdio>
int main(){
  int n, x;
  scanf("%d %d", &n, &x);
  
  long int a[];
  for(int i=0; i<n, i++)
    scanf("%d", &a[i]);
  
  long long ans = 0;
  while(a[0]>x){
    a[0]--;
    ans++;
  }
  for(int i; i<(n-1); i++){
    while( a[i]+a[i+1] >= x ){
      a[i+1]--;
      ans++;
    }
  }
  printf("%lld", ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:12: error: storage size of 'a' isn't known
    6 |   long int a[];
      |            ^
a.cc:7:24: error: expected ';' before ')' token
    7 |   for(int i=0; i<n, i++)
      |                        ^
      |                        ;
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N, x;
    cin >> N >> x;
    rep(i, N) {
        cin >> a[i];
    }
    ll ans = 0;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:16: error: 'a' was not declared in this scope
   15 |         cin >> a[i];
      |                ^
a.cc:20:12: error: 'a' was not declared in this scope
   20 |         if(a[i]+a[i+1] <= x) {
      |            ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

long long arr[100002];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    long long x;
    cin >> n >> x;

    long long tot = 0;

    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        tot += max(0, arr[i] - x);
        arr[i] = min(x, arr[i]);
    }

    for(int i = 1; i < n; ++i){
        if(arr[i - 1] + arr[i] > x){
            long long dec = arr[i - 1] + arr[i] - x;
            arr[i] -= dec;
            tot += dec;
        }
    }

    cout << tot;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:19: error: no matching function for call to 'max(int, long long int)'
   25 |         tot += max(0, arr[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:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:25:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   25 |         tot += max(0, arr[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:25:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   25 |         tot += max(0, arr[i] - x);
      |                ~~~^~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: no matching function for call to 'max(int, ll)'
   34 |     temp=max(0,x-temp);
      |          ~~~^~~~~~~~~~
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:34:13: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   34 |     temp=max(0,x-temp);
      |          ~~~^~~~~~~~~~
/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:3:
/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:34:13: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |     temp=max(0,x-temp);
      |          ~~~^~~~~~~~~~
Language: C++

#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll N,x,pre,A,ans;

int main(){
    cin>>N>>x;
    rep(i,N){
        cin>>A;
        if(i){
            if(pre+A>x){
                    ans+=pre+A-x;
                    pre=max(x-pre,0);
            }
            else pre=A;
        }
        else pre=A;

    }
    out(ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:28: error: no matching function for call to 'max(ll, int)'
   31 |                     pre=max(x-pre,0);
      |                         ~~~^~~~~~~~~
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:3:
/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:31:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |                     pre=max(x-pre,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,
                 from a.cc:5:
/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:31:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |                     pre=max(x-pre,0);
      |                         ~~~^~~~~~~~~
Language: C++

import java.util.*;
import java.lang.*;
public class Main{
public static void main(String[] args) 
{
	Scanner scanner=new Scanner(System.in);
	int n=scanner.nextInt();
	int x=scanner.nextInt();
	int[] a=new int[n];
	for(int i=0;i<n;i++)a[i]=scanner.nextInt();
	int cnt=0;
	for(int i=0;i<n-2;i++)
	{	
		while((a[i]+a[i+1])>x){
			if((a[i+1]+a[i+2])>x){
				{if(a[i+1]>0){a[i+1]--;cnt++;}else {a[i]--;cnt++;}}}
				else {
					if(a[i]>0){a[i]--;cnt++;}
					else {a[i+1]--;cnt++;}
				}			
		}
	}
	if(a[n-2]+a[n-1]>x)cnt+=a[n-1]+a[n-2]-x;
	System.out.print(cnt);
}	
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.lang.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main{
      | ^~~~~~
Language: C++

#include <iostream>
#include <math.h>
using namespace std;
typedef long long int ll;
int main() {
    ll N, x, a1, a2, ans = 0;
    cin >> N >> x >> a1;
    for(ll i = 1; i < N; i++) {
        cin >> a2;
        ll sum = a1 + a2;
        if(sum > x) {
            ans += sum - x;
            a1 = max(0ll, b - sum - x);
        } else {
            a1 = a2;
        }
    }
    cout << ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:27: error: 'b' was not declared in this scope
   13 |             a1 = max(0ll, b - sum - x);
      |                           ^
Language: C++

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  int ans = 0;
  //まず左端
  while(a[0] + a[1] > x) {
    if(a[1] >= 0) {
      a[1]--;
      ans++;
    } else {
      a[0]--;
      ans++;
    }
  }
  //つぎに右端
  while(a[N - 1] + a[N - 2] > x) {
    if(a[N - 2] >= 0) {
      a[N - 2]--;
      ans++;
    } else {
      a[N - 1]--;
      ans++;
    }
  }
  for(int i = 0; i < N - 1; i++) {
    while(a[i] + a[i + 1] > x) {
      if(a[i + 1] >= 0) {
        a[i + 1]--;
        ans++;
      } else {
        a[i]--;
        ans++;
      }
    }
    cout << ans << endl;
    return 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:46:4: error: expected '}' at end of input
   46 |   }
      |    ^
a.cc:6:12: note: to match this '{'
    6 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,x,a[100000],ans;
int32_t main(){
CODE_START;
cin >> n;
cin >> x;
for(ll i=0;i<n;i++)
    cin >> a[i];
for(ll i=1;i<n;i++)
if(a[i]+a[i-1]>x){
        ans=ans+a[i]+a[i-1]-x;
        a[i]=max(0LL,a[i]-a[i]-a[i-1]+x);

}
cout < <ans;
return 0;}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:33:8: error: expected primary-expression before '<' token
   33 | cout < <ans;
      |        ^
Language: C++

#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

ll gcd(ll a, ll b){
  return b == 0 ? a : gcd(b, a % b);
}

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

  ll n, x;
  cin >> n >> x;
  ll ans = 0;

  ll pre, cur;
  cin >> pre;
  REP(i, n-1) {
    cin >> cur;
    ll diff = (pre + tmp) - x;

    if(diff > 0) {
      ans += diff;
      cur -= min(cur, diff);
    }
    pre = cur;
  }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:34:22: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   34 |     ll diff = (pre + tmp) - x;
      |                      ^~~
      |                      tm
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;

int main(){
	int N;
	cin>>N;
	vector<ll> A(N);
	vector<ll> B(N, 0);
	ll x;
	cin>>x;
	cin>>A[0];
	B[0] = A[0];
	for(int i = 1; i < N; i++){
		cin>>A[i];
		B[i] = B[i - 1] + A[i];
	}
	
	ll cnt = 0;
	ll st = 0;
	st = A[0];
	ll em = 0;
	//cout<<st<<endl;
	for(ll i = 1; i < N; i++){
		em = 0;
		st += A[i];
		
		if(st > x){
			A[i] -= st - x;
			A[i] < 0)em = abs(A[i]);
			cnt += st - x;
			cnt -= em;
			st -= st - x;
			st += em;
			
			
		}

		st -= A[i - 1];
	}
	cout<<cnt<<endl;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:33: error: expected ';' before ')' token
   36 |                         A[i] < 0)em = abs(A[i]);
      |                                 ^
      |                                 ;
Language: C++

#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |     ans += count;
      |     ^~~
      |     abs
a.cc:31:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |   cout << ans << endl;
      |           ^~~
      |           abs
Language: Java

import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int x = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i<N; i++) {
            a[i] = sc.nextInt();
        }
        long ans = 0;
        for(int i = 1; i<N; i++) {
            long sum = a[i]+a[i-1];
            if(sum>x) {
                ans += sum-x;
                a[i] = Math.max(0, a[i]-sum);
            }
        }
        System.out.println(ans);
    }
}

Compiler output:
Main.java:16: error: incompatible types: possible lossy conversion from long to int
                a[i] = Math.max(0, a[i]-sum);
                               ^
1 error
Language: C++

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

typedef long long ll;

int main(){
    int n;
    ll x;
    cin >> n >> x;
    ll ans = 0;
    ll a[100010];
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:27: error: no matching function for call to 'max(int, ll)'
   19 |         if(i==0) ans+= max(0, a[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: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:19:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   19 |         if(i==0) ans+= max(0, a[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:19:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   19 |         if(i==0) ans+= max(0, a[i]-x);
      |                        ~~~^~~~~~~~~~~
Language: C++

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

int box[100005];
int main()
{
    int n,x;
    scanf("%d%d",&n,&x)；
    
        for (int i=1;i<=n;i++)
            scanf("%d",&box[i]);
        long long all=0;
        if (box[1]>x)
        {
            all+=box[1]-x;
            box[1]=x;
        }
        for (int i=2;i<=n;i++)
        {
            int k = box[i]+box[i-1]-x;
            if (k>0)
            {
                all+=k;
                box[i]-=k;
            }
        }
        cout<<all;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:24: error: expected ';' before '\U0000ff1b'
    9 |     scanf("%d%d",&n,&x)；
      |                        ^~
      |                        ;
a.cc:11:22: error: 'i' was not declared in this scope
   11 |         for (int i=1;i<=n;i++)
      |                      ^
Language: C++

#include <iostream>
#include <vector>

#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
int main(int argc, const char * argv[]) {
    ll n, x;
    cin >> n >> x;
    vector<ll> v1(n), v2(n);
    for (ll i = 0; i < n; i++) {
        cin >> v1[i];
        v2[i] = v1[i];
    }
    
    ll cnt = 0;
    for (ll i = 0; i < n - 1; i++) {
        if (v1[i] + v1[i+1] > x) {
            cnt += v1[i] + v1[i+1] - x;
            v1[i+1] -= v1[i] + v1[i+1] - x;
        }
    }
    
    ll ans = cnt;
    vrev(v2);
    for (ll i = 0; i < n - 1; i++) {
        if (v2[i] + v2[i+1] > x) {
            cnt += v2[i] + v2[i+1] - x;
            v2[i+1] -= v2[i] + v2[i+1] - x;
        }
    }
    
    ans = min(ans, cnt);
    cout << cnt << endl;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:4:17: error: 'reverse' was not declared in this scope
    4 | #define vrev(v) reverse((v).begin(), (v).end())
      |                 ^~~~~~~
a.cc:26:5: note: in expansion of macro 'vrev'
   26 |     vrev(v2);
      |     ^~~~
Language: C++

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	ll N,X,ans=0;
	cin>>N>>X;
	VI a(N);
	REP(i,N){
		cin>>a[i];
		if(a[i]>X){
			ans+=a[i]-X;
			a[i]=X;
		if(a[i]+a[i-1]>X && i-1>=0){
			ans+=a[i]+a[i-1]-X;
			a[i]-=a[i]+a[i-1]-X;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:2: error: expected '}' at end of input
   34 | }
      |  ^
a.cc:15:11: note: to match this '{'
   15 | int main(){
      |           ^
Language: Java

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int number = sc.nextInt();
		long max = sc.nextLong();
		int count = 0;
		long[] c = new long[number];
		for(int i = 0; i < number; i++){
			long a = sc.nextLong();
			c[i]=a;
		}
		for(int i = 1; i < number; i++){
			if(c[i-1]+c[i]>max){
				if(((a[i-1]+a[i])-x) < a[i]){
					count += c[i-1]+c[i]-max;
					c[i]=max-c[i-1];
				}else{
					count += c[i]-max+c[i-1];
					
					c[i]=0;
				}
			}
		}
		System.out.println(count);
	}
}

Compiler output:
Main.java:15: error: cannot find symbol
				if(((a[i-1]+a[i])-x) < a[i]){
				     ^
  symbol:   variable a
  location: class Main
Main.java:15: error: cannot find symbol
				if(((a[i-1]+a[i])-x) < a[i]){
				            ^
  symbol:   variable a
  location: class Main
Main.java:15: error: cannot find symbol
				if(((a[i-1]+a[i])-x) < a[i]){
				                  ^
  symbol:   variable x
  location: class Main
Main.java:15: error: cannot find symbol
				if(((a[i-1]+a[i])-x) < a[i]){
				                       ^
  symbol:   variable a
  location: class Main
4 errors
Language: C++

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    int N, x;
    cin >> N >> x;
    REP(i, N)
    {
        cin >> A[i];
    }

    ll n = 0;
    FOR(i, N, 1)
    {
        if (A[i] + A[i - 1] <= x)
            continue;
        int t = x - (A[i] + A[i - 1]);

        n += t;
        A[i] -= std::min(t, A[i]);
    }
    cout << n << endl;
    return 0;
}

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

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];

int main()
{
    int N, x;
    cin >> N >> x;
    REP(i, N)
    {
        cin >> A[i];
    }

    ll n = 0;
    FOR(i, N, 1)
    {
        if (A[i] + A[i - 1] <= x)
            continue;
        int t = x - (A[i] + A[i - 1]);

        n += t;
        A[i] -= std::min(t, A[i]);
    }
    cout << n << endl;
    return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inclde; did you mean #include?
    1 | #inclde < bits / stdc++.h >
      |  ^~~~~~
      |  include
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair<ll, ll> pll;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:19:5: error: 'cin' was not declared in this scope
   19 |     cin >> N >> x;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inclde < bits / stdc++.h >
a.cc:33:22: error: 'min' is not a member of 'std'
   33 |         A[i] -= std::min(t, A[i]);
      |                      ^~~
a.cc:35:5: error: 'cout' was not declared in this scope
   35 |     cout << n << endl;
      |     ^~~~
a.cc:35:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:35:18: error: 'endl' was not declared in this scope
   35 |     cout << n << endl;
      |                  ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #inclde < bits / stdc++.h >
Language: C++

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	long long n, x;
	cin >> n >> x;
	vector<long long> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int cnt = 0;
	for(int i = 1; i < n; i++) {
		long long adj = a[i] + a[i - 1];
		if(adj > x) {
			cnt += adj - x;
			a[i] = max(a[i] - (adj - x), 0);
		}
	}
	cout << cnt << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:35: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)'
   19 |                         a[i] = max(a[i] - (adj - 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:19:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   19 |                         a[i] = max(a[i] - (adj - 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:19:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   19 |                         a[i] = max(a[i] - (adj - x), 0);
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int main(){
  int n,x;
  int c=0;
  cin>>n>>x;
  int arr[n];
  for(int i=0;i<n;i++)cin>>arr[i];
  if(arr[0]>x){
    c = arr[0]-x;
    arr[0]=x;
  }
  for(int i==1; i <n; i++){
    int a;
    a = arr[i] + arr[i-1];
    if(a > x){
      c+=a-x;
      arr[i] =a-x;
    }
  }
  
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:12: error: expected ';' before '==' token
   13 |   for(int i==1; i <n; i++){
      |            ^~
      |            ;
a.cc:13:12: error: expected primary-expression before '==' token
   13 |   for(int i==1; i <n; i++){
      |            ^~
a.cc:13:21: error: expected ')' before ';' token
   13 |   for(int i==1; i <n; i++){
      |      ~              ^
      |                     )
a.cc:13:23: error: 'i' was not declared in this scope
   13 |   for(int i==1; i <n; i++){
      |                       ^
Language: C++

/**
*   @Author : MeGaCrazy
*   @InitTime : Sun Dec 30 14:56:45 2018
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+7;
long long a[N];
int main(){
#ifndef ONLINE_JUDGE
//   freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
    long long n,m;
    scanf("%lld %lld",&n,&m);

    for(int i=0;i<n;i++){
    	scanf("%lld",&a[i]);
    }
    long long ans=0;
    for(int i=0;i+1<n;i++){
    	long long cur=a[i]+a[i+1];
    	if(cur>m){
    	     long long dif=cur-m;
    	     a[i+1]=max(0,a[i+1]-dif);
    	     ans+=dif;	
    	}
    }
    printf("%lld",ans);



}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:24: error: no matching function for call to 'max(int, long long int)'
   32 |              a[i+1]=max(0,a[i+1]-dif);
      |                     ~~~^~~~~~~~~~~~~~
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:12:
/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:32:24: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |              a[i+1]=max(0,a[i+1]-dif);
      |                     ~~~^~~~~~~~~~~~~~
/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:32:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |              a[i+1]=max(0,a[i+1]-dif);
      |                     ~~~^~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  ll c_all = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    c_all += a.at(i);
  }
  if (a.at(0) > x) a.at(0) = x;
  for (int i = 0; i < n - 1; i++) {
    if (a.at(i) + a.at(i + 1) > x) {
      int tmp += a.at(i) + a.at(i + 1) - x;
      a.at(i + 1) -= tmp;
    }
  }
  ll c_min = accumulate(a.begin(), a.end(), 0);
  cout << c_all - c_min << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:15: error: expected initializer before '+=' token
   18 |       int tmp += a.at(i) + a.at(i + 1) - x;
      |               ^~
a.cc:19:22: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   19 |       a.at(i + 1) -= tmp;
      |                      ^~~
      |                      tm
Language: C++

# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    optimize_cin();
 
    lint N; cin >> N;
    lint x; cin >> x;
    vector<lint> a(N);
    rep (i, N) { cin >> a[i]; }
 
    lint cnt = 0;

    rep (lint i = 0; i < N - 1; ++i)
    {
        if (a[i]+a[i+1] > x)
        {
            if (a[i] > a[i+1])
            {
                cnt += a[i] - (x - a[i+1]);
                a[i] = x - a[i+1];
            }
            else
            {
                cnt += a[i+1] - (x - a[i]);
                a[i+1] = x - a[i];
            }
        }
    }
 
    cout << cnt << "\n";
 
    return 0;
}


Compiler output:
a.cc:26:36: error: macro "rep" requires 2 arguments, but only 1 given
   26 |     rep (lint i = 0; i < N - 1; ++i)
      |                                    ^
a.cc:2:10: note: macro "rep" defined here
    2 | # define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
      |          ^~~
a.cc: In function 'int main()':
a.cc:26:5: error: 'rep' was not declared in this scope
   26 |     rep (lint i = 0; i < N - 1; ++i)
      |     ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)

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

Compiler output:
a.cc: In function 'int main()':
a.cc:21:29: error: expected ')' before '{' token
   21 |     for(ll i = 1; i < n; i++{
      |        ~                    ^
      |                             )
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: 'i' was not declared in this scope
   18 |         cnt += a[i] -x;
      |                  ^
a.cc:21:29: error: expected ')' before '{' token
   21 |     for(ll i = 1; i < n; i++{
      |        ~                    ^
      |                             )