Language: C++

#include <bits/stdc++.h>

using namespace std;
#define N 200200

long long v[N], w[N];
long long ans, prev;
int i, n;
int main()
{
    cin >> n;
    ++n;
    for (i = 0; i < n; ++i)
        cin >> v[i];
    for (i = 1; i < n; ++i)
        cin >> w[i - 1];
    prev = 0;
    for (i = 0; i < n; ++i){
        v[i] -= prev;
        if (w[i] > v[i]){
            ans += v[i] + prev;
            prev = w[i] - v[i];
        }
        else{
            ans += prev + w[i];
            prev = 0;
        }
    }
    cout << ans;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:5: error: reference to 'prev' is ambiguous
   17 |     prev = 0;
      |     ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:7:16: note:                 'long long int prev'
    7 | long long ans, prev;
      |                ^~~~
a.cc:19:17: error: reference to 'prev' is ambiguous
   19 |         v[i] -= prev;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:7:16: note:                 'long long int prev'
    7 | long long ans, prev;
      |                ^~~~
a.cc:21:27: error: reference to 'prev' is ambiguous
   21 |             ans += v[i] + prev;
      |                           ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:7:16: note:                 'long long int prev'
    7 | long long ans, prev;
      |                ^~~~
a.cc:22:13: error: reference to 'prev' is ambiguous
   22 |             prev = w[i] - v[i];
      |             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:7:16: note:                 'long long int prev'
    7 | long long ans, prev;
      |                ^~~~
a.cc:25:20: error: reference to 'prev' is ambiguous
   25 |             ans += prev + w[i];
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:7:16: note:                 'long long int prev'
    7 | long long ans, prev;
      |                ^~~~
a.cc:26:13: error: reference to 'prev' is ambiguous
   26 |             prev = 0;
      |             ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:7:16: note:                 'long long int prev'
    7 | long long ans, prev;
      |                ^~~~