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

#include <iostream>
#include <vector>
#include <algorithm>

unsigned mod(long x)
{
  if (x < 0) return -x; 
  return x;
}

unsigned get_sum(unsigned sum, std::vector<long>& cache, std::vector<int>& vec, unsigned i)
{
  if (i+1 == vec.size())
  { 
    cache[i] = 0;
    return sum; 
  }  
  if (i+2 == vec.size())
  { 
    cache[i] = mod(vec[i] - vec[i+1]);
    return sum + cache[i];
  }
  unsigned sum1;
  unsigned sum2;
  if (cache[i] == -1)
  { 
    sum1 = get_sum(mod(vec[i] - vec[i+1]), cache, vec, i+1);
    sum2 = get_sum(mod(vec[i] - vec[i+2]), cache, vec, i+2);
    cache[i] = std::min(sum1, sum2);
  }
  return std::min(sum + cache[i], sum + cache[i]);
}

int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  unsigned N = 0;
  std::cin >> N;
  std::vector<int> vec(N, 0);
  for (unsigned i = 0; i < N; ++i)
  {
    std::cin >> vec[i];
  }
  std::vector<int> cache(vec.size(), -1);
  unsigned ans = get_sum(0, cache, vec, 0);
  std::cout << ans;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:29: error: invalid initialization of reference of type 'std::vector<long int>&' from expression of type 'std::vector<int>'
   47 |   unsigned ans = get_sum(0, cache, vec, 0);
      |                             ^~~~~
a.cc:11:51: note: in passing argument 2 of 'unsigned int get_sum(unsigned int, std::vector<long int>&, std::vector<int>&, unsigned int)'
   11 | unsigned get_sum(unsigned sum, std::vector<long>& cache, std::vector<int>& vec, unsigned i)
      |                                ~~~~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

unsigned mod(long x)
{
  if (x < 0) return -x; 
  return x;
}

unsigned get_sum(unsigned sum, std::vector<long>& cache, std::vector<int>& vec, unsigned i)
{
  if (i+1 == vec.size())
  { 
    cache[i] = 0;
    return sum; 
  }  
  if (i+2 == vec.size())
  { 
    cache[i] = mod(vec[i] - vec[i+1]);
    return sum + cache[i];
  }
  unsigned sum1;
  unsigned sum2;
  if (cache[i] == -1)
  { 
    sum1 = get_sum(x, mod(vec[i] - vec[i+1]), cache, vec, i+1);
    sum2 = get_sum(x, mod(vec[i] - vec[i+2]), cache, vec, i+2);
    cache[i] = std::min(sum1, sum2);
  }
  return std::min(sum + cache[i], sum + cache[i]);
}

int main()
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  unsigned N = 0;
  std::cin >> N;
  std::vector<int> vec(N, 0);
  for (unsigned i = 0; i < N; ++i)
  {
    std::cin >> vec[i];
  }
  std::vector<int> cache(vec.size(), -1);
  unsigned ans = get_sum(0, cache, vec, 0);
  std::cout << ans;

  return 0;
}

Compiler output:
a.cc: In function 'unsigned int get_sum(unsigned int, std::vector<long int>&, std::vector<int>&, unsigned int)':
a.cc:27:20: error: 'x' was not declared in this scope
   27 |     sum1 = get_sum(x, mod(vec[i] - vec[i+1]), cache, vec, i+1);
      |                    ^
a.cc: In function 'int main()':
a.cc:47:29: error: invalid initialization of reference of type 'std::vector<long int>&' from expression of type 'std::vector<int>'
   47 |   unsigned ans = get_sum(0, cache, vec, 0);
      |                             ^~~~~
a.cc:11:51: note: in passing argument 2 of 'unsigned int get_sum(unsigned int, std::vector<long int>&, std::vector<int>&, unsigned int)'
   11 | unsigned get_sum(unsigned sum, std::vector<long>& cache, std::vector<int>& vec, unsigned i)
      |                                ~~~~~~~~~~~~~~~~~~~^~~~~
Language: Java

