criyle/codenet-compile-errors huggingface dataset:
Language: C++

/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}
const int N = (int)1e5 + 10;
const ll inf = (ll) 1e18;
int h[N];
ll dp[N];
int n;

void solve() {
   for (int i = 1; i <= n; ++i) dp[i] = inf;
   dp[1] = 0;

   for (int i = 2; i <= n; ++i) {
      dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
      if (i > 2) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-]));
   }
   cout << dp[n] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 1; i <= n; ++i) cin >> h[i];
   solve();

   return EXIT_SUCCESS;
}


Compiler output:
a.cc: In function 'void err(std::istream_iterator<std::__cxx11::basic_string<char> >)':
a.cc:29:50: warning: ignoring return value of 'bool std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::empty() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]', declared with attribute 'nodiscard' [-Wunused-result]
   29 | void err(istream_iterator<string> it) { it->empty();
      |                                         ~~~~~~~~~^~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:8:
/usr/include/c++/14/bits/basic_string.h:1231:7: note: declared here
 1231 |       empty() const _GLIBCXX_NOEXCEPT
      |       ^~~~~
a.cc: In function 'void solve()':
a.cc:49:62: error: expected primary-expression before ']' token
   49 |       if (i > 2) dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-]));
      |                                                              ^
Language: C++

