Language: C++

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define int long long
#define fori(j,n) for(int i=j;i<n;i++)
#define forb(n,j) for(int i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define PI 3.141592653589793
#define M 1000000007
using namespace std;
int fast(int a,int b)
{
    int ans=1;
    a=a%M;
    if(a==0)
        return 0;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b>>=1;
        a=(a*a)%M;
    }
}
int h[100010];
int n;
int dp[100010];
int fun(int i)
{
    if(i==n)
        return 0;
    if(i>n)
        return INT_MAX;
    if(dp[i]!=-1)
        return dp[i];
    int left=abs(h[i]-h[i+1])+fun(i+1);
    right=abs(h[i]-h[i+2])+fun(i+2);
    dp[i]=min(left,right);
    return min(left,right);
}
int32_t main()
{
    IOS;
    cin>>n;
    memset(dp,-1,sizeof(dp));
    fori(1,n+1)
        cin>>h[i];
    cout<<fun(1);
    return 0;
}


Compiler output:
a.cc: In function 'long long int fun(long long int)':
a.cc:42:10: error: assignment of function 'std::ios_base& std::right(ios_base&)'
   42 |     right=abs(h[i]-h[i+2])+fun(i+2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:43:14: error: no matching function for call to 'min(long long int&, std::ios_base& (&)(std::ios_base&))'
   43 |     dp[i]=min(left,right);
      |           ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:43:14: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::ios_base&(std::ios_base&)')
   43 |     dp[i]=min(left,right);
      |           ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:43:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   43 |     dp[i]=min(left,right);
      |           ~~~^~~~~~~~~~~~
a.cc:44:15: error: no matching function for call to 'min(long long int&, std::ios_base& (&)(std::ios_base&))'
   44 |     return min(left,right);
      |            ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:44:15: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::ios_base&(std::ios_base&)')
   44 |     return min(left,right);
      |            ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:44:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   44 |     return min(left,right);
      |            ~~~^~~~~~~~~~~~
a.cc: In function 'long long int fast(long long int, long long int)':
a.cc:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^