public class Main {
	public static long findMin(int n, int[] a) {
        long[] dp = new long[n];
        dp[0]=0;
        dp[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;++i) {
            dp[i]=Math.min(dp[i-2]+Math.abs(a[i]-a[i-2]),dp[i-1]+Math.abs(a[i]-a[i-1]));
        }
        return dp[n-1];
    }
    public static void main(String[] args) {
        InputStreamReader r=new InputStreamReader(System.in);
        String input=null;
        BufferedReader reader = new BufferedReader(r);
        try {
            input = reader.readLine();
            int n= Integer.parseInt(input);
            int[] a= new int[n];
            String nums = reader.readLine();
            String [] nums1 = nums.split(" ");
            for(int i=0;i<nums1.length;++i) {
                a[i]=Integer.parseInt(nums1[i]);
            }
            System.out.println(findMin(n,a));
        } catch(IOException e) {

        }

    }
}

Compiler output:
Main.java:12: error: cannot find symbol
        InputStreamReader r=new InputStreamReader(System.in);
        ^
  symbol:   class InputStreamReader
  location: class Main
Main.java:12: error: cannot find symbol
        InputStreamReader r=new InputStreamReader(System.in);
                                ^
  symbol:   class InputStreamReader
  location: class Main
Main.java:14: error: cannot find symbol
        BufferedReader reader = new BufferedReader(r);
        ^
  symbol:   class BufferedReader
  location: class Main
Main.java:14: error: cannot find symbol
        BufferedReader reader = new BufferedReader(r);
                                    ^
  symbol:   class BufferedReader
  location: class Main
Main.java:25: error: cannot find symbol
        } catch(IOException e) {
                ^
  symbol:   class IOException
  location: class Main
5 errors
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0; i<n; i++)
    cin>>h[i];
  int c, c1, c2;
  c = abs(h[i] - h[i-1]);
  c1 = c;
  c2 = 0;
  for(int i=2; i<n; i++){
      int x = abs(h[i] - h[i-1]) + c1;
      int y = abs(h[i] - h[i-2]) + c2;
      if(x <= y)
        c = x;
      else
        c = y;
      c2 = c1;
      c1 = c;
  }
  cout<<c;
}

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

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

int main(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0; i<n; i++)
    cin>>h[i];
  int c[n];
  int c, c1, c2;
  c = abs(h[i] - h[i-1]);
  c1 = c;
  c2 = 0;
  for(int i=2; i<n; i++){
      int x = abs(h[i] - h[i-1]) + c1;
      int y = abs(h[i] - h[i-2]) + c2;
      if(x <= y)
        c = x;
      else
        c = y;
      c2 = c1;
      c1 = c;
  }
  cout<<c;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: conflicting declaration 'int c'
   12 |   int c, c1, c2;
      |       ^
a.cc:11:7: note: previous declaration as 'int c [n]'
   11 |   int c[n];
      |       ^
a.cc:13:13: error: 'i' was not declared in this scope
   13 |   c = abs(h[i] - h[i-1]);
      |             ^
a.cc:14:8: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   14 |   c1 = c;
      |        ^
      |        |
      |        int*
a.cc:20:11: error: incompatible types in assignment of 'int' to 'int [n]'
   20 |         c = x;
      |         ~~^~~
a.cc:22:11: error: incompatible types in assignment of 'int' to 'int [n]'
   22 |         c = y;
      |         ~~^~~
a.cc:24:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   24 |       c1 = c;
      |            ^
      |            |
      |            int*
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:12: error: expected '}' at end of input
   19 |   return 0;
      |            ^
a.cc:6:1: note: to match this '{'
    6 | {
      | ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:83: error: expected ')' before ';' token
   16 |     dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]);
      |                ~                                                                  ^
      |                                                                                   )
Language: C++

