Language: C++

int rec_helper(const vector<int>&s, int pos, int cost)
{
	if (pos == 0)
		return cost;
	int minimum = numeric_limits<int>::max();
	for (int step = 1; step <= 2; step++) {
		if (pos >= step) {
			int curr = rec_helper(s, pos-step, cost + abs(s[pos] - s[pos-step]));
			if (curr < minimum)
				minimum = curr;
		}
	}
	return minimum;
}


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


int main()
{
	int N;
	cin >> N;
	vector<int> s(N);
	for(int i = 0; i < N; i++) {
		cin >> s[i];
	}
	cout << sol_rec(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)
      |                      ^~~~~~
a.cc:1:28: error: expected ',' or '...' before '<' token
    1 | int rec_helper(const vector<int>&s, int pos, int cost)
      |                            ^
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:23: error: 'numeric_limits' was not declared in this scope
    5 |         int minimum = numeric_limits<int>::max();
      |                       ^~~~~~~~~~~~~~
a.cc:5:38: error: expected primary-expression before 'int'
    5 |         int minimum = numeric_limits<int>::max();
      |                                      ^~~
a.cc:7:21: error: 'pos' was not declared in this scope
    7 |                 if (pos >= step) {
      |                     ^~~
a.cc:8:47: error: 's' was not declared in this scope
    8 |                         int curr = rec_helper(s, pos-step, cost + abs(s[pos] - s[pos-step]));
      |                                               ^
a.cc:8:60: error: 'cost' was not declared in this scope; did you mean 'const'?
    8 |                         int curr = rec_helper(s, pos-step, cost + abs(s[pos] - s[pos-step]));
      |                                                            ^~~~
      |                                                            const
a.cc:8:67: error: 'abs' was not declared in this scope
    8 |                         int curr = rec_helper(s, pos-step, cost + abs(s[pos] - s[pos-step]));
      |                                                                   ^~~
a.cc: At global scope:
a.cc:17:19: error: 'vector' does not name a type
   17 | int sol_rec(const vector<int>&s)
      |                   ^~~~~~
a.cc:17:25: error: expected ',' or '...' before '<' token
   17 | int sol_rec(const vector<int>&s)
      |                         ^
a.cc: In function 'int sol_rec(int)':
a.cc:19:27: error: 's' was not declared in this scope
   19 |         return rec_helper(s, (int)s.size()-1, 0);
      |                           ^
a.cc: In function 'int main()':
a.cc:26:9: error: 'cin' was not declared in this scope
   26 |         cin >> N;
      |         ^~~
a.cc:27:9: error: 'vector' was not declared in this scope
   27 |         vector<int> s(N);
      |         ^~~~~~
a.cc:27:16: error: expected primary-expression before 'int'
   27 |         vector<int> s(N);
      |                ^~~
a.cc:29:24: error: 's' was not declared in this scope
   29 |                 cin >> s[i];
      |                        ^
a.cc:31:9: error: 'cout' was not declared in this scope
   31 |         cout << sol_rec(s) << endl;
      |         ^~~~
a.cc:31:25: error: 's' was not declared in this scope
   31 |         cout << sol_rec(s) << endl;
      |                         ^
a.cc:31:31: error: 'endl' was not declared in this scope
   31 |         cout << sol_rec(s) << endl;
      |                               ^~~~