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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:32: error: 'h' was not declared in this scope
    8 |         dp[0]= 0 , dp[1] = abs(h[1]- h[0] ) ;
      |                                ^
a.cc:10:18: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   10 |         dp[i]=min( { dp[i-1], abs(h[i] - h[i-1]), abs(h[i]-h[i-2]) } );
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:
/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
Language: Java

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), w = sc.nextInt();
        int[] ws = new int[n];
        long[] vs = new long[n];

        long[][] dp = new long[n][w + 1];
        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        }
        System.out.println(maxKnapsack(ws, vs, w));
    }

    private static long maxKnapsack(int[] ws, long[] vs, int w) {
        long[] dp = new long[w + 1];

        for (int i = 0; i < ws.length; i++) {
            for (int s = w[i]; s <= w; s++) {
                dp[s] = Math.max(dp[s - ws[i]] + vs[i], dp[s]);
            }
        }
        return dp[w];
    }
}



Compiler output:
Main.java:22: error: array required, but int found
            for (int s = w[i]; s <= w; s++) {
                          ^
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(), w = sc.nextInt();
        int[] ws = new int[n];
        long[] vs = new long[n];

        long[][] dp = new long[n][w + 1];
        for (int i = 0; i < n; i++) {
            ws[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        }
        System.out.println(maxKnapsack(ws, vs, w));
    }

    private static long maxKnapsack(int[] ws, long[] vs, int w) {
        long[] dp = new long[w + 1];

        for (int i = 0; i < ws.length; i++) {
            for (int s = w[i]; ws <= ; s++) {
                dp[s] = Math.max(dp[s - ws[i]] + vs[i], dp[s]);
            }
        }
        return dp[w];
    }
}