#include <bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int main()
{
  int n; cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i <= n; i++)
  {
    dp[i] = max(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]);
  }
  cout << dp[n] << endl;
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int main()
{
  int n; cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i]
  }
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  for (int i = 2; i <= n; i++)
  {
    dp[i] = max(dp[i - 1] + abs(h[i] - h[i - 1], dp[i - 2] + abs(h[i] - h[i - 2]);
  }
  cout << dp[n] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:16: error: expected ';' before '}' token
   10 |     cin >> h[i]
      |                ^
      |                ;
   11 |   }
      |   ~             
a.cc:16:82: error: expected ')' before ';' token
   16 |     dp[i] = max(dp[i - 1] + abs(h[i] - h[i - 1], dp[i - 2] + abs(h[i] - h[i - 2]);
      |                                ~                                                 ^
      |                                                                                  )
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i< n;i++)
    {
        cin>>v[i];
        
    }
    vector<int > dp(n);
    for(int i=1;i<n;i++)
    {
        dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        if(i>1) dp[i]=min(dp[i],dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<'\n';
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:27: error: 'a' was not declared in this scope
   18 |         dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      |                           ^
Language: Java

package nirvana;

import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Nirvana {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n=in.nextInt();
            int[] heights=new int[n];
            for(int i=0;i<n;i++){
                heights[i]=in.nextInt();
            }
            int[] dp =new int[n];
            dp[0]=0;
            dp[1]=Math.abs(heights[0]-heights[1]);
            for(int i=2;i<n;i++){
                dp[i]=Math.min(dp[i-1]+Math.abs(heights[i]-heights[i-1]), dp[i-2]+Math.abs(heights[i]-heights[i-2]));
            }
            out.println(dp[n-1]);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Nirvana {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n=in.nextInt();
            int[] heights=new int[n];
            for(int i=0;i<n;i++){
                heights[i]=in.nextInt();
            }
            int[] dp =new int[n];
            dp[0]=0;
            dp[1]=Math.abs(heights[0]-heights[1]);
            for(int i=2;i<n;i++){
                dp[i]=Math.min(dp[i-1]+Math.abs(heights[i]-heights[i-1]), dp[i-2]+Math.abs(heights[i]-heights[i-2]));
            }
            out.println(dp[n-1]);
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

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

#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
  int k;
  cin>>k;
    int niza[n];
    for(int i=0; i<n; i++)
    {
        cin>>niza[i];
    }
    int dp[n];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(niza[1]-niza[0]);
  dp[k]=abs(niza[k]-niza[0]);
    for(int i=2; i<n; i++)
    {
        dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2]),dp[i-k]+abs(niza[i]-niza[i-k]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:115: error: expected ')' before ';' token
   23 |         dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2]),dp[i-k]+abs(niza[i]-niza[i-k]);
      |                                                     ~                                                             ^
      |                                                                                                                   )
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
  int k;
  cin>>k;
    int niza[n];
    for(int i=0; i<n; i++)
    {
        cin>>niza[i];
    }
    int dp[n];
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(niza[1]-niza[0]);
  dp[k]=abs(niza[k]-niza[0]);
    for(int i=2; i<n; i++)
    {
        dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2])),dp[i-k]+abs(niza[i]-niza[i-k]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:53: error: no matching function for call to 'min(int)'
   23 |         dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2])),dp[i-k]+abs(niza[i]-niza[i-k]);
      |                                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
a.cc:23:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   23 |         dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2])),dp[i-k]+abs(niza[i]-niza[i-k]);
      |                                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided
a.cc:23:116: error: expected ')' before ';' token
   23 |         dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2])),dp[i-k]+abs(niza[i]-niza[i-k]);
      |                  ~                                                                                                 ^
      |                                                                                                                    )
Language: Java

package dp;

import java.util.Scanner;

public class A {

	static final int INF = Integer.MAX_VALUE;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] h = new int[N + 1];
		int[] d = new int[N + 1];
		for (int i=1; i <= N; i++) {
			h[i] = in.nextInt();
			d[i] = INF;
		}
		d[1] = 0;
		d[2] = Math.abs(h[2] - h[1]);
		for(int i=3; i<=N; i++) {
			d[i] = Math.min(d[i-1] + Math.abs(h[i-1]-h[i]), d[i-2] + Math.abs(h[i-2]-h[i])); 
		}
		System.out.println(d[N]);
	}
}


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

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

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

