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

#include <iostream>

using namespace std;

int
proc(vector<int>& footings, int n) {
  if (n == 0) {
     return 0;
  } else if (n == 1) {
     return abs(footings[1] - footing[2]);
  } 
  
  int a = proc(footings, n - 1) + abs(footings[n] - footings[n-1]);
  int b = proc(footings, n - 2) + abs(footings[n] - footings[n-2]);
  return min(a, b);
}

int main(void) {
  int n;
  cin >> n;
  vector<int> footings;
  for (size_t i = 0; i < n; i++) {
     int height;
     cin >> height;
     footings.push_back(height);
  }
  int r = proc(footings, n);
  cout << r << endl;
}

Compiler output:
a.cc:6:6: error: 'vector' was not declared in this scope
    6 | proc(vector<int>& footings, int n) {
      |      ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:6:13: error: expected primary-expression before 'int'
    6 | proc(vector<int>& footings, int n) {
      |             ^~~
a.cc:6:29: error: expected primary-expression before 'int'
    6 | proc(vector<int>& footings, int n) {
      |                             ^~~
a.cc:6:34: error: expression list treated as compound expression in initializer [-fpermissive]
    6 | proc(vector<int>& footings, int n) {
      |                                  ^
a.cc: In function 'int main()':
a.cc:21:3: error: 'vector' was not declared in this scope
   21 |   vector<int> footings;
      |   ^~~~~~
a.cc:21:3: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:21:10: error: expected primary-expression before 'int'
   21 |   vector<int> footings;
      |          ^~~
a.cc:25:6: error: 'footings' was not declared in this scope
   25 |      footings.push_back(height);
      |      ^~~~~~~~
a.cc:27:16: error: 'footings' was not declared in this scope
   27 |   int r = proc(footings, n);
      |                ^~~~~~~~
a.cc:27:15: error: 'proc' cannot be used as a function
   27 |   int r = proc(footings, n);
      |           ~~~~^~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int best[100005];
  int a[100005];
  for( i=0;i<n;i++)
  {    cin>>a[i];
   
  }
  //best[i]=best option to reach ith stone
  best[0]=0;//standing on 1st stone
  
    best[1]=abs(a[1]-a[0]);

    
  for(i=2;i<=n-1;i++)
  {    best[i]=max((abs(a[i]-a[i-2])+best[i-2]),(best[i-1]+abs(a[i]-a[i-1]));
 //    cout<<best[i];
   }
  cout<<best[n-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:77: error: expected ')' before ';' token
   20 |   {    best[i]=max((abs(a[i]-a[i-2])+best[i-2]),(best[i-1]+abs(a[i]-a[i-1]));
      |                   ~                                                         ^
      |                                                                             )
Language: C++

N = int(input())
h = list(map(int,input().split()))


dp = [float("inf")]*len(h)
dp[0] = 0


for i in range(1, len(h)):
    if(i == 1):
        dp[i] = h[i]
    dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))

print(dp[N-1])

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

nclude <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
const int oo = 1e9;
const int mod = 1e9+9;
//===========================================================//
const int nax = 1e5+3;
int n;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));
	return dp[i]=ans;
}
int main(){
	cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Compiler output:
a.cc:1:1: error: 'nclude' does not name a type
    1 | nclude <bits/stdc++.h>
      | ^~~~~~
a.cc: In function 'int f(int)':
a.cc:16:19: error: 'abs' was not declared in this scope; did you mean 'ans'?
   16 |         int ans = abs(a[i]-a[i+1])+f(i+1);
      |                   ^~~
      |                   ans
a.cc:17:26: error: 'min' was not declared in this scope
   17 |         if(i!=n-2) ans = min(ans, abs(a[i]-a[i+2])+f(i+2));
      |                          ^~~
a.cc: In function 'int main()':
a.cc:21:9: error: 'cin' was not declared in this scope
   21 |         cin>>n;
      |         ^~~
a.cc:23:9: error: 'memset' was not declared in this scope
   23 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | nclude <bits/stdc++.h>
a.cc:24:9: error: 'cout' was not declared in this scope
   24 |         cout<<f(0)<<endl;
      |         ^~~~
a.cc:24:21: error: 'endl' was not declared in this scope
   24 |         cout<<f(0)<<endl;
      |                     ^~~~
Language: C++

#1:初期化
N = int(input())
h = list(map(int, input().split()))
inf = float("inf")
dp = [inf]*(N)

#2:初期値
dp[0] = 0

#3:dp実行部
for i in range(1,N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if(i>1): #2つ目の足場には二個前の足場がないので．
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

#4:出力
print(dp[N-1])

Compiler output:
a.cc:1:3: error: ":" is not a valid filename
    1 | #1:初期化
      |   ^
a.cc:7:3: error: ":" is not a valid filename
    7 | #2:初期値
      |   ^
a.cc:10:3: error: ":" is not a valid filename
   10 | #3:dp実行部
      |   ^
a.cc:13:14: error: stray '#' in program
   13 |     if(i>1): #2つ目の足場には二個前の足場がないので．
      |              ^
a.cc:16:3: error: ":" is not a valid filename
   16 | #4:出力
      |   ^
a.cc:2:1: error: 'N' does not name a type
    2 | N = int(input())
      | ^
Language: C++

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first;
#define S second;
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(int i = a; i <= b; i++)
#define SQ(a) (a)*(a);

const int INF = 1e9 + 5;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n ;
    scanf("%d",&n);
    vector<int> h(n);

    for(int&x : h){
        scanf("%d",&x);
    }

    vector<int> dp(n,INF);
    dp[0] = 0;

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

    printf("%d",dp[n - 1]);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:13: error: 'dp_state' was not declared in this scope
   36 |             dp_state(dp);
      |             ^~~~~~~~
Language: Java

import java.util.*;
import java.io.*;
class Main
{
   String Fill(int i,int j,String s1,String s2,String str[][],int l1,int l2)
    {
        if(i>l1-1||j>l2-1)
        return "";
        int x=0;
        for( x=0;x<l2;x++)
        {
            char ch=s2.charAt(x);
            if((ch==s1.charAt(i))&&(x>=j))
            { 
            
            break;
        }
            if(x==l2-1)
            {
                x=-1000000000;
                break;
                
            }
        }    
            String r="";String r1="";
            if(x>=0)
            r=s1.charAt(i)+str[i+1][x+1];
            
            r1=str[i+1][j];
            
            if(r1.length()>r.length())
            return r1;
        
              else
             return r;
        
        }
            
        
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String s1;
        String s2;
        s1=sc.nextLine();
        s2=sc.nextLine();
        int l1,l2;
        l1=s1.length();
        l2=s2.length();
        lcs obj=new lcs();
        String str[][]=new String[l1+1][l2+1];
        for(int s=0;s<l2+1;s++)
        {
            
        
        for(int t=0;t<l1+1;t++)
        {
            str[t][s]="";
        }
    }
        for(int i=l1-1;i>=0;i--)
        {
            for(int j=l2-1;j>=0;j--)
            {
                str[i][j]=obj.Fill(i,j,s1,s2,str,l1,l2);
            }
        }
        System.out.print(str[0][0]);
    }
}
        
        
        

Compiler output:
Main.java:50: error: cannot find symbol
        lcs obj=new lcs();
        ^
  symbol:   class lcs
  location: class Main
Main.java:50: error: cannot find symbol
        lcs obj=new lcs();
                    ^
  symbol:   class lcs
  location: class Main
2 errors
Language: C++

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


int main()
{
	long long n;
	cin>>n;
	long long ar[n];
	for(long long i=0;i<n;i++)
		cin>>ar[i];
	long long dp[n+1],sum=0;
	
	dp[1]=0;
	dp[2]=abs(ar[1]-ar[0]);
	
	for(long long i=3;i<=n;i++)
		dp[i]=min(dp[i-2]+abs(ar[i-1]-ar[i-3]),dp[i-1]+abs(ar[i-1]-ar[i-2]));
	cout<<dp[n];
}

Compiler output:
a.cc:1:1: error: stray '##' in program
    1 | ##include<bits/stdc++.h>
      | ^~
a.cc:1:3: error: 'include' does not name a type
    1 | ##include<bits/stdc++.h>
      |   ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope
    8 |         cin>>n;
      |         ^~~
a.cc:15:15: error: 'abs' was not declared in this scope
   15 |         dp[2]=abs(ar[1]-ar[0]);
      |               ^~~
a.cc:18:23: error: 'min' was not declared in this scope; did you mean 'main'?
   18 |                 dp[i]=min(dp[i-2]+abs(ar[i-1]-ar[i-3]),dp[i-1]+abs(ar[i-1]-ar[i-2]));
      |                       ^~~
      |                       main
a.cc:19:9: error: 'cout' was not declared in this scope
   19 |         cout<<dp[n];
      |         ^~~~
Language: C++

int main()
{
    int no_of_stones;
    cin >> no_of_stones;

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

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> no_of_stones;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector <int> height(no_of_stones + 1, 0);
      |     ^~~~~~
a.cc:6:13: error: expected primary-expression before 'int'
    6 |     vector <int> height(no_of_stones + 1, 0);
      |             ^~~
a.cc:8:16: error: 'height' was not declared in this scope
    8 |         cin >> height[i];
      |                ^~~~~~
a.cc:10:13: error: expected primary-expression before 'int'
   10 |     vector <int> minimum_cost(no_of_stones + 1);
      |             ^~~
a.cc:11:5: error: 'minimum_cost' was not declared in this scope
   11 |     minimum_cost[2] = abs(height[2] - height[1]);
      |     ^~~~~~~~~~~~
a.cc:11:27: error: 'height' was not declared in this scope
   11 |     minimum_cost[2] = abs(height[2] - height[1]);
      |                           ^~~~~~
a.cc:11:23: error: 'abs' was not declared in this scope
   11 |     minimum_cost[2] = abs(height[2] - height[1]);
      |                       ^~~
a.cc:13:27: error: 'min' was not declared in this scope; did you mean 'main'?
   13 |         minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
      |                           ^~~
      |                           main
a.cc:16:5: error: 'cout' was not declared in this scope
   16 |     cout << minimum_cost[no_of_stones];
      |     ^~~~
Language: C++


import kotlin.math.*

fun main(){
    // val inputData = "10 30 40 20"
    var N = readLine()!!.toInt()
    // val N = 4
    val heights = readLine()!!.split(" ").map{it.toInt()}
    // val heights = inputData.split(" ").map{it.toInt()}
    val dp = MutableList(N) { Int.MAX_VALUE }
    dp[0] = 0
    for(i in 1 until heights.size){
        dp[i] = dp[i-1] + abs(heights[i] - heights[i-1])
        // println("dp[$i] is ${dp[i]}, dp[${i - 1}] is ${dp[i-1]}")
        
        if(i > 1) {
            dp[i] = min(dp[i-1] + abs(heights[i] - heights[i-1]), dp[i-2] + abs(heights[i] - heights[i-2]))
            // println("dp[$i] is ${dp[i]}, dp[${i - 1}] is ${dp[i-1]} and dp[${i - 2}] is ${dp[i-2]}")
        }
        // println(dp[i])
    }


    println(dp[heights.size-1])

}


fun chmin() {

}




Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import kotlin.math.*
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:29:1: error: 'fun' does not name a type
   29 | fun chmin() {
      | ^~~
Language: Java

import java.io.*;
import java.util.*;
public class Frog1 {
	public static final int MAX = 100000;
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String input[] = (br.readLine()).trim().split("\\s+");
		int ar[] = new int[n];
		for(int i = 0; i < n; i++) {
			ar[i] = Integer.parseInt(input[i]);
		}
		int dp[][] = new int[n][2];
		for(int i = n - 1; i >= 0; i--) {
			if(i == n - 1) {
				dp[i][0] = dp[i][1] = 0;
				continue;
			}
			// dp[i][0] : one step
			// dp[i][1] : two step
			if(i + 1 < n) {
				dp[i][0] = Math.min(dp[i + 1][0], dp[i + 1][1]) + (int) Math.abs(ar[i + 1] - ar[i]);
			}
			else {
				dp[i][0] = MAX;
			}
			if(i + 2 < n) {
				dp[i][1] = Math.min(dp[i + 2][0], dp[i + 2][1]) + (int) Math.abs(ar[i + 2] - ar[i]);
			}
			else {
				dp[i][1] = MAX;
			}
		}
		System.out.println(Math.min(dp[0][0], dp[0][1]));
	}
}


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

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

long long int main()
{
    long long int  n;
    cin>>n;
    long long int a[n+1];
    long long int  b[n+1];
    a[0]=0;
    for(long long int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<=n;i++)
    {
      if(i==0 || i==1) b[i]=0;
        if(i>=2)
            b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));

          }
          cout<<b[n];
    return 0;}


Compiler output:
a.cc:4:11: error: '::main' must return 'int'
    4 | long long int main()
      |           ^~~
Language: Java

import java.util.*;

public class Frog1
{
	static Map<Integer,Integer> m;
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=sc.nextInt();
		}
		m=new HashMap<Integer,Integer>();
		System.out.println(dp(0,h));
	}
	
	static int dp(int i,int arr[])
	{
		if(m.containsKey(i))
			return m.get(i);
		int returnVal=-1;
		if(i==arr.length-1)
			returnVal=0;
		else if(i==arr.length-2)
			returnVal=abs(arr[i]-arr[i+1]) + dp(i+1,arr);
		else
			returnVal=min(abs(arr[i]-arr[i+1]) + dp(i+1,arr),abs(arr[i]-arr[i+2]) + dp(i+2,arr));
		m.put(i,returnVal);
		return returnVal;
	}	
	
	static int min(int a,int b)
	{
		if(a<b)
			return a;
		return b;
	}
	
	static int abs(int a)
	{
		if(a<0)
			return a*-1;
		else
			return a;
	}
}

