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

#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i],b[i]=a[i];
    sort(b,b+n);
    int count=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])
            count++;
    }
    if(count==2|| count==0)
        cout<<"YES";#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i],b[i]=a[i];
    sort(b,b+n);
    int count=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])
            count++;
    }
    if(count==2|| count==0)
        cout<<"YES";
    else
        cout<<"NO";
}
    else
        cout<<"NO";
}#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i],b[i]=a[i];
    sort(b,b+n);
    int count=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i])
            count++;
    }
    if(count==2|| count==0)
        cout<<"YES";
    else
        cout<<"NO";
}

Compiler output:
a.cc:18:21: error: stray '#' in program
   18 |         cout<<"YES";#include<bits/stdc++.h>
      |                     ^
a.cc:41:2: error: stray '#' in program
   41 | }#include<bits/stdc++.h>
      |  ^
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:18:22: error: 'include' was not declared in this scope
   18 |         cout<<"YES";#include<bits/stdc++.h>
      |                      ^~~~~~~
a.cc:18:30: error: 'bits' was not declared in this scope
   18 |         cout<<"YES";#include<bits/stdc++.h>
      |                              ^~~~
a.cc:18:35: error: 'stdc' was not declared in this scope; did you mean 'std'?
   18 |         cout<<"YES";#include<bits/stdc++.h>
      |                                   ^~~~
      |                                   std
a.cc:20:1: error: expected primary-expression before 'using'
   20 | using namespace std;
      | ^~~~~
a.cc:21:7: error: expected ';' before '{' token
   21 | main()
      |       ^
      |       ;
   22 | {
      | ~      
a.cc:39:5: error: 'else' without a previous 'if'
   39 |     else
      |     ^~~~
a.cc: At global scope:
a.cc:41:3: error: 'include' does not name a type
   41 | }#include<bits/stdc++.h>
      |   ^~~~~~~
a.cc:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main()
      | ^~~~
a.cc:44:1: error: redefinition of 'int main()'
a.cc:4:1: note: 'int main()' previously defined here
    4 | main()
      | ^~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int maxn = 70;
int n, a[maxn], c;