int main() {
    int N;
    cin >>N;
    vector<int> height(N);
    vector<int> dp(N+10);
    for(int i=0;i<N;i++){
        cin>> height.at(i);
    }
    for(int i=0;i<N+10;i++){
        dp[i]=1<<29;
    }
    dp[0]=0;
    for(int i=1;i<N;++i){
        chmin(dp[i],dp[i-1]+abs(height.at(i)-height.at(i-1)));
        if(i>1)chmin(d[i],dp[i-1]+abs(height.at(i)-height.at(i-2)));
    }
    cout <<dp[N-1]<<endl;



    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:22: error: 'd' was not declared in this scope
   26 |         if(i>1)chmin(d[i],dp[i-1]+abs(height.at(i)-height.at(i-2)));
      |                      ^
Language: C++

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

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

int main() {
    int N;
    cin >>N;
    vector<int> height(N);
    vector<int> dp(N+10);
    for(int i=0;i<N;i++){
        cin>> height.at(i);
    }
    for(int i=0;i<N+10;i++){
        dp[i]=1<<29;
    }
    dp[0]=0;
    for(int i=1;i<N;++i){
        chmin(d[i],dp[i-1]+abs(height.at(i)-height.at(i-1)));
        if(i>1)chmin(d[i],dp[i-1]+abs(height.at(i)-height.at(i-2)));
    }
    cout <<dp[N-1]<<endl;



    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:15: error: 'd' was not declared in this scope
   25 |         chmin(d[i],dp[i-1]+abs(height.at(i)-height.at(i-1)));
      |               ^
Language: Java

import java.util.Scanner;

public 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();
        }

        int[] dp = new int[N+1];
        dp[0] = 0;
        dp[1] = 0;
        for (int i = 2; i <= N ; i++) {

            if(i==2){
                dp[i]=dp[i-1] + Math.abs(arr[i-1]-arr[i-2]);
            }else{
                dp[i]= Math.min(
                        dp[i-1] + Math.abs(arr[i-1]-arr[i-2]),
                        dp[i-2] + Math.abs(arr[i-1]-arr[i-3])
                );
            }

        }
        System.out.println(dp[N]);


    }


Compiler output:
Main.java:32: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

#include <algorithm>
#include <iostream>

using namespace std;

int main(void)
{
	int N;
	cin >> N;
	int h[N];
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	int d[N];
	d[0] = 0;
	for (int i = 1; i < N; i++) {
		int cost1 = INT_MAX, cost2 = INT_MAX;
		if (i >= 2) {
			cost2 = d[i-2] + abs(h[i]-h[i-2]);
		}
		if (i >= 1) {
			cost1 = d[i-1] + abs(h[i]-h[i-1]);
		}
		d[i] = min(cost1, cost2);
	}
	cout << d[N-1] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:29: error: 'INT_MAX' was not declared in this scope
   17 |                 int cost1 = INT_MAX, cost2 = INT_MAX;
      |                             ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <iostream>
  +++ |+#include <climits>
    3 | 
a.cc:19:25: error: 'cost2' was not declared in this scope; did you mean 'cost1'?
   19 |                         cost2 = d[i-2] + abs(h[i]-h[i-2]);
      |                         ^~~~~
      |                         cost1
a.cc:24:35: error: 'cost2' was not declared in this scope; did you mean 'cost1'?
   24 |                 d[i] = min(cost1, cost2);
      |                                   ^~~~~
      |                                   cost1
Language: Java

import java.util.Scanner;

import static java.lang.Math.min;

public class Frog1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        System.out.println(solution(arr, 0));
    }

    public static int solution(int[] arr, int index) {

        //base case
        if (index == arr.length - 1) {
            return 0;
        } else if (index == arr.length - 2) {
            return Math.abs(arr[index] - arr[index + 1]);
        }

        //recursive case
        int min = 0;
        if (index + 2 <= arr.length - 1) {
            min = min((Math.abs(arr[index] - arr[index + 1]) + solution(arr, index + 1))
                    , (Math.abs(arr[index] - arr[index + 2]) + solution(arr, index + 2)));
        }
        return min;
    }

}


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

#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 2, 1e8);
  vector<int> g(n);
  for (auto& x: g) {
    cin >> x;
  }
  for (int i = 0; i < n - 1; ++i) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(g[i] - g[i + 1]));
    if (i + 2 < n) {
    	dp[i + 2] = min(dp[i + 2], dp[i] + abs(g[i] - g[i + 2]));
    }
  }
  cout << dp[n - 1];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> dp(n + 2, 1e8);
      |   ^~~~~~
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:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> dp(n + 2, 1e8);
      |          ^~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> g(n);
      |          ^~~