Compiler output:
Main.java:22: error: illegal start of expression
            for (int s = w[i]; ws <= ; s++) {
                                     ^
1 error
Language: C++

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


Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {
      | ^
Language: C++

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

Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {
      | ^
Language: C++

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

Compiler output:
a.cc:4:1: error: expected unqualified-id before '{' token
    4 | {
      | ^
Language: C++

import java.util.*;
import java.io.*;
class Solution
{
	static StringBuilder sb;
	public static final boolean ONLINE_JUDGE=true;
	public static void main(String []args)throws IOException
	{
		sb=new StringBuilder();
		Scanner sc=new Scanner(System.in);
		if(ONLINE_JUDGE)
		{
			File file=new File("output.txt");
			sc=new Scanner(new FileReader(new File("input.txt")));
			PrintStream ps=new PrintStream(file);
			System.setOut(ps);
		}
		int t=1;
		for(int tt=1;tt<=t;tt++)
		{
			int n=sc.nextInt();
			int a[]=new int[n];
			for(int i=0;i<n;i++)
				a[i]=sc.nextInt();
			int dp[]=new int[n];
			Arrays.fill(dp,Integer.MAX_VALUE);
			dp[0]=0;
			dp[1]=Math.abs(a[1]-a[0]);
			for(int i=2;i<n;i++)
			{
				for(int j=1;j<=2;j++)
				{
					dp[i]=Math.min(dp[i],dp[i-j]+Math.abs(a[i]-a[i-j]));
				}
			}
			System.out.println(dp[n-1]);
		}
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:16: error: 'StringBuilder' does not name a type
    5 |         static StringBuilder sb;
      |                ^~~~~~~~~~~~~
a.cc:6:15: error: expected ':' before 'static'
    6 |         public static final boolean ONLINE_JUDGE=true;
      |               ^~~~~~~
      |               :
a.cc:6:23: error: 'final' does not name a type
    6 |         public static final boolean ONLINE_JUDGE=true;
      |                       ^~~~~
a.cc:7:15: error: expected ':' before 'static'
    7 |         public static void main(String []args)throws IOException
      |               ^~~~~~~
      |               :
a.cc:7:33: error: 'String' has not been declared
    7 |         public static void main(String []args)throws IOException
      |                                 ^~~~~~
a.cc:7:42: error: expected ',' or '...' before 'args'
    7 |         public static void main(String []args)throws IOException
      |                                          ^~~~
a.cc:7:46: error: expected ';' at end of member declaration
    7 |         public static void main(String []args)throws IOException
      |                                              ^
      |                                               ;
a.cc:7:47: error: 'throws' does not name a type
    7 |         public static void main(String []args)throws IOException
      |                                               ^~~~~~
a.cc:39:2: error: expected ';' after class definition
   39 | }
      |  ^
      |  ;
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:8:12: error: 'h' was not declared in this scope
    8 |     cin >> h[i];
      |            ^
a.cc:10:17: error: 'h' was not declared in this scope
   10 |   dp[0]=0;dp[1]=h[0];dp[2]=h[1];
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    //入力
    ll N;
    cin >> N;
    ll h[1000000];
    for (ll i = 0;i<N;i++) cin >> h[i];

    //初期化
    ll dp[1000000];
    for (ll i = 0;i<1000000;i++) dp[i] = INF;

    //初期設定
    dp[0] = 0;
    
    //遷移
    for (ll 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:28:49: error: expected ')' before ';' token
   28 |         chmin(dp[i+1],dp[i] + abs(h[i] - h[i+1]);
      |              ~                                  ^
      |                                                 )
a.cc:29:49: error: expected ')' before ';' token
   29 |         chmin(dp[i+2],dp[i] + abs(h[i] - h[i+2]);
      |              ~                                  ^
      |                                                 )
Language: C++

#include <bits/stdc++.h>

using namespace std;

int n;
int ar[100005];
int  mem[100005];

int sol(int last, int i){
    if(i>=n)
        return 1E9;
    if(i==n-1)
        return 0;
    if(~mem[i])
        return mem[i];
    return mem[i] = min(abs(ar[i]-ar[i+1])+sol(i, i+1), abs(ar[i]-ar[i+2])sol(i, i+2));
}

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

    memset(mem, -1, sizeof(mem));
    //mem[0] = abs(ar[0]-ar[1]);

    cout << min(sol(0, 1), sol(0, 2));
    return 0;
}


Compiler output:
a.cc: In function 'int sol(int, int)':
a.cc:16:75: error: expected ')' before 'sol'
   16 |     return mem[i] = min(abs(ar[i]-ar[i+1])+sol(i, i+1), abs(ar[i]-ar[i+2])sol(i, i+2));
      |                        ~                                                  ^~~
      |                                                                           )
Language: C++

n,w = map(int,input().split())
d = {}
p = []
for i in range(n):
    k,v = map(int,input().split())
    d[k] = v
    p.append(k)

l = []
for i in range(n+1):
    o = []
    for j in range(w+1):
        o.append(0)

    l.append(o)

# MAIN DP MATRIX OPERATION
for i in range(1,n+1):
    for j in range(1,w+1):
        if p[i-1] > j:
            l[i][j] = l[i-1][j]

        else:
            l[i][j] = max(d[p[i-1]] + l[i-1][j-p[i-1]],l[i-1][j])


print(max(l[n]))







Compiler output:
a.cc:17:3: error: invalid preprocessing directive #MAIN
   17 | # MAIN DP MATRIX OPERATION
      |   ^~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n,w = map(int,input().split())
      | ^
a.cc:3:1: error: 'p' does not name a type
    3 | p = []
      | ^
Language: C++

#include <iostream>
#include <vector>

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

const long long INF = 1LL << 60;

//Input
int N;
long long h[100010];

//DP table
long long dp[100010];

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

  for (int i=0; i<100010; ++i) dp[i] = INF;
  dp[0] = 0;

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:17:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   17 |   int N; cin >> N;
      |          ^~~
      |          std::cin
In file included 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:28:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   28 |   cout << dp[N-1] << endl;
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:28:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   28 |   cout << dp[N-1] << endl;
      |                      ^~~~
      |                      std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF=1e9+5;

int main(){
	int n,temp;
	cin>>n;
	vector<int> h(n);
	for(int& x; h){
		cin>>temp;
		h.push_back(temp);
	}
	vector<int> dp(n, INF);
	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]));
		}
	}
	cout<<dp[n-1];
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:18: error: 'x' declared as reference but not initialized
   16 |         for(int& x; h){
      |                  ^
a.cc:16:21: error: could not convert 'h' from 'std::vector<int>' to 'bool'
   16 |         for(int& x; h){
      |                     ^
      |                     |
      |                     std::vector<int>
a.cc:16:22: error: expected ';' before ')' token
   16 |         for(int& x; h){
      |                      ^
      |                      ;
a.cc:21:25: error: expected primary-expression before ';' token
   21 |         for(int i=0;i<n;;i++){
      |                         ^
a.cc:21:25: error: expected ')' before ';' token
   21 |         for(int i=0;i<n;;i++){
      |            ~            ^
      |                         )
a.cc:21:26: error: 'i' was not declared in this scope
   21 |         for(int i=0;i<n;;i++){
      |                          ^
Language: C++

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

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

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+5;
const int INF = 0x3f3f3f;
int dp[MAXN],a[MAXN];

int main(){
	int N;
	memset(dp,INF,sizeof(dp));
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	for(int i=0;i<N-1;++i){
		dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		if(i+1==N-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:21:67: error: expected ')' before ';' token
   21 |                         dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]);
      |                                    ~                              ^
      |                                                                   )
Language: C++

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+5;
const int INF = 0x3f3f3f;
int dp[MAXN],a[MAXN];

int main(){
	int N;
	memset(dp,INF,sizeof(dp));
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	for(int i=0;i<N-1;++i){
		dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		if(i+1==N-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:20:67: error: expected ')' before ';' token
   20 |                         dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]);
      |                                    ~                              ^
      |                                                                   )
Language: C++

def frog1(h):
    dp = [float('inf')]*3
    dp[0] = 0
    for i in range(1,len(h)):
        dp[i%3] = min([dp[(i-j)%3] + abs(h[i]-h[i-j]) for j in range(1,3)])
    return dp[(len(h)-1)%3]
    
n = raw_input()
vals = map(int, raw_input.split())

print(frog1(vals))

Compiler output:
a.cc:2:17: warning: multi-character character constant [-Wmultichar]
    2 |     dp = [float('inf')]*3
      |                 ^~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def frog1(h):
      | ^~~
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;
  const long long INF = 1LL << 60;
  
  long long DP[100010];


  vector<int> high(N);
  for(int j=0;j<N;++j){
    cin >> h[j];
  }
  
  for(int i=0;i<100010;++i){
    DP[i] = INF;
  }
  DP[0] = 0;

  for(int k=0;k<N;++k){
    chmin(DP[k],DP[k-1] + abs(h[k]-h[k-1]));
    if(k > 1){
      chmin(DP[k],DP[k-2] + abs(h[k]-h[k-2]));
    }
  }
  cout << DP[N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: 'h' was not declared in this scope
   22 |     cin >> h[j];
      |            ^
a.cc:31:31: error: 'h' was not declared in this scope
   31 |     chmin(DP[k],DP[k-1] + abs(h[k]-h[k-1]));
      |                               ^
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;
  const long long INF = 1LL << 60;
  
  long long DP[100010];


  vector<int> high(N);
  for(int j=0;j<N;++j){
    cin >> high[j];
  }
  
  for(int i=0;i<100010;++i){
    DP[i] = INF;
  }
  DP[0] = 0;

  for(int k=0;k<N;++k){
    chmin(DP[i],DP[i-1] + abs(h[i]-h[i-1]));
    if(i > 1){
      chmin(DP[i],DP[i-2] + abs(h[i]-h[i-2]));
    }
  }
  cout << DP[N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:14: error: 'i' was not declared in this scope
   31 |     chmin(DP[i],DP[i-1] + abs(h[i]-h[i-1]));
      |              ^
a.cc:31:31: error: 'h' was not declared in this scope
   31 |     chmin(DP[i],DP[i-1] + abs(h[i]-h[i-1]));
      |                               ^
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;
  const long long INF = 1Ll << 60;
  
  long long DP[100010];


  vector<int> high(N);
  for(int j=0,j<N,++j){
    cin >> high[j];
  }
  
  for(int i=0,i<100010,++i){
    DP[i] = INF;
  }
  DP[0] = 0;

  for(int k=0;k<N;++k){
    chmin(DP[i],DP[i-1] + abs(h[i]-h[i-1]));
    if(i > 1){
      chmin(DP[i],DP[i-2] + abs(h[i]-h[i-2]));
    }
  }
  cout << DP[N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: unable to find numeric literal operator 'operator""Ll'
   15 |   const long long INF = 1Ll << 60;
      |                         ^~~
a.cc:21:16: error: expected ';' before '<' token
   21 |   for(int j=0,j<N,++j){
      |                ^
      |                ;
a.cc:21:16: error: expected primary-expression before '<' token
a.cc:21:22: error: expected ';' before ')' token
   21 |   for(int j=0,j<N,++j){
      |                      ^
      |                      ;
a.cc:25:16: error: expected ';' before '<' token
   25 |   for(int i=0,i<100010,++i){
      |                ^
      |                ;
a.cc:25:16: error: expected primary-expression before '<' token
a.cc:25:27: error: expected ';' before ')' token
   25 |   for(int i=0,i<100010,++i){
      |                           ^
      |                           ;
a.cc:31:14: error: 'i' was not declared in this scope
   31 |     chmin(DP[i],DP[i-1] + abs(h[i]-h[i-1]));
      |              ^
a.cc:31:31: error: 'h' was not declared in this scope
   31 |     chmin(DP[i],DP[i-1] + abs(h[i]-h[i-1]));
      |                               ^
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
const int INF=1e9+5;
int main()
{
    int n;
    cin>>n;
    vector<int> h(n);
    for(int& x:h)
    {
        cin>>x;
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j:(i+1,i+2))
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
                
            }
        }
    }
    cout<<dp[n-1];
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:27: error: 'begin' was not declared in this scope
   24 |         for(int j:(i+1,i+2))
      |                           ^
a.cc:24:27: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:24:27: error: 'end' was not declared in this scope
   24 |         for(int j:(i+1,i+2))
      |                           ^
a.cc:24:27: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
Language: Java

import java.util.*;
import java.lang.*;

public class MyClass {
    public static void main(String args[]) {
        Scanner sc  = new Scanner(System.in);
      int n = sc.nextInt();
        Integer[] a = new Integer[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        Integer[] dp = new Integer[n];
        dp[0] = 0;
        for(int i=1;i<n;i++){
            dp[i] = Math.min((dp[Math.max(i-1,0)]+(Math.abs(a[i]-a[Math.max(i-1,0)]))),(dp[Math.max(i-2,0)]+(Math.abs(a[i]-a[Math.max(i-2,0)]))));
        }
        System.out.print(dp[n-1]);
    }
}

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

/*package whatever //do not write package name here */

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

class Main {
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(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 nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  
    static boolean is_palindrome(String s){
        for (int i=0;i<=s.length()/2 ;i++ ) {
            if(s.charAt(i)!=s.charAt(s.length()-1-i)){
                return false;
            }
        }
        return true;
    }
	public static void main (String[] args) {
	    FastReader ob = new FastReader();
	    int n = ob.nextInt();
	    int arr[] = new int[n];
	    for (int i=0;i<arr.length ;i++ ) {
	        arr[i]=ob.nextInt();
	    }
	    long dp[] = new long[n];
	    dp[0]=0;
	    dp[1]=Math.abs(arr[1],arr[0]);
	    dp[2]=Math.min(dp[1]+Math.abs(arr[1]-arr[2]),arr[2]-arr[0]);
	    for(int i=3;i<n;i++){
	        dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]));
	    }
	    System.out.println(dp[n-1]);
	}
}

Compiler output:
Main.java:82: error: no suitable method found for abs(int,int)
	    dp[1]=Math.abs(arr[1],arr[0]);
	              ^
    method Math.abs(int) is not applicable
      (actual and formal argument lists differ in length)
    method Math.abs(long) is not applicable
      (actual and formal argument lists differ in length)
    method Math.abs(float) is not applicable
      (actual and formal argument lists differ in length)
    method Math.abs(double) is not applicable
      (actual and formal argument lists differ in length)
1 error
Language: Java

/*package whatever //do not write package name here */

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

class Main {
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(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 nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  
    static boolean is_palindrome(String s){
        for (int i=0;i<=s.length()/2 ;i++ ) {
            if(s.charAt(i)!=s.charAt(s.length()-1-i)){
                return false;
            }
        }
        return true;
    }
	public static void main (String[] args) {
	    FastReader ob = new FastReader();
	    int n = ob.nextInt();
	    int arr[] = new int[n];
	    for (int i=0;i<arr.length ;i++ ) {
	        arr[i]=ob.nextInt();
	    }
	    long dp[] = new long dp[n];
	    dp[0]=0;
	    dp[1]=Math.abs(arr[1],arr[0]);
	    dp[2]=Math.min(dp[1]+Math.abs(arr[1]-arr[2]),arr[2]-arr[0]);
	    for(int i=3;i<n;i++){
	        dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]))
	    }
	    System.out.println(dp[n-1]);
	}
}

Compiler output:
Main.java:80: error: '[' expected
	    long dp[] = new long dp[n];
	                        ^
Main.java:80: error: ']' expected
	    long dp[] = new long dp[n];
	                              ^
Main.java:85: error: ';' expected
	        dp[i]=Math.min(dp[i-1]+Math.abs(arr[i]-arr[i-1]),dp[i-2]+Math.abs(arr[i-2]-arr[i]))
	                                                                                           ^
3 errors
Language: C++

#include<bits/stdc++.h>
#include<stdio.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long int
#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int INF = 1<<29;

using namespace std;


int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock();  
	int n;
	scanf("%d",&n);
	vector<int> stones(n);
	for(int& x:stones)
	{
		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})
		{
			if(j<n) dp[j] = min(dp[j],dp[i]+abs(stones[i]-stones[j]));
		}
	}
	printf("%d",dp[n-1]);


	//time_req = clock()- time_req;cout << "Time Compexity:"<< (float)time_req/CLOCKS_PER_SEC << " seconds" << endl; 
	return 0;
}

Compiler output:
a.cc:4:23: error: '::main' must return 'int'
    4 | #define int long long int
      |                       ^~~
a.cc:11:1: note: in expansion of macro 'int'
   11 | int main()
      | ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N; cin>>N;
  vector<ll> height(N+10);
  rep(i,N) cin >> height[i+1];
  
  vector<ll> cost(N+10);
  cost[1]=0;
  cost[2]=abs(height(2)-height(1));
  
  for(int i=1; i<=N; ++i) {
    cost[i+2] = min(cost[i]+abs(height[i+2]-height[i]) ,cost[i+1]+abs(height[i+2]-height[i+1]));
  }
  
  cout << cost[N] <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: no match for call to '(std::vector<long long int>) (int)'
   16 |   cost[2]=abs(height(2)-height(1));
      |               ~~~~~~^~~
a.cc:16:31: error: no match for call to '(std::vector<long long int>) (int)'
   16 |   cost[2]=abs(height(2)-height(1));
      |                         ~~~~~~^~~
Language: C++

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

int main()
{
  int n;
  cin>>n;
  const int INF = 1e9 + 5;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  vector<int> dp(n,INF)
  dp[0]=0;
  for(int i=0;i<n;i++)
  {
    for(int j :{i+1,i+2})
    {
      if(j<n)
      {
        dp[j]= min(dp[j], dp[i]+abs(arr[j]-arr[i]));

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


Compiler output:
a.cc: In function 'int main()':
a.cc:15:3: error: expected ',' or ';' before 'dp'
   15 |   dp[0]=0;
      |   ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n+1]={0};
  for(int i=1;i<=n;i++)
    cin>>a[i];
  int dp[n+2]={0};
  int i=0,j=0,q=0;
  for(int i=2;i<=n;i++)
  {  q=1;
   long long int mi=1000000000;
    for(j=1;i-j>0,j<=k;j++)
    {
      mi=min(mi,abs(a[i]-a[i-j])+dp[i-j]);
    }
   dp[i]=mi;
  }
  cout<<dp[n];
  return 0;
}



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

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

Compiler output:
a.cc:1:9: fatal error: bits/stc++.h: No such file or directory
    1 | #include<bits/stc++.h>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: Java

public class Main {


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scan.nextInt();
            dp[i] = 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[j], dp[i] + Math.abs(nums[j] - nums[i]));
                }
            }
        }
        System.out.println(dp[n - 1]);
    }

}

Compiler output:
Main.java:5: error: cannot find symbol
        Scanner scan = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
        Scanner scan = new Scanner(System.in);
                           ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

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

const long long INF = 1LL << 60;

//input
int N;
long long h[100010];

//DP_table
long long dp[100010];

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

	//init
	dp[0] = 0;
	for (int i = 1; i < N; i++) dp[i] = INF;

	//loop
	for (int i = 1; i < N; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(i>1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

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

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:30: error: expected ';' before 'i'
   19 |         for (int i = 0; i < N i++) cin >> h[i];
      |                              ^~
      |                              ;
Language: C++

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

const long long INF = 1LL << 60;

//input
int N;
long long h[100010];

//DP_table
long long dp[100010];

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

	//init
	dp{ 0 } = 0;
	for (int i = 1; i < N; i++) dp[i] = INF;

	//loop
	for (int i = 1; i < N; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(i>1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

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

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:30: error: expected ';' before 'i'
   19 |         for (int i = 0; i < N i++) cin >> h[i];
      |                              ^~
      |                              ;
a.cc:22:11: error: expected ';' before '{' token
   22 |         dp{ 0 } = 0;
      |           ^
      |           ;
a.cc:22:17: error: expected primary-expression before '=' token
   22 |         dp{ 0 } = 0;
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll n;
ll ar[100001];
ll dp[100001];
ll func(ll idx)
{
	if(idx<=0)
	return 0;
	if(dp[idx]!=-1)
	return dp[idx];
	ll ret=min(func(idx-1)+abs(ar[idx]-ar[idx-1]),func(idx-2)+abs(ar[idx]-ar[idx-2]));
	return dp[idx]=ret;
}
int main()
{
	cin>>n;
	for(ll i=0;i<n;i++)
	cin>>ar[i];
	dp[0]=ar[0];
	dp[1]=abs(ar[0]-ar[1]);
	for(ll i=2;i<100001;i++)
	{
		dp[i]=min(dp[i-1]+abs(ar[i]-ar[i-1]),dp[i-2]+abs(ar[i]-ar[i-2]));
	}
	cout<<dp(n-1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: 'dp' cannot be used as a function
   27 |         cout<<dp(n-1);
      |               ~~^~~~~
Language: Java

import java.util.Scanner;

public class Frog {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int[] test = new int[N];
		for (int i = 0; i < N; i++) {
			test[i] = input.nextInt();
		}
		System.out.println(JUMP(test));
	}
	public static int JUMP(int[] test) {
		int[] dp = new int[test.length];
		dp[0]=0;
		dp[1]=Math.abs(test[1]-test[0]);
		for (int i = 2; i < test.length; i++) {
			dp[i]=Math.min(dp[i-1]+Math.abs(test[i]-test[i-1]), dp[i-2]+Math.abs(test[i]-test[i-2]));
		}
		return dp[test.length-1];
	}
}

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author aakas
 */
import java.util.*;
public class FrogA {
    static int n;
    static boolean[] v1;
    static int[] dp4;
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        v1 = new boolean[n];
        dp4 = new int[n];
        int[] height = new int[n+2];
        for(int i=0;i<n;i++)
        {
            height[i] = sc.nextInt();
        }
        height[n] = height[n+1] = 100000;
        System.out.println(dp3(0,height));
    }
    public static int dp3(int i,int[] height)
    {
        if(i==n-1)
            return 0;
        if(i>=n)
            return 100000;
        if(v1[i])
            return dp4[i];
        v1[i] = true;
        return dp4[i] = Math.min(dp3(i+1,height)+Math.abs(height[i+1]-height[i]),dp3(i+2,height)+Math.abs(height[i+2]-height[i]));
       
    }
}


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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: 'i' was not declared in this scope
   21 |   cout<<dp[i]<<"\n";
      |            ^
Language: C++

#include <iostream>
#include <vector>
#include<bitset>
using namespace std;
const int MOD = 1e9 + 7;
int n; // no. of pairs
vector<int> dp(1 << 21);
  vector<vector<int>> check(21, vector<int>(21));
inline int add(int a, int b){
	a += b;
	if(a >= MOD)a -= MOD;
	return a;
}
int findways(vector<int> &dp, int male, int mask, vector<vector<int>> &check)
{
  //cout << "mask " << std::bitset<5>(mask)<<endl;
  if (mask == 0)
    return 1;
  if (dp[mask] != 0)
    return dp[mask];
// male is ith male for which female has to be choosen
  for (int female = 0; female < n; ++female) // ith female
    if (check[male - 1][female] && (mask & (1 << female))) // ith female available or not
    {
      int new_mask = mask ^ (1 << female);
     
      dp[mask] = add(dp[mask], findways(dp, male - 1,  new_mask, check));
    }
  return dp[mask];
}

int main()
{
  ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 0;i<n;++1)
    for(int j = 0;j<n;++j)
      cin >> check[i][j];
  cout << findways(dp, n, (1 << n) - 1, check) << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:24: error: lvalue required as increment operand
   37 |   for (int i = 0;i<n;++1)
      |                        ^
Language: C++

/* created by <xrssa> */
#pragma GCC optimize("O3","unroll-loops","omit-frame-pointer","inline","fast-math","no-stack-protector") //Optimization flags
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
// #include <x86intrin.h> //AVX/SSE Extensions

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

#define f(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define fa(elem, arr) for(auto &elem:arr)
#define gcd(x,y)         __gcd(x,y)
#define lcm(x,y)        (x/gcd(x,y))*y
#define mod             1000000007
#define all(a)           a.begin(),a.end()
#define INF 1e9 // # define INF 0x3f3f3f3f 
#define EPS 1e-6

void solve(){
    int n;cin>>n;int arr[n];f(i,n) cin>>arr[i];
    vector<int> dp(n,INF);
    dp[0]=0;
    f(i,n){
        for(int j: {i+1,i+2}){
            if (j<n){
                dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
            }
        }
    }
    cout << dp[n-1] << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    // for multiple test case use
    // int t;cin>>t;while(t--) solve();
    return 0;
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:6:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

int main()
{
    int n;
    scanf("%d", &n);
    if (n == 0)
        return 0;
    int array[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &array[i]);
    }
    if (n == 1)
        return array[0];
    if (n == 2)
        return abs(array[1] - array[0]);

    int a = 0, b = abs(array[1] - array[0]), c = abs(array[1] - array[0]);
    for (int i = 2; i < n; i++)
    {
        c = min(abs(array[i] - array[i - 2]) + a, abs(array[i] - array[i - 1]) + b);
        a = b;
        b = c;
    }
    return b;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'scanf' was not declared in this scope
    4 |     scanf("%d", &n);
      |     ^~~~~
a.cc:15:16: error: 'abs' was not declared in this scope
   15 |         return abs(array[1] - array[0]);
      |                ^~~
a.cc:17:20: error: 'abs' was not declared in this scope
   17 |     int a = 0, b = abs(array[1] - array[0]), c = abs(array[1] - array[0]);
      |                    ^~~
a.cc:20:9: error: 'c' was not declared in this scope
   20 |         c = min(abs(array[i] - array[i - 2]) + a, abs(array[i] - array[i - 1]) + b);
      |         ^
a.cc:20:13: error: 'min' was not declared in this scope; did you mean 'main'?
   20 |         c = min(abs(array[i] - array[i - 2]) + a, abs(array[i] - array[i - 1]) + b);
      |             ^~~
      |             main
Language: C++

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout << x << newl;
using namespace std;
int main()
{
  fastio;
  int n;
  cin>>n;
  vector<int> h(n);
  vector<int> d(n);
  fore(i,0,n)
    cin>>h[i];
  d[0]=0;d[1]=abs(h[1]-h[0]);
  fore(i,2,n)
    d[i]=min( d[i-1]+abs(h[i]-h[i-1]) , d[i-2]+abs(h[i]-h[i-2]) );
  print(d[n-1]);
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:8:31: error: 'newl' was not declared in this scope
    8 | #define print(x) cout << x << newl;
      |                               ^~~~
a.cc:22:3: note: in expansion of macro 'print'
   22 |   print(d[n-1]);
      |   ^~~~~
Language: C++

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define fore(i,a,b) for(int i=a;i<b;i++)
#define maxe(a,b,c) max(a,max(b,c))
#define pb push_back
#define eb emplace_back
#define em emplace
#define print(x) cout << x << newl;
using namespace std;
int main()
{
  fastio;
  int n;
  cin>>n;
  vector<int> h(n);
  vector<int> d(n);
  for(i,0,n)
    cin>>h[i];
  d[0]=0;d[1]=abs(h[1]-h[0]);
  fore(i,2,n)
    d[i]=min( d[i-1]+abs(h[i]-h[i-1]) , d[i-2]+abs(h[i]-h[i-2]) );
  print(d[n-1]);
}
 


Compiler output:
a.cc: In function 'int main()':
a.cc:17:7: error: 'i' was not declared in this scope
   17 |   for(i,0,n)
      |       ^
a.cc:19:29: error: expected ')' before ';' token
   19 |   d[0]=0;d[1]=abs(h[1]-h[0]);
      |                             ^
      |                             )
a.cc:17:6: note: to match this '('
   17 |   for(i,0,n)
      |      ^
a.cc:8:31: error: 'newl' was not declared in this scope
    8 | #define print(x) cout << x << newl;
      |                               ^~~~
a.cc:22:3: note: in expansion of macro 'print'
   22 |   print(d[n-1]);
      |   ^~~~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:66: error: expected ';' before 'cout'
   13 |     d[i]=min( d[i-1]+abs(h[i]-h[i-1]) , d[i-2]+abs(h[i]-h[i-2]) )
      |                                                                  ^
      |                                                                  ;
   14 |   cout<<d[n-1];
      |   ~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:66: error: expected ';' before 'cout'
   13 |     d[i]=min( d[i-1]+abs(h[i]-h[i-1]) , d[i-2]+abs(h[i]-h[i-2]) )
      |                                                                  ^
      |                                                                  ;
   14 |   cout<<d[n-1];
      |   ~~~~