Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template<class T> inline bool change_min(T& a, T b) {
	if (a > b) {
    	a = b;
        return 1;
    } else {
    	return 0;
    }
}
 
const long H_MAX = 9999999999;
int n = 100001;
 
int N;
long long h[n];
 
long long dp[n];
 
int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];
 
    for (int i = 0; i < 100010; i++) {
    	dp[i] = H_MAX;
    }
 
    dp[0] = 0;
 
    for (int i = 1; i < N; ++i) {
        change_min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1){
        	change_min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
 
    cout << dp[N-1] << endl;
}
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template<class T> inline bool change_min(T& a, T b) {
	if (a > b) {
    	a = b;
        return 1;
    } elae {
    	return 0;
    }
}
 
const long H_MAX = 9999999999;
int n = 100001;
 
int N;
long long h[n];
 
long long dp[n];
 
int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];
 
    for (int i = 0; i < 100010; i++) {
    	dp[i] = H_MAX;
    }
 
    dp[0] = 0;
 
    for (int i = 1; i < N; ++i) {
        change_min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1){
        	change_min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
 
    cout << dp[N-1] << endl;
}

Compiler output:
a.cc:19:13: error: size of array 'h' is not an integral constant-expression
   19 | long long h[n];
      |             ^
a.cc:21:14: error: size of array 'dp' is not an integral constant-expression
   21 | long long dp[n];
      |              ^
a.cc:47:31: error: redefinition of 'template<class T> bool change_min(T&, T)'
   47 | template<class T> inline bool change_min(T& a, T b) {
      |                               ^~~~~~~~~~
a.cc:6:31: note: 'template<class T> bool change_min(T&, T)' previously declared here
    6 | template<class T> inline bool change_min(T& a, T b) {
      |                               ^~~~~~~~~~
a.cc:56:12: error: redefinition of 'const long int H_MAX'
   56 | const long H_MAX = 9999999999;
      |            ^~~~~
a.cc:15:12: note: 'const long int H_MAX' previously defined here
   15 | const long H_MAX = 9999999999;
      |            ^~~~~
a.cc:57:5: error: redefinition of 'int n'
   57 | int n = 100001;
      |     ^
a.cc:16:5: note: 'int n' previously defined here
   16 | int n = 100001;
      |     ^
a.cc:59:5: error: redefinition of 'int N'
   59 | int N;
      |     ^
a.cc:18:5: note: 'int N' previously declared here
   18 | int N;
      |     ^
a.cc:60:13: error: size of array 'h' is not an integral constant-expression
   60 | long long h[n];
      |             ^
a.cc:60:11: error: redefinition of 'long long int h [1]'
   60 | long long h[n];
      |           ^
a.cc:19:11: note: 'long long int h [1]' previously declared here
   19 | long long h[n];
      |           ^
a.cc:62:14: error: size of array 'dp' is not an integral constant-expression
   62 | long long dp[n];
      |              ^
a.cc:62:11: error: redefinition of 'long long int dp [1]'
   62 | long long dp[n];
      |           ^~
a.cc:21:11: note: 'long long int dp [1]' previously declared here
   21 | long long dp[n];
      |           ^~
a.cc:64:5: error: redefinition of 'int main()'
   64 | int main() {
      |     ^~~~
a.cc:23:5: note: 'int main()' previously defined here
   23 | int main() {
      |     ^~~~