int main()
{
  cin >> n;
  
  for (int i = 0; i < n; i++)
	cin >> a[i];
  
  for (int i = 1; i < n; i++)
	ans += (a[i] - a[i - 1] != 1);
 
  if (ans <= 2)
    	cout << "YES";
  else
    	cout << "NO";
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |         ans += (a[i] - a[i - 1] != 1);
      |         ^~~
      |         abs
a.cc:18:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   18 |   if (ans <= 2)
      |       ^~~
      |       abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007LL
ll pre[100002][2];
ll fact[1000002];
ll inv(ll a,ll b){
   ll res=1;
   while(b){
    if(b%2) res=(res*a)%mod;
    a=(a*a)%mod;
    b/=2;
   }
   return res;
}
ll ncr(ll n,ll r){
  if(r<0 or r>n) return 0;
  return (((fact[n]*inv(fact[r],mod-2))%mod)*inv(fact[n-r],mod-2))%mod;
}
ll arr[100002];
int main() {
       ios::sync_with_stdio(false);
       cin.tie(0);
       cout.tie(0);
       ll n;
       cin>>n;
       ll x=0;
       for(i=1;i<=n;i++){
         cin>>arr[i];
          if(i!=arr[i]){
          x++;
          }
       }
       if(x<=2){
        cout<<"YES";
       }
       else cout<<"NO";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:12: error: 'i' was not declared in this scope
   41 |        for(i=1;i<=n;i++){
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, mod = 1e9 + 7;

int a[maxn], pos[maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        pos[a[i]] = i;
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i){
        if (a[i] != i){
            swap(a[i], a[pos[a[i]]);
            ++cnt;
        }
    }
    if (cnt > 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:35: error: expected ']' before ')' token
   20 |             swap(a[i], a[pos[a[i]]);
      |                                   ^
      |                                   ]
Language: C++

#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n ;
  int arr[n + 1] , h[n + 1] ;
  for(int i = 1 ;i  <= n ; i++){
    cin >> arr[i] ;
    if(arr[i] != i) cnt++ ;
  }
  if(cnt > 2)cout << "NO" ;
  else cout << "YES" ;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: 'cnt' was not declared in this scope; did you mean 'int'?
   15 |     if(arr[i] != i) cnt++ ;
      |                     ^~~
      |                     int
a.cc:17:6: error: 'cnt' was not declared in this scope; did you mean 'int'?
   17 |   if(cnt > 2)cout << "NO" ;
      |      ^~~
      |      int
Language: C++

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

int main()
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;

	int err=0;

	for(int i=1; i<=n; i++)
	{
		int pi;
		cin>>pi;

		if(i!=pi) err++;
	}

	if(err>2) cout "NO" << endl;
	else cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:23: error: expected ';' before string constant
   23 |         if(err>2) cout "NO" << endl;
      |                       ^~~~~
      |                       ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  vector<ll>vec(a+1);
  for(ll i=0;i<a+1;i++){
    cin>>vec.at(i);
  }
  vector<ll>veco(a)
  for(ll i=0;i<a;i++){
    cin>>veco.at(i);
  }
  for(ll i=0;i<a;i++){
    if(veco.at(i)>=vec.at(i)+vec.at(i+1)){
      b+=vec.at(i)+vec.at(i+1);
      vec.at(i+1)=0;
    }
    else{
      b+=veco.at(i);
      vec.at(i+1)=min(vec.at(i+1)-veco.at(i)+vec.at(i),vec.at(i+1));
    }
  }
    cout<<b<<endl;
    return 0;
}

  
  
    
  



Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: expected ',' or ';' before 'for'
   13 |   for(ll i=0;i<a;i++){
      |   ^~~
a.cc:13:14: error: 'i' was not declared in this scope
   13 |   for(ll i=0;i<a;i++){
      |              ^
Language: C++

# include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
  int n;cin>>n;
  int a[n+1],b[n];
  for(int i=0;i<=n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++)
    cin>>b[i];
  int save=0
  for(int i=0;i<n;i++){
    if(a[i]+a[i+1]>b[i]){
      if(a[i]<b[i]){
        save+=a[i]
        a[i+1]-=b[i]-a[i];
      }
      else{
        save+=b[i];
      }
    }
     else if(a[i]+a[i+1]<=b[i]){
      save+=a[i]+a[i+1];
      a[i]=0;a[i+1]=0;
    }
  }cout<<save;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: expected ',' or ';' before 'for'
   14 |   for(int i=0;i<n;i++){
      |   ^~~
a.cc:14:15: error: 'i' was not declared in this scope
   14 |   for(int i=0;i<n;i++){
      |               ^
Language: C++

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

int main(){
  int N;
  cin>>N;
  int A[N+1];
  int B[N];
  for(int i=0;i<N+1;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }
  int sum=0;
  for(int i=N-1;i>=0;i--){
    if(A[i+1]>=B[i]){
      sum+=B[i];
      B[i]=0;
    }else if((B[i]-A[i+1])>=A[i]){
      sum+=A[i+1];
      sum+=A[i];
      A[i]=0;
    }else{
      sum+=A[i+1];
      sum+=B[i]-A[i+1];
      A[i]=A[i]-B[i]+A[i+1];
    }
  }

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

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

int main(){
  int N;
  cin >> N;
  vector<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 count=0;
  for(int i=0;i<N;i++){
    int C=min(A.at(i),B.at(i));
    A.at(i)-=C;
    count+=C;
    B.at(i)-=C;
    int D=min(A.at(i+1),B.at(i)));
    A.at(i+1)-=D;
    count+=D;
    B.at(i)-=D;
  }
  cout << count << endl;
}  

Compiler output:
a.cc: In function 'int main()':
a.cc:20:33: error: expected ',' or ';' before ')' token
   20 |     int D=min(A.at(i+1),B.at(i)));
      |                                 ^
Language: C++

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

int main(){
    int N;cin>>N;
    int a[N+1],b[N+1];
    for(int i=0;i<=N;i++)cin>>a[i];
    for(int i=0;i<N;i++)cin>>b[i];
    int monster=0;

    for(int i=0;i<N;i++){
        int ans1=min(a[i],b[i]);
        int ans2=min(a[i+1],b[i]-ans);
        monster+=ans1;
        monster+=ans2;
        a[i]=ans1;
        a[i+1]-=ans2;
    }
    cout <<monster;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:34: error: 'ans' was not declared in this scope; did you mean 'ans2'?
   14 |         int ans2=min(a[i+1],b[i]-ans);
      |                                  ^~~
      |                                  ans2
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N+1);
  for(int i=0;i<N+1;i++){
    cin>>A.at(i);
  }
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  int_64t ans=0;
  for(int i=0;i<N;i++){
    if(A.at(i)<B.at(i)&&A.at(i)+A.at(i+1)>B.at(i)){
      ans+=B.at(i);
      A.at(i+1)=A.at(i+1)-(B.at(i)-A.at(i));
    }
    else if(A.at(i)<B.at(i)&&A.at(i)+A.at(i+1)<B.at(i)){
      ans+=A.at(i)+A.at(i+1);
      A.at(i+1)=0;
    }
    else if(A.at(i)==B.at(i)){
      ans+=A.at(i);
    }
    else if(A.at(i)>B.at(i)){
      ans+=B.at(i);
    }
  }
  cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:3: error: 'int_64t' was not declared in this scope; did you mean 'int64_t'?
   14 |   int_64t ans=0;
      |   ^~~~~~~
      |   int64_t
a.cc:17:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |       ans+=B.at(i);
      |       ^~~
      |       abs
a.cc:21:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |       ans+=A.at(i)+A.at(i+1);
      |       ^~~
      |       abs
a.cc:25:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |       ans+=A.at(i);
      |       ^~~
      |       abs
a.cc:28:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |       ans+=B.at(i);
      |       ^~~
      |       abs
a.cc:31:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |   cout<<ans<<endl;
      |         ^~~
      |         abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N+1);
  for(int i=0;i<N+1<i++){
    cin>>A.at(i);
  }
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(A.at(i)<B.at(i)&&A.at(i)+A.at(i+1)>B.at(i)){
      ans+=B.at(i);
      A.at(i+1)=A.at(i+1)-(B.at(i)-A.at(i));
    }
    else if(A.at(i)==B.at(i)){
      ans+=A.at(i);
    }
    else if(A.at(i)>B.at(i)){
      ans+=B.at(i);
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:24: error: expected ';' before ')' token
    7 |   for(int i=0;i<N+1<i++){
      |                        ^
      |                        ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<long long> A(n+1), B(n);
  for (int i = 0; i < n + 1; ++i) cin >> A[i];
  for(int i = 0; i < n; ++i) cin >> B[i];
  long long int count=0;
  for (int i = 0; i < n; ++i) {
    if (A[i] <= B[i] + tmp) {
      count += A[i];
      tmp = B[i] + tmp - A[i];
    }
    else if (A[i] > B[i] + tmp) {
      count += B[i] + tmp;
      tmp = 0;
    }
  }
  if(A[n]>=tmp) count += tmp;
  else
    count += A[n];
  cout << count << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   12 |     if (A[i] <= B[i] + tmp) {
      |                        ^~~
      |                        tm
a.cc:21:12: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   21 |   if(A[n]>=tmp) count += tmp;
      |            ^~~
      |            tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);

int main() {
int n;
cin >> n;
vector<int> a(n+1);
vector<int> b(n);
rep(i,n+1) cin >> a.at(i);
rep(i,n) cin >> b.at(i);
ll ans = 0;
rep(i,n){
  int left = min(a.at(i),b.at(i))
  ans += left;
  a.at(i) -= left;
  b.at(i) -= left;

  int right = min(a.at(i+1),b.at(i))
  ans += right;
  a.at(i+1) -= right;
  b.at(i) -= right;
}
cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:3: error: expected ',' or ';' before 'ans'
   18 |   ans += left;
      |   ^~~
a.cc:23:3: error: expected ',' or ';' before 'ans'
   23 |   ans += right;
      |   ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define ll long long
int main() {
    int n;
    cin>>n;
    ll ar[n+1];
    ll a[n];
    REP(i,n+1)
    cin>>ar[i];
    REP(i,n)
    cin>>a[i];
    int c=0;
    ll p=0;
    REP(i,n)
    {
        c+=ar[i];
        c+=ar[i+1];
        p+=min(c,a[i]);
        c=0;
    }
    cout<<p<<endl;
}

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

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a.at(i);
    vector<ll> b(n);
    rep(i,n) cin >> b.at(i);
    ll ans=0;
    rep(i,n){
        ll left=min(a.at(i),b.at(i));
        ans+=left;
        a.at(i)-=left;
        b.at(i)-=legt;
        ll left2=min(a.at(i+1),b.at(i));
        ans+=left2;
        a.at(i+1)-=left2;
    }
    cout << ans << endl;
}
   


Compiler output:
a.cc: In function 'int main()':
a.cc:20:18: error: 'legt' was not declared in this scope; did you mean 'left'?
   20 |         b.at(i)-=legt;
      |                  ^~~~
      |                  left
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
 
int main() {
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a.at(i);
    vector<ll> b(n);
    rep(i,n) cin >> b.at(i);
    rep(i,n){
        ll left=min(a.at(i),b.at(i));
        ans+=left;
        a.at(i)-=left;
        b.at(i)-=legt;
        ll left2=min(a.at(i+1),b.at(i));
        ans+=left2;
        a.at(i+1)-=left2;
    }
    cout << ans << endl;
}
   


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |         ans+=left;
      |         ^~~
      |         abs
a.cc:19:18: error: 'legt' was not declared in this scope; did you mean 'left'?
   19 |         b.at(i)-=legt;
      |                  ^~~~
      |                  left
a.cc:24:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   24 |     cout << ans << endl;
      |             ^~~
      |             abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll main(){
  ll N;
  cin>>N;
  vector<ll>A(N+1);
  vector<ll>B(N);
  for(ll i=0;i<N+1;i++)cin>>A[i];
  for(ll i=0;i<N;i++)cin>>B[i];
  ll ans=0;
  for(ll i=0;i<N;i++){
    if(A[i]<=B[i]){
      ans+=A[i];
      B[i]-=A[i];
    }else{
      ans+=B[i];
      B[i]=0;
    }
    if(A[i+1]<=B[i]){
      ans+=A[i+1];
      A[i+1]=0;
    }else{
      ans+=B[i];
      A[i+1]-=B[i];
      B[i]=0;
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;

  
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | ll main(){
      | ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll main(){
  ll N;
  cin>>N;
  vector<ll>A(N+1);
  vector<ll>B(N);
  for(ll i=0;i<N+1;i++)cin>>A[i];
  for(ll i=0;i<N;i++)cin>>B[i];
  ll ans=0;
  for(ll i=0;i<N;i++){
    if(A[i]<=B[i]){
      ans+=A[i];
      B[i]-=A[i];
    }else{
      ans+=B[i];
      B[i]=0;
    }
    if(A[i+1]<=B[i]){
      ans+=A[i+1];
    }else{
      ans+=B[i];
      A[i+1]-=B[i];
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;

  
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | ll main(){
      | ^~
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long n = scan.nextInt();
        long[] a = new long[n + 1];
        long[] b = new long[n];
        long sum = 0;
        for(int i = 0; i < n + 1; i++){
            a[i] = scan.nextLong();
            sum += a[i];
        }
        for(int i = 0; i < n; i++) b[i] = scan.nextLong();
        for(int i = 0; i < n; i++){
            if(a[i] <= b[i]){
                a[i + 1] = Math.max(0, a[i + 1] - b[i] + a[i]);
                a[i] = 0;
            }else{
                a[i] -= b[i];
            }
        }
        long out = 0;
        for(int i = 0; i < n + 1; i++) out += a[i];
        System.out.println(sum - out);
        scan.close();
    }
}

Compiler output:
Main.java:7: error: incompatible types: possible lossy conversion from long to int
        long[] a = new long[n + 1];
                              ^
Main.java:8: error: incompatible types: possible lossy conversion from long to int
        long[] b = new long[n];
                            ^
2 errors
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        long n = scan.nextInt();
        long[] a = new int[n + 1];
        long[] b = new int[n];
        long sum = 0;
        for(int i = 0; i < n + 1; i++){
            a[i] = scan.nextInt();
            sum += a[i];
        }
        for(int i = 0; i < n; i++) b[i] = scan.nextInt();
        for(int i = 0; i < n; i++){
            if(a[i] <= b[i]){
                a[i + 1] = Math.max(0, a[i + 1] - b[i] + a[i]);
                a[i] = 0;
            }else{
                a[i] -= b[i];
            }
        }
        long out = 0;
        for(int i = 0; i < n + 1; i++) out += a[i];
        System.out.println(sum - out);
        scan.close();
    }
}

Compiler output:
Main.java:7: error: incompatible types: possible lossy conversion from long to int
        long[] a = new int[n + 1];
                             ^
Main.java:7: error: incompatible types: int[] cannot be converted to long[]
        long[] a = new int[n + 1];
                   ^
Main.java:8: error: incompatible types: possible lossy conversion from long to int
        long[] b = new int[n];
                           ^
Main.java:8: error: incompatible types: int[] cannot be converted to long[]
        long[] b = new int[n];
                   ^
4 errors
Language: C++

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

int main(){
 
  int n;
 
  cin >> n;
  
  long a[n+1],b[n],ans=0.0;
  
  //入力を受け取る
  rep(i,0,n)cin >> a[i]; 
  rep(i,0,n-1)cin >> b[i];
  
  rep(i,0,n-1){
    //勇者iが倒せる数が残っていないときは次の勇者へ
    if(b[i]==0)continue;

    //勇者iが倒せる数が残っているモンスターの数より少ないときは倒せるだけ倒す
    //都市iのモンスターを倒しきれないとき
    if(b[i] <= a[i]){
      ans += b[i];
      continue;
    }

    //勇者iが倒せる数が残っているモンスターの数より少ないときは倒せるだけ倒す
    //都市iのモンスターは倒せるが都市i+1のモンスターは倒しきれないとき
    if(b[i] <= a[i] + a[i+1]){
      ans += b[i];
      b[i] -= a[i];
      a[i+1] -= b[i];
      continue;
    }

    //勇者iが都市i, i+1のモンスターをすべて倒しきれるときはすべて倒す
    ans += a[i]+a[i+1];
    //a[i]も0にすべきだが、この変数はこの後使わないので省略
    a[i+1]=0;
  }
 
  cout << ans << endl;
 
  return 0;
 
}
© 2020 GitHub, Inc.

Compiler output:
a.cc:49:1: error: extended character © is not valid in an identifier
   49 | © 2020 GitHub, Inc.
      | ^
a.cc:49:1: error: '\U000000a9' does not name a type
   49 | © 2020 GitHub, Inc.
      | ^
Language: Java

public class Main {

	public static void main(String[] args) {
	    Scanner scanner = new Scanner(System.in);

	    int N = Integer.parseInt(scanner.next());
	    long[] A  = new long[N+1];
	    long[] B  = new long[N];
	    
	    for (int i=0; i<N+1; i++) {
	    	A[i]=Long.parseLong(scanner.next());
	    }
	    for (int i=0; i<N; i++) {
	    	B[i]=Long.parseLong(scanner.next());
	    }
	    
	    long max=0;
	    for (int i=0; i<N; i++) {
	        long b = B[N-i-1];
	        long a1 = A[N-i];
	        long a2 = A[N-i-1];
	        if (a1 >= b) {
	        	max+=b;
	        } else {
	        	max += a1;
	        	b-=a1;
	        	if (a2>=b) {
	        		max+=b;
	        		A[N-i-1] -=b;
	        	} else {
	        		max+=a2;
	        		A[N-i-1] =0;
	        	}
	        }
	    }
        System.out.print(max);
	}

}

Compiler output:
Main.java:4: error: cannot find symbol
	    Scanner scanner = new Scanner(System.in);
	    ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
	    Scanner scanner = new Scanner(System.in);
	                          ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

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

int main() {
  ll N;
  cin>>N;
  vector<ll> a(N+1);
  vector<ll> b(N);
  rep(i,N+1) cin>>a[i];
  rep(i,N) cin>>b[i];
  
  ll ans=0;
  
  rep(i,N){
    if(b[i]>a[i]+a[i+1]){
      ans+=a[i]+a[i+1];
      a[i+1]=0;
    }
    else if(b[i]>a[i]){
      ans+=b[i];
      ans[i+1]-=(b[i]-a[i]);
    }
    else{
      ans+=b[i];
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:10: error: invalid types 'll {aka long long int}[int]' for array subscript
   25 |       ans[i+1]-=(b[i]-a[i]);
      |          ^
Language: C


#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 135 -C City Saver
#define MAX 100001
//#define MAX 101
int cnt_m(int* a, int* b, int* ans);
int cnt_m(int* a, int* b, ll* ans) {
	if (*a >= *b) {
		*ans += *b;
		*a -= *b;
		return 0;
	}
	
	*ans += *a;
	*b -= *a;
	*a = 0;
	return 1;
}


int main(void) {
	int n, i;
	ll  ans = 0;
	int a[MAX], b[MAX];


	scanf("%d", &n);

	for (i = 0; i < n+1; i++) 
		scanf("%d", &a[i]);

	for (i = 0; i < n; i++)
		scanf("%d", &b[i]);

	int rc = 0;
	for (i = 0; i < n; i++) {
		rc = cnt_m(&a[i], &b[i], &ans);
//		printf("\n%d ", ans);
		if (rc == 0) continue;
		if (i + 1 > n) break;
		rc = cnt_m(&a[i + 1], &b[i], &ans);
//		printf("\n%d ", ans);
	}
	printf("%lld\n", ans);
	return 0;
}


Compiler output:
main.c:125:5: error: conflicting types for 'cnt_m'; have 'int(int *, int *, ll *)' {aka 'int(int *, int *, long long int *)'}
  125 | int cnt_m(int* a, int* b, ll* ans) {
      |     ^~~~~
main.c:124:5: note: previous declaration of 'cnt_m' with type 'int(int *, int *, int *)'
  124 | int cnt_m(int* a, int* b, int* ans);
      |     ^~~~~
Language: Java

import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int city  = sc.nextInt();
		long[] monster = new long[city+1];
		long[] brave = new long[city];
		long anser = 0;
		for(int i=0;i<city+1;i++) {
			monster[i] = sc.nextLong();
		}
		for(int i =0;i<city;i++) {
			brave[i] = sc.nextLong();
		}

		//勇者の攻撃がなくなるまで
		for(int i = 0; i<brave.length;i++) {
			//AとBの小さいほうをanserにいれる
			anser += Math.min(monster[i],brave[i]);
			//A(i+1)と（B-A）の小さいほうを入れる。
			anser += Math.min(monster[i+1],Math.max(brave[i]-monster[i], 0));
			//A(i+1) = A(i+1)とmax(0,(B-A))の小さいほうを引く
			monster[i+1] -= Math.min(monster[i+1],Math.max(brave[i]-monster[i], 0));
		}
		System.out.println(anser);
	}


Compiler output:
Main.java:30: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++


int main() {
 //   ios_base::sync_with_stdio(0); cin.tie(0);

    //
 
    // int patka = 0;
    // int N; cin >> N;
    // loop(i, N) {
    //     int current; cin >> current;
    //     if (current != i+1) patka++;
    // }
    // string ans = (patka <= 2) ? "YES" : "NO";
    // cout << ans << endl;

    // //cout <<N;
 
    // return 0;

    ios_base::sync_with_stdio(0); cin.tie(0);
    freopen("a.txt", "r", stdin);
    int N; 

    cin>> N;
    cout <<N;
    int A[N];
    int B[N+1];
    loop(i,N+1){
        cin >> B[i];
    }
    loop(i, N){
        cin>>A[i];
    }

    int a = 0;
    loop(i,N){
        int V = min(A[i],B[i]); A[i]-=V; B[i]-=V; a += V;
        V = min(A[i], B[i+1]); A[i] -= V; B[i+1] -= V; a += V;

        //ll A[i] =V;

    }
    cout <<a;
    return 0;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'ios_base' has not been declared
   20 |     ios_base::sync_with_stdio(0); cin.tie(0);
      |     ^~~~~~~~
a.cc:20:35: error: 'cin' was not declared in this scope
   20 |     ios_base::sync_with_stdio(0); cin.tie(0);
      |                                   ^~~
a.cc:21:27: error: 'stdin' was not declared in this scope
   21 |     freopen("a.txt", "r", stdin);
      |                           ^~~~~
a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | 
a.cc:21:5: error: 'freopen' was not declared in this scope
   21 |     freopen("a.txt", "r", stdin);
      |     ^~~~~~~
a.cc:25:5: error: 'cout' was not declared in this scope
   25 |     cout <<N;
      |     ^~~~
a.cc:28:10: error: 'i' was not declared in this scope
   28 |     loop(i,N+1){
      |          ^
a.cc:28:5: error: 'loop' was not declared in this scope
   28 |     loop(i,N+1){
      |     ^~~~
Language: C++

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

int main(){
  int n;
  cin>>n;
  long long a[n+1] b[n];
  long long ans=0;
  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++){
      int v=min(a[i],b[i]);
      a[i]-=v;
      b[i]-=v;
      ans+=v;
      v=min(a[i+1],b[i]);
      a[i+1]-=v;
      b[i]-=v;
      ans+=v;
  }
  cout<<ans<<endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:7:20: error: expected initializer before 'b'
    7 |   long long a[n+1] b[n];
      |                    ^
a.cc:10:12: error: 'a' was not declared in this scope
   10 |       cin>>a[i];
      |            ^
a.cc:13:12: error: 'b' was not declared in this scope
   13 |       cin>>b[i];
      |            ^
a.cc:16:17: error: 'a' was not declared in this scope
   16 |       int v=min(a[i],b[i]);
      |                 ^
a.cc:16:22: error: 'b' was not declared in this scope
   16 |       int v=min(a[i],b[i]);
      |                      ^
Language: C

#include <iostream>
#include <vector>
#include <string>

#define rep(i, cc, n) for (int i = cc; i < n; ++i)

using namespace std;

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

    long a[n + 1], b[n], ans = 0.0;

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

    rep(i, 0, n)
    {
        if (b[i] == 0)
        {
            continue;
        }

        if (b[i] <= a[i])
        {
            ans += b[i];
        }

        if (b[i] <= a[i] + a[i + 1])
        {
            ans += b[i];
            b[i] -= a[i];
            a[i + 1] -= b[i];
            continue;
        }
    }

    cout << ans << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main()
{
    ll N;
    cin>>N;
    VL A(N+1);
    VL B(N);
    rep(i,0,N+1)cin>>A[i];
    rep(i,0,N)cin>>B[i];

    ll ans=0;
    rep(i,0,N){
        if(B[i]<A[i]){
            ans+=B[i];
            B[i]=0;
            A[i]=A[i]-B[i];
        }else if(B[i]>=A[i]){
            ans+=A[i];
            A[i]=0;
            B[i]=B[i]-A[i];
            if(B[i]<A[i+1]){
                ans+=B[i];
                A[i+1]=A[i+1]-B[i];
                B[i]=0;
            }else if(){
                ans+=A[i+1];
                A[i+1]=0;
                B[i]=B[i]-A[i+1];
            }
        }
    }
    cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:22: error: expected primary-expression before ')' token
   38 |             }else if(){
      |                      ^
Language: C++

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
   ll n,i,j,cc=0,m;
   cin>>n;
   ll ara[n+1],bra[n];
   for(i=0;i<=n;i++)cin>>ara[i];
   for(i=0;i<n;i++)cin>>bra[i];
   for(i=0;i<n;i++){
      if(bra[i]>ara[i]){
        cc+=ara[i],bra[i]-=ara[i];
        if(bra[i]>ara[i+1])cc+=ara[i+1],bra[i]-=ara[i+1];
        else cc+=bra[i],ara[i+1]-=bra[i];
      }
      else{
         cc+=bra[i];
         ara[i]-=bra[i];
         if(bra[i]>ara[i+1])cc+=ara[i+1],bra[i]-=ara[i+1]'
            else cc+=bra[i],ara[i+1]-=bra[i];
      }
   }
   cout<<cc<<endl;
return 0;
}


Compiler output:
a.cc:53:58: warning: missing terminating ' character
   53 |          if(bra[i]>ara[i+1])cc+=ara[i+1],bra[i]-=ara[i+1]'
      |                                                          ^
a.cc:53:58: error: missing terminating ' character
a.cc: In function 'int main()':
a.cc:53:58: error: expected ';' before 'else'
   53 |          if(bra[i]>ara[i+1])cc+=ara[i+1],bra[i]-=ara[i+1]'
      |                                                          ^
      |                                                          ;
   54 |             else cc+=bra[i],ara[i+1]-=bra[i];
      |             ~~~~
Language: C++

#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
	using namespace std;

	int main() {
		int N;
		cin >> N;
		int ans = 0;
		vector<int> city(N + 1);
		vector<int> hero(N);
		for (int i = 0; i < N + 1; i++) cin >> city[i];
		for (int i = 0; i < N; i++) cin >> hero[i];
		for (int i = 0; i < N; i++) {
			if (hero[i] >= (city[i] + city[i + 1])) {
				ans += (city[i] + city[i + 1]);
				city[i + 1] = 0;
				city[i] = 0;
			}
			else if (hero[i] > city[i] && hero[i] < (city[i] + city[i + 1])) {
				ans += hero[i];
				city[i + 1] -= hero[i] - city[i];
				city[i] = 0;

			}
			else {
				ans += hero[i];
				city[i] -= hero[i];
			}
		}
		cout << ans << endl;
	}

}

Compiler output:
a.cc:48:1: error: expected declaration before '}' token
   48 | }
      | ^
Language: C++

#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	vector<int> city(N + 1);
	vector<int> hero(N);
	for (int i = 0; i < N + 1; i++) cin >> city[i];
	for (int i = 0; i < N; i++) cin >> hero[i];
	for (int i = 0; i < N; i++) {
		if (hero[i] >(city[i] + city[i + 1])) {
			ans += (city[i] + city[i + 1]);
			city[i + 1] = 0;
			city[i] = 0;
		}
		else if (hero[i] > city[i] && hero[i] < (city[i] + city[i + 1])) {
			city[i + 1] -= hero[i] - city[i];
			city[i] = 0;
			ans += hero[i];
		}
		else {
			ans += hero[i];
			city[i] -= hero[i];
		}
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:9: error: 'cin' was not declared in this scope
   17 |         cin >> N;
      |         ^~~
a.cc:13:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   12 | #include <cctype> // isupper, islower, isdigit, toupper, tolower
  +++ |+#include <iostream>
   13 | using namespace std;
a.cc:39:9: error: 'cout' was not declared in this scope
   39 |         cout << ans << endl;
      |         ^~~~
a.cc:39:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:24: error: 'endl' was not declared in this scope
   39 |         cout << ans << endl;
      |                        ^~~~
a.cc:13:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
   12 | #include <cctype> // isupper, islower, isdigit, toupper, tolower
  +++ |+#include <ostream>
   13 | using namespace std;
Language: C++

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

int mod = 1000000007;
int64_t large = 9223372036854775807;

int main()
{
    int N;
    cin >> N;
    vector<int> monster(N + 1);
    vector<int> list(N);
    for (int i = 0; i < N + 1; i++)
        cin >> monster[i];

    for (int i = 0; i < N; i++)
        cin >> list[i];

    int ans = 0;

    for (int i = 0; i < N; i++)
    {
        int tmp;
        tmp = min(list[i], monster[i]);
        ans += tmp;
        list[i] -= tmp;
        monster[i] -= tmp;
        tmp = min(list[i], moster[i + 1]);
        ans += tmp;
        list[i] -= tmp;
        monster[i + 1] -= tmp;
    }

    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:28: error: 'moster' was not declared in this scope; did you mean 'monster'?
   28 |         tmp = min(list[i], moster[i + 1]);
      |                            ^~~~~~
      |                            monster
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:31:16: error: invalid types 'int[int]' for array subscript
   31 |             ans[i+1]-=rest;
      |                ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  cin>>n;
  vector<int>a(n+1),b(n);
  rep(i,n+1) cin>>a[i];
  rep(i,n) cin>>b[i];
  int ans=0;
  rep(i,n){
    p=min(a[i],b[i]);
    a[i]-=p;
    b[i]-=p;
    ans+=p;
    q=min(a[i+1],b[i]);
    a[i+1]-=q;
    b[i]-=q;
    ans+=q;
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:5: error: 'p' was not declared in this scope
   23 |     p=min(a[i],b[i]);
      |     ^
a.cc:27:5: error: 'q' was not declared in this scope
   27 |     q=min(a[i+1],b[i]);
      |     ^
Language: C++

using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n+1) cin >> a[i];
    vector<ll> b(n);
    rep(i,n) cin >> b[i];
    vector<ll> f_1(n), f_2(n);
    ll ans = 0;
    rep(i,n){
        if(i==0){
            f_1[i] = min(a[i],b[i]);
        }else{
            f_1[i] = min(a[i]-f_2[i-1], b[i]);
        }
        f_2[i] = min(a[i+1], b[i]-f_1[i]);
        ans = ans + f_1[i] + f_2[i];
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'cin' was not declared in this scope
    5 |     cin >> n;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<ll> a(n);
      |     ^~~~~~
a.cc:6:14: error: expected primary-expression before '>' token
    6 |     vector<ll> a(n);
      |              ^
a.cc:6:16: error: 'a' was not declared in this scope
    6 |     vector<ll> a(n);
      |                ^
a.cc:7:9: error: 'i' was not declared in this scope
    7 |     rep(i,n+1) cin >> a[i];
      |         ^
a.cc:7:5: error: 'rep' was not declared in this scope
    7 |     rep(i,n+1) cin >> a[i];
      |     ^~~
a.cc:8:14: error: expected primary-expression before '>' token
    8 |     vector<ll> b(n);
      |              ^
a.cc:8:16: error: 'b' was not declared in this scope
    8 |     vector<ll> b(n);
      |                ^
a.cc:10:14: error: expected primary-expression before '>' token
   10 |     vector<ll> f_1(n), f_2(n);
      |              ^
a.cc:10:16: error: 'f_1' was not declared in this scope
   10 |     vector<ll> f_1(n), f_2(n);
      |                ^~~
a.cc:10:24: error: 'f_2' was not declared in this scope
   10 |     vector<ll> f_1(n), f_2(n);
      |                        ^~~
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout << ans << endl;
      |     ^~~~
a.cc:22:20: error: 'endl' was not declared in this scope
   22 |     cout << ans << endl;
      |                    ^~~~
Language: C++

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

int main(){
    int n; cin >> n;
    vector<int> a(n+1),b(n);
    for(int i=0;i=<n;++i) cin >> a[i];
    rep(i,n) cin >> b[i];
    ll ans = 0;
    rep(i,n){
        int res = a[i]-b[i];
        if(res>0){
            ans += b[i];
            continue;
        }
        else{
            ans += a[i];
            res *= -1;
            int sec = a[i+1]-res;
            if(sec>0){
                ans += res;
                a[i+i]-= res;
            }else{
                ans += a[i+1];
                a[i+1] = 0;
            }
        }
        //cout << res << ' ' << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: expected primary-expression before '<' token
    9 |     for(int i=0;i=<n;++i) cin >> a[i];
      |                   ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  cin>>n;
  vector<int>a(n+1),b(n);
  rep(i,n+1) cin>>a[i];
  rep(i,n) cin>>b[i];
  ll ans=0;
  rep(i,n){
    int at1=min(b[i],a[i]);
    ans+=at;
    b[i]-=at1;
    a[i]-=at1;
    int at2=min(a[i+1],b[i]);
    ans+=at2;
    a[i+1]-=at2;
    b[i]-=at2;
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:10: error: 'at' was not declared in this scope; did you mean 'at1'?
   24 |     ans+=at;
      |          ^~
      |          at1
Language: C++

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

int gcd(int a, int b) {
	if (a < b) {
		int c = a;
		a = b;
		b = c;
	}
	if (b == 0) return a;
	return gcd (b, a % b);
}

ll sum(ll x) { // sum of subsequent numbers from 0 to x
	return x*(x + 1)/2;
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n + 1), b(n);
	rep(i, n + 1) cin >> a.at(i);
	rep(i, n) cin >> b.at(i);

	ll ans = 0;
	vector<int> rest(n);
	rep(i, n) {
		int beat_prev = 0, beat;
		if (i >= 1) {
			beat_prev = min(rest.at(i - 1), a.at(i));
		}
		beat = min(a.at(i) - beat_prev, b.at(i));
		rest.at(i) = b.at(i) - beat;
		ans += beat;
	}
	ans += min(rest.at(n - 1), a.at(n))
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:47:44: error: expected ';' before 'cout'
   47 |         ans += min(rest.at(n - 1), a.at(n))
      |                                            ^
      |                                            ;
   48 |         cout << ans << endl;
      |         ~~~~
Language: C

#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int fac(int num) {
  if(num==1) return 1;
  else return num*fac(num-1);
}



int main() {
  ll N; cin >> N;
  ll a[N+1],b[N];
  rep(i,N+1) cin >> a[i];
  rep(i,N) cin >> b[i];
  ll ans = 0;
  rep(i,N) {
    ans += min(a[i],b[i]);
    b[i] -= min(a[i],b[i]);
    ans += min(a[i+1],b[i]);
    a[i+1] -= min(a[i+1],b[i]);
  }
  cout << ans << endl;
 
  return 0;
}


Compiler output:
main.c:1:10: fatal error: algorithm: No such file or directory
    1 | #include <algorithm>
      |          ^~~~~~~~~~~
compilation terminated.