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

void Main()
{
	ll n,m,l; ll res=0;
	cin>>n;
	VI dp(n+2,INF);
	VI h(n);
	rep(i, n) cin >> h[i];
	//初期条件はじめはコスト0
	dp[0]=0;
	//配るDP
	rep(i,n){
		//１個先のすでに計算したコストと新しく計算する1個先のコスト比較
		ll cost1=abs(h[i+1]-h[i]);
		dp[i+1]=min(dp[i+1],dp[i]+cost1);
		//2個先のすでに計算したコストと新しく計算する2個先のコスト比較
		ll cost2=abs(h[i+2]-h[i]);
		dp[i+2]=min(dp[i+2],dp[i]+cost2);
	}
	res=dp[n-1];
	cout << res << "\n";
	return;
}


Compiler output:
a.cc: In function 'void Main()':
a.cc:3:9: error: 'll' was not declared in this scope
    3 |         ll n,m,l; ll res=0;
      |         ^~
a.cc:3:21: error: expected ';' before 'res'
    3 |         ll n,m,l; ll res=0;
      |                     ^~~~
      |                     ;
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin>>n;
      |         ^~~
a.cc:4:14: error: 'n' was not declared in this scope
    4 |         cin>>n;
      |              ^
a.cc:5:9: error: 'VI' was not declared in this scope
    5 |         VI dp(n+2,INF);
      |         ^~
a.cc:6:11: error: expected ';' before 'h'
    6 |         VI h(n);
      |           ^~
      |           ;
a.cc:7:13: error: 'i' was not declared in this scope
    7 |         rep(i, n) cin >> h[i];
      |             ^
a.cc:7:9: error: 'rep' was not declared in this scope
    7 |         rep(i, n) cin >> h[i];
      |         ^~~
a.cc:9:9: error: 'dp' was not declared in this scope
    9 |         dp[0]=0;
      |         ^~
a.cc:19:9: error: 'res' was not declared in this scope
   19 |         res=dp[n-1];
      |         ^~~
a.cc:20:9: error: 'cout' was not declared in this scope
   20 |         cout << res << "\n";
      |         ^~~~
Language: C++

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

