Language: C++

#include <bits/stdc++.h>
int fun(vector<int>&dp, vector<int>&arr, int i, int n){
  if(i==n)
    return INT_MAX;
  if(dp[i]!=INT_MAX)
    return dp[i];
  dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1] + fun(dp,arr,i+1,n), dp[i-2] + abs(arr[i]-arr[i-2] + fun(dp,arr,i+1,n)));
              return dp[i];
              
 }

int main(void){
  int n;
  cin>>n;
  vector<int>dp(n,INT_MAX), arr(n,0);
  
  for(int i = 0;i<n;i++){
    cin>>arr[i];
  }
  dp[0] = arr[0];
  dp[1] = arr[1];
  fun(dp,2,n,arr);
  cout<<dp[n-1]<<"\n";
  return 0;  
}

Compiler output:
a.cc:2:9: error: 'vector' was not declared in this scope
    2 | int fun(vector<int>&dp, vector<int>&arr, int i, int n){
      |         ^~~~~~
a.cc:2: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,
                 from a.cc:1:
/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:2:16: error: expected primary-expression before 'int'
    2 | int fun(vector<int>&dp, vector<int>&arr, int i, int n){
      |                ^~~
a.cc:2:25: error: 'vector' was not declared in this scope
    2 | int fun(vector<int>&dp, vector<int>&arr, int i, int n){
      |                         ^~~~~~
a.cc:2:25: note: suggested alternatives:
/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:2:32: error: expected primary-expression before 'int'
    2 | int fun(vector<int>&dp, vector<int>&arr, int i, int n){
      |                                ^~~
a.cc:2:42: error: expected primary-expression before 'int'
    2 | int fun(vector<int>&dp, vector<int>&arr, int i, int n){
      |                                          ^~~
a.cc:2:49: error: expected primary-expression before 'int'
    2 | int fun(vector<int>&dp, vector<int>&arr, int i, int n){
      |                                                 ^~~
a.cc:2:54: error: expression list treated as compound expression in initializer [-fpermissive]
    2 | int fun(vector<int>&dp, vector<int>&arr, int i, int n){
      |                                                      ^
a.cc: In function 'int main()':
a.cc:14:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   14 |   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:15:3: error: 'vector' was not declared in this scope
   15 |   vector<int>dp(n,INT_MAX), arr(n,0);
      |   ^~~~~~
a.cc:15:3: note: suggested alternatives:
/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:15:10: error: expected primary-expression before 'int'
   15 |   vector<int>dp(n,INT_MAX), arr(n,0);
      |          ^~~
a.cc:18:10: error: 'arr' was not declared in this scope
   18 |     cin>>arr[i];
      |          ^~~
a.cc:20:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |   dp[0] = arr[0];
      |   ^~
      |   dup
a.cc:20:11: error: 'arr' was not declared in this scope
   20 |   dp[0] = arr[0];
      |           ^~~
a.cc:22:6: error: 'fun' cannot be used as a function
   22 |   fun(dp,2,n,arr);
      |   ~~~^~~~~~~~~~~~
a.cc:23:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   23 |   cout<<dp[n-1]<<"\n";
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~