Language: C++

int rec_helper(const vector<int>&s, int pos, int cost, vector<int>& cache)
{
	if (pos == 0)
		return cost;
	if(cache[pos] != -1)
		return cache[pos];
	int mini = numeric_limits<int>::max();
	if(pos >= 2) {
		mini = min(mini, rec_helper(s, pos - 2, abs(s[pos] - s[pos - 2] + cost), cache));
		cache[pos-2] = mini;
	}
	if(pos >= 1) {
		mini = min(mini, rec_helper(s, pos - 1, abs(s[pos] - s[pos - 1] + cost), cache));
		cache[pos-1] = mini;
	}
	return mini;
}

int sol_rec_memo(const vector<int>&s)
{
	vector<int> cache(s.size(), -1);
	return rec_helper(s, (int)s.size()-1, 0, cache);
}

int main()
{
	int N;
	cin >> N;
	vector<int> s(N);
	for(int i = 0; i < N; i++) {
		cin >> s[i];
	}
	cout << sol_rec_memo(s) << endl;

}

Compiler output:
a.cc:1:22: error: 'vector' does not name a type
    1 | int rec_helper(const vector<int>&s, int pos, int cost, vector<int>& cache)
      |                      ^~~~~~
a.cc:1:28: error: expected ',' or '...' before '<' token
    1 | int rec_helper(const vector<int>&s, int pos, int cost, vector<int>& cache)
      |                            ^
a.cc: In function 'int rec_helper(int)':
a.cc:3:13: error: 'pos' was not declared in this scope
    3 |         if (pos == 0)
      |             ^~~
a.cc:4:24: error: 'cost' was not declared in this scope; did you mean 'const'?
    4 |                 return cost;
      |                        ^~~~
      |                        const
a.cc:5:12: error: 'cache' was not declared in this scope
    5 |         if(cache[pos] != -1)
      |            ^~~~~
a.cc:5:18: error: 'pos' was not declared in this scope
    5 |         if(cache[pos] != -1)
      |                  ^~~
a.cc:7:20: error: 'numeric_limits' was not declared in this scope
    7 |         int mini = numeric_limits<int>::max();
      |                    ^~~~~~~~~~~~~~
a.cc:7:35: error: expected primary-expression before 'int'
    7 |         int mini = numeric_limits<int>::max();
      |                                   ^~~
a.cc:8:12: error: 'pos' was not declared in this scope
    8 |         if(pos >= 2) {
      |            ^~~
a.cc:9:45: error: 's' was not declared in this scope
    9 |                 mini = min(mini, rec_helper(s, pos - 2, abs(s[pos] - s[pos - 2] + cost), cache));
      |                                             ^
a.cc:9:83: error: 'cost' was not declared in this scope; did you mean 'const'?
    9 |                 mini = min(mini, rec_helper(s, pos - 2, abs(s[pos] - s[pos - 2] + cost), cache));
      |                                                                                   ^~~~
      |                                                                                   const
a.cc:9:57: error: 'abs' was not declared in this scope
    9 |                 mini = min(mini, rec_helper(s, pos - 2, abs(s[pos] - s[pos - 2] + cost), cache));
      |                                                         ^~~
a.cc:9:90: error: 'cache' was not declared in this scope
    9 |                 mini = min(mini, rec_helper(s, pos - 2, abs(s[pos] - s[pos - 2] + cost), cache));
      |                                                                                          ^~~~~
a.cc:9:24: error: 'min' was not declared in this scope; did you mean 'mini'?
    9 |                 mini = min(mini, rec_helper(s, pos - 2, abs(s[pos] - s[pos - 2] + cost), cache));
      |                        ^~~
      |                        mini
a.cc:12:12: error: 'pos' was not declared in this scope
   12 |         if(pos >= 1) {
      |            ^~~
a.cc:13:45: error: 's' was not declared in this scope
   13 |                 mini = min(mini, rec_helper(s, pos - 1, abs(s[pos] - s[pos - 1] + cost), cache));
      |                                             ^
a.cc:13:83: error: 'cost' was not declared in this scope; did you mean 'const'?
   13 |                 mini = min(mini, rec_helper(s, pos - 1, abs(s[pos] - s[pos - 1] + cost), cache));
      |                                                                                   ^~~~
      |                                                                                   const
a.cc:13:57: error: 'abs' was not declared in this scope
   13 |                 mini = min(mini, rec_helper(s, pos - 1, abs(s[pos] - s[pos - 1] + cost), cache));
      |                                                         ^~~
a.cc:13:90: error: 'cache' was not declared in this scope
   13 |                 mini = min(mini, rec_helper(s, pos - 1, abs(s[pos] - s[pos - 1] + cost), cache));
      |                                                                                          ^~~~~
a.cc:13:24: error: 'min' was not declared in this scope; did you mean 'mini'?
   13 |                 mini = min(mini, rec_helper(s, pos - 1, abs(s[pos] - s[pos - 1] + cost), cache));
      |                        ^~~
      |                        mini
a.cc: At global scope:
a.cc:19:24: error: 'vector' does not name a type
   19 | int sol_rec_memo(const vector<int>&s)
      |                        ^~~~~~
a.cc:19:30: error: expected ',' or '...' before '<' token
   19 | int sol_rec_memo(const vector<int>&s)
      |                              ^
a.cc: In function 'int sol_rec_memo(int)':
a.cc:21:9: error: 'vector' was not declared in this scope
   21 |         vector<int> cache(s.size(), -1);
      |         ^~~~~~
a.cc:21:16: error: expected primary-expression before 'int'
   21 |         vector<int> cache(s.size(), -1);
      |                ^~~
a.cc:22:27: error: 's' was not declared in this scope
   22 |         return rec_helper(s, (int)s.size()-1, 0, cache);
      |                           ^
a.cc:22:50: error: 'cache' was not declared in this scope
   22 |         return rec_helper(s, (int)s.size()-1, 0, cache);
      |                                                  ^~~~~
a.cc: In function 'int main()':
a.cc:28:9: error: 'cin' was not declared in this scope
   28 |         cin >> N;
      |         ^~~
a.cc:29:9: error: 'vector' was not declared in this scope
   29 |         vector<int> s(N);
      |         ^~~~~~
a.cc:29:16: error: expected primary-expression before 'int'
   29 |         vector<int> s(N);
      |                ^~~
a.cc:31:24: error: 's' was not declared in this scope
   31 |                 cin >> s[i];
      |                        ^
a.cc:33:9: error: 'cout' was not declared in this scope
   33 |         cout << sol_rec_memo(s) << endl;
      |         ^~~~
a.cc:33:30: error: 's' was not declared in this scope
   33 |         cout << sol_rec_memo(s) << endl;
      |                              ^
a.cc:33:36: error: 'endl' was not declared in this scope
   33 |         cout << sol_rec_memo(s) << endl;
      |                                    ^~~~