Compiler output:
a.cc:4:1: error: ISO C++ forbids declaration of 'count' with no type [-fpermissive]
    4 | count(int h[],int n,int sum){
      | ^~~~~
Language: C++

#include <iostream>
using namespace std;

int frog(int h[], int i, int n, int dp[]){
    if(i>n)
        return 0;
    
  	if(dp[i]!=-1){
      return dp[i];
    }
    int a = frog(h, i+1, n);
    int b = frog(h, i+2, n);
  
    if(i+1 <=n)
        a += abs(h[i]-h[i+1]);

    if(i+2 <=n)
        b+= abs(h[i]-h[i+2]); 
    return dp[i] = min(a, b);
}

int main() {
  int n;
  cin >> n;
  
  int *dp = new int[n+1]{-1};
  int *arr = new int[n];
  for(int i=0;i<n;i++){
  	cin >> arr[i];
  }
  
  cout << frog(arr, 0, n, dp) << endl;
}


Compiler output:
a.cc: In function 'int frog(int*, int, int, int*)':
a.cc:11:17: error: too few arguments to function 'int frog(int*, int, int, int*)'
   11 |     int a = frog(h, i+1, n);
      |             ~~~~^~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int frog(int h[], int i, int n, int dp[]){
      |     ^~~~
a.cc:12:17: error: too few arguments to function 'int frog(int*, int, int, int*)'
   12 |     int b = frog(h, i+2, n);
      |             ~~~~^~~~~~~~~~~
a.cc:4:5: note: declared here
    4 | int frog(int h[], int i, int n, int dp[]){
      |     ^~~~
Language: C++

#include<iostream>
using namespace std;
int main(){
int n,k;
  cin>>n;
  int a[n];
  bool dp[k+1];
  memset(dp,false,sizeof(dp));
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=1;i<=k;i++){
  for(int j=0;j<n;j++){
  if(i>=a[j] && dp[i-a[j]]==false)
                   dp[i]=true;
  
  
  }
  
  }
                   if(dp[k]==true)
                   cout<<"First\n";
                   else
                   cout<<"Second\n";
 
 
}

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

import java.util.*;
import java.util.Arrays;
public class Main{
  public int[] A;
  
  public int[]dp;
  
  public static int solve(int i, int N){
   	 if(i == N) return 0;
     if(dp[i]!=-1) return dp[i];
    
     if(i+1<=N){
     	dp[i]= Math.abs(A[i]-A[i+1]) + solve(i+1,N);
     }
     if(i+2<=N){
      	dp[i]= Math.min(dp[i], Math.abs(A[i]-A[i+2])  + solve(i+2,N)); 
     }
    return dp[i];
  }
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    
    int N = s.nextInt();
    A = new int[N];
    dp = new int[N];
    Arrays.fill(dp, -1);
    
    for(int i=0;i<N;i++){
     	A[i]=s.nextInt(); 
    }
    
    System.out.println(solve(1,N));
  }
}

Compiler output:
Main.java:10: error: non-static variable dp cannot be referenced from a static context
     if(dp[i]!=-1) return dp[i];
        ^
Main.java:10: error: non-static variable dp cannot be referenced from a static context
     if(dp[i]!=-1) return dp[i];
                          ^
Main.java:13: error: non-static variable dp cannot be referenced from a static context
     	dp[i]= Math.abs(A[i]-A[i+1]) + solve(i+1,N);
     	^
Main.java:13: error: non-static variable A cannot be referenced from a static context
     	dp[i]= Math.abs(A[i]-A[i+1]) + solve(i+1,N);
     	                ^
Main.java:13: error: non-static variable A cannot be referenced from a static context
     	dp[i]= Math.abs(A[i]-A[i+1]) + solve(i+1,N);
     	                     ^
Main.java:16: error: non-static variable dp cannot be referenced from a static context
      	dp[i]= Math.min(dp[i], Math.abs(A[i]-A[i+2])  + solve(i+2,N)); 
      	^
Main.java:16: error: non-static variable dp cannot be referenced from a static context
      	dp[i]= Math.min(dp[i], Math.abs(A[i]-A[i+2])  + solve(i+2,N)); 
      	                ^
Main.java:16: error: non-static variable A cannot be referenced from a static context
      	dp[i]= Math.min(dp[i], Math.abs(A[i]-A[i+2])  + solve(i+2,N)); 
      	                                ^
Main.java:16: error: non-static variable A cannot be referenced from a static context
      	dp[i]= Math.min(dp[i], Math.abs(A[i]-A[i+2])  + solve(i+2,N)); 
      	                                     ^
Main.java:18: error: non-static variable dp cannot be referenced from a static context
    return dp[i];
           ^
Main.java:24: error: non-static variable A cannot be referenced from a static context
    A = new int[N];
    ^
Main.java:25: error: non-static variable dp cannot be referenced from a static context
    dp = new int[N];
    ^
Main.java:26: error: non-static variable dp cannot be referenced from a static context
    Arrays.fill(dp, -1);
                ^
Main.java:29: error: non-static variable A cannot be referenced from a static context
     	A[i]=s.nextInt(); 
     	^
14 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int MAX=1e9+5;
int main()
{
	int n; cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	}
	vector<int> dp(n,MAX);
	for(int i=0;i<n-2;i++)
	{
		for(int j=i+1;j<i+3;j++)
		{
			if(j<n)
			{
				int t=h[i]-h[j];
				if(t<0)
				{
					t=t*(-1);
				}
				if(dp[j]>(dp[i]+t))
				{
					dp[j]=dp[i]+t;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   31 |         cout<<ans;
      |               ^~~
      |               abs
Language: C++

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

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

#include <iostream>

using namespace std;
int main(int argc,char *argv[]){
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  int dp[n+1];
  dp[0]=dp[1]=0;
  memset(dp,0,(n+1)*sizeof(int));
  if(n>=2){
    dp[2]=abs(arr[1]-arr[0]);
  }
  for(int i=3;i<=n;i++){
    dp[i]=min(dp[i-1]+abs(arr[i-2]-arr[i-1]),dp[i-2]+abs(arr[i-3]-arr[i-1]));
  }
  cout<<dp[n]<<endl;
}


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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> dp(n,-1);
  dp[0] = 0;
  dp[1] = abs(a[0] - a[1]);

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

  cout << dp[i-1] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:14: error: 'i' was not declared in this scope
   23 |   cout << dp[i-1] << endl;
      |              ^
Language: C++

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

}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:74: error: expected ';' before 'else'
   19 |                                 dp[i]=min(dp[i-j]+abs(a[i]-a[i-j]),dp[i])
      |                                                                          ^
      |                                                                          ;
   20 |                            else
      |                            ~~~~
Language: C++

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: 'j' was not declared in this scope
   16 |                 for(j=1;j<=k;j++)
      |                     ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |   dp[1]=0;
      |   ^~
      |   dup
Language: C++

// #include <bits/stdc++.h>
#include "stdc++.h"
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int N;
vector<int> h(100001);

int main(void)
{
	cin >> N;

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

	ll dp[100001];
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);

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

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

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


#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d",res);
#define pfl(res) printf("%lld",res);
#define pfd(res) printf("%lf",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];

int main()
{
    int n;
    sc(n);
    for(int i=1;i<=n;i++)
    {
        sc(arr[i]);
    }
    a[0]=9999999;
    for(int i=2;i<=n;i++)
    {
        int x=abs(arr[i]-arr[i-1])+arr2[i-1];
        int y=abs(arr[i]-arr[i-2])+arr2[i-2];
        arr2[i]=min(x,y);
        //cout<<arr2[i]<<endl;
    }
    cout<<arr2[n];

}






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

#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VVI vector<vector<ll>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define lb(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define ub(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define pb push_back
#define pf push_front
#define m_p make_pair
#define fi first
#define se second
#define sz size()
#define sort(v) sort(v.begin(),v.end())
ll n;
VI v;
ll dp[100005]; 
ll fun(ll ind)
    {   if(ind>=n)
            return 0;
        if(dp[ind]!=-1)
            return dp[ind];
        return dp[ind]=min(abs(v[ind]-v[ind+1])+fun(ind+1),abs(v[ind]-v[ind+2])+fun(ind+2));
    }
int main()
{   cin>>n;
    v=VI(n+1);
    lf(i,1,n)
    {   cin>>v[i];
    }
    memset(dp,-1,sizof(dp));
    cout<<fun(1)<<endl;    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:18: error: 'sizof' was not declared in this scope
   44 |     memset(dp,-1,sizof(dp));
      |                  ^~~~~
Language: C++

#include <iostream>
using namespace std;
// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

void solve(){
  ll N;cin>>N;
  ll A[N];rep(i, 0, N) cin>>A[i];
  ll dp[N];
  dp[0] = 0;dp[1] = abs(A[1]-A[0]);
  rep(i, 2, N){
    dp[i] = min(dp[i-2]+abs(A[i]-A[i-2]), dp[i-1]+abs(A[i]-A[i-1]));
  }
  cout<<dp[N-1];

}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);

  solve();

  return 0;
}


Compiler output:
a.cc:8:9: error: 'vector' does not name a type
    8 | typedef vector<int> vi;
      |         ^~~~~~
a.cc:13:9: error: 'vector' does not name a type
   13 | typedef vector<vector<ll>> matrix;
      |         ^~~~~~
a.cc:14:9: error: 'vector' does not name a type
   14 | typedef vector<ll> vl;
      |         ^~~~~~
Language: C++

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll i,x;
  vector<ll> v;
  for(i=0;i<n;i++)
  {
    cin>>x;
    v.push_back(x);
  }
  ll dp[n+7];
  for(i=0;i<n+7;i++)
  {
    dp[i]=LLONG_MAX;
  }
  dp[0]=0;
  dp[1]=v[1]-v[0];
  for(i=2;i<n;i++)
  {
    for(ll j=i-1;j>max((ll)0,i-k);j--)
    {
      dp[i]=min(dp[i],dp[j]+abs(v[i]-v[j]));
    }
  }
  cout<<dp[n-1];

 }


Compiler output:
a.cc: In function 'int main()':
a.cc:24:32: error: 'k' was not declared in this scope
   24 |     for(ll j=i-1;j>max((ll)0,i-k);j--)
      |                                ^
Language: C++

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

using namespace std;


int solution_DP_bottom_up(const vector<int>& s)
{
	vector<int> DP(s.size(), 0);
	int s2;
	int s1;
	for (int i = 1; i < (int) s.size(); i++) {
		if (i-2 >= 0)
			s2 = DP[i-2] + abs(s[i-2] - s[i]);
		else
			s2 = numeric_limits<int>::max();
		if (i-1 >= 0)
			s1 = DP[i-1] + abs(s[i-1] - s[i]);
		else
			s1 = numeric_limits<int>::max();
		if (s1 < s2) {
			seq.emplace_back(i + 1);
			DP[i] = s1;
		} else {
			seq.emplace_back(i + 2);
			DP[i] = s2;
		}
	}
	return DP[s.size()-1];
}



int main()
{
	int N;
	cin >> N;
	vector<int> s(N);
	for(int i = 0; i < N; i++) {
		cin >> s[i];
	}
	cout << solution_DP_bottom_up(s) << endl;
}


Compiler output:
a.cc: In function 'int solution_DP_bottom_up(const std::vector<int>&)':
a.cc:17:30: error: 'numeric_limits' was not declared in this scope
   17 |                         s2 = numeric_limits<int>::max();
      |                              ^~~~~~~~~~~~~~
a.cc:17:45: error: expected primary-expression before 'int'
   17 |                         s2 = numeric_limits<int>::max();
      |                                             ^~~
a.cc:21:30: error: 'numeric_limits' was not declared in this scope
   21 |                         s1 = numeric_limits<int>::max();
      |                              ^~~~~~~~~~~~~~
a.cc:21:45: error: expected primary-expression before 'int'
   21 |                         s1 = numeric_limits<int>::max();
      |                                             ^~~
a.cc:23:25: error: 'seq' was not declared in this scope; did you mean '__pstl::execution::v1::seq'?
   23 |                         seq.emplace_back(i + 1);
      |                         ^~~
      |                         __pstl::execution::v1::seq
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/execution_defs.h:42:46: note: '__pstl::execution::v1::seq' declared here
   42 | _GLIBCXX17_INLINE constexpr sequenced_policy seq{};
      |                                              ^~~
a.cc:26:25: error: 'seq' was not declared in this scope; did you mean '__pstl::execution::v1::seq'?
   26 |                         seq.emplace_back(i + 2);
      |                         ^~~
      |                         __pstl::execution::v1::seq
/usr/include/c++/14/pstl/execution_defs.h:42:46: note: '__pstl::execution::v1::seq' declared here
   42 | _GLIBCXX17_INLINE constexpr sequenced_policy seq{};
      |                                              ^~~
Language: Java

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

public class Frogs {
    public static void main(String[] args) {

        FastReader f = new FastReader();
        int n =f.nextInt();
        int k = f.nextInt();
        int heights [] = new int[n];
        for(int i=0;i<n;i++)
            heights[i] =f.nextInt();
        System.out.println(solve(heights,n,k));



    }
    static  int solve(int[] heights,int n,int k)
    {
       int dp[] = new int[n];
       Arrays.fill(dp,Integer.MAX_VALUE);
       dp[0]=0;
       for(int i=0;i<n;i++)
       {
           for(int j=i+1;j<Math.min(i+k+1,n);j++)
           {
               dp[j] =Math.min(dp[j],dp[i]+Math.abs(heights[i]-heights[j]));
           }


       }

       return dp[n-1];

    }



    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;
        }
    }
}


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