#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include <iostream>
#include <algorithm>
#include <limits>
using namespace std;
#define MAX numeric_limits<int>::max()
int min(int a,int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
int main(void){
	int K,A,B;
	int N;
	int i,j,Q,W,M,R;
	cin >> N;
	int h[N+1];
	for(i=0;i<N;i++){
		cin >> h[i+1];
	}
	int dp[N+1][N+1];
	for(i=0;i<N+1;i++){
		for(j=0;j<N+1;j++){
			dp[i][j] = MAX;
		}
	}
	//cout << "aa";
	dp[1][1]=f[1];
	for(i=1;i<N;i++){
		for(j=i;j<=2*i+2&&j<N;j++){
			if(dp[i][j]<MAX){
				//cout << i << " " << j << endl;
				dp[i+1][j+1]=min(dp[i][j]+(int)abs(h[j+1]-h[j]),dp[i+1][j+1]);
				//cout << dp[i+1][j+1] << endl;
				if(j+2>N){
					//cout << "q" << endl;
					break;
				}else{
					dp[i+1][j+2]=min(dp[i][j]+(int)abs(h[j+2]-h[j]),dp[i+1][j+2]);
					//cout << dp[i+1][j+2]<<endl;
				}
			}
		}
		
		/*for(int i1=1;i1<=N;i1++){
			for(int 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;
	int summin=MAX;
	for(i=1;i<=N;i++){
		summin=min(summin,dp[i][N]);
	}
	cout << summin <<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:18: error: 'f' was not declared in this scope
   32 |         dp[1][1]=f[1];
      |                  ^
Language: C++

#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include <iostream>
#include <algorithm>
#include <limits>
using namespace std;
#define MAX numeric_limits<long long>::max()
long long min(long long a,long long b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
int main(void){
	int K,A,B;
	long long N;
	int i,j,Q,W,M,R;
	cin >> N;
	long long h[N+1];
	for(i=0;i<N;i++){
		cin >> h[i+1];
	}
	long long dp[N+1][N+1];
	for(i=0;i<N+1;i++){
		for(j=0;j<N+1;j++){
			dp[i][j] = MAX;
		}
	}
	//cout << "aa";
	dp[1][1]=f[1];
	for(i=1;i<N;i++){
		for(j=i;j<=2*i+2&&j<N;j++){
			if(dp[i][j]<MAX){
				//cout << i << " " << j << endl;
				dp[i+1][j+1]=min(dp[i][j]+(long long)abs(h[j+1]-h[j]),dp[i+1][j+1]);
				//cout << dp[i+1][j+1] << endl;
				if(j+2>N){
					//cout << "q" << endl;
					break;
				}else{
					dp[i+1][j+2]=min(dp[i][j]+(long long)abs(h[j+2]-h[j]),dp[i+1][j+2]);
					//cout << dp[i+1][j+2]<<endl;
				}
			}
		}
		
		/*for(int i1=1;i1<=N;i1++){
			for(int 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 << summin <<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:18: error: 'f' was not declared in this scope
   32 |         dp[1][1]=f[1];
      |                  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;


int solve(int a[n], int n){

	int dp[n];
	dp[0] = a[0];
	dp[1] = abs(a[0]-a[1]);
	dp[2] = min(abs(a[0]-a[2]), abs(a[0]-a[1]) + abs(a[2]-a[1]));
	for (int i = 3; i < n; ++i){
		dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
	}

	return dp[n-1];

}

int main(){

	int n;
	cin>>n;
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		/* code */cin>>h[i];
	}
	cout<<solve(h,n);
	
	return 0;
}

Compiler output:
a.cc:5:17: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 | int solve(int a[n], int n){
      |                 ^
      |                 yn
a.cc:5:19: error: expected ')' before ',' token
    5 | int solve(int a[n], int n){
      |          ~        ^
      |                   )
a.cc:5:21: error: expected unqualified-id before 'int'
    5 | int solve(int a[n], int n){
      |                     ^~~
Language: Java


/*
9 2
        1 1 1 1 1 0 0 0 0
        1 2
        1 5
        5 6
        5 7
        2 3
        2 4
        3 8
        3 9
*/


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.Vector;

public class Question {


    static LinkedList<Integer> adj[];
    static boolean[] visited;
    static boolean[] visited_;
    static int[] ans;
    static int count_ = 0;
    static final int MAX_SIZE = 1000001;
    static Vector<Boolean> isprime = new Vector<>(MAX_SIZE);
    static Vector<Integer> prime = new Vector<>();
    static Vector<Integer> SPF = new Vector<>(MAX_SIZE);

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        int n = Reader.nextInt();
        int[] arr = new int[n];
        int[] ans = new int[n];
        for (int i = 0 ; i < n ; i++){
            arr[i] = Reader.nextInt();
        }
        if (n==1){
            System.out.println(0);
            System.exit(0);
        }
        else if (n==2){
            System.out.println(Math.abs(arr[1]-arr[0]));
            System.exit(0);
        }
        else{
            ans[1] = Math.abs(arr[1] - arr[0]);
            for (int i=2; i < n ; i++){
                ans[i] = Math.min(Math.abs(arr[i] - arr[i-2]) + ans[i-2],Math.abs(arr[i]-arr[i-1]) + ans[i-1]);
            }
        }

        for (int i = 0 ; i < n ; i++){
            //System.out.println(ans[i] + " ");
        }
        System.out.println(ans[n-1]);



    }
}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
}

Compiler output:
Main.java:24: error: class Question is public, should be declared in a file named Question.java
public class Question {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n,w;
    cin >> n >> w;
    vector<vector<long long>> dp(105,vector<long long>(100005,100)),x(n+1,vector<long long>(2));
    for(int i = 1 ; i <= n ; i += 1){
        cin >> x[i][0] >> x[i][1];
    }
    for(int i = 0 ; i <= n ; i += 1){
        dp[i][0] = 0;
    }
    long long max_sum = n * 1000,ans=0;
    for(int i = 1 ; i <= n ; i += 1){
        for(int v = 0 ; v <= max_sum ; v += 1){
            dp[i][v] = dp[i-1][v];
            if(v - x[i][1] >= 0){
                dp[i][v] = min(dp[i][v],dp[i-1][v-x[i][1]] + x[i][0]);
            }
            if(dp[i][v] <= w){
                ans = max(ans,v);
            }
        }
    }
    cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:26: error: no matching function for call to 'max(long long int&, int&)'
   23 |                 ans = max(ans,v);
      |                       ~~~^~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:23:26: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   23 |                 ans = max(ans,v);
      |                       ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:23:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   23 |                 ans = max(ans,v);
      |                       ~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
using namespace std;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int l) { uniform_int_distribution<int> uid(0, l - 1); return uid(rang); }

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	int h0, h1, h2;
	cin >> h1 >> h2;
	int c0 = 0;
	int c1 = abs(h2 - h1);
	print(c1, c0);
	print(h1, h2);
	for (int i = 2; i < n; ++i) {
		tie(h0, h1) = tie(h1, h2);
		cin >> h2;
		print(h0, h1, h2);
		print(abs(h0 - h2) + c0, abs(h2 - h1) + c1, c1, c0);
		c0 = min(abs(h0 - h2) + c0, abs(h2 - h1) + c1); swap(c1, c0);
		print(c1);
	}
	cout << c1;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:16:9: error: 'print' was not declared in this scope; did you mean 'rint'?
   16 |         print(c1, c0);
      |         ^~~~~
      |         rint
Language: Java

public class Main {
    public static int findMinCost(int[] heights){
        int n = heights.length;
        int min[] = new int[n];
        min[0] = 0;
        min[1] = Math.abs(heights[1]-heights[0]);
        for(int i=2;i<n;i++){
            min[i] = Math.min(Math.abs(heights[i]-heights[i-1])+min[i-1],
                                    Math.abs(heights[i]-heights[i-2])+min[i-2]);
        }
        return min[n-1];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int heights[] = new int[n];
        for(int i=0;i<n;i++){
            heights[i] = sc.nextInt();
        }
        System.out.println(findMinCost(heights));
    }
}

Compiler output:
Main.java:14: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:14: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.Scanner;
public class Frog_1 {
    public static int findMinCost(int[] heights){
        int n = heights.length;
        int min[] = new int[n];
        min[0] = 0;
        min[1] = Math.abs(heights[1]-heights[0]);
        for(int i=2;i<n;i++){
            min[i] = Math.min(Math.abs(heights[i]-heights[i-1])+min[i-1],
                                    Math.abs(heights[i]-heights[i-2])+min[i-2]);
        }
        return min[n-1];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int heights[] = new int[n];
        for(int i=0;i<n;i++){
            heights[i] = sc.nextInt();
        }
        System.out.println(findMinCost(heights));
    }
}

Compiler output:
Main.java:2: error: class Frog_1 is public, should be declared in a file named Frog_1.java
public class Frog_1 {
       ^
1 error
Language: C++

/*

#include <bits/stdc++.h>

using namespace std;

int main () {
	int n;
	cin >> n;
	
	vector<int> input(n);
	for (int i = 0; i < n; i++) {
		cin >> input[i];
	}

	vector<int> ans(n);
	ans[0] = 0; ans[1] = abs(input[1] - input[0]);
	for (int i = 2; i <n; i++) {
		ans[i] = min ( ans[i-1] + abs(input[i] - input[i - 1]), ans[i-2] + abs(input[i] - input[i - 2]) );
	}
	
	cout << ans[n-1] << endl;
	return 0;
}

*/

#include <bits/stdc++.h>

using namespace std;

int main () {
	int n;
	cin >> n;
	
	int in1, in2, in3, ans1, ans2, ans3;
	cin >> in1 >> in2;
	ans1 = 0; ans2 = abs(in[0] - in[1]);

	for (int i = 2; i <n; i++) {
		cin >> in3;
		ans3 = min ( ans2 + abs(in3 - in2), ans1 + abs(in3 - in1) );

		in1 = in2;
		in2 = in3;
		ans1 = ans2;
		ans2 = ans3;
		
	}
	
	cout << ans3 << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:30: error: 'in' was not declared in this scope; did you mean 'in3'?
   38 |         ans1 = 0; ans2 = abs(in[0] - in[1]);
      |                              ^~
      |                              in3
Language: C++

#include<bits/stdc++.h>
#define fastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define f(i, l, r) for(i = l; i < r; i++)
#define fd(i, l, r) for(i = l; i > r; i--)
using namespace std;
#pragma GCC optimize ("-O3")

int main(){
	fastIO
	
    int n, i;
    cin >> n;

    int arr_h[n];
    f(i,0,n)
        cin >> arr_h[i];

    int cost = 0;
    last_i = n-1;
    while(last_i != 0){
        if(last_i == 1)
            cost+=abs(arr_h[last_i--]-arr_h[0]);
        else{
            if(abs(arr_h[last_i] - arr_h[last_i-1]) >= abs(arr_h[last_i] - arr_h[last_i-2])){
                last_i -= 2;
                cost+=abs(arr_h[last_i] - arr_h[last_i-2]);
            }
            else
                cost+=abs(arr_h[last_i--] - arr_h[last_i-1]);
        }

    }
    cout << cost;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'last_i' was not declared in this scope
   20 |     last_i = n-1;
      |     ^~~~~~
Language: Java

import java.util.*; import java.io.*; import java.math.*;


public class iloveemma {
	
	static Scanner scan = new Scanner(System.in);
	static int lim = 1000000007;
	static long[] dp; 
	public static void main(String[] args) {
		
		int N = scan.nextInt(); long[] arr = new long[N]; dp = new long[N];
		for(int i=0; i<N; i++) {arr[i] = scan.nextLong(); } Arrays.fill(dp,-1);
		System.out.println(solve(arr,0)); 
	}
	
	
	public static long solve(long[] arr, int index) {
		if(index >= arr.length-2) {return 0;}
		else if(dp[index] != -1){return dp[index];}
		else {
			dp[index] = Long.min(solve(arr,index+1)+Math.abs(arr[index]-arr[index+1]), 
					solve(arr,index+2)+Math.abs(arr[index]-arr[index+2]));
			return dp[index];
		}
	}

}


Compiler output:
Main.java:4: error: class iloveemma is public, should be declared in a file named iloveemma.java
public class iloveemma {
       ^
1 error
Language: C++

#include <iostream>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
	/* 入力 */
	int n; cin >> n;
	long long h[100010];
	for (int i = 0; i < n; ++i) cin >> h[i];
	
	/* DPテーブル */
	long long dp[100010];
	for (int i = 0; i < 100010; ++i) dp[i] = 1000000; // 初期化

	dp[0] = 0;

	for (int i = 1; i < n; ++i) {
		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;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:73: error: expected ')' before ';' token
   20 |                 if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]);
      |                                 ~                                       ^
      |                                                                         )
Language: Java

import java.util.Scanner;

public class main{
    static int dp(int[] arr){
        int n = arr.length;
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(arr[0]-arr[1]);
        for(int i=2;i<n;i++){
            dp[i] = Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i]-arr[i-2]));

        }
        return dp[n-1];
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = scan.nextInt();
        }
        scan.close();
        System.out.println(dp(arr));
        
    }
}