Compiler output:
Main.java:3: error: class Frog1 is public, should be declared in a file named Frog1.java
public class Frog1
       ^
1 error
Language: Java

import java.util.*;

public class AFrog
{
	static Map<Integer,Integer> m;
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=sc.nextInt();
		}
		m=new HashMap<Integer,Integer>();
		System.out.println(dp(0,h));
	}
	
	static int dp(int i,int arr[])
	{
		if(m.containsKey(i))
			return m.get(i);
		int returnVal=-1;
		if(i==arr.length-1)
			returnVal=0;
		else if(i==arr.length-2)
			returnVal=abs(arr[i]-arr[i+1]) + dp(i+1,arr);
		else
			returnVal=min(abs(arr[i]-arr[i+1]) + dp(i+1,arr),abs(arr[i]-arr[i+2]) + dp(i+2,arr));
		m.put(i,returnVal);
		return returnVal;
	}	
	
	static int min(int a,int b)
	{
		if(a<b)
			return a;
		return b;
	}
	
	static int abs(int a)
	{
		if(a<0)
			return a*-1;
		else
			return a;
	}
}

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

#include<bits/stdc++.h>
using namespace std;
int func(int h[],int n,int i)
{
	if(i+1==n-1)      
    {
      return (h[i+1] - h[i]);
    }else{
     return min(abs(h[i+1] - h[i]) + func(h[],n,i+1), abs(h[i+2] - h[i]) + func(h[],n,i+2));
    }

}
int main()
{
	int n;
  	cin>>n;
  	int h[n];
  for(int i=0;i<n;i++)
 	cin>>h[i];
  long long int x = func(h,n,i);
  cout<<x<<endl;
  
}


