Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
vector <ll> dp, valores;
ll size;
ll conta( int posicao, int qtosEscolheu ) {
        if(posicao == (size-1) ) {
                //cout<<"qtose"<<qtosEscolheu<<"vallim"<<floor(size/2)<<endl;
                if(qtosEscolheu != floor(size/2)){
                        return dp[posicao] = valores[posicao];
                }else{
                        return 0;
                }
        }
        if(dp[posicao] > -1)
                return dp[posicao];
        if(posicao == (size-2) ){
                return dp[posicao] = max(valores[posicao], valores[posicao+1]);
        }else{
                return dp[posicao] = max( valores[posicao] + conta(posicao+2, qtosEscolheu+1), conta(posicao+1, qtosEscolheu) );
        }
}

int main(){
        ios::sync_with_stdio(0);cin.tie(nullptr);
        cin>>size;
        ll delta = 0, temp;
        for(int i = 0; i < size; i++ ) {
                cin>>temp;
                dp.pb(-1);
                delta = min(delta, temp);
                valores.pb(temp);
        }
        delta *= -1;
        if( size == 1 ) {
                cout<<valores[0]<<endl;
                return 0;
        }
        for ( int i = 0; i < size; i++ ) {
                valores[i] = valores[i] + delta;
        }
        /*
        for ( int i = 0; i < size; i++ ) {
                cout<<valores[i]<<endl;
        }
        */
        ll resposta = conta(0, 0);
        resposta -= delta * floor(size/2);
        cout<<resposta<<endl;
        return 0;
}


Compiler output:
a.cc: In function 'long long int conta(int, int)':
a.cc:8:24: error: reference to 'size' is ambiguous
    8 |         if(posicao == (size-1) ) {
      |                        ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc:10:42: error: reference to 'size' is ambiguous
   10 |                 if(qtosEscolheu != floor(size/2)){
      |                                          ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc:18:24: error: reference to 'size' is ambiguous
   18 |         if(posicao == (size-2) ){
      |                        ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc: In function 'int main()':
a.cc:27:14: error: reference to 'size' is ambiguous
   27 |         cin>>size;
      |              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc:29:28: error: reference to 'size' is ambiguous
   29 |         for(int i = 0; i < size; i++ ) {
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc:36:13: error: reference to 'size' is ambiguous
   36 |         if( size == 1 ) {
      |             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc:40:30: error: reference to 'size' is ambiguous
   40 |         for ( int i = 0; i < size; i++ ) {
      |                              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc:49:35: error: reference to 'size' is ambiguous
   49 |         resposta -= delta * floor(size/2);
      |                                   ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:6:4: note:                 'long long int size'
    6 | ll size;
      |    ^~~~
a.cc: In function 'long long int conta(int, int)':
a.cc:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^