Language: C++

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> va(n + 1);
    vector<int> vb(n);

    rep(i, n + 1) cin >> va[i];
    rep(i, n) cin >> vb[i];

    int ans = 0;
    rep(i, n){
        int j = i;
        if(0 <= va[j] - vb[i]){
            ans += vb[j];
            cout << "1:" << ans << endl;
        }else{
            vb[i] -= va[j];
            ans += va[j];
            if(0 <= va[j + 1] - vb[i]){
                ans += vb[i];
                va[j + 1] -= vb[i];
                cout << "21:" << ans << endl;
            }else{
                va[j + 1] -= 0;
                ans += va[j + 1];
                cout << "22:" << ans << endl;
            }
        }
    }
    OP(ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: 'cin' was not declared in this scope
   10 |     int n; cin >> n;
      |            ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:11:5: error: 'vector' was not declared in this scope
   11 |     vector<int> va(n + 1);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:11:12: error: expected primary-expression before 'int'
   11 |     vector<int> va(n + 1);
      |            ^~~
a.cc:12:12: error: expected primary-expression before 'int'
   12 |     vector<int> vb(n);
      |            ^~~
a.cc:14:26: error: 'va' was not declared in this scope
   14 |     rep(i, n + 1) cin >> va[i];
      |                          ^~
a.cc:15:22: error: 'vb' was not declared in this scope
   15 |     rep(i, n) cin >> vb[i];
      |                      ^~
a.cc:20:17: error: 'va' was not declared in this scope
   20 |         if(0 <= va[j] - vb[i]){
      |                 ^~
a.cc:20:25: error: 'vb' was not declared in this scope
   20 |         if(0 <= va[j] - vb[i]){
      |                         ^~
a.cc:22:13: error: 'cout' was not declared in this scope
   22 |             cout << "1:" << ans << endl;
      |             ^~~~
a.cc:22:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:36: error: 'endl' was not declared in this scope
   22 |             cout << "1:" << ans << endl;
      |                                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:29:17: error: 'cout' was not declared in this scope
   29 |                 cout << "21:" << ans << endl;
      |                 ^~~~
a.cc:29:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:29:41: error: 'endl' was not declared in this scope
   29 |                 cout << "21:" << ans << endl;
      |                                         ^~~~
a.cc:29:41: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:33:17: error: 'cout' was not declared in this scope
   33 |                 cout << "22:" << ans << endl;
      |                 ^~~~
a.cc:33:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:33:41: error: 'endl' was not declared in this scope
   33 |                 cout << "22:" << ans << endl;
      |                                         ^~~~
a.cc:33:41: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:6:15: error: 'cout' was not declared in this scope
    6 | #define OP(x) cout << x << endl;
      |               ^~~~
a.cc:37:5: note: in expansion of macro 'OP'
   37 |     OP(ans);
      |     ^~
a.cc:6:15: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    6 | #define OP(x) cout << x << endl;
      |               ^~~~
a.cc:37:5: note: in expansion of macro 'OP'
   37 |     OP(ans);
      |     ^~
a.cc:6:28: error: 'endl' was not declared in this scope
    6 | #define OP(x) cout << x << endl;
      |                            ^~~~
a.cc:37:5: note: in expansion of macro 'OP'
   37 |     OP(ans);
      |     ^~
a.cc:6:28: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    6 | #define OP(x) cout << x << endl;
      |                            ^~~~
a.cc:37:5: note: in expansion of macro 'OP'
   37 |     OP(ans);
      |     ^~