/********************************************//**
 ****** Author: Shivam Kejriwal *****************
 ****** Handle: techno_phyle    *****************
 ***********************************************/

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;

#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
typedef pair<double, long> key;

struct comp {
    bool operator()(pair<int,int> p1, pair<int,int> p2) {
        if (p1.first < p2.first) return false;
        if (p2.first < p1.first) return true;
        return p1.second < p2.second;
    };
};
//greater<pair<int,int> , greater<int>>
int main(){
	fastIO;
    #ifndef ONLINE_JUDGE
        freopen("../input.txt", "r", stdin)
        freopen("../output.txt","w",stdout)	
    #endif
	int n;
	cin >> n;
	int a[n+1];
	for(int i=1;i<=n;i++) cin >> a[i];
	int dp[n+1];
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i=3;i<=n;i++){
		dp[i] = min(abs(a[i] - a[i-1]) + dp[i-1] , abs(a[i] - a[i-2]) + dp[i-2]);
	}
	cout << dp[n] << endl;
	return 0;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:44: error: expected ';' before 'freopen'
   35 |         freopen("../input.txt", "r", stdin)
      |                                            ^
      |                                            ;
   36 |         freopen("../output.txt","w",stdout)
      |         ~~~~~~~                             
a.cc:39:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   39 |         cin >> n;
      |                ^
      |                yn