a.cc:10:17: error: 'g' was not declared in this scope
   10 |   for (auto& x: g) {
      |                 ^
a.cc:14:5: error: 'dp' was not declared in this scope
   14 |     dp[i + 1] = min(dp[i + 1], dp[i] + abs(g[i] - g[i + 1]));
      |     ^~
a.cc:14:44: error: 'g' was not declared in this scope
   14 |     dp[i + 1] = min(dp[i + 1], dp[i] + abs(g[i] - g[i + 1]));
      |                                            ^
a.cc:19:11: error: 'dp' was not declared in this scope
   19 |   cout << dp[n - 1];
      |           ^~
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; ++i) {
            arr[i] = scanner.nextInt();
        }

        int beforePrev = 0;
        int prev = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < count; ++i) {
            int cur = Math.min(
                    Math.abs(arr[i] - arr[i - 1]) + prev,
                    Math.abs(arr[i] - arr[i - 2]) + beforePrev);
            beforePrev = prev;
            prev = cur;
        }
        System.out.println(prev);
    }
}


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

public class Frog1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; ++i) {
            arr[i] = scanner.nextInt();
        }

        int beforePrev = 0;
        int prev = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < count; ++i) {
            int cur = Math.min(
                    Math.abs(arr[i] - arr[i - 1]) + prev,
                    Math.abs(arr[i] - arr[i - 2]) + beforePrev);
            beforePrev = prev;
            prev = cur;
        }
        System.out.println(prev);
    }
}


Compiler output:
Main.java:1: error: class Frog1 is public, should be declared in a file named Frog1.java
public class Frog1 {
       ^
Main.java:3: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Frog1
Main.java:3: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Frog1
3 errors
Language: C++

//
// Created by yuu on 2019-04-17.
//
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int N;
    int H[10010];

    cin>>N;
    vector<long long> dp(N+10,1e18);

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

    dp[1] = abs(H[0] - H[1]);
    dp[2] = abs(H[0] - H[2]);
    for (int j = 1; j < N; ++j) {
        if(j+1 >= N){
            break;
        }
        dp[j+1] = min(dp[j+1], (dp[j] + abs(H[j+1]-H[j]));
        if(j+2 >= N){
            continue;
        }
        dp[j+2] = dp[j] + abs(H[j]-H[j+2]);
    }

    cout<<dp[N-1]<<endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:58: error: expected ')' before ';' token
   34 |         dp[j+1] = min(dp[j+1], (dp[j] + abs(H[j+1]-H[j]));
      |                      ~                                   ^
      |                                                          )
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Frog1 {
	static FastReader input = new FastReader();
	static PrintWriter out = new PrintWriter(System.out);

	static int n;
	static int[] a;
	static int[] memo;
	static final int INF =(int) 1e9;

	static int solve(int n) {

		if (n < 0)
			return INF;

		if (n == 0)
			return 0;

		if (memo[n] != -1)
			return memo[n];

		int x = (int) Math.abs(a[n] - a[n - 1]);
		int y = INF;
		
		if (n >= 2)
			y = Math.abs(a[n] - a[n - 2]);

		return memo[n] = Math.min(x + solve(n - 1), y + solve(n - 2));
	}

	public static void main(String[] args) throws NumberFormatException, IOException {

		n = input.nextInt();
		a = new int[n];
		memo = new int[n + 10];
		Arrays.fill(memo, -1);

		for (int i = 0; i < n; i++)
			a[i] = input.nextInt();

		System.out.println(solve(n - 1));

	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

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

		String nextLine() throws IOException {
			String str = "";
			str = br.readLine();
			return str;
		}
	}
}


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

#include <stdio.h>
int min(int a,int b){
  return a < b ? a : b;
}

int abs(int a, int b){
  return a < b ? b-a:a-b;
}

int main(){
  int n;
  scanf("%d",&n);
  int h[n];
  int i;
  for(i = 0;i < n;i++){
    scanf("%d",&h[i]);
  }
  int c[n];
  c[0] = 0;
  c[1] = abs(h[1]-h[0]);
  for(i = 2;i < n;i++){
    c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]));
  }
  printf("%d",c[n-1]);
}

