Language: C++

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

		if (A[i+1] >= B[i]) {
			counter += B[i];
			A[i+1] -= B[i];
			B[i] = 0;
		}
		else
		{
			counter += A[i+1];
			B[i] -= A[i+1];
			A[i + 1] = 0;
		}
			
		
	}
	int j = N;
	for (int i = 0; i <N; i++) {
		j -= 1;
		if (A2[j + 1] >= B2[j]) {
			counter2 += B2[j];
			A2[j + 1] -= B2[j];
			B2[j] = 0;
		}
		else
		{
			counter2 += A2[j + 1];
			B2[j] -= A2[j + 1];
			A2[j + 1] = 0;
		}
		if (A2[j] >= B2[j]) {
			counter2 += B2[j];
			A2[j] -= B2[j];
			B2[j] = 0;
		}
		else
		{
			counter2 += A2[j];
			B2[j] -= A2[j];
			A2[j] = 0;
		}


	}
	if (counter > counter2) {
		cout << counter << endl;
	}
	else {
		cout << counter2 << endl;
	}
	

}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin >> N;
      |         ^~~
a.cc:4:9: error: 'vector' was not declared in this scope
    4 |         vector<int> A(N+1);
      |         ^~~~~~
a.cc:4:16: error: expected primary-expression before 'int'
    4 |         vector<int> A(N+1);
      |                ^~~
a.cc:5:16: error: expected primary-expression before 'int'
    5 |         vector<int> B(N);
      |                ^~~
a.cc:6:16: error: expected primary-expression before 'int'
    6 |         vector<int> A2(N + 1);
      |                ^~~
a.cc:7:16: error: expected primary-expression before 'int'
    7 |         vector<int> B2(N);
      |                ^~~
a.cc:11:24: error: 'A' was not declared in this scope
   11 |                 cin >> A[i];
      |                        ^
a.cc:12:17: error: 'A2' was not declared in this scope
   12 |                 A2[i] = A[i];
      |                 ^~
a.cc:15:24: error: 'B' was not declared in this scope
   15 |                 cin >> B[i];
      |                        ^
a.cc:16:17: error: 'B2' was not declared in this scope
   16 |                 B2[i] = B[i];
      |                 ^~
a.cc:19:21: error: 'A' was not declared in this scope
   19 |                 if (A[i] >= B[i]) {
      |                     ^
a.cc:19:29: error: 'B' was not declared in this scope
   19 |                 if (A[i] >= B[i]) {
      |                             ^
a.cc:31:21: error: 'A' was not declared in this scope
   31 |                 if (A[i+1] >= B[i]) {
      |                     ^
a.cc:31:31: error: 'B' was not declared in this scope
   31 |                 if (A[i+1] >= B[i]) {
      |                               ^
a.cc:48:21: error: 'A2' was not declared in this scope
   48 |                 if (A2[j + 1] >= B2[j]) {
      |                     ^~
a.cc:48:34: error: 'B2' was not declared in this scope
   48 |                 if (A2[j + 1] >= B2[j]) {
      |                                  ^~
a.cc:59:21: error: 'A2' was not declared in this scope
   59 |                 if (A2[j] >= B2[j]) {
      |                     ^~
a.cc:59:30: error: 'B2' was not declared in this scope
   59 |                 if (A2[j] >= B2[j]) {
      |                              ^~
a.cc:74:17: error: 'cout' was not declared in this scope
   74 |                 cout << counter << endl;
      |                 ^~~~
a.cc:74:36: error: 'endl' was not declared in this scope
   74 |                 cout << counter << endl;
      |                                    ^~~~
a.cc:77:17: error: 'cout' was not declared in this scope
   77 |                 cout << counter2 << endl;
      |                 ^~~~
a.cc:77:37: error: 'endl' was not declared in this scope
   77 |                 cout << counter2 << endl;
      |                                     ^~~~