a.cc:41:38: error: 'a' was not declared in this scope
   41 |         for(int i=1;i<=n;i++) cin >> a[i];
      |                                      ^
a.cc:43:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   43 |         dp[1] = 0;
      |         ^~
      |         dup
a.cc:44:21: error: 'a' was not declared in this scope
   44 |         dp[2] = abs(a[2] - a[1]);
      |                     ^
Language: C++

#define ll long long int
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
const ll INF = long long(1000) * 1000 * 1000 * 1000 * 1000 * 1000;
int main() {
	ll n, k;
	cin >> n >> k;
	vector <ll> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector <ll> dp(n, INF);
	dp[0] = 0; dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i-j>=0) dp[i] = min(dp[i - j] + abs(h[i - j] - h[i]), dp[i]);
		}
	}
	cout << dp[n - 1];
}

Compiler output:
a.cc:8:16: error: expected primary-expression before 'long'
    8 | const ll INF = long long(1000) * 1000 * 1000 * 1000 * 1000 * 1000;
      |                ^~~~
Language: C++

#define ll long long int
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
const ll INF = ll(1000) * 1000 * 1000 * 1000 * 1000 * 1000;
int main() {
	ll n, k;
	cin >> n >> k;
	vector <ll> h(n);
	for (int i = 0; i < n; i++) cin >> h[i];
	vector <ll> dp(n, INF);
	dp[0] = 0; dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i-j>=0) dp[i] = min(dp[i - j] + abs(h[i - j] - h[i]), dp[i]);
		}
	}
	cout << dp[n - 1];
}

