Language: C++

#include <iostream>
using namespace std;

int hash[100000];

int minCost(int index, int* stoneHeight, int nStones){

    if(index == nStones){
        return 0;
    }

    if(hash[index] != -1){
        return hash[index];
    }


    int op1 = (index+1, stoneHeight, nStones)  + abs(stoneHeight[index] -  stoneHeight[index+1]);
    int op2 = INT_MAX;
    if(index+2 < nStones){
        op2 = (index+2, stoneHeight, nStones)  + abs(stoneHeight[index] -  stoneHeight[index+2]);
    }

    hash[index] = min(op1, op2);
    return hash[index];
}

int main(){

    int nStones;
    cin >> nStones;

    int stoneHeight[100000];
    for(int i=0; i<nStones; ++i){
        cin >> stoneHeight[i];
    }

    memset(hash, -1, sizeof(int) * 100000);
    cout<<minCost(0, stoneHeight, nStones);

    return 0;
}

Compiler output:
a.cc: In function 'int minCost(int, int*, int)':
a.cc:12:8: error: reference to 'hash' is ambiguous
   12 |     if(hash[index] != -1){
      |        ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:5: note:                 'int hash [100000]'
    4 | int hash[100000];
      |     ^~~~
a.cc:13:16: error: reference to 'hash' is ambiguous
   13 |         return hash[index];
      |                ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:5: note:                 'int hash [100000]'
    4 | int hash[100000];
      |     ^~~~
a.cc:18:15: error: 'INT_MAX' was not declared in this scope
   18 |     int op2 = INT_MAX;
      |               ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
a.cc:23:5: error: reference to 'hash' is ambiguous
   23 |     hash[index] = min(op1, op2);
      |     ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:5: note:                 'int hash [100000]'
    4 | int hash[100000];
      |     ^~~~
a.cc:24:12: error: reference to 'hash' is ambiguous
   24 |     return hash[index];
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:5: note:                 'int hash [100000]'
    4 | int hash[100000];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:37:12: error: reference to 'hash' is ambiguous
   37 |     memset(hash, -1, sizeof(int) * 100000);
      |            ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:5: note:                 'int hash [100000]'
    4 | int hash[100000];
      |     ^~~~
a.cc:37:5: error: 'memset' was not declared in this scope
   37 |     memset(hash, -1, sizeof(int) * 100000);
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;