Compiler output:
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main{
       ^
1 error
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
using namespace std;


int cost[100000];

int main() {
	int N;

	cin >> N;

	vector<int> H(N);
	for (int i=0; i<N; i++) {
		int h;
		cin >> h;
		H.at(i) = h;
	}

	for (int i=0; i<N; i;++) {
		int c1 = abs(H.at(i) - H.at(i+1));
		int c2 = abs(H.at(i) - H.at(i+2));
		if (c1 < cost[i+1]) cost[i+1] = c1;
		if (c2 < cost[i+1]) cost[i+2] = c2;
	}

	cout << cost[N-1];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:29: error: expected ')' before ';' token
   23 |         for (int i=0; i<N; i;++) {
      |             ~               ^
      |                             )
a.cc:23:32: error: expected primary-expression before ')' token
   23 |         for (int i=0; i<N; i;++) {
      |                                ^
Language: C++

#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <iomanip> //小数点以下を表示させる(setprecision())

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'

//DP法
template <class T>
inline bool chmin(T &a, T b) //change minimum
{
        if (a > b)
        {
                a = b;
                return true;
        }
        return false;
}
template <class T>
inline bool chmax(T &a, T b) //change max
{
        if (a < b)
        {
                a = b;
                return true;
        }
        return false;
}

typedef long long ll; //64bit型
using namespace std;

//無限大の値
const long long INF = 1LL << 60;

int main()
{
        int N;
        cin >> N;
        vector<int> cost(100010);

        REP(i, N)
        {
                cin >> cost[i];
        }

        ll dp[100010];
        REP(i, N) { dp[i] = INF; }
        dp[0] = 0;

        FOR(i, 1, N)
        {
                chmin(dp[i],dp[i-1]+abs(cost[i]-cost[i-1]);
                if(i>1)
                {
                        chmin(dp[i],dp[i-2]+abs(cost[i]-cost[i-2]);
                }
        }
        cout << dp[N - 1] << endl;
        return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:59: error: expected ')' before ';' token
   62 |                 chmin(dp[i],dp[i-1]+abs(cost[i]-cost[i-1]);
      |                      ~                                    ^
      |                                                           )
a.cc:65:67: error: expected ')' before ';' token
   65 |                         chmin(dp[i],dp[i-2]+abs(cost[i]-cost[i-2]);
      |                              ~                                    ^
      |                                                                   )
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;

    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];

    vector<int> cost(N);
    cost[0]=0;
    cost[1]=abs(height[1]-height[0]);

    for(int i=2 ; i<N ;i++){
        cost[i]=min(abs(height[i]-height[i-1])+cost[i-1],
                    abs(height[i]-height[i-2])+cost[i-2]
                    );
    }

    cout << cost[N-1] << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;

    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];

    vector<int> cost(N);
    cost[0]=0;
    cost[i]=abs(height[i]-height[i-1]);

    for(int i=2 ; i<N ;i++){
        cost[i]=min(abs(height[i]-height[i-1])+cost[i-1],
                    abs(height[i]-height[i-2])+cost[i-2]
                    );
    }

    cout << cost[N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: 'i' was not declared in this scope
   12 |     cost[i]=abs(height[i]-height[i-1]);
      |          ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;

    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];

    vector<int> cost(N);
    cost[0]=0;
    cost[i]=abs(height[i]-height[i-1]);

    for(int i=2 ; i<N ;i++){
        cost[i]=min(abs(height[i]-height[i-1])+cost[i-1],
                    abs(height[i]-height[i-2])+cost[i-2]
                    );
    }

    cout << cost[N-1] << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:12:10: error: 'i' was not declared in this scope
   12 |     cost[i]=abs(height[i]-height[i-1]);
      |          ^
a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    
    for (int i = 2 ; i < N ; i++){
        vector<int> cost(N);
        for(int i=1; i<N;i++)
        cost[0]=0;
        cost[i]=abs(height[i]-height[i-1]);
        for(int i=2 ; i<N ;i++){
            cost[i]=min(abs(height[i]-height[i-1])+cost[i-1],
                        abs(height[1]-height[i-2])+cost[i-2]
                        );
        }
    }
    cout << cost[N-1] << endl;
}


Compiler output:
a.cc: In function 'int mian()':
a.cc:20:13: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   20 |     cout << cost[N-1] << endl;
      |             ^~~~
      |             cosl
a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    
    for (int i = 3 ; i < N ; i++){
        vector<int> cost(N);
        for(int i=1; i<N;i++)
        cost[0]=0;
        cost[i]=abs(height[i]-height[i-1]);
        for(int i=2 ; i<N ;i++){
            cost[i]=min(abs(height[i]-height[i-1])+cost[i-1],
                        abs(height[1]-height[i-2])+cost[i-2]
                        );
        }
    }
    cout << cost[N] << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:20:13: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   20 |     cout << cost[N] << endl;
      |             ^~~~
      |             cosl
a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    
    for (int i = 3 ; i < N ; i++){
        vector<int> cost(N);
        for(int i=1; i<N;i++)
        cost[0]=0;
        cost[i]=abs(height[i]-height[i-1]);
        for(int i=2 ; i<N ;i++){
            cost[i]=min(abs(height[i]-height[i-1]),
                        abs(height[1]-height[i-2]);
                        );
        }
    }
    cout << cost[N] << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:16:51: error: expected ')' before ';' token
   16 |                         abs(height[1]-height[i-2]);
      |                                                   ^
      |                                                   )
a.cc:15:24: note: to match this '('
   15 |             cost[i]=min(abs(height[i]-height[i-1]),
      |                        ^
a.cc:17:25: error: expected primary-expression before ')' token
   17 |                         );
      |                         ^
a.cc:20:13: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   20 |     cout << cost[N] << endl;
      |             ^~~~
      |             cosl
a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
Language: C++

int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    
    for (int i = 3 ; i < N ; i++){
        vector<int> cost(N);
        cost[0]=0;
        cost[1]=abs(height[1]-height[0]);
        for(int i=2 ; i<N ;i++){
            cost[i]=min(abs(height[i]-height[i-1]),
                        abs(height[1]-height[i-2]);
                        );
        }
    }
    cout << cost[N] << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> N;
      |     ^~~
a.cc:4:5: error: 'vector' was not declared in this scope
    4 |     vector<int> height(N);
      |     ^~~~~~
a.cc:4:12: error: expected primary-expression before 'int'
    4 |     vector<int> height(N);
      |            ^~~
a.cc:5:41: error: 'height' was not declared in this scope
    5 |     for (int i = 0 ; i < N ; i++)cin >> height[i];
      |                                         ^~~~~~
a.cc:8:16: error: expected primary-expression before 'int'
    8 |         vector<int> cost(N);
      |                ^~~
a.cc:9:9: error: 'cost' was not declared in this scope; did you mean 'const'?
    9 |         cost[0]=0;
      |         ^~~~
      |         const
a.cc:10:21: error: 'height' was not declared in this scope
   10 |         cost[1]=abs(height[1]-height[0]);
      |                     ^~~~~~
a.cc:10:17: error: 'abs' was not declared in this scope
   10 |         cost[1]=abs(height[1]-height[0]);
      |                 ^~~
a.cc:14:25: error: expected primary-expression before ')' token
   14 |                         );
      |                         ^
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout << cost[N] << endl;
      |     ^~~~
a.cc:17:13: error: 'cost' was not declared in this scope; did you mean 'const'?
   17 |     cout << cost[N] << endl;
      |             ^~~~
      |             const
a.cc:17:24: error: 'endl' was not declared in this scope
   17 |     cout << cost[N] << endl;
      |                        ^~~~
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    
    for (int i = 3 ; i < N ; i++){
        vector<int> cost(N);
        for (int p=0 ; p<N ; p++){
            cost[p]=height[p];
        }
        int gapone = height[i]-height[i-1]+cost[i-1];
        int gaptwo = height[i]-height[i-2]+cost[i-2];
        if(gapone-gaptwo > 0)cost[i]=gaptwo;
        else{
            cost[i]=gapone;
        }
    }
    cout << cost[N] << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:21:13: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   21 |     cout << cost[N] << endl;
      |             ^~~~
      |             cosl
a.cc:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    
    for (int i = 3 ; i < N ; i++){
        vector<int> cost(N);
        for(int j = 3 ; i < N ; i++)cin >> cost[N];
        int gapone = height[i]-height[i-1]+cost[i-1];
        int gaptwo = height[i]-height[i-2]+cost[i-2];
        if(gapone-gaptwo > 0)cost[i]=gaptwo;
        else{
            cost[i]=gapone;
        }
    }
    cout << cost[N] << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:19:13: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   19 |     cout << cost[N] << endl;
      |             ^~~~
      |             cosl
a.cc:20:1: warning: no return statement in function returning non-void [-Wreturn-type]
   20 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    int cost = 0;
    for (int i = 3 ; i < N+1 ; i++){
        int gapone = height[i]-height[i-1]+cost;
        int gaptwo = height[i]-height[i-2]+cost;
        if(gapone-gaptwo > 0)cost=gaptwo;
        else{
            cost=gapone;
        }
    }
    cout << cost << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    int cost = 0;
    for (int i = 3 ; i < N-1 ; i++){
        int gapone = height[i]-height[i-1]+cost;
        int gaptwo = height[i]-height[i-2]+cost;
        if(gapone-gaptwo > 0)cost=gaptwo;
        else{
            cost=gapone;
        }
    }
    cout << cost << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    int cost = 0;
    for (int i = 3 ; i < N ; i++){
        int gapone = height[i]-height[i-1]+cost;
        int gaptwo = height[i]-height[i-2]+cost;
        if(gapone-gaptwo > 0)cost=gaptwo;
        else{
            cost=gapone;
        }
    }
    cout << cost << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < N ; i++)cin >> height[i];
    int cost = 0;
    for (int i = 3 ; i =< N ; i++){
        int gapone = height[i]-height[i-1]+cost;
        int gaptwo = height[i]-height[i-2]+cost;
        if(gapone-gaptwo > 0)cost=gaptwo;
        else{
            cost=gapone;
        }
    }
    cout << cost << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:9:25: error: expected primary-expression before '<' token
    9 |     for (int i = 3 ; i =< N ; i++){
      |                         ^
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int mian(){
    int N;
    cin >> N;
    vector<int> height(N);
    for (int i = 0 ; i < n ; i++)cin >> height[i];
    int cost = 0;
    for (int i = 3 ; i =< n ; i++){
        int gapone = height[i]-height[i-1]+cost;
        int gaptwo = height[i]-height[i-2]+cost;
        if(gapone-gaptwo > 0)cost=gaptwo;
        else{
            cost=gapone;
        }
    }
    cout << cost << endl;
}

Compiler output:
a.cc: In function 'int mian()':
a.cc:7:26: error: 'n' was not declared in this scope
    7 |     for (int i = 0 ; i < n ; i++)cin >> height[i];
      |                          ^
a.cc:9:25: error: expected primary-expression before '<' token
    9 |     for (int i = 3 ; i =< n ; i++){
      |                         ^
a.cc:9:27: error: 'n' was not declared in this scope
    9 |     for (int i = 3 ; i =< n ; i++){
      |                           ^
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
   18 | }
      | ^
Language: C++


// 数列dp：i番目の項は足場iへ行くために必要最低限のコスト

// L_n = min(L_n-2 + |h_n-2 - h_n|, L_n-1 + |h_n-1 - h_n|)
// L_2 = |h_2|
// L_1 = 0
// (L_0 = 0)

int main(){

	int n;
	cin >> n;
	
	int dp[100001];
	dp[0] = 0;
	dp[1] = 0;

	int h[100001];
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	h[0] = h[1];

	for(int i = 2; i <= n; i++){
		dp[i] = min(
			dp[i-2] + abs(h[i] - h[i-2]),
			dp[i-1] + abs(h[i] - h[i-1]));
	}

	cout << dp[n];

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'cin' was not declared in this scope
   12 |         cin >> n;
      |         ^~~
a.cc:26:35: error: 'abs' was not declared in this scope
   26 |                         dp[i-2] + abs(h[i] - h[i-2]),
      |                                   ^~~
a.cc:25:25: error: 'min' was not declared in this scope; did you mean 'main'?
   25 |                 dp[i] = min(
      |                         ^~~
      |                         main
a.cc:30:9: error: 'cout' was not declared in this scope
   30 |         cout << dp[n];
      |         ^~~~
Language: C++

#include <iostream>
using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  int dp[N];
  memset(dp, 0, sizeof(dp) );
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  dp[N - 1] = 0;
  int i = N - 2;
  int previnc = 1;

  int index = N - 1;
  int c = 0;
  while(index > 0){
      if(index >= 2){
        int comp = min( abs(A[index] - A[index - 1]), abs(A[index] - A[index - 2]) );
        if(comp == abs(A[index] - A[index - 1]) ){
            c += abs(A[index] - A[index - 1]);
            index--;
        } else {
          c += abs(A[index] - A[index - 2]);
          index-= 2;
        }
      } else {
          if(index == 1){
              c += abs(A[0] - A[1]);
              index--;
          }
      }
  }

  cout << c << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'memset' was not declared in this scope
    9 |   memset(dp, 0, sizeof(dp) );
      |   ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;
Language: C

#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
template<class T>inline bool chmax(T& a,T b){
  if(a<b){
    a=b;
    return 1;
  }
  return 0;
}
template<class T>inline bool chmin(T& a,T b){
  if(a>b){
    a=b;
    return 1;
  }
  return 0;
}

const long long INF = 1LL<<60;

int main(){
  int n,i,a[100000];
  long long dp[100000];
  cin >> n;
  for(i=0;i<n;i++){cin >> a[i];}
  for(i=0;i<100000;i++)dp[i]=INF;

  dp[0]=0;
  for(i=1;i<n;i++){
    chmin(dp[i],dp[i-1]+abs(a[i]-a[i-1]));
    if(i>1)chmin(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
  }

  cout << dp[n-1] << endl;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n;
    int dp[10010];
    cin >> n;
  	vector<int> h(n), dp(n);
    
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    
    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]), dp[i-2] + abs(h[i-2] - h[i]));
    }
    
    cout << dp[n-1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'vector' was not declared in this scope
   11 |         vector<int> h(n), dp(n);
      |         ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | 
a.cc:11:16: error: expected primary-expression before 'int'
   11 |         vector<int> h(n), dp(n);
      |                ^~~
a.cc:14:16: error: 'h' was not declared in this scope
   14 |         cin >> h[i];
      |                ^
a.cc:17:17: error: 'h' was not declared in this scope
   17 |     dp[1] = abs(h[0] - h[1]);
      |                 ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }


#define int long long
const int INF = 1001001001;


int rec(int i, vector<int> &dp, vector<int> &h){
    if(i == 0) return 0;
    if(dp[i] < INF) return dp[i];

    int ans = INF;
    amin(ans, rec(i-1, vector<int> &dp, vector<int> &h) + abs(h[i] - h[i-1]));
    amin(ans, rec(i-2, vector<int> &dp, vector<int> &h) + abs(h[i] - h[i-2]));

    return dp[i] = ans;
}

signed main(){

    int n;cin >> n;
    vector<int> h(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];

    vector<int> dp(n+1, INF);

    dp[0] = 0;
    dp[1] = (int)abs(h[0] - h[1]);
cout << rec(n-1, dp, h) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'long long int rec(long long int, std::vector<long long int>&, std::vector<long long int>&)':
a.cc:19:36: error: expected primary-expression before '&' token
   19 |     amin(ans, rec(i-1, vector<int> &dp, vector<int> &h) + abs(h[i] - h[i-1]));
      |                                    ^
a.cc:19:53: error: expected primary-expression before '&' token
   19 |     amin(ans, rec(i-1, vector<int> &dp, vector<int> &h) + abs(h[i] - h[i-1]));
      |                                                     ^
a.cc:20:36: error: expected primary-expression before '&' token
   20 |     amin(ans, rec(i-2, vector<int> &dp, vector<int> &h) + abs(h[i] - h[i-2]));
      |                                    ^
a.cc:20:53: error: expected primary-expression before '&' token
   20 |     amin(ans, rec(i-2, vector<int> &dp, vector<int> &h) + abs(h[i] - h[i-2]));
      |                                                     ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }


#define int long long
const int INF = 1001001001;


int rec(int i, vector<int> &dp, vector<int> &h){
    if(i == 0) return 0;
    if(dp[i] < INF) return dp[i];

    int ans = INF;
    amin(ans, rec(i-1) + abs(h[i] - h[i-1]));
    amin(ans, rec(i-2) + abs(h[i] - h[i-2]));

    return dp[i] = ans;
}

signed main(){

    int n;cin >> n;
    vector<int> h(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];

    vector<int> dp(n+1, INF);

    dp[0] = 0;
    dp[1] = (int)abs(h[0] - h[1]);
cout << rec(n-1, dp, h) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'long long int rec(long long int, std::vector<long long int>&, std::vector<long long int>&)':
a.cc:19:18: error: too few arguments to function 'long long int rec(long long int, std::vector<long long int>&, std::vector<long long int>&)'
   19 |     amin(ans, rec(i-1) + abs(h[i] - h[i-1]));
      |               ~~~^~~~~
a.cc:14:5: note: declared here
   14 | int rec(int i, vector<int> &dp, vector<int> &h){
      |     ^~~
a.cc:20:18: error: too few arguments to function 'long long int rec(long long int, std::vector<long long int>&, std::vector<long long int>&)'
   20 |     amin(ans, rec(i-2) + abs(h[i] - h[i-2]));
      |               ~~~^~~~~
a.cc:14:5: note: declared here
   14 | int rec(int i, vector<int> &dp, vector<int> &h){
      |     ^~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }


#define int long long
const int INF = 1001001001;


int rec(int i, int *dp, int *h){
    if(i == 0) return 0;
    if(dp[i] < INF) return dp[i];

    int ans = INF;
    amin(ans, rec(i-1) + abs(h[i] - h[i-1]));
    amin(ans, rec(i-2) + abs(h[i] - h[i-2]));

    return dp[i] = ans;
}

signed main(){

    int n;cin >> n;
    vector<int> h(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];

    vector<int> dp(n+1, INF);

    dp[0] = 0;
    dp[1] = (int)abs(h[0] - h[1]);
cout << rec(n-1, dp, h) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'long long int rec(long long int, long long int*, long long int*)':
a.cc:19:18: error: too few arguments to function 'long long int rec(long long int, long long int*, long long int*)'
   19 |     amin(ans, rec(i-1) + abs(h[i] - h[i-1]));
      |               ~~~^~~~~
a.cc:14:5: note: declared here
   14 | int rec(int i, int *dp, int *h){
      |     ^~~
a.cc:20:18: error: too few arguments to function 'long long int rec(long long int, long long int*, long long int*)'
   20 |     amin(ans, rec(i-2) + abs(h[i] - h[i-2]));
      |               ~~~^~~~~
a.cc:14:5: note: declared here
   14 | int rec(int i, int *dp, int *h){
      |     ^~~
a.cc: In function 'int main()':
a.cc:35:18: error: cannot convert 'std::vector<long long int>' to 'long long int*'
   35 | cout << rec(n-1, dp, h) << endl;
      |                  ^~
      |                  |
      |                  std::vector<long long int>
a.cc:14:21: note:   initializing argument 2 of 'long long int rec(long long int, long long int*, long long int*)'
   14 | int rec(int i, int *dp, int *h){
      |                     ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }


#define int long long
const int INF = 1001001001;


int recurcive(int i, int *dp){
    if(i == 0) return 0;
    if(dp[i] < INF) return dp[i];

    int ans = INF;
    amin(ans, rec(i-1) + abs(h[i] - h[i-1]));
    amin(ans, rec(i-2) + abs(h[i] - h[i-2]));

    return dp[i] = ans;
}

signed main(){

    int n;cin >> n;
    vector<int> h(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];

    vector<int> dp(n+1, INF);

    dp[0] = 0;
    dp[1] = (int)abs(h[0] - h[1]);
cout << rec(n-1, dp) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'long long int recurcive(long long int, long long int*)':
a.cc:19:15: error: 'rec' was not declared in this scope
   19 |     amin(ans, rec(i-1) + abs(h[i] - h[i-1]));
      |               ^~~
a.cc:19:30: error: 'h' was not declared in this scope
   19 |     amin(ans, rec(i-1) + abs(h[i] - h[i-1]));
      |                              ^
a.cc: In function 'int main()':
a.cc:35:9: error: 'rec' was not declared in this scope
   35 | cout << rec(n-1, dp) << endl;
      |         ^~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;

#define int long long
const int INF 1001001001;

signed main(){

    int n;cin >> n;
    vector<int> h(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> h[i];

    vector<int> dp(n+1, INF);

    dp[0] = 0;
    dp[1] = (int)abs(h[0] - h[1]);
    /*
    dp[2] = (int)abs(h[1] - h[2]);
    dp[2] = (int)abs(h[0] - h[2]);
    amin(dp[2], dp[1] + (int)abs(h[1] - h[2]));
    amin(dp[2], dp[0] + (int)abs(h[0] - h[2]));

    amin(dp[i], dp[i-1] + (int)abs(h[i-1] - h[i]));
    amin(dp[i], dp[i-2] + (int)abs(h[i-2] - h[i]));
    */

    for(int i = 2; i < n; ++i){
        amin(dp[i], dp[i-1] + (int)abs(h[i-1] - h[i]));
        amin(dp[i], dp[i-2] + (int)abs(h[i-2] - h[i]));        
    } 


cout << dp[n] << endl;
    return 0;
}

Compiler output:
a.cc:6:15: error: expected initializer before numeric constant
    6 | const int INF 1001001001;
      |               ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:14:25: error: 'INF' was not declared in this scope
   14 |     vector<int> dp(n+1, INF);
      |                         ^~~
a.cc:29:9: error: 'amin' was not declared in this scope; did you mean 'main'?
   29 |         amin(dp[i], dp[i-1] + (int)abs(h[i-1] - h[i]));
      |         ^~~~
      |         main