Compiler output:
a.cc:1:12: error: expected primary-expression before 'long'
    1 | #define ll long long int
      |            ^~~~
a.cc:8:16: note: in expansion of macro 'll'
    8 | const ll INF = ll(1000) * 1000 * 1000 * 1000 * 1000 * 1000;
      |                ^~
Language: C++

#inlcude <bits/stdc++.h>

using namespace std;

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

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inlcude; did you mean #include?
    1 | #inlcude <bits/stdc++.h>
      |  ^~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:8:3: error: 'cin' was not declared in this scope
    8 |   cin >> n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inlcude <bits/stdc++.h>
a.cc:13:11: error: 'abs' was not declared in this scope
   13 |   dp[1] = abs(a[0]-a[1]);
      |           ^~~
a.cc:20:17: error: 'min' was not declared in this scope; did you mean 'main'?
   20 |         dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
      |                 ^~~
      |                 main
Language: Java

import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    
    if (n == 0)
      System.out.println("0");
    
    if (n == 1)
      System.out.println(h[0]);
    
    if( n == 2)
      System.out.println(Math.abs(h[1]-h[0]);
    
    int totalCost = 0;
    int[] cost = new int[n];
    cost[0] = 0;
    cost[1] = Math.abs(h[1] - h[0]);
    for (int i = 2; i < n; i++) {
      int cost1 = cost[i-1] + Math.abs(h[i] - h[i-1]);
      int cost2 = cost[i-2] + Math.abs(h[i-1] - h[i-2]);
      cost[i] = Math.min(cost1, cost2);
    }
    
    System.out.println(cost[n-1]);
  }
}

Compiler output:
Main.java:20: error: ')' or ',' expected
      System.out.println(Math.abs(h[1]-h[0]);
                                            ^
1 error
Language: Java

import java.util.*;
 
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    
    int totalCost = 0, i = n-1;
    while(i > 1) {
      int cost1 = Math.abs(h[i] - h[i-1]);
      int cost2 = Math.abs(h[i] - h[i-2]);
      
      if(cost1 < cost2){
        totalCost += cost1;
        i--;
      } else {
        totalCost += cost2;
        i -= 2;
      }
    }
    
    if(i == 1)
      totalCost = Math.abs(h[1] - h[0]);
    
    return totalCost;
  }
}

Compiler output:
Main.java:30: error: incompatible types: unexpected return value
    return totalCost;
           ^
1 error
Language: Java

import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    
    for(int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }
    
    int totalCost = 0, i = n-1;
    while(i > 1) {
      int cost1 = Math.abs(h[i] - h[i-1]);
      int cost2 = Math.abs(h[i] - h[i-2]);
      
      if(cost1 < cost2){
        totalCost += cost1;
        i--;
      } else {
        totalCost += cost2;
        i -= 2;
      }
    }
    
    return totalCost;
  }
}

Compiler output:
Main.java:27: error: incompatible types: unexpected return value
    return totalCost;
           ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
vector<vector<int>>dp; // dp(i,j) ways when i children and ith children get j candies
vector<int>v;
 