Compiler output:
main.c:6:5: warning: conflicting types for built-in function 'abs'; expected 'int(int)' [-Wbuiltin-declaration-mismatch]
    6 | int abs(int a, int b){
      |     ^~~
main.c:2:1: note: 'abs' is declared in header '<stdlib.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | int min(int a,int b){
main.c: In function 'main':
main.c:20:10: error: too few arguments to function 'abs'
   20 |   c[1] = abs(h[1]-h[0]);
      |          ^~~
main.c:6:5: note: declared here
    6 | int abs(int a, int b){
      |     ^~~
main.c:22:23: error: too few arguments to function 'abs'
   22 |     c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]));
      |                       ^~~
main.c:6:5: note: declared here
    6 | int abs(int a, int b){
      |     ^~~
main.c:22:48: error: too few arguments to function 'abs'
   22 |     c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]));
      |                                                ^~~
main.c:6:5: note: declared here
    6 | int abs(int a, int b){
      |     ^~~
Language: C

#include <stdio.h>
#include <math.h>

int main(){
  int n;
  scanf("%d",&n);
  int h[n];
  int i;
  for(i = 0;i < n;i++){
    scanf("%d",&h[i]);
  }
  int c[n];
  c[0] = 0;
  c[1] = abs(h[1]-h[0]);
  for(i = 2;i < n;i++){
    c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]));
  }
  printf("%d",c[n-1]);
}

Compiler output:
main.c: In function 'main':
main.c:14:10: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   14 |   c[1] = abs(h[1]-h[0]);
      |          ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
    2 | #include <math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:16:12: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
   16 |     c[i] = min(c[i-1]+abs(h[i]-h[i-1]), c[i-2]+abs(h[i]-h[i-2]));
      |            ^~~
      |            main
Language: C++

#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <memory.h>
#include <fstream>

using namespace std;

const int N = 100005;
int n, a[N], dp[N][2];

int rec(int i, bool p)
{
	if (i == n - 1) return 0;

	int &dp = ::dp[i][p];

	if (dp != -1) return dp;

	dp = (int)1e9;

	if (p == 1)
	{
		return dp = rec(i + 1, 0);
	}

	return dp = min(rec(i + 1, 0) + abs(a[i] - a[i + 1]), rec(i + 1, 1) + abs(a[i] - a[i + 2]));
}

int main()
{

	cin >> n;
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < n; i++)
	{
		scanf_s("%d", a + i);
	}

	printf("%d", rec(0, 0));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   38 |                 scanf_s("%d", a + i);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include <stdio>
#include <stdlib.h>

using namespace std;

int main(){
  int n, i, j;
  int* stones;
  int* result;
  int cost1, cost2;
  scanf("%d", &n);
  stones = new int[n];
  result = new int[n];
  for(i=0; i<n; i++){
    scanf("%d", &stones[i]);
    //result[i] = 0;
  }
  result[0] = stones[0];
  cost1 = abs(stones[0]-stones[1]);
  result[1] = min(cost1, stones[1]);
  for(i=2; i<n; i++){
    cost1 = abs(stones[i-1]-stones[i]);
    cost2 = abs(stones[i-2]-stones[i]);
    result[i] = min(cost1 + result[i-1], cost2 + result[i-2]);
  }
  printf("%d", result[n]);
  return 0;
}


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

#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>

using namespace std;
int N,C;
vector< int > sassi;


int solve2(int DP[],int i){
	if(i <= 0){
		return 0;
	}
	else{
		int primo = solve2(DP,i-1);
		int secondo = solve2(DP,i-2);
		
		if(DP[i] == -1){
			if(primo + abs(sassi[i] - sassi[i-1]) < secondo + abs(sassi[i] - sassi[i-2]) ){
				DP[i] = primo + abs(sassi[i] - sassi[i-1]);
			}
			else{
				DP[i] =secondo + abs(sassi[i] - sassi[i-2]);
			}
		}
		
		
		return DP[i];
	}
}