Compiler output:
a.cc: In function 'int func(int*, int, int)':
a.cc:9:45: error: expected primary-expression before ']' token
    9 |      return min(abs(h[i+1] - h[i]) + func(h[],n,i+1), abs(h[i+2] - h[i]) + func(h[],n,i+2));
      |                                             ^
a.cc:9:83: error: expected primary-expression before ']' token
    9 |      return min(abs(h[i+1] - h[i]) + func(h[],n,i+1), abs(h[i+2] - h[i]) + func(h[],n,i+2));
      |                                                                                   ^
a.cc: In function 'int main()':
a.cc:20:30: error: 'i' was not declared in this scope
   20 |   long long int x = func(h,n,i);
      |                              ^
Language: C++

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int best[n];
  int a[n];
  for( i=0;i<n;i++)
  {	cin>>a[i];
   
  }
  best[0]=abs(a[1]-a[0]);
  if(abs(a[2]-a[1])>abs(a[2]-a[0]))
    best[1]=abs(a[2]-a[0]);
  else
    best[1]=abs(a[2]-a[1]);
  for(i=1;i<n-1;i++)
  {	if(best[i-1]+abs(a[i+1]-a[i])<best[i-2]+abs(a[i+1]-a[i-1]))
    best[i]=best[i-1]+abs(a[i+1];
     else
     best[i]=best[i-2]+abs(a[i+1]-a[i-1];
   }
  cout<<best[n-2];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:33: error: expected ')' before ';' token
   21 |     best[i]=best[i-1]+abs(a[i+1];
      |                          ~      ^
      |                                 )
a.cc:23:41: error: expected ')' before ';' token
   23 |      best[i]=best[i-2]+abs(a[i+1]-a[i-1];
      |                           ~             ^
      |                                         )
Language: C++

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int best[n];
  int a[n];
  for( i=0;i<n;i++)
  {	cin>>a[i];
   
  }
  best[0]=abs(a[1]-a[0]);
  if(abs(a[2]-a[1])>abs(a[2]-a[0]))
    best[1]=abs(a[2]-a[0]);
  else
    best[1]=abs(a[2]-a[1]);
  for(i=1;i<n-1;i++)
  {	if(best[i-1]+abs(a[i+1]-a[i])<best[i-2]+abs(a[i+1]-a[i-1]))
    best[i]=best[i-1]+abs(a[i+1];
     else
     best[i]=best[i-2]+abs(a[i+1]-a[i-1];
   }
  cout<<best[n-2];
  

Compiler output:
a.cc: In function 'int main()':
a.cc:21:33: error: expected ')' before ';' token
   21 |     best[i]=best[i-1]+abs(a[i+1];
      |                          ~      ^
      |                                 )
a.cc:23:41: error: expected ')' before ';' token
   23 |      best[i]=best[i-2]+abs(a[i+1]-a[i-1];
      |                           ~             ^
      |                                         )
a.cc:25:19: error: expected '}' at end of input
   25 |   cout<<best[n-2];
      |                   ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include<iostream>
#include<math.h>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=0;i<n-2;i++)
  {
    if(abs(a[i+1]-a[i])>abs(a[i+2]-a[i]))
    { dis+=abs(a[i+2]-a[i]);i++;}
    else
      dis+=abs(a[i+1]-a[i]);
  }
  if(i==n-2)
    dis+=abs(a[i+1]-a[i]);
  cout<<dis;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:7: error: 'dis' was not declared in this scope; did you mean 'div'?
   16 |     { dis+=abs(a[i+2]-a[i]);i++;}
      |       ^~~
      |       div
a.cc:18:7: error: 'dis' was not declared in this scope; did you mean 'div'?
   18 |       dis+=abs(a[i+1]-a[i]);
      |       ^~~
      |       div
a.cc:21:5: error: 'dis' was not declared in this scope; did you mean 'div'?
   21 |     dis+=abs(a[i+1]-a[i]);
      |     ^~~
      |     div
a.cc:22:9: error: 'dis' was not declared in this scope; did you mean 'div'?
   22 |   cout<<dis;
      |         ^~~
      |         div
Language: C++

#include<iostream>
#include<math>
using namespace std;
int main()
{
  int n,i;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=0;i<n-2;i++)
  {
    if(abs(a[i+1]-a[i])>abs(a[i+2]-a[i]))
    { dis+=abs(a[i+2]-a[i]);i++;}
    else
      dis+=abs(a[i+1]-a[i]);
  }
  if(i==n-2)
    dis+=abs(a[i+1]-a[i]);
  cout<<dis;    

Compiler output:
a.cc:2:9: fatal error: math: No such file or directory
    2 | #include<math>
      |         ^~~~~~
compilation terminated.
Language: C++

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


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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   for(i=0;i<n;i++)
      |       ^
a.cc:15:7: error: 'i' was not declared in this scope
   15 |   for(i=2;i<n;i++)
      |       ^
Language: C++

#include<iostream>
using namespace std;
int main()
{
        int n,x;
        vector<int>height;
        vector<int>dp;
        cin>>n;
        while(n--)
        {
                cin>>x;
                height.push_back(x);
        }
        dp.push_back(0);
        for(int i=1;i<height.size();i++)
        {
                if(i<2)
                        dp.push_back(abs(height[i]-height[i-1]));
                else{
                        dp.push_back(min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i-2]-height[i])));
                }
        }
        cout<<dp.back()<<endl;
        return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'vector' was not declared in this scope
    6 |         vector<int>height;
      |         ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:6:16: error: expected primary-expression before 'int'
    6 |         vector<int>height;
      |                ^~~
a.cc:7:16: error: expected primary-expression before 'int'
    7 |         vector<int>dp;
      |                ^~~
a.cc:12:17: error: 'height' was not declared in this scope
   12 |                 height.push_back(x);
      |                 ^~~~~~
a.cc:14:9: error: 'dp' was not declared in this scope
   14 |         dp.push_back(0);
      |         ^~
a.cc:15:23: error: 'height' was not declared in this scope
   15 |         for(int i=1;i<height.size();i++)
      |                       ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define si short int
using namespace std;
#define MOD 1000000007

int main(){
	int N;
	cin >> N;
	si arr[N+1];
	ll dp[N+5];

	for(int i=1;i<=N;i++){
		cin >> arr[i];
	}

	memset(ans, 0, sizeof(ans));
	dp[2] = abs(arr[2]-arr[1]);

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

	cout << dp[N];

}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |         memset(ans, 0, sizeof(ans));
      |                ^~~
      |                abs
Language: C++

#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

template<class T> inline bool chmin(T& a, T b) {if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if(a<b){a=b;return true;}return false;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi HV(n);
  VIN(HV)
  int dp[n+10];
  REP(i,n+10) dp[i] = INF;
  dp[0] = 0;
  FOR(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]));
  }
  OUT(dp[n-1]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:32: error: 'h' was not declared in this scope
   78 |     chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
      |                                ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <utility>
#include <functional>
using namespace std;
#define rep(k,i,n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
int dp[100010];
int main(){
    dp[0]=0;
    int N;
    cin>>N;
    vector<int>h(N);
    rep(i,N) cin>>h[i];
    rep(i,N){
        if(i==0) continue;
        if(i==1){
            dp[i]=abs(h[i]-h[i-1]);
        }
        dp[i]=min(dp[i-2]abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
    }
    cout<<dp[N-1];
}

Compiler output:
a.cc:11:9: warning: "rep" redefined
   11 | #define rep(i,n) for (int i = 0; i < (int)(n); i++)
      |         ^~~
a.cc:10:9: note: this is the location of the previous definition
   10 | #define rep(k,i,n) for (int i = (int)(k); i < (int)(n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:24:26: error: expected ')' before 'abs'
   24 |         dp[i]=min(dp[i-2]abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
      |                  ~       ^~~
      |                          )
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <utility>
#include <functional>
using namespace std;
#define rep(k,i,n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
int dp[100010];
int main(){
    dp[0]=0;
    int N;
    cin>>N;
    vector<int>h(N);
    rep(i,N) cin>>h[i];
    rep(i,N){
        if(i==0) continue;
        if(i==1){
            dp[i]=abs(h[i]-h[i-1]);
        }
        dp[i]=min(abs(dp[i-2]-h[i]),abs(dp[i-1]-h[i]));
    }
    cout<<dp[N-1];

Compiler output:
a.cc:11:9: warning: "rep" redefined
   11 | #define rep(i,n) for (int i = 0; i < (int)(n); i++)
      |         ^~~
a.cc:10:9: note: this is the location of the previous definition
   10 | #define rep(k,i,n) for (int i = (int)(k); i < (int)(n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:26:19: error: expected '}' at end of input
   26 |     cout<<dp[N-1];
      |                   ^
a.cc:13:11: note: to match this '{'
   13 | int main(){
      |           ^
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N,H, n,m , M, K,a;

vector<ll> v;
int main(){
    cin >> N;
    vector<ll> h(N+1);
    vector<ll> dp(N+1);
    for(int i = 1; i <= N; ++i){
        ll h; cin >>h; h[i] = h;
    }
    dp[0] = 1e12;
    dp[1] = 0;
    for(int i = 2;  i <= N; ++i){
        dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]));
    }
    cout << dp[N];
    return 0;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:17:25: error: invalid types 'll {aka long long int}[int]' for array subscript
   17 |         ll h; cin >>h; h[i] = h;
      |                         ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  		int n1;
 	 	cin>>n1;
		while(n1--){
  		int n;
          cin>>n;
        int cost[n]
          for(int i=0;i<n;i++)
            cin>>cost[i];
        int dp[n+1];
        dp[1] = 0;
        dp[2] = abs(cost[1]-cost[0]);
        for(int i=3;i<=n;i++)
        {
                dp[i] = dp[i-1]+abs(cost[i-1]-cost[i-2]);
                for(int j=2;j<=m&&i-j>0;j++)
                {
                        dp[i] = min(dp[i],dp[i-j]+(abs(cost[i-1]-cost[i-j-1])));
                }
        }
        cout<<dp[n];}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: expected initializer before 'for'
   12 |           for(int i=0;i<n;i++)
      |           ^~~
a.cc:12:23: error: 'i' was not declared in this scope
   12 |           for(int i=0;i<n;i++)
      |                       ^
a.cc:16:21: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   16 |         dp[2] = abs(cost[1]-cost[0]);
      |                     ^~~~
      |                     cosl
a.cc:20:32: error: 'm' was not declared in this scope
   20 |                 for(int j=2;j<=m&&i-j>0;j++)
      |                                ^
Language: C++

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

int main()
{
  		int n1;
  cin>>n1;
	while(n1--){
  		int n;
        int cost[n]
          for(int i=0;i<n;i++)
            cin>>cost[i];
        int dp[n+1];
        dp[1] = 0;
        dp[2] = abs(cost[1]-cost[0]);
        for(int i=3;i<=n;i++)
        {
                dp[i] = dp[i-1]+abs(cost[i-1]-cost[i-2]);
                for(int j=2;j<=m&&i-j>0;j++)
                {
                        dp[i] = min(dp[i],dp[i-j]+(abs(cost[i-1]-cost[i-j-1])));
                }
        }
        cout<<dp[n];}
}
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~       

Compiler output:
a.cc: In function 'int main()':
a.cc:11:11: error: expected initializer before 'for'
   11 |           for(int i=0;i<n;i++)
      |           ^~~
a.cc:11:23: error: 'i' was not declared in this scope
   11 |           for(int i=0;i<n;i++)
      |                       ^
a.cc:15:21: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   15 |         dp[2] = abs(cost[1]-cost[0]);
      |                     ^~~~
      |                     cosl
a.cc:19:32: error: 'm' was not declared in this scope
   19 |                 for(int j=2;j<=m&&i-j>0;j++)
      |                                ^
a.cc: At global scope:
a.cc:27:1: error: expected class-name before '~' token
   27 | ~
      | ^
Language: C++

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

int main()
{
        int n=5;
        int cost[5] ={ 10,20,30,40,50};
        int dp[n+1];
        int m = 2;
        dp[1] = 0;
        dp[2] = abs(cost[1]-cost[0]);
        for(int i=3;i<=n;i++)
        {
                dp[i] = dp[i-1]+abs(cost[i-1]-cost[i-2]);
                for(int j=2;j<=m&&i-j>0;j++)
                {
                        dp[i] = min(dp[i],dp[i-j]+(abs(cost[i-1]-cost[i-j-1])));
                }
        }
        cout<<dp[n];
}
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~                                                                                                                                                     
~       

Compiler output:
a.cc:23:1: error: expected class-name before '~' token
   23 | ~
      | ^
Language: C++

#include<bits/stdc++.h>
int main()
{long int n;
 cin>>n;
 for(long int i=0;i<n;i++)
  cin>>a[i] ;
 int dp[n];
 dp[0]=0;
 dp[1]=abs(a[1]-a[0]);
 for(long int i=2;i<n;i++)
 {dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
 }
 cout<<dp[n-1]
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:2: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    4 |  cin>>n;
      |  ^~~
      |  std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:6:8: error: 'a' was not declared in this scope
    6 |   cin>>a[i] ;
      |        ^
a.cc:9:12: error: 'a' was not declared in this scope
    9 |  dp[1]=abs(a[1]-a[0]);
      |            ^
a.cc:11:9: error: 'min' was not declared in this scope; did you mean 'std::min'?
   11 |  {dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
      |         ^~~
      |         std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:13:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   13 |  cout<<dp[n-1]
      |  ^~~~
      |  std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C++

#include <iostream>
using namespace std;
const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:9: error: 'memset' was not declared in this scope
   19 |         memset(dp, -1, 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++

const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int f(int)':
a.cc:8:19: error: 'abs' was not declared in this scope; did you mean 'ans'?
    8 |         int ans = abs(a[i]-a[i+1])+f(i+1);
      |                   ^~~
      |                   ans
a.cc:10:33: error: 'min' was not declared in this scope
   10 |                 if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
      |                                 ^~~
a.cc: In function 'int main()':
a.cc:15:9: error: 'cin' was not declared in this scope
   15 |         cin>>n>>k;
      |         ^~~
a.cc:17:9: error: 'memset' was not declared in this scope
   17 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | const int nax = 1e5+103;
a.cc:18:9: error: 'cout' was not declared in this scope
   18 |         cout<<f(0)<<endl;
      |         ^~~~
a.cc:18:21: error: 'endl' was not declared in this scope
   18 |         cout<<f(0)<<endl;
      |                     ^~~~
Language: C++

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

long long int calci(int arr[], long long int cost, int i)
{
    long long int arr2[1000000], long long int arr3[1000000];
    if(i==2)
    {
        long long int t1=abs(arr[i]-arr[i-2]), t2=(abs(arr[i]-arr[i-1])+abs(arr[i-1]-arr[i-2]));
        long long int cop1=min(t1, t2);
        if(cop1==t1)
        {
            return t1;
        }
        else
        {
            cop1=abs(arr[i]-arr[i-1]);
            return cop1;
        }
    }
    else if(i==1)
    {
        long long int t2=abs(arr[i]-arr[i-1]);
        return t2;
    }

    else if(i>=2)
    {
        long long int c1, c2;
        arr2[i]=calci(arr, cost, i-1)+abs(arr[i]-arr[i-1]);
        arr3[i]=calci(arr, cost, i-2)+abs(arr[i]-arr[i-2]);
        return min(arr2[i-1], arr2[i-2]);
    }
}
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    long long int cot=0;
    long long int ans=calci(arr, cot, n-1);
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'long long int calci(int*, long long int, int)':
a.cc:6:34: error: expected unqualified-id before 'long'
    6 |     long long int arr2[1000000], long long int arr3[1000000];
      |                                  ^~~~
a.cc:31:9: error: 'arr3' was not declared in this scope; did you mean 'arr2'?
   31 |         arr3[i]=calci(arr, cost, i-2)+abs(arr[i]-arr[i-2]);
      |         ^~~~
      |         arr2
a.cc:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
Language: C++

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

long long int calci(int arr[], long long int cost, int i)
{
    long long int arr2[10000];
    if(i==2)
    {
        arr[i]=abs(arr[i]-arr[i-2]), t2=(abs(arr[i]-arr[i-1])+abs(arr[i-1]-arr[i-2]));
        long long int cop1=min(t1, t2);
        if(cop1==t1)
        {
            return t1;
        }
        else
        {
            cop1=abs(arr[i]-arr[i-1]);
            return cop1;
        }
    }
    else if(i==1)
    {
        long long int t2=abs(arr[i]-arr[i-1]);
        return t2;
    }

    else if(i>=2)
    {
        long long int c1, c2;
        arr2[i-1]=calci(arr, cost, i-1)+abs(arr[i]-arr[i-1]);
        arr2[i-2]=calci(arr, cost, i-2)+abs(arr[i]-arr[i-2]);
        return min(arr2[i-1], arr2[i-2]);
    }
}
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    long long int cot=0;
    long long int ans=calci(arr, cot, n-1);
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'long long int calci(int*, long long int, int)':
a.cc:9:38: error: 't2' was not declared in this scope; did you mean 'tm'?
    9 |         arr[i]=abs(arr[i]-arr[i-2]), t2=(abs(arr[i]-arr[i-1])+abs(arr[i-1]-arr[i-2]));
      |                                      ^~
      |                                      tm
a.cc:10:32: error: 't1' was not declared in this scope; did you mean 'y1'?
   10 |         long long int cop1=min(t1, t2);
      |                                ^~
      |                                y1
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'a' was not declared in this scope
   11 |   dp[0]=a[0];
      |         ^
Language: C

#include<stdio.h>
int dp[100000]={-1};
dp[0]=0;
int min(int a,int b){
if(a>b){
  return b;}
else{
  return a;
}}
int mod(int l,int h){
if(l>h){
  return l-h;}
else{
  return h-l;
}}
int ans(int arr[],int n){
  
  if(n==2)
  {if(dp[n-1]!=-1)
      dp[1]=mod(arr[n-1],arr[0]);
  }
  if(n>2){
      if(dp[n-1]!=-1)
        dp[n-1]=min(ans(arr,n-1)+mod(arr[n-2],arr[n-1]),ans(arr,n-2)+mod(arr[n-1],arr[n-3]));
      
  }
return dp[n-1];
}
int main(){
  int n;
  int a;
  scanf("%d",&n);
  int arr[n];
  for(int i=0;i<n;i++){
    scanf("%d",&arr[i]);}
  a=ans(arr,n);
  printf("%d",a);
return 0;
}

Compiler output:
main.c:3:1: warning: data definition has no type or storage class
    3 | dp[0]=0;
      | ^~
main.c:3:1: error: type defaults to 'int' in declaration of 'dp' [-Wimplicit-int]
main.c:3:1: error: conflicting types for 'dp'; have 'int[0]'
main.c:2:5: note: previous definition of 'dp' with type 'int[100000]'
    2 | int dp[100000]={-1};
      |     ^~
main.c:3:7: error: invalid initializer
    3 | dp[0]=0;
      |       ^
Language: Java

import java.util.*;
public static class Solution{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    for(int i = 0 ; i < n ; i++) arr[i] = sc.nextInt();
    int[] dp = new int[n];
    Arrays.fill(dp , Integer.MAX_VALUE);
    dp[0] = 0;
    for(int i = 0 ; i < n ; i++){
      for(int j = i + 1 ; j <= i + 2 ; j++){
        if(j < n) dp[j] = Math.min(dp[i] , dp[i] + Math.abs(arr[j] - arr[i])); 
      }
    }System.out.println(dp[n-1]);
  }
}

Compiler output:
Main.java:2: error: class Solution is public, should be declared in a file named Solution.java
public static class Solution{
              ^
1 error
Language: Java

import java.util.Scanner;
class Main{
	public static void main(String args[])
    {
    	Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int arr[]=new int[n];
      	for(int i=0;i<n;i++){
        	arr[i]=sc.nextInt();
          	if(i == 0)	dp[i]=0;
          	else if(i ==1) dp[i]=arr[i]-arr[i-1];
          	else{
            	int m = dp[i-1];
              	int n = dp[i-2];
              	if(m< n) dp[i]=m+Math.abs((arr[i]-arr[i-1]));
              	else dp[i]=n+Math.abs((arr[i]-arr[i-2]));
            }
        }
      System.out.println(dp[n-1]);
    }
}

Compiler output:
Main.java:10: error: cannot find symbol
          	if(i == 0)	dp[i]=0;
          	          	^
  symbol:   variable dp
  location: class Main
Main.java:11: error: cannot find symbol
          	else if(i ==1) dp[i]=arr[i]-arr[i-1];
          	               ^
  symbol:   variable dp
  location: class Main
Main.java:13: error: cannot find symbol
            	int m = dp[i-1];
            	        ^
  symbol:   variable dp
  location: class Main
Main.java:14: error: variable n is already defined in method main(String[])
              	int n = dp[i-2];
              	    ^
Main.java:14: error: cannot find symbol
              	int n = dp[i-2];
              	        ^
  symbol:   variable dp
  location: class Main
Main.java:15: error: cannot find symbol
              	if(m< n) dp[i]=m+Math.abs((arr[i]-arr[i-1]));
              	         ^
  symbol:   variable dp
  location: class Main
Main.java:16: error: cannot find symbol
              	else dp[i]=n+Math.abs((arr[i]-arr[i-2]));
              	     ^
  symbol:   variable dp
  location: class Main
Main.java:19: error: cannot find symbol
      System.out.println(dp[n-1]);
                         ^
  symbol:   variable dp
  location: class Main
8 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0];
              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-1];
              return 0;
              }

Compiler output:
a.cc: In function 'int main()':
a.cc:13:24: error: expected ')' before ';' token
   13 |   dp[1] = abs(h[1]-h[0];
      |              ~         ^
      |                        )
Language: C++

//#include <bits/stdc++.h>
#include <iostream.h>
#include <vector.h>
using namespace std;
int main() {
 	int n; 
  	cin>>n;
  	int h[n] = {0};
  	for(int i = 0; i < n; i++) {
     cin>>h[i]; 
    }
  	vector <int> res;
  	res.push_back(0);
  	int x = h[1] - h[0];
  	res.push_back(abs(x));
//   	cout<<res[0]<<"\n";
//  	cout<<res[1]<<"\n";

  	for(int i = 2; i < n; i++) {
  		int a = h[i] - h[i - 1];
  		// cout<<"a"<<a<<"\n";
  		int b = h[i] - h[i - 2];
//  		cout<<"b"<<b<<"\n";

      int c = min((abs(a) + res[i - 1]), (abs(b) + res[i - 2]));
      //cout<<c<<"\n";
      res.push_back(c);
    }
//    for(int i = 0; i < n; i++) {
//    	cout<<res[i]<<"\n";
//	}
  	cout<<res[n - 1];
  return 0;
  	
  
  
}

Compiler output:
a.cc:2:10: fatal error: iostream.h: No such file or directory
    2 | #include <iostream.h>
      |          ^~~~~~~~~~~~
compilation terminated.