Language: C++

#include <bits/stdc++.h>

vector<int> hi(10000);
vector<int> cost(10000);

void cost_fn(int n)
{
	// if(n == 0) return 0;
	// if(n == 1) return 

	// int onestep = abs(hi[n]-hi[n-1]) + cost(n-1);
	// int twostep = abs(hi[n]-hi[n-1]) + cost(n-2);

	// return min(onestep, twostep);

	cost[1] = abs(hi[1]-hi[0]);

	for(int i = 2; i <= n; i++)
	{
		int onestep = abs(hi[n]-hi[n-1]) + cost[i-1];
		int twostep = abs(hi[n]-hi[n-1]) + cost[i-2];
		cost[i] = min(onestep, twostep);
	}

	cout << cost[n] << endl;
}

int main()
{
	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
		cin >> hi[i];
	cost_fn(n-1);
	return 0;
}

Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector<int> hi(10000);
      | ^~~~~~
a.cc:4:1: error: 'vector' does not name a type
    4 | vector<int> cost(10000);
      | ^~~~~~
a.cc: In function 'void cost_fn(int)':
a.cc:16:9: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   16 |         cost[1] = abs(hi[1]-hi[0]);
      |         ^~~~
      |         cosl
a.cc:16:23: error: 'hi' was not declared in this scope
   16 |         cost[1] = abs(hi[1]-hi[0]);
      |                       ^~
a.cc:22:27: error: 'min' was not declared in this scope; did you mean 'std::min'?
   22 |                 cost[i] = min(onestep, twostep);
      |                           ^~~
      |                           std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:25:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   25 |         cout << cost[n] << endl;
      |         ^~~~
      |         std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:25:28: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   25 |         cout << cost[n] << endl;
      |                            ^~~~
      |                            std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:31:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   31 |         cin >> n;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:34:24: error: 'hi' was not declared in this scope; did you mean 'i'?
   34 |                 cin >> hi[i];
      |                        ^~
      |                        i