int ways(int n,int candies){
    //cout<< n<<" "<<candies<<"\n";
    //int q;cin>>q;
    if(dp[n][candies]  != -1){
        return dp[n][candies];
    }
    int ans=0;
    ans = (ways(n,candies-1) + ways(n-1,candies))%mod;
    if(candies>=(v[n]+1)){
        ans -= ways(n-1,candies-v[n]-1);
        ans %=mod;
    }
    return dp[n][candies] =ans;
 
}
 
void solve(){
    int n,k;cin>>n>>k;
    dp.resize(n,vector<int>(k+1,-1));
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int x = min(v[0],k);
    for(int i=0;i<=x;i++){
        dp[0][i]=1;
    }
    for(int i=x+1;i<=k;i++){
        dp[0][i]=0;
    }
    for(int i=0;i<n;i++){
        dp[i][0]=1;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod
            if(j>= (v[i]+1)){
                dp[i][j] -= dp[i-1][j-v[i]-1]%mod;
            }
        }
    }
    cout<<dp[n-1][k]<<"\n";
 
 
}
 
int main(){
//    cin.tie(0);
//    cout.tie(0);
//    cin.sync_with_stdio(0);
//    cout.sync_with_stdio(0);
 
    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){
 
        solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:43:13: error: expected ';' before 'if'
   43 |             if(j>= (v[i]+1)){
      |             ^~
Language: Java

import java.util.*;
public class afrog1{
    public static void main(String[] args) {
        Scanner ob=new Scanner(System.in);
        int n=ob.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=ob.nextInt();
        }
        int arr[]=new int[n];
        arr[0]=0;
        arr[1]=Math.abs(a[1]-a[0]);
        for(int i=2;i<n;i++){
            arr[i]=Math.min(arr[i-2]+Math.abs(a[i]-a[i-2]),arr[i-1]+Math.abs(a[i]-a[i-1]));
        }
        System.out.println(arr[n-1]);
        ob.close();
    }
}

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

#include <bits/stdc++.h>
using namespace std;
const int INF=le9+5;
int main() {

    int n;
    cin>>n;
  vector<int>h(n)
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
vector<int>sol(n,INF)


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

        
    }
    cout<<sol[n-1];
  




	return 0;
}


Compiler output:
a.cc:3:15: error: 'le9' was not declared in this scope
    3 | const int INF=le9+5;
      |               ^~~