int solve(){
	int DP[N];
	
	DP[0] = 0;
	DP[1] = min( DP[1] + abs(sassi[1] - sassi[1]) , DP[0] + abs(sassi[0] - sassi[0]) );
	
	for(int i=2; i < N; i++){
		DP[i] = min( DP[i-1] + abs(sassi[i] - sassi[i-1]) , DP[i-2] + abs(sassi[i] - sassi[i-2]) );
	}
	
	return DP[N-1];
}


int main(int argc, char** argv) {
	cin >> N;
	
	for(int i=0;i< N;i++){
		int p;
		cin >> p;
		sassi.push_back(p);
	}
	
	cout << solve2(DP,N-1);	
	return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:58:24: error: 'DP' was not declared in this scope
   58 |         cout << solve2(DP,N-1);
      |                        ^~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> heights;
    vector<int> DP;
    heights.resize(n);
    DP.assign(n, -1);
    for(int i=0; i<n; i++)
    {
        cin>>height[i];
    }

    DP[0] = 0;
    DP[1] = maths.abs(heights[1] - heights[0]);
    for(int i = 2; i<n; i++)
    {
        DP[i] = min(DP[i-2] + maths.abs(heights[i] - heights[i-2], heights[i] - heights[i-1]));
    }
    cout<<DP[n-1];

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:14: error: 'height' was not declared in this scope; did you mean 'heights'?
   15 |         cin>>height[i];
      |              ^~~~~~
      |              heights
a.cc:19:13: error: 'maths' was not declared in this scope
   19 |     DP[1] = maths.abs(heights[1] - heights[0]);
      |             ^~~~~
Language: C++


#include "pch.h"
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define lint long long
#define INF 10000000000000
lint dp[100010];
lint h[100010];
int main() {

	lint N; cin >> N;
	
	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	for (int 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] << endl;
	return 0;
}

Compiler output:
a.cc:2:10: fatal error: pch.h: No such file or directory
    2 | #include "pch.h"
      |          ^~~~~~~
compilation terminated.
Language: C++

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

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 ll INF =1LL<<60;

int N;
ll h[100010];

ll dp[10010];

ll rec(int i){
    if(dp[i]<INF) return dp[i];
    if(i==0) return 0;
    ll res = INF;
    chmin(res,rec(i-1)+abs(h[i]-h[i-1]));
    if(i>1) chmin(res,rec(i-2)+abs(h[i]-h[i-2]));

    return dp[i] = res;
}

int main(){
    int N;cin>>N;
    REP(i,N) cin>>h[i];
    REP(i,100010) dp[i] = INF;
    cout<<rec(N-1)<<endl;
}

Compiler output:
a.cc:8:7: error: 'll' does not name a type
    8 | const ll INF =1LL<<60;
      |       ^~
a.cc:11:1: error: 'll' does not name a type
   11 | ll h[100010];
      | ^~
a.cc:13:1: error: 'll' does not name a type
   13 | ll dp[10010];
      | ^~
a.cc:15:1: error: 'll' does not name a type
   15 | ll rec(int i){
      | ^~
a.cc: In function 'int main()':
a.cc:27:9: error: 'i' was not declared in this scope
   27 |     REP(i,N) cin>>h[i];
      |         ^
a.cc:27:5: error: 'REP' was not declared in this scope
   27 |     REP(i,N) cin>>h[i];
      |     ^~~
a.cc:29:11: error: 'rec' was not declared in this scope
   29 |     cout<<rec(N-1)<<endl;
      |           ^~~
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
    int N;
    vector<int> h(N);
    REP(i,N) cin>>h[i];
    vector<int> cost(N,0);
    for(int i = 1; i < N; i++)
    {   
        if (i>1){
            int cost_1 = cost[i-1] + abs(h[i] - h[i-1]);
            int cost_2 = cost[i-2] + abs(h[i] - h[i-2]);
            int cost =min(cost_1,cost_2);
        }else{
            int tcost = cost[i-1] + abs(h[i] - h[i-1]);
        }
        cost[i] = tcost;
    }
    cout<<cost[N-1]<<endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:19: error: 'tcost' was not declared in this scope; did you mean 'cost'?
   36 |         cost[i] = tcost;
      |                   ^~~~~
      |                   cost
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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 long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // 答え
    cout << dp[N-1] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:34:29: error: expected '}' at end of input
   34 |     cout << dp[N-1] << endl;
      |                             ^
a.cc:17:12: note: to match this '{'
   17 | int main() {
      |            ^
Language: C++

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

const int INF = 1 << 30;

int a[100001];
int dp[100001];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:37: error: 'INT_MAX' was not declared in this scope
   16 |     for (i = 1; i < n; i++) dp[i] = INT_MAX;
      |                                     ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

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

int a[100001];
int dp[100001];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:37: error: 'INT_MAX' was not declared in this scope
   14 |     for (i = 1; i < n; i++) dp[i] = INT_MAX;
      |                                     ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | using namespace std;
a.cc:19:22: error: expected primary-expression before '<<' token
   19 |     cout << dp[n-1]; << endl;
      |                      ^~
Language: C++

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

int main(){
  int n=0;
  cin>>n;
  int arr[n+1]={0};
  cin>>arr[1];
  pair<int,int> jumps[n+2]={};
  for(int i=2;i<=n;i++){
    cin>>arr[i];
    jumps[n-2].second=abs(arr[n-2]-arr[n]);
    jumps[n-1].first=abs(arr[n-1]-arr[n]);
  }
  int dp[n+1]={0};
  jumps[0].second=1e5;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1]+jumps[i-1].first;
    if(dp[i]>dp[i-2]+jumps[i-2].second) do[i]=dp[i-2]+jumps[i-2].second;
  }
  cout<<dp[n]<<endl;
  return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:20:46: error: expected '{' before '=' token
   20 |     if(dp[i]>dp[i-2]+jumps[i-2].second) do[i]=dp[i-2]+jumps[i-2].second;
      |                                              ^
a.cc: In function 'int main()':
a.cc:20:66: error: no match for 'operator=' (operand types are 'main()::<lambda()>' and 'int')
   20 |     if(dp[i]>dp[i-2]+jumps[i-2].second) do[i]=dp[i-2]+jumps[i-2].second;
      |                                                                  ^~~~~~
a.cc:20:45: note: candidate: 'main()::<lambda()>& main()::<lambda()>::operator=(const main()::<lambda()>&)' (deleted)
   20 |     if(dp[i]>dp[i-2]+jumps[i-2].second) do[i]=dp[i-2]+jumps[i-2].second;
      |                                             ^
a.cc:20:45: note:   no known conversion for argument 1 from 'int' to 'const main()::<lambda()>&'
a.cc:21:3: error: expected 'while' before '}' token
   21 |   }
      |   ^
a.cc:21:3: error: expected '(' before '}' token
   21 |   }
      |   ^
      |   (
a.cc:21:3: error: expected primary-expression before '}' token
a.cc:20:73: error: expected ')' before '}' token
   20 |     if(dp[i]>dp[i-2]+jumps[i-2].second) do[i]=dp[i-2]+jumps[i-2].second;
      |                                                                         ^
      |                                                                         )
   21 |   }
      |   ~                                                                      
a.cc:20:73: error: expected ';' before '}' token
   20 |     if(dp[i]>dp[i-2]+jumps[i-2].second) do[i]=dp[i-2]+jumps[i-2].second;
      |                                                                         ^
      |                                                                         ;
   21 |   }
      |   ~
Language: Java

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

public class A {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        int[] h = new int[N];
        for(int i= 0; i < N; i++) h[i] = scanner.nextInt();
        //Want the solution at N
        //cost at 0 = 0
        //Overlapping subproblem -> recompute :(
        //                          store intermediate answers :)
        int[] dp = new int[N];
        dp[0] = 0;
        dp[1] = Math.abs(h[1]-h[0]);
        for(int i = 2; i < N; i++) {
//            dp[i] = h[i] + Math.min(dp[i-1], dp[i-2]);
            //Cost of hopping from previous??
            dp[i] = Math.min(Math.abs(h[i] - h[i-1]) + dp[i-1], Math.abs(h[i] - h[i-2]) + dp[i-2]);
//            int min = Math.abs(h[i] - h[i-1]) + dp[i-1];
//            min = Math.min(min, Math.abs(h[i]-h[i-2]) + dp[i-2]);
//            dp[i] = min;
        }
        out.println(dp[N-1]);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


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