Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

    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) {
        ll tmp = 0;
        if(a[i]<=b[i]) {
            tmp += a[i];
            b[i] -= a[i];
            if(a[i+1]<=b[i]) {
                tmp += a[i+1];
                b[i] -= a[i+1];
            }
            else {
                tmp += b[i];
                a[i+1]-=b[i];
            }
        }
        else tmp += b[i];
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:14:12: error: 'cin' does not name a type
   14 |     int n; cin >> n;
      |            ^~~
a.cc:2:19: error: expected unqualified-id before 'for'
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                   ^~~
a.cc:16:5: note: in expansion of macro 'REP'
   16 |     REP(i,n+1) cin >> a[i];
      |     ^~~
a.cc:16:9: error: 'i' does not name a type
   16 |     REP(i,n+1) cin >> a[i];
      |         ^
a.cc:2:34: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                                  ^
a.cc:2:41: error: expected unqualified-id before '++' token
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                                         ^~
a.cc:16:5: note: in expansion of macro 'REP'
   16 |     REP(i,n+1) cin >> a[i];
      |     ^~~
a.cc:2:19: error: expected unqualified-id before 'for'
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                   ^~~
a.cc:17:5: note: in expansion of macro 'REP'
   17 |     REP(i,n) cin >> b[i];
      |     ^~~
a.cc:17:9: error: 'i' does not name a type
   17 |     REP(i,n) cin >> b[i];
      |         ^
a.cc:2:34: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                                  ^
a.cc:2:41: error: expected unqualified-id before '++' token
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                                         ^~
a.cc:17:5: note: in expansion of macro 'REP'
   17 |     REP(i,n) cin >> b[i];
      |     ^~~
a.cc:2:19: error: expected unqualified-id before 'for'
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                   ^~~
a.cc:19:5: note: in expansion of macro 'REP'
   19 |     REP(i,n) {
      |     ^~~
a.cc:19:9: error: 'i' does not name a type
   19 |     REP(i,n) {
      |         ^
a.cc:2:34: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                                  ^
a.cc:2:41: error: expected unqualified-id before '++' token
    2 | #define REP(i, n) for(int i = 0; i < n; ++i)
      |                                         ^~
a.cc:19:5: note: in expansion of macro 'REP'
   19 |     REP(i,n) {
      |     ^~~
a.cc:36:5: error: 'cout' does not name a type
   36 |     cout << ans << endl;
      |     ^~~~
a.cc:37:5: error: expected unqualified-id before 'return'
   37 |     return 0;
      |     ^~~~~~
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^