Language: C++

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
"#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)",
"#define reprev(i,n) reprrev(i,0,n)",
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
struct UnionFind {
	vector<int> par, rank;
 
	UnionFind(int n) : par(n, -1), rank(n, 0) { }
	void init(int n) { par.assign(n, -1), rank.assign(n, 0); }
 
	int root(int x) {
		if (par[x] == -1) return x;
		else return par[x] = root(par[x]);
	}
 
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
 
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y);
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		return true;
	}
};
 
int main() {
	ll N;
	cin >> N;
  	vector<ll> h(N);
  	rep(i, N) cin >> h[i];
  	vector<ll> dp(N);
  	rep(i,N) dp[i] = INF;
  	dp[0] = 0;
  	REP(i, 1, N){
      chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
	  if(i > 1)chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
	
	cout << dp[N-1] << endl;
}

Compiler output:
a.cc:6:1: error: expected unqualified-id before string constant
    6 | "#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)",
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:49:9: error: 'vector' does not name a type
   49 |         vector<int> par, rank;
      |         ^~~~~~
a.cc: In constructor 'UnionFind::UnionFind(int)':
a.cc:51:28: error: class 'UnionFind' does not have any field named 'par'
   51 |         UnionFind(int n) : par(n, -1), rank(n, 0) { }
      |                            ^~~
a.cc:51:40: error: class 'UnionFind' does not have any field named 'rank'
   51 |         UnionFind(int n) : par(n, -1), rank(n, 0) { }
      |                                        ^~~~
a.cc: In member function 'void UnionFind::init(int)':
a.cc:52:28: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   52 |         void init(int n) { par.assign(n, -1), rank.assign(n, 0); }
      |                            ^~~
      |                            __pstl::execution::v1::par
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc:52:47: error: 'rank' was not declared in this scope; did you mean 'std::rank'?
   52 |         void init(int n) { par.assign(n, -1), rank.assign(n, 0); }
      |                                               ^~~~
      |                                               std::rank
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/type_traits:1437:12: note: 'std::rank' declared here
 1437 |     struct rank
      |            ^~~~
a.cc: In member function 'int UnionFind::root(int)':
a.cc:55:21: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   55 |                 if (par[x] == -1) return x;
      |                     ^~~
      |                     __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc: In member function 'bool UnionFind::merge(int, int)':
a.cc:66:21: error: 'rank' was not declared in this scope; did you mean 'std::rank'?
   66 |                 if (rank[x] < rank[y]) swap(x, y);
      |                     ^~~~
      |                     std::rank
/usr/include/c++/14/type_traits:1437:12: note: 'std::rank' declared here
 1437 |     struct rank
      |            ^~~~
a.cc:66:40: error: 'swap' was not declared in this scope
   66 |                 if (rank[x] < rank[y]) swap(x, y);
      |                                        ^~~~
a.cc:66:40: note: suggested alternatives:
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181:
/usr/include/c++/14/bits/regex.h:2230:5: note:   'std::__cxx11::swap'
 2230 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:61:
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
In file included from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/stdexcept:38,
                 from /usr/include/c++/14/system_error:43,
                 from /usr/include/c++/14/bits/ios_base.h:46,
                 from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   'std::__exception_ptr::swap'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/14/filesystem:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_path.h:736:15: note:   'std::filesystem::__cxx11::swap'
  736 |   inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); }
      |               ^~~~
a.cc:67:21: error: 'rank' was not declared in this scope; did you mean 'std::rank'?
   67 |                 if (rank[x] == rank[y]) ++rank[x];
      |                     ^~~~
      |                     std::rank
/usr/include/c++/14/type_traits:1437:12: note: 'std::rank' declared here
 1437 |     struct rank
      |            ^~~~
a.cc:68:17: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   68 |                 par[y] = x;
      |                 ^~~
      |                 __pstl::execution::v1::par
/usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here
   43 | _GLIBCXX17_INLINE constexpr parallel_policy par{};
      |                                             ^~~
a.cc: In function 'int main()':
a.cc:75:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   75 |         cin >> N;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:76:9: error: 'vector' was not declared in this scope
   76 |         vector<ll> h(N);
      |         ^~~~~~
a.cc:76:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:76:18: error: expected primary-expression before '>' token
   76 |         vector<ll> h(N);
      |                  ^
a.cc:76:20: error: 'h' was not declared in this scope
   76 |         vector<ll> h(N);
      |                    ^
a.cc:78:18: error: expected primary-expression before '>' token
   78 |         vector<ll> dp(N);
      |                  ^
a.cc:78:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   78 |         vector<ll> dp(N);
      |                    ^~
      |                    dup
a.cc:86:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   86 |         cout << dp[N-1] << endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:86:28: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   86 |         cout << dp[N-1] << 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)
      |     ^~~~