a.cc: In function 'int main()':
a.cc:9:5: error: expected ',' or ';' before 'for'
    9 |     for(int i=0;i<n;i++){
      |     ^~~
a.cc:9:17: error: 'i' was not declared in this scope
    9 |     for(int i=0;i<n;i++){
      |                 ^
a.cc:15:2: error: expected ',' or ';' before 'sol'
   15 |  sol[0]=0;
      |  ^~~
Language: C++

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

Compiler output:
a.cc:3:25: error: 'n' has not been declared
    3 | int solve(vector<int>ar,n){
      |                         ^
a.cc: In function 'int solve(std::vector<int>, int)':
a.cc:4:17: error: 'n' was not declared in this scope; did you mean 'yn'?
    4 |   vector<int>dp(n+1);
      |                 ^
      |                 yn
Language: C++

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

int solve(vector<int> h)
{
  int n=h.size();
  vector<int> t(n,INT_MAX);
  t[0]=0;
  for(int i=0;i<n-1;++i)
  {
      if(i!=n-2)
      {
        t[i+2]=min(t[i]+abs(h[i]-h[i+2]), t[i+2]);
      }

       t[i+1]=min(t[i]+abs(h[i]-h[i+1]), t[i+1]);
  }
  return t[n-1];  
}

int main(){
  int n;
  cin>>n;
  vector<int> h;
  for(int i=0;i<n;++i){
    int ele ;
    cin>>ele;
    h.pb(ele);
  }
  cout<<solve(h)<<"\n";
return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #incldude; did you mean #include?
    1 | #incldude<bits/stdc++.h>
      |  ^~~~~~~~
      |  include
a.cc:6:11: error: 'vector' was not declared in this scope
    6 | int solve(vector<int> h)
      |           ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #incldude<bits/stdc++.h>
a.cc:6:18: error: expected primary-expression before 'int'
    6 | int solve(vector<int> h)
      |                  ^~~
a.cc: In function 'int main()':
a.cc:25:3: error: 'cin' was not declared in this scope
   25 |   cin>>n;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #incldude<bits/stdc++.h>
a.cc:26:3: error: 'vector' was not declared in this scope
   26 |   vector<int> h;
      |   ^~~~~~
a.cc:26:3: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:26:10: error: expected primary-expression before 'int'
   26 |   vector<int> h;
      |          ^~~
a.cc:30:5: error: 'h' was not declared in this scope
   30 |     h.pb(ele);
      |     ^
a.cc:32:3: error: 'cout' was not declared in this scope
   32 |   cout<<solve(h)<<"\n";
      |   ^~~~
a.cc:32:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:15: error: 'h' was not declared in this scope
   32 |   cout<<solve(h)<<"\n";
      |               ^
a.cc:32:16: error: 'solve' cannot be used as a function
   32 |   cout<<solve(h)<<"\n";
      |                ^
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main()
{
   int n,i,j;
   cin>>n;
   int h[n],dp[n];
   memset(dp,INT_MAX,n);
   for(i=0;i<n;i++)
   {
     cin>>h[i];
   }
   dp[0] = 0;
  for(i=0;i<n;i++)
  {
    for(j=i+1;j<n;j++)
    {
      dp[j] = min(dp[j],dp[i]+fabs(h[i]-h[j]));
    }
  }
  cout<<dp[n-1];
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:18: error: no matching function for call to 'min(int&, __gnu_cxx::__enable_if<true, double>::__type)'
   20 |       dp[j] = min(dp[j],dp[i]+fabs(h[i]-h[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:20:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__enable_if<true, double>::__type' {aka 'double'})
   20 |       dp[j] = min(dp[j],dp[i]+fabs(h[i]-h[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:20:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |       dp[j] = min(dp[j],dp[i]+fabs(h[i]-h[j]));
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long 
const long long inf=1e9;
int main()
{
	int n;
  cin>>n;
  int arr[n+1];
  for(int i=1;i<=n;i++)cin>>arr[i];
  
  int dp[n+1];
  dp[1]=0;
  dp[2]=abs(arr[2]-arr[1]);
  for(int i=3;i<=n;i++){
    int option1=dp[i-1] + abs(arr[i]-arr[i-1]);
    int option2=dp[i-2] + abs(arr[i]-arr[i-2]);
    dp[i]=min(option1,option2);
  }
  cout<<dp[n];
  return 0;
}
  
  
  

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:25: error: expected ',' or ';' before ':' token
   10 |     vector<int> arr(n+1):
      |                         ^
a.cc:11:21: error: 'i' was not declared in this scope
   11 |     for (int i = 1; i <= n+; i++) {
      |                     ^
a.cc:11:28: error: expected primary-expression before ';' token
   11 |     for (int i = 1; i <= n+; i++) {
      |                            ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:15: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   11 |     memset(0, arr, sizeof(arr));
      |               ^~~
      |               |
      |               int*
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:37: note:   initializing argument 2 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                                 ~~~~^~~
a.cc:12:28: error: expected primary-expression before ';' token
   12 |     for (int i = 1; i <= n+; i++) {
      |                            ^
a.cc:16:15: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   16 |     memset(0, dp, sizeof(dp));
      |               ^~
      |               |
      |               int*
/usr/include/string.h:61:37: note:   initializing argument 2 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                                 ~~~~^~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:19:1: error: expected initializer before 'for'
   19 | for(int i=0;i<n;i++)
      | ^~~
a.cc:19:13: error: 'i' was not declared in this scope
   19 | for(int i=0;i<n;i++)
      |             ^
a.cc:23:22: error: 'arr' was not declared in this scope
   23 | cout<<getMinimumCost(arr,0,n)<<endl;
      |                      ^~~
Language: Java

import java.util.*;
import java.uitl.function.*;
import java.util.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] H = new int[N];
		for(int i = 0; i < N; i++) {
			H[i] = s.nextInt();
		}
		
		int[] result = new int[N+1];
		result[0] = 0;
		result[1] = Math.abs(H[1] - H[0]);
		for(int i = 2; i < N; i++) {
			result[i] = Math.min(result[i - 1] + Math.abs(H[i] - H[i - 1]), result[i - 2] + Math.abs(H[i] - H[i - 2]));
		}
		System.out.println(result[N-1]);
    }
}

Compiler output:
Main.java:2: error: package java.uitl.function does not exist
import java.uitl.function.*;
^
Main.java:3: error: package java.util.math does not exist
import java.util.math.*;
^
2 errors
Language: C++

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

 

int dp[100001];

int minCost(vector<int> ar,int i){
    if(i >= ar.size()-1){
        return 0;
    }
    if(dp[i]!=-1){
        return dp[i];
    }
    int minC = LLONG_MAX;
    minC=min(minC,minCost(ar,i+1)+abs(ar[i]-ar[i+1]));
    minC=min(minC,minCost(ar,i+2)+abs(ar[i]-ar[i+2]));
    return dp[i]=minC;
}

 
int goEasy( int i, vector<int> &v ){
    int n = v.size();
    if( i == n-1 )return 0;
    if( dp[i] != -1 )return dp[i];
    int ans = LLONG_MAX;
    for( int j = i+1; j <= n-1 && j <= i+2; j++ ){
        ans = min(ans, goEasy(j,v) + abs(v[i] - v[j]));
    }
    return dp[i] = ans;
}

int32_t main(){
    int t;
    cin>>t;
    memset(dp,-1,sizeof(dp));
    vector<int> h(t);
    for(int i=0;i<t;i++){
        cin>>h[i];
    }
    cout<<miinCost(h,0)<<endl;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:42:11: error: 'miinCost' was not declared in this scope; did you mean 'minCost'?
   42 |     cout<<miinCost(h,0)<<endl;
      |           ^~~~~~~~
      |           minCost
Language: C++

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

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin >> n;
      |         ^~~
a.cc:4:9: error: 'vector' was not declared in this scope
    4 |         vector<int> h(n);
      |         ^~~~~~
a.cc:4:16: error: expected primary-expression before 'int'
    4 |         vector<int> h(n);
      |                ^~~
a.cc:5:13: error: 'i' was not declared in this scope
    5 |         rep(i, n) {
      |             ^
a.cc:5:9: error: 'rep' was not declared in this scope
    5 |         rep(i, n) {
      |         ^~~
a.cc:10:21: error: 'h' was not declared in this scope
   10 |         dp[1] = abs(h[1] - h[0]);
      |                     ^
a.cc:10:17: error: 'abs' was not declared in this scope
   10 |         dp[1] = abs(h[1] - h[0]);
      |                 ^~~
a.cc:14:25: error: 'min' was not declared in this scope; did you mean 'main'?
   14 |                 dp[i] = min(step1, step2);
      |                         ^~~
      |                         main
a.cc:16:9: error: 'cout' was not declared in this scope
   16 |         cout << dp[n - 1] << endl;
      |         ^~~~
a.cc:16:30: error: 'endl' was not declared in this scope
   16 |         cout << dp[n - 1] << endl;
      |                              ^~~~
Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define fo(i,a,b) for(i=a; i<b; ++i)
#define foe(i,a,b) for(i=a; i<=b; ++i)
#define rep(i,n) for(i=1;i<=n;i++)
#define all(a) a.begin(), a.end()
#define pb push_back
#define ins insert
#define mk make_pair
#define f first
#define s second
#define mod 1000000007
#define vi vector<int>
#define vll	vector<ll>
#define vvi	vector<vi>
#define pii	pair<int,int> //typedef pair<int,int> pii;
#define pll	pair<ll , ll>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
//mp.reserve(4096);
//mp.max_load_factor(0.25);

int main()
{
	ll n,k,i,j;
    cin>>n>>k;
    int h[n+1];
    fo(i,0,n){
        cin>>h[i+1];
    }
    vector<ll>dp (n+1,INF);
    dp[1] = 0;
    foe(i,1,n){
        foe(j,1,k){
            if (i+j<=n)
            {
                dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]));
            }
        }
    }
    cout<<dp[n]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:23: error: 'INF' was not declared in this scope
   42 |     vector<ll>dp (n+1,INF);
      |                       ^~~
Language: C++

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    foe(i,1,n)
    cin>>a[i];
    int pos=1;
    int sum=a[1];
    while(pos!=n)
    {
        sum+=min(a[pos+1]-a[pos],a[pos+2]-a[pos]);
        if(a[pos+1]-a[pos]<a[pos+2]-a[pos])
        pos++;
        else
        pos=pos+2;
        
    }
    cout<<pos<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'i' was not declared in this scope
   29 |     foe(i,1,n)
      |         ^
a.cc:12:24: note: in definition of macro 'foe'
   12 | #define foe(i,a,b) for(i=a;i<=b;i++)
      |                        ^