Language: C++

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const ll oo = 1e18L+7;

int abso(ll a) {
    if(a < 0) return -a;
    return a;
}

vector<ll> h, dp;
int n;

int main() {
    
    scanf("%d",&n);
    h.resize(n+1);
    
    for(int i = 1; i <= n; ++i) {
        scanf("%lld",&h[i]);
    }
    
    dp.assign(n+1, oo);
    dp[1] = 0;
    
    for(int i = 1; i <= n; ++i) {
        for(int j = i+1; j <= i+2 && j <= n; ++j) {
            dp[j] = min(dp[j], dp[i]+abso(h[i]-h[j]));
        }
    }

    printf("%lld\n", dp[n]);
    
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const ll oo = 1e18L+7;

int abso(ll a) {
    if(a < 0) return -a;
    return a;
}

vector<ll> h, dp;
int n;

int main() {
    
    scanf("%d",&n);
    h.resize(n+1);
    
    for(int i = 1; i <= n; ++i) {
        scanf("%lld",&h[i]);
    }
    
    dp.assign(n+1, oo);
    dp[1] = 0;
    
    for(int i = 1; i <= n; ++i) {
        for(int j = i+1; j <= i+2 && j <= n; ++j) {
            dp[j] = min(dp[j], dp[i]+abso(h[i]-h[j]));
        }
    }

    printf("%lld\n", dp[n]);
    
    return 0;
}




Compiler output:
a.cc:77:14: error: redefinition of 'struct rge<c>'
   77 | sim > struct rge { c b, e; };
      |              ^~~
a.cc:8:14: note: previous definition of 'struct rge<c>'
    8 | sim > struct rge { c b, e; };
      |              ^~~
a.cc:78:14: error: redefinition of 'template<class c> rge<c> range(c, c)'
   78 | sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
      |              ^~~~~
a.cc:9:14: note: 'template<class c> rge<c> range(c, c)' previously declared here
    9 | sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
      |              ^~~~~
a.cc:81:8: error: redefinition of 'struct debug'
   81 | struct debug {
      |        ^~~~~
a.cc:12:8: note: previous definition of 'struct debug'
   12 | struct debug {
      |        ^~~~~
a.cc:105:10: error: redefinition of 'const ll oo'
  105 | const ll oo = 1e18L+7;
      |          ^~
a.cc:36:10: note: 'const ll oo' previously defined here
   36 | const ll oo = 1e18L+7;
      |          ^~
a.cc:107:5: error: redefinition of 'int abso(ll)'
  107 | int abso(ll a) {
      |     ^~~~
a.cc:38:5: note: 'int abso(ll)' previously defined here
   38 | int abso(ll a) {
      |     ^~~~
a.cc:112:12: error: redefinition of 'std::vector<long long int> h'
  112 | vector<ll> h, dp;
      |            ^
a.cc:43:12: note: 'std::vector<long long int> h' previously declared here
   43 | vector<ll> h, dp;
      |            ^
a.cc:112:15: error: redefinition of 'std::vector<long long int> dp'
  112 | vector<ll> h, dp;
      |               ^~
a.cc:43:15: note: 'std::vector<long long int> dp' previously declared here
   43 | vector<ll> h, dp;
      |               ^~
a.cc:113:5: error: redefinition of 'int n'
  113 | int n;
      |     ^
a.cc:44:5: note: 'int n' previously declared here
   44 | int n;
      |     ^
a.cc:115:5: error: redefinition of 'int main()'
  115 | int main() {
      |     ^~~~
a.cc:46:5: note: 'int main()' previously defined here
   46 | int main() {
      |     ^~~~