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

#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<vs> vvs;

typedef vector<pair<int, int>> vpi;
typedef vector<tuple<int, int, int>> vti;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin >> n;
    vl a(n+1), b(n+1);
    for (int i=0;i<n+1;i++) cin >> a[i];
    for (int i=0;i<n;i++) cin >> b[i];
    
    ll prev=0, ans=0;
    for (int i=0;i<n+1;i++){
        int now = b[i] + prev;
        ans += min(a[i], now);
        if (now > a[i]) prev = min(b[i], now - a[i]);
        else prev = 0;
    }
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:19: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, int&)'
   33 |         ans += min(a[i], now);
      |                ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:33:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   33 |         ans += min(a[i], now);
      |                ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:33:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |         ans += min(a[i], now);
      |                ~~~^~~~~~~~~~~
Language: C++

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

int main(void){
    int n;
    cin>>n;
    vector <ll> a(n+1);
    rep(i, n+1){
        cin>>a[i];
    }
    
    vector <ll> b(n);
    rep(i, n){
        cin>>b[i];
    }
    int ans=accumulate(a.begin(), a.end(), 0);s
    rep(i, n){
        ll first=min(a[i], b[i]);
        a[i]-=first;s
        ll second=min(b[i]-first, a[i+1]);
        a[i+1]-=second;
    }
    ans-=accumulate(a.begin(), a.end(), 0);
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:47: error: 's' was not declared in this scope
   27 |     int ans=accumulate(a.begin(), a.end(), 0);s
      |                                               ^
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     rep(i, n){
      |         ^
a.cc:3:32: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (int i=0;i<n;i++)
      |                                ^
Language: C++

#include <iostream>

const int MAXN=1e5+5;
long long int a[MAXN],n[MAXN];
int main() {
	
	int n;
	scanf("%d",&n);
    
    for(int i=0;i<n+1;i++){
    	scanf("%d",&a[i]);
	}
    long long int sum=0;
    for(int i=0;i<n;i++){
    	scanf("%d",&b[i]);
    	if(b[i]<=a[i]){
    		sum+=b[i];
		}else if(b[i]<=(a[i]+a[i+1])){
			sum+=b[i];
			a[i+1]-=b[i]-a[i];
		}else{
			sum+=a[i]+a[i+1];
			a[i+1]=0;
		}
	}
	printf("%lld",sum);
	return 0;
    
}





/*
2 3 5
3 3
3 2
3 2

4 3 8
8

1 1 100
1 1 1
1 2
1 3
*/





 

Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'b' was not declared in this scope
   15 |         scanf("%d",&b[i]);
      |                     ^
Language: C

#include<cstdio>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
const long  maxn = 1e5+7;
long long n;
long long a[maxn];
long long b[maxn];
long long i,j;
long long count = 0;
int main(void)
{
	scanf("%d",&n);

	for(i = 0;i<=n;i++)
		scanf("%ld",&a[i]);
	for(i = 0;i<n;i++)
		scanf("%ld",&b[i]);
	
	for(i = 0;i<n;i++)
	{
		long long temp = b[i] - a[i];
		if(temp >= 0)
		{
			count += a[i];
			b[i] = temp;
			temp = b[i] - a[i+1];
			if(temp >= 0)
			{
				count += a[i+1];
				a[i+1] = 0;
			}
			else{
					count += b[i];
					b[i] = 0;
					a[i+1] = abs(temp);
				}
		}
		else 
		{
			count += b[i];
			a[i] -= b[i];
		}
	}
	printf("%ld",count);
	return 0;
}

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

#include<stdio.h>
#include<stdlib.h>
const long  maxn = 1e5+7;
long long n;
long long a[maxn];
long long b[maxn];
long long i,j;
long long count = 0;
int main(void)
{
	scanf("%d",&n);

	for(i = 0;i<=n;i++)
		scanf("%ld",&a[i]);
	for(i = 0;i<n;i++)
		scanf("%ld",&b[i]);
	
	for(i = 0;i<n;i++)
	{
		long long temp = b[i] - a[i];
		if(temp >= 0)
		{
			count += a[i];
			b[i] = temp;
			temp = b[i] - a[i+1];
			if(temp >= 0)
			{
				count += a[i+1];
				a[i+1] = 0;
			}
			else{
					count += b[i];
					b[i] = 0;
					a[i+1] = abs(temp);
				}
		}
		else 
		{
			count += b[i];
			a[i] -= b[i];
		}
	}
	printf("%ld",count);
	return 0;
}

Compiler output:
main.c:5:11: error: variably modified 'a' at file scope
    5 | long long a[maxn];
      |           ^
main.c:6:11: error: variably modified 'b' at file scope
    6 | long long b[maxn];
      |           ^
Language: C++

#include<iostream>
using namespace std;
typedef long long int in64;
int main(){
  int64 n;
  cin>>n;
  int64 a[n],b[n];
  for(int i=0;i<=n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++)
    cin>>b[i];
  int64 sum=0;
  for(int i=0;i<n;i++){
    sum+=min(b[i],a[i]+a[i+1]);
  }
  cout<<sum<<"\n";
  return 0;  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'int64' was not declared in this scope; did you mean 'in64'?
    5 |   int64 n;
      |   ^~~~~
      |   in64
a.cc:6:8: error: 'n' was not declared in this scope
    6 |   cin>>n;
      |        ^
a.cc:7:8: error: expected ';' before 'a'
    7 |   int64 a[n],b[n];
      |        ^~
      |        ;
a.cc:9:10: error: 'a' was not declared in this scope
    9 |     cin>>a[i];
      |          ^
a.cc:11:10: error: 'b' was not declared in this scope
   11 |     cin>>b[i];
      |          ^
a.cc:12:8: error: expected ';' before 'sum'
   12 |   int64 sum=0;
      |        ^~~~
      |        ;
a.cc:14:5: error: 'sum' was not declared in this scope
   14 |     sum+=min(b[i],a[i]+a[i+1]);
      |     ^~~
a.cc:14:14: error: 'b' was not declared in this scope
   14 |     sum+=min(b[i],a[i]+a[i+1]);
      |              ^
a.cc:14:19: error: 'a' was not declared in this scope
   14 |     sum+=min(b[i],a[i]+a[i+1]);
      |                   ^
a.cc:16:9: error: 'sum' was not declared in this scope
   16 |   cout<<sum<<"\n";
      |         ^~~
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'vectro' was not declared in this scope
    9 |   vectro<ll> b(n);
      |   ^~~~~~
a.cc:9:12: error: expected primary-expression before '>' token
    9 |   vectro<ll> b(n);
      |            ^
a.cc:9:14: error: 'b' was not declared in this scope
    9 |   vectro<ll> b(n);
      |              ^
Language: C++

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

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

Compiler output:
a.cc:2:2: error: invalid preprocessing directive #typedef
    2 | #typedef long long ll;
      |  ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:10: error: 'll' was not declared in this scope
    8 |   vector<ll> a(n+1);
      |          ^~
a.cc:8:12: error: template argument 1 is invalid
    8 |   vector<ll> a(n+1);
      |            ^
a.cc:8:12: error: template argument 2 is invalid
a.cc:9:3: error: 'vectro' was not declared in this scope
    9 |   vectro<ll> b(n);
      |   ^~~~~~
a.cc:9:14: error: 'b' was not declared in this scope
    9 |   vectro<ll> b(n);
      |              ^
a.cc:12:17: error: invalid types 'int[int]' for array subscript
   12 |     ans += min(a[0],b[0]);
      |                 ^
a.cc:13:6: error: invalid types 'int[int]' for array subscript
   13 |     a[0] -= ans;
      |      ^
a.cc:16:17: error: invalid types 'int[int]' for array subscript
   16 |     ans += min(a[1],b[0]);
      |                 ^
a.cc:17:6: error: invalid types 'int[int]' for array subscript
   17 |     a[1] -= ans;
      |      ^
Language: C++

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

int main(){
    int N; cin >> N;
    vector <int> A(N+1);
    vector <int> B(N);
    rep(i,N+1) cin >> A[i];
    rep(i,N) cin >> B[i];
    
    int ans=0;
    //N人の勇者チャレンジ
    rep(i,N){
        int sen=B[i]-A[i];
        if (B[i]>A[i] && (sen <= A[i+1])){
            ans=ans+{A[i]+(B[i]-A[i])};
            A[i+1]-=(B[i]-A[i]);
        }
        else if (B[i]>A[i] && (sen > A[i+1])){
            ans+=(A[i]+A[i+1]);
            A[i+1]=0;
        }
        else ans+=B[i];
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: expected primary-expression before '{' token
   17 |             ans=ans+{A[i]+(B[i]-A[i])};
      |                     ^
Language: C++

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

int main(){
    int N; cin >> N;
    vector <int> A(N+1);
    vector <int> B(N);
    rep(i,N+1) cin >> A[i];
    rep(i,N) cin >> B[i];
    
    int ans=0;
    //N人の勇者チャレンジ
    rep(i,N){
        int sen=B[i]-A[i];
        if (B[i]>A[i] && (sen <= A[i+1])){
            ans+={A[i]+(B[i]-A[i])};
            A[i+1]-=(B[i]-A[i]);
        }
        else if (B[i]>A[i] && (sen > A[i+1])){
            ans+=A[i]+A[i+1];
            A[i+1]=0;
        }
        else ans+=B[i];
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:35: error: invalid use of brace-enclosed initializer list
   17 |             ans+={A[i]+(B[i]-A[i])};
      |                                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long n;
long long k;
long long a[200000006];
long long b[200000006];
long long count1 = 0;
int main()
{
	cin >> n;
    for(int i=0;i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n;i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < n;i++)
    {
        if(a[i] >= b[i]) {
            count1 += b[i];
        } else {
            count1 += a[i];
            b[i] -= a[i];
            if(a[i+1] >= b[i]) {
                a[i+1] -= b[i];
                count1 += b[i];
            } else {
                count1 += a[i+1];
                a[i+1] = 0;
            }
        }
    }
    cout << count1;
}


Compiler output:
/tmp/ccZlXDLR.o: in function `main':
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x117): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x13b): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x145): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x243): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x24d): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x271): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x27b): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
a.cc:(.text+0x2bb): relocation truncated to fit: R_X86_64_PC32 against symbol `count1' defined in .bss section in /tmp/ccZlXDLR.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main()
{
  long long N, Sum=0;
  cin >> N;
  vector<long long> T(N+1);
  vector<long long> Y(N);
  rep(i,N+1) cin >> T.at(i);
  rep(i,N) cin >> Y.at(i);
  rep(i,N){
    if(Y.at(i)<=T.at(i)){
      Sum=Sum+Y.at(i);
    }
    else if(Y.at(i)<=T.at(i)+T.at(i+1)){
      Sum=Sum+Y.at(i);
      T.at(i+1)=T.at(i+1)-(Y.at(i)-T.at(i));
    }
    else if(Y.at(i)> T.at(i)+T.at(i+1)){
      Sum=Sum+T.at(i)+T.at(i+1);
      T.at(i+1)=0;
    }
  }
  cout << Sum << endl;
} 

Compiler output:
a.cc:4:2: error: 'std' does not name a type
    4 |  std;
      |  ^~~
Language: C++

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

using namespace std;

typedef long long int ll;
int MAXN = 100005;

int n;
ll ans;
ll a[MAXN], B[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; ++i) 
	{
        scanf("%lld", &a[i]);
    }
    for (int i = 1; i < n + 1; ++i)
	{
        scanf("%lld", &B[i]);
        if (B[i] <= a[i])
            ans += B[i];
        else if (B[i] <= a[i] + a[i + 1]) 
		{
            ans += B[i];
            a[i + 1] -= (B[i] - a[i]);
        }
        else 
		{
            ans += (a[i] + a[i + 1]);
            a[i + 1] = 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Compiler output:
a.cc:11:6: error: size of array 'a' is not an integral constant-expression
   11 | ll a[MAXN], B[MAXN];
      |      ^~~~
a.cc:11:15: error: size of array 'B' is not an integral constant-expression
   11 | ll a[MAXN], B[MAXN];
      |               ^~~~
Language: C++

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

const int MAXN = 1e5 + 5;

int n;
ll ans;
ll a[MAXN], b[MAXN];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; ++i)
	{
        scanf("%lld", &a[i]);
    }
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &b[i]);
        if (b[i] <= a[i])
            ans += b[i];
        else if (b[i] <= a[i] + a[i + 1]) {
            ans += B[i];
            a[i + 1] -= (b[i] - a[i]);
        }
        else {
            ans += (a[i] + a[i + 1]);
            a[i + 1] = 0;
        }
    }
    printf("%lld", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:20: error: 'B' was not declared in this scope
   22 |             ans += B[i];
      |                    ^
Language: C++

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



int main(){
    int n;
    cin >> n;
    int sum=0;
    int a[n+1];
    int b[n];
    rep(i,n+1){
        int x;
        cin >> x;
        a[i] = x;
    }
    rep(i,n){
        int x;
        cin >> x;
        b[i] = x;
    }
    rep(i,n){
        if(a[i]-b[i] > 0){
            a[i] = a[i]-b[i];
            sum+=b[i];
            b[i] = 0;
        }
        else{
            b[i] = b[i] -a[i];
            sum+=a[i];
            a[i] = 0;
        }
        if(b[i] > 0 && a[i+1]-b[i] >0){
            a[i+1] = a[i+1]-b[i];
            sum+=b[i];
            b[i] = 0;
        }
        else (b[i] > 0 && a[i+1]-b[i] <=0){
            b[i] = b[i] -a[i+1];
            sum+=a[i+1];
            a[i+1] = 0;
        }
        
    }
    cout << sum <<endl;
    
    
        
    
    
    
    return 0;
}













Compiler output:
a.cc: In function 'int main()':
a.cc:40:43: error: expected ';' before '{' token
   40 |         else (b[i] > 0 && a[i+1]-b[i] <=0){
      |                                           ^
      |                                           ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define loop(i, a, b) for(ll i = a; i < b; i++)
#define rloop(i, e, s) for(ll i = e; i >= s; i--)
#define mod 1000000007
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr);

int main()
{//CITY SAVERS
     ll n, ans = 0, x = 0;
     cin >> n;
     ll a[n+1], b[n];
     loop(i, 0, n+1){
         cin >> a[i];
         x += a[i];
     }
     loop(i, 0, n) cin >> b[i];
     rloop(i, n-1, 0){
         if(a[i+1] > b[i]) {
             a[i+1] -= b[i];
         }
         else if (a[i+1]== b[i]) a[i+1] = 0;
         else{
             b[i] -= a[i+1];
             a[i+1] = 0;
             if(a[i] >= b[i]) a[i] -= b[i];
             else a[i] = 0;
         }
     }
     loop(i, 0, n+1) ans += a[i];
    cout << x - ans << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:33:29: error: expected '}' at end of input
   33 |     cout << x - ans << endl;
      |                             ^
a.cc:11:1: note: to match this '{'
   11 | {//CITY SAVERS
      | ^
Language: C++

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

int main () {
  int n; cin >> n;
  vector<int64_t> a(n+1);
  for (int i=0;i<n+1;i++)
    cin >> a.at(i);
  vector<int64_t> b(n);
  for (int i=0;i<n;i++)
    cin >> b.at(i);
  int ans = 0;
  for (int i=0;i<n;i++) {
    int p = min(a.at(i), b.at(i));
    ans += p;
    a.at(i) -= p;
    b.at(i) -= p;
    int q = min(a.at(i+1), b.at(i))
      ans += q;
    a.at(i+1) -= q;
    b.at(i) -= q;
  }
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:7: error: expected ',' or ';' before 'ans'
   19 |       ans += q;
      |       ^~~
Language: C++

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

int main () {
  int n; cin >> n;
  vector<int64_t> a(n+1);
  for (int i=0;i<n+1;i++)
    cin >> a.at(i);
  vector<int64_t> b(n);
  for (int i=0;i<n;i++)
    cin >> b.at(i);
  int ans = 0;
  for (int i=0;i<n;i++) {
    int p += min(a.at(i), b.at(i));
    ans += p;
    a.at(i) -= p;
    b.at(i) -= p;
    int q += min(a.at(i+1), b.at(i))
      ans += q;
    a.at(i+1) -= q;
    b.at(i) -= q;
  }
  cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:11: error: expected initializer before '+=' token
   14 |     int p += min(a.at(i), b.at(i));
      |           ^~
a.cc:15:12: error: 'p' was not declared in this scope
   15 |     ans += p;
      |            ^
a.cc:18:11: error: expected initializer before '+=' token
   18 |     int q += min(a.at(i+1), b.at(i))
      |           ^~
a.cc:20:18: error: 'q' was not declared in this scope
   20 |     a.at(i+1) -= q;
      |                  ^
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n;
  ll a[100001],b[100001];

  cin>>n;
  rep(i,0,n) cin>>a[i];
  rep(i,0,n-1) cin>>b[i];
  b[n]=0;

  ll cnt=0;
  rep(i,0,n){
    cnt+=min(a[i],b[i]);
    b[i+1]+=max(0,b[i]-a[i]);
  }

  cout<<cnt<<endl;
}

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

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

int main() {
	ll N, count = 0, num;
	int A[(int)1e5+1];
	cin >> N;
	rep(i, N+1) cin >> A[i];
	rep(i, N){
		cin >> num;
		if(A[i] + A[i+1] <= num){
			count += A[i] + A[i+1];
			A[i+1] = 0;
		}else{
			count += num;
			A[i+1] -= max(0, (num - A[i]));
		}
	}
	cout << count;
}


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


#include <bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vi>
#define rep(i,x,n) for(int (i)=(x);(i)<(n);(i)++)
using namespace std;

int main(){
    
    int n;
    long ans=0
    cin >> n;
    vector<long> a(n+1),b(n);
    rep(i,0,n+1)cin >> a[i];
    rep(i,0,n)cin >> b[i];

    rep(i,0,n){

        if(b[i] >= a[i]){
            ans += a[i];
            b[i] -= a[i];
            if(b[i] >= a[i+1]){
                ans += a[i+1];
                a[i+1] = 0;
            }else{
                ans += b[i];
                a[i+1] -= b[i];
            }
        }else{
            ans += b[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: expected ',' or ';' before 'cin'
   12 |     cin >> n;
      |     ^~~
Language: C++

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
	int n, int a[10050], b[10050];
	ll ans = 0;
	cin >> n;
	rep(i, n) a[i];
	rep(i, n) b[i];
	for(int i = 0; i < n; i++){
		//左を全力で倒す
		int left = min(a[i], b[i]);
		ans += left;
		a[i] -= left;
		b[i] -= left;
		//残った戦力で右を全力で倒す
		int right = min(a[i+1], b[i]);
		ans += right;
		a[i+1] -= right;
		b[i] -= right;
	}
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: expected unqualified-id before 'int'
   11 |         int n, int a[10050], b[10050];
      |                ^~~
a.cc:14:19: error: 'a' was not declared in this scope
   14 |         rep(i, n) a[i];
      |                   ^
a.cc:15:19: error: 'b' was not declared in this scope
   15 |         rep(i, n) b[i];
      |                   ^
a.cc:18:32: error: 'a' was not declared in this scope
   18 |                 int left = min(a[i], b[i]);
      |                                ^
a.cc:18:38: error: 'b' was not declared in this scope
   18 |                 int left = min(a[i], b[i]);
      |                                      ^
Language: C

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

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

int main(void){
	int n;
	int *a, in;
	long count = 0;
	scanf("%d", &n);
	a = malloc(sizeof(int) * (n + 1));
	for(int i = 0; i < n + 1; i++)
		scanf("%d", a + i);
	for(int i = 0; i < n; i++){
		scanf("%d", &in);
		int left = min(a[i], b[i]);
		int right = min(a[i + 1], b[i] - left);
		count += left + right;
		a[i + 1] -= right;
	}
	printf("%ld\n", count);
	return 0;
}


Compiler output:
main.c: In function 'main':
main.c:18:38: error: 'b' undeclared (first use in this function)
   18 |                 int left = min(a[i], b[i]);
      |                                      ^
main.c:18:38: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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


 
int main() {
  
  int n;
  long ko=0,kof=0;
  long count=0;
  int aa[n+1]={0};
  int bb[n]={0};
  scanf("%d",&n);
  for(int i=0;i<=n;i++){
  	int a;
    scanf("%d",&a);
    aa[i]=a;
    //cout << aa[i] << endl;
  }
  for(int i=0;i<n;i++){
  	int b;
    scanf("%d",&b);
    bb[i]=b;
    //cout << bb[i] << endl;
  }
  int enm=aa[0];
  for(int i=0;i<n;i++){
  	ko=min(enm,bb[i]);
    kof=min(aa[i+1],(bb[i]-ko));
    enm=aa[i+1]-kof;
    count+=ko+kof;
  }
  
  
	printf("%d\n",count);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:12: error: no matching function for call to 'min(int&, long int)'
   30 |     kof=min(aa[i+1],(bb[i]-ko));
      |         ~~~^~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:30:12: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   30 |     kof=min(aa[i+1],(bb[i]-ko));
      |         ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:30:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |     kof=min(aa[i+1],(bb[i]-ko));
      |         ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
using namespace std;

int n;
int a[100001],b[100000];
long long int ans;

int main(){
    cin>>n;
    for (int i=0; i<n+1; i++){
        cin>>a[i];
    }
    long long int temp=0;
    ans=0;
    for (int i=0; i<n; i++){
        cin>>b[i];
        ans+=min(temp,a[i]);
        a[i]-=temp;
        a[i]=max(a[i],0);
        ans+=min(a[i],b[i]);
        temp=max(0, b[i]-a[i]);
        //cout<<i<<" : "<<temp<<" : "<<ans<<endl;
    }
    ans+=min(temp,a[n]);
    //cout<<min(temp,a[n]);
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: no matching function for call to 'min(long long int&, int&)'
   17 |         ans+=min(temp,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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:17:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   17 |         ans+=min(temp,a[i]);
      |              ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
a.cc:24:13: error: no matching function for call to 'min(long long int&, int&)'
   24 |     ans+=min(temp,a[n]);
      |          ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:24:13: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   24 |     ans+=min(temp,a[n]);
      |          ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include<iostream>
using namespace std;

int n;
long long int a[100001],b[100000];
long long int ans;

int main(){
    cin>>n;
    for (int i=0; i<n+1; i++){
        cin>>a[i];
    }
    long long int temp=0;
    ans=0;
    for (int i=0; i<n; i++){
        cin>>b[i];
        ans+=min(temp,a[i]);
        a[i]-=temp;
        a[i]=max(a[i],0);
        ans+=min(a[i],b[i]);
        temp=max(0, b[i]-a[i]);
        //cout<<i<<" : "<<temp<<" : "<<ans<<endl;
    }
    ans+=min(temp,a[n]);
    //cout<<min(temp,a[n]);
    cout<<ans<<endl;
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long ans=0,c=0;
  cin>>n;
  vector<long> a(n+1);
  vector<long> b(n);
  for(int i=0;i<n+1;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    ans+=Math.min(a[i],b[i]+c);
    c=Math.max(0,b[i]+c-a[i]);
  }
  ans+=Math.min(c,a[n]);
  cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:10: error: 'Math' was not declared in this scope
   16 |     ans+=Math.min(a[i],b[i]+c);
      |          ^~~~
a.cc:19:8: error: 'Math' was not declared in this scope
   19 |   ans+=Math.min(c,a[n]);
      |        ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long ans=0,c=0;
  cin>>n;
  vector<long> a(n+1);
  vector<long> b(n);
  for(int i=0;i<n+1;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n;i++){
    ans+=min(a[i],b[i]+c);
    c=max(0,b[i]+c-a[i]);
  }
  ans+=min(c,a[n]);
  cout<<ans;
}

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

#include <algorithm>
#include <cstdio>

using namespace std;

int getIndex(int* arr, int index) {
  if ((arr[index - 1] >= arr[index]) && (arr[index - 1] >= arr[index + 1])) {
    return index - 1;
  }
  return arr[index] >= arr[index + 1] ? index : index + 1;
}

int main() {
  int n;
  scanf("%d", &n);

  int city[n + 1];
  long sum = 0;
  int saver[n];
  memset(saver, 0, n + 1);

  for (int i = 0; i < n + 1; ++i) {
    int a;
    scanf("%d", &a);
    city[i] = a;
    sum += a;
  }
  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    saver[i] = a;
  }

  for (int i = 1; i < n; ++i) {
    int prev_saver = saver[i - 1];
    int prev_city = city[i - 1];
    int current_saver = saver[i];
    int current_city = city[i];

    if (prev_saver >= current_saver) {
      // 前の勇者 >= 今の勇者
      // 前の勇者が現在の都市に振り分ける分
      int current_city_part_for_prev_saver = prev_saver - current_saver;
      // 前の勇者が前の都市に振り分ける分
      int prev_city_part_for_prev_saver =
          prev_saver - current_city_part_for_prev_saver;
      if (current_city_part_for_prev_saver >= current_city) {
        // 前の勇者の現在の都市担当分でモンスターを全て倒した場合
        int remaied = current_city_part_for_prev_saver - current_city;
        prev_city_part_for_prev_saver += remaied;
        city[i] = 0;
      } else {
        // 前の勇者の現在の都市担当分でモンスターを全て倒せなかった場合
        city[i] = current_city - current_city_part_for_prev_saver;
      }
      city[i - 1] = max(prev_city - prev_city_part_for_prev_saver, 0);
    } else {
      // 前の勇者 < 今の勇者
      if (prev_saver >= prev_city) {
        // 前の勇者 >= 前の都市
        city[i - 1] = 0;
        city[i] = max(current_city - (prev_saver - prev_city), 0);
      } else {
        // 前の勇者 < 前の都市
        city[i - 1] = prev_city - prev_saver;
      }
    }
  }

  int last_saver = saver[n - 1];
  int last_2nd_city = city[n - 1];
  int last_city = city[n];
  if (last_saver >= last_2nd_city) {
    int remained = last_saver - last_2nd_city;
    city[n - 1] = 0;
    city[n] = max(last_city - remained, 0);
  } else {
    city[n - 1] = last_2nd_city - last_saver;
  }

  long cnt = 0;
  for (int i = 0; i < n + 1; ++i) {
    cnt += city[i];
  }
  printf("%ld\n", sum - cnt);

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:3: error: 'memset' was not declared in this scope
   20 |   memset(saver, 0, n + 1);
      |   ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <cstdio>
  +++ |+#include <cstring>
    3 |
Language: C++

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

	int n = 0;
	ll count = 0;
	scnaf("%d",&n);
	vector<ll>a(n + 1);
	vector<ll>b(n);
	rep0(i, n) scanf("%lld", &a[i]);
	rep0(j, n - 1)scanf("%lld", &b[j]);
	rep0(k, n - 1) {
		if (a[k] >= b[k]) {
			count += b[k];
		}
		else {
			count += a[k];
			b[k] -= a[k];
			if (b[k] >= a[k + 1]) {
				count += a[k + 1];
				a[k + 1] = 0;
			}
			else {
				a[k + 1] -= b[k];
				count += b[k];
			}
		}
	}
	printf("%lld",count);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'scnaf' was not declared in this scope; did you mean 'scanf'?
    9 |         scnaf("%d",&n);
      |         ^~~~~
      |         scanf
Language: C++

#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
typedef long long ll;
using namespace std;
int main() {

	int n = 0;
	ll count = 0;
	scnaf("%d",&n);
	vector<ll>a(n + 1);
	vector<ll>b(n);
	rep0(i, n) scanf("%lld", &a[i]);
	rep0(j, n - 1)scanf("%lld", &b[j]);
	rep0(k, n - 1) {
		if (a[k] >= b[k]) {
			count += b[k];
		}
		else {
			count += a[k];
			b[k] -= a[k];
			if (b[k] >= a[k + 1]) {
				count += a[k + 1];
				a[k + 1] = 0;
			}
			else {
				a[k + 1] -= b[k];
				count += b[k];
			}
		}
	}
	printf("%lld",count);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'scnaf' was not declared in this scope; did you mean 'scanf'?
   14 |         scnaf("%d",&n);
      |         ^~~~~
      |         scanf
Language: C++

#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
typedef long long ll;
using namespace std;
int main() {

	int n;
	ll count = 0;
	scnaf("%d",&n);
	vector<ll>a(n + 1);
	vector<ll>b(n);
	rep0(i, n) scanf("%lld", &a[i]);
	rep0(j, n - 1)scanf("%lld", &b[j]);
	rep0(k, n - 1) {
		if (a[k] >= b[k]) {
			count += b[k];
		}
		else {
			count += a[k];
			b[k] -= a[k];
			if (b[k] >= a[k + 1]) {
				count += a[k + 1];
				a[k + 1] = 0;
			}
			else {
				a[k + 1] -= b[k];
				count += b[k];
			}
		}
	}
	printf("%lld",count);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'scnaf' was not declared in this scope; did you mean 'scanf'?
   14 |         scnaf("%d",&n);
      |         ^~~~~
      |         scanf
Language: C++

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

int main() {
  int n;
  cin >> n;
  vector<long long int> a(n+1), b(n);
  for(int i = 0; i < n+1; i++){
    cin >> a.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> b.at(i);
  }

  long long int count;
  for(int i = 0; i < n; i++){
    if (b.at(i) > a.at(i)){
      if (a.at(i+1) >= b.at(i) - a.at(i)) {
        count += b.at(i);
        a.at(i+1) -= b.at(i) - a.at(i)
      } else {
        count += a.at(i) + a.at(i+1);
        a.at(i+1) = 0;
      }
    } else {
      count += b.at(i);
      a.at(i) -= b.at(i);
    }
  }
  cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:39: error: expected ';' before '}' token
   20 |         a.at(i+1) -= b.at(i) - a.at(i)
      |                                       ^
      |                                       ;
   21 |       } else {
      |       ~
Language: C

#include<stdio.h>
int main(void){
    int N,x;
    scanf("%d",&N);
    int A[N+1],B[N];
    long int sum=0;
    for(int i=0;i<N+1;i++){
        scanf("%d",&A[i]);
        count+=A[i];
    }
    for(int i=0;i<N;i++){
        scanf("%d",&B[i]);
    }
    for(int i=0;i<N;i++){
        if(A[i]>B[i]){
            sum+=B[i];
        }else{
            sum+=A[i];
            x=B[i]-A[i];
            if(x>=A[i+1]){
                sum+=A[i+1];
                A[i+1]=0;
            }else{
                sum+=x;
                A[i+1]-=x;
            }
        }
    }
    printf("%ld\n",sum);
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:9:9: error: 'count' undeclared (first use in this function)
    9 |         count+=A[i];
      |         ^~~~~
main.c:9:9: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<iostream>

using namespace std;

int main()
{
    long int n;
    cin>>n;
    long int a[n+1], b[n];
    for(int i=0; i<n+1; i++)
    {
        cin>>a[i];
        a1[i] = a[i];
    }

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

    int c = 0;

    for(int i=0; i<n; i++)
    {
        if(a[i]+a[i+1] <= b[i])
        {
            c += a[i] + a[i+1];
            a[i+1] = 0;
        }
        else if(a[i] <= b[i])
        {
            b[i] = b[i] - a[i];
            c += a[i] + b[i];
            a[i+1] = a[i+1] - b[i];
        }
        else
            c += b[i];
    }

    cout<<c;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'a1' was not declared in this scope; did you mean 'a'?
   13 |         a1[i] = a[i];
      |         ^~
      |         a
a.cc:19:9: error: 'b1' was not declared in this scope; did you mean 'b'?
   19 |         b1[i] = b[i];
      |         ^~
      |         b