Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <tuple>
 
using namespace std;
 
template<typename E>
using Matrix = std::vector<std::vector<E> >;
 
typedef long long LL;
typedef long double LD;
typedef std::pair<LL ,LL> LP;
 
#define INF		1e9
#define EPS		1e-9
#define gcd 	__gcd
#define make_matrix(rows, col, type, default) 			\
					std::vector< std::vector<type> >( 	\
						rows 						  	\
						std::vector<type>(col, default) \
					);
 
#define repeat(n)	for(LL __x = 0; __x < n; __x++)
#define watch(x)	cout << (#x) << " is " << (x) << "\n";
#define DEG_TO_RAD(x) (x * PI / 180.0)
#define RAD_TO_DEG(x) (x * 180.0 / PI)

auto cost(LL i, LL j) -> LL {
    return abs(i-j);
}

auto main() -> int {
    LL n, t;

    std::vector<LL> memo;
    std::vector<LL> rocks; // rock height

    std::cin >> n;
    for(LL i = 0; i < n; i++) {
        std::cin >> t;
        rocks.emplace_back(t);

        if(i == 0) { memo.emplace_back(0); continue; }
        if(i == 1) { memo.emplace_back(rocks[i], rocks[i-1]); continue; }

        memo.emplace_back(
            min(memo[i-1] + cost(rocks[i], rocks[i-1]), 
                memo[i-2] + cost(rocks[i], rocks[i-2])
            )
        );
    }
    std::cout << memo[n-1];
}

Compiler output:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = long long int; _Args = {long long int&, long long int&}; _Tp = long long int]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = long long int; _Args = {long long int&, long long int&}; _Tp = long long int; allocator_type = std::allocator<long long int>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int&, long long int&}; _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:52:39:   required from here
   52 |         if(i == 1) { memo.emplace_back(rocks[i], rocks[i-1]); continue; }
      |                      ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~