Language: C++

#include<bits/stdc++.h>
#include<math.h>
//#include<vector>
//#include <iostream>
//#include <algorithm>
#include <limits>
using namespace std;
#define nMAX 1000000
int main(void){
	int N;
	int i,j,k;
	cin >> N;
	int h[N+1];
	for(i=0;i<N;i++){
		cin >> h[i+1];
	}
	int dp[N+1];
	for(i=0;i<N+1;i++){
		dp[i] = nMAX;
	}
	//cout << "aa";
	dp[1]=0;
	for(i=1;i<N;i++){
		for(j=i;j<=i+2&&j<N;j++){
				//cout << i << " " << j << endl;
				dp[j+1]=min(dp[j]+(long)abs(h[j+1]-h[j]),dp[j+1]);
				//cout << dp[i+1][j+1] << endl;
			if(j+2>N){
				//cout << "q" << endl;
				break;
			}else{
				dp[j+2]=min(dp[j]+(long)abs(h[j+2]-h[j]),dp[j+2]);
				//cout << dp[i+1][j+2]<<endl;
				
			}
			/*for(k=1;k<=N;k++){
				cout << dp[k] << " ";
			}
			cout << endl;*/
		}
		
		/*for(long long i1=1;i1<=N;i1++){
			for(long long j1=1;j1<=N;j1++){
				cout << dp[i1][j1] << " ";
			}
			cout << endl;
		}*/
	}
	/*for(i=1;i<=N;i++){
		for(j=1;j<=N;j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	//cout << endl;
	/*long long summin=MAX;
	for(i=1;i<=N;i++){
		summin=min(summin,dp[i][N]);
	}*/
	cout << dp[N] <<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:44: error: no matching function for call to 'min(long int, int&)'
   26 |                                 dp[j+1]=min(dp[j]+(long)abs(h[j+1]-h[j]),dp[j+1]);
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:26:44: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   26 |                                 dp[j+1]=min(dp[j]+(long)abs(h[j+1]-h[j]),dp[j+1]);
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:26:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   26 |                                 dp[j+1]=min(dp[j]+(long)abs(h[j+1]-h[j]),dp[j+1]);
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:32:44: error: no matching function for call to 'min(long int, int&)'
   32 |                                 dp[j+2]=min(dp[j]+(long)abs(h[j+2]-h[j]),dp[j+2]);
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:32:44: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   32 |                                 dp[j+2]=min(dp[j]+(long)abs(h[j+2]-h[j]),dp[j+2]);
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:32:44: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   32 |                                 dp[j+2]=min(dp[j]+(long)abs(h[j+2]-h[j]),dp[j+2]);
      |                                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~