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

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <bitset>  
using namespace std;

//======================================================
#define for1(i,n)  for (int i = 0; i < (int)(n); ++i)
#define for2(i,n)  for (int i = 1; i <=(int)(n); ++i)
#define forr1(i,n)  for (int i = n - 1 ;i <= 0; --i)
#define forr2(i,n)  for (int i = n  ;i < 0; --i)
#define all(v)	   ((v).begin()), ((v).end())
#define allr(v)	   ((v).rbegin()), ((v).rend())
#define clr(v,d)   memset(v, d, sizeof(v))
#define ull        unsigned long long
#define MP(a,b)	   make_pair(a,b)
#define S          second
#define F          first
#define PI         3.14159265359
#define ll         long long
#define sz(v)	   v.size()
#define pb         push_back
#define pp         pop_back
#define bgn        begin
#define N          100000+5
#define	MOD        1e9+7
#define inf        1e18
//======================================================
int dx[] = { 0,  0, 1, -1 ,  1,  -1,  1,  -1 };
int dy[] = { 1, -1, 0,  0 , -1,   1,  1,  -1 };
//======================================================
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ull a, ull b, ull ret = 1LL) {
	while (b--) ret = (ret * a);
	return ret;
}
//======================================================





int main()
{

	int n , k;
	cin >> n >> k;
	vector<int> v(n + 1);
	for (size_t i = 1; i <= n; i++)
	{
		cin >> v[i];
	}
	vector<int> dp(n + 1 , INT_MAX);

	dp[1] = 0;
	dp[2] = abs(v[2] - v[1]);
	for (size_t i1 = 3; i1 <=n; i1++)
	{

		for (size_t i2 = 1; i2 <=k; i2++)
		{
			int secIndex = i1 - i2;
			if (secIndex >= 1 && secIndex <= i1- 1)
			{
				dp[i1] = min(dp[secIndex] + abs(v[i1] - v[secIndex]), dp[i1]);

			}
		}
	}
	cout << dp[n];



}




Compiler output:
a.cc: In function 'int main()':
a.cc:62:32: error: 'INT_MAX' was not declared in this scope
   62 |         vector<int> dp(n + 1 , INT_MAX);
      |                                ^~~~~~~
a.cc:13:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   12 | #include <bitset>
  +++ |+#include <climits>
   13 | using namespace std;
Language: Java


import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;


public class b {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt();
		int k =sc.nextInt();
		long[]a = input(n);
		long[] dp = new long[n];
		for(int i =1 ; i < n ;i++) {
			long max = 0 ;
			for(int j =1  ; j<=k && i-j>=0;j++ ) {
				long temp = Math.abs(a[i]-a[i-j]) + dp[i-j];
				max = Math.min(temp, max);
			}
			dp[i]=max  ;
		}
		System.out.println(dp[n-1]);
	}
	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

}


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

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
ll dp[205005]={0};
ll ans,n,k;
ll a[205005]={0};
int main()
{
	ll i,j,x,y,t;
	cin>>n>>k;
	for(i=1+k;i<=n+k;i++)
	cin>>a[i];
	for(i=0;i<=k;i++)
	{
		a[i]=a[1+k];
	}
	for(i=2+k;i<=n+k;i++)
	{
		//dp[i]=2*100000*10005;
		for(j=1;j<=k;j++)
		{
			t=dp[i];
			dp[i]=min(dp[i-1]+50000;,(dp[i-j]+abs(a[i]-a[i-j])));
		}
	}
	cout<<dp[n+k];
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:48: error: expected ')' before ';' token
   25 |                         dp[i]=min(dp[i-1]+50000;,(dp[i-j]+abs(a[i]-a[i-j])));
      |                                  ~             ^
      |                                                )
a.cc:25:49: error: expected primary-expression before ',' token
   25 |                         dp[i]=min(dp[i-1]+50000;,(dp[i-j]+abs(a[i]-a[i-j])));
      |                                                 ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define pb push_back
#define P pair<int,int>
using namespace std;
using ll = long long;
// using mod = int 1000000000 + 7;
void self_max(int &a,int b){
	a = max(a,b);
}

void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
	int n,k; cin >> n >> k;
	vector<int> dp(n,0);
	int arr[n];
	rep(i,n){
		cin >> arr[i];
	}

	dp[0] = 0;
	for(int i=1;i<n;i++){
		int local = INT_MAX;
		for(int j = k;j>0 && i-j>=0 ;--j){
			self_min(local,dp[j] + abs(arr[j] - arr[i]));
		}
		dp[j] = local;
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:30:20: error: 'j' was not declared in this scope
   30 |                 dp[j] = local;
      |                    ^
Language: Java

import java.util.*;
public class Main
{
  public static void main(String[] args )
  {
    Scanner scn = new Scanner(System.in) ;
    
    int n = scn.nextInt() ;
    
    int k = scn.nextInt() ;
    
    int[] arr =new int[n] ;
    
    for(int i =0 ; i < n; i++ ) arr[i] = scn.nextInt() ;
    
    
    if( n== 1 )
    {
     System.out.print(0) ; 
    }
    else{
    long[] dp = new long[n];
    
      dp[0] =  0 ; 
      //dp[1] =  (long)Math.abs(arr[1] - arr[0] ) ;
      
      for(int i =1 ; i < n; i++ )
      {
        long ans =  Long.MAX_VALUE ;
          
        
        for(int j = 1  ; j <= k ; j++ )
        {
         if( i-j < 0 ) break ;
          
          else{
           
            ans = Math.min(dp[i-j] + Math.abs(arr[i] - arr[j] ,ans ) ;
            
            
            }
          
        }
        dp[i] = ans  ;
        
        
     }
      
      System.out.print(dp[n-1]) ;
    
    }
    
    
    
  }
  
  
}


Compiler output:
Main.java:38: error: ')' or ',' expected
            ans = Math.min(dp[i-j] + Math.abs(arr[i] - arr[j] ,ans ) ;
                                                                    ^
1 error
Language: Java


import java.util.Scanner;

public class Frog2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), k = sc.nextInt();

        int[] num = new int[n];
        for (int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }

        int[] dp = new int[n];
        dp[1] = Math.abs(num[0] - num[1]);

        for (int i = 2; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 1; j <= k; j++) {
                if (i >= j)
                    dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(num[i] - num[i - j]));
            }

        }

        System.out.println(dp[n - 1]);


    }
}


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

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int recur(int a[1000000],ll int n,ll int i,ll int j,ll int sum,ll int k)
{

        int ans=INT_MAX;

 ll int v;
    sum=sum+(abs(a[i]-a[j]));
    if(j==n)
    {

        return sum;
    }
    i=j;
    for(int l=1;l<=k;l++)
    {
        if(i+l<=n)
         {

        v=recur(a,n,i,i+l,sum,k);

        ans=min(ans,v);
      }
        else
            break;
    }
        return ans;
}
int main()
{

   ll int n,k;
    cin>>n>>k;
    int a[100000];
    for(llint i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    cout<<recur(a,n,1,1,0,k);
    return 0;
}


Compiler output:
a.cc: In function 'int recur(int*, long long int, long long int, long long int, long long int, long long int)':
a.cc:24:16: error: no matching function for call to 'min(int&, long long int&)'
   24 |         ans=min(ans,v);
      |             ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:24:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |         ans=min(ans,v);
      |             ~~~^~~~~~~
/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:24:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |         ans=min(ans,v);
      |             ~~~^~~~~~~
a.cc: In function 'int main()':
a.cc:37:9: error: 'llint' was not declared in this scope; did you mean 'lrint'?
   37 |     for(llint i=1;i<=n;i++)
      |         ^~~~~
      |         lrint
a.cc:37:19: error: 'i' was not declared in this scope
   37 |     for(llint i=1;i<=n;i++)
      |                   ^
Language: C++

#include<iostream>
#include<cmath>
 
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
 
  int dp[n];
  dp[0]=0;
  for(int i=1;i<n;i++){
    dp[i]=INT_MAX;
    
    for(int j=max(0,i-k);j<i;j++){
      int cost=dp[j]+abs(h[i]-h[j]);
      dp[i]=min(dp[i],cost);
    }
  }
 
  cout<<dp[n-1]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: 'INT_MAX' was not declared in this scope
   16 |     dp[i]=INT_MAX;
      |           ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<cmath>
  +++ |+#include <climits>
    3 | 
a.cc:18:23: error: 'k' was not declared in this scope
   18 |     for(int j=max(0,i-k);j<i;j++){
      |                       ^
Language: Java

import java.util.Scanner;

public class Frog2 {

	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int h[] = new int[n+1];
		for(int i=1;i<=n;i++) {
			h[i] = scan.nextInt();
		}
		
		int cost[] = new int[n+1];
		cost[1] = 0;
		
		for(int i=2;i<=n;i++) {
			int min = Integer.MAX_VALUE;
			for(int j=1;j<=k;j++) {
				if(i - j <=0) {
					break;
				}
				
				min = Math.min(min, Math.abs(h[i]-h[i-j]) + cost[i-j]);
				
			}
			
			cost[i] = min;
			
		}
		
		System.out.println(cost[n]);
	}
}


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

#include<bits/stdc++.h>
using namespace std;
int dp[1000010];
const int inf=0x3f3f3f3f;
int main()
{
	int n,k;
	cin>>n>>k;
	dp[1]=dp[0]=0;
	for(int i=1;i<n;i++)cin>>a[i];
	for(int i=2;i<n;i++)dp[i]=inf;
	for(int i=2;i<n;i++){
		for(int j=i-1;j>=max(111,i-k);j--) {
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n];
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:10:34: error: 'a' was not declared in this scope
   10 |         for(int i=1;i<n;i++)cin>>a[i];
      |                                  ^
a.cc:14:51: error: 'a' was not declared in this scope
   14 |                         dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
      |                                                   ^
Language: C++

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

#define deb(x) cout << #x << "=" << x << endl
#define ll long long

const int mod = 1000000007;
const int N = 3e5, M = N;

void solve() {
	ll a, b, n, k;
	ll input;
	cin >> n >> k;
	vector<ll> arr(n);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	ll dp[1e5 + 1];
	if (k == 0 || k > n)
	{
		cout << "0" << endl;
		return;
	}
	dp[0] = 0;
	for (ll i = 1; i < n; i++)
	{
		dp[i] = INT_MAX;
		for (ll j = i - 1; j >= i - k && j >= 0; j--)
		{
			dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
		}
	}
	cout << dp[n - 1] << endl;













}



int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:17:19: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
   17 |         ll dp[1e5 + 1];
      |               ~~~~^~~
a.cc:17:19: error: could not convert '(1.0e+5 + (double)1)' from 'double' to 'long unsigned int'
   17 |         ll dp[1e5 + 1];
      |               ~~~~^~~
      |                   |
      |                   double
a.cc:17:19: error: size of array 'dp' has non-integral type 'double'
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	scanf("%d %d",&n,&x);
	int a[n];
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	long long b[n];
	for(int i=2;i<n;i++)
	{
		b[i]=0x3f3f3f3f;
	}
	b[0]=0;
	b[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		for(int t=1;t<=x;t++)
		{
			if(i-t<0)break;
			b[i]=min(b[i-t]+abs(a[i]-a[i-t]),b[i]);
		}
	}
	printf("%ll
	d",b[n-1]);
	return 0;
}

Compiler output:
a.cc:27:16: warning: missing terminating " character
   27 |         printf("%ll
      |                ^
a.cc:27:16: error: missing terminating " character
   27 |         printf("%ll
      |                ^~~~
a.cc:28:10: warning: missing terminating " character
   28 |         d",b[n-1]);
      |          ^
a.cc:28:10: error: missing terminating " character
   28 |         d",b[n-1]);
      |          ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:28:9: error: 'd' was not declared in this scope
   28 |         d",b[n-1]);
      |         ^
Language: C

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

int main(){
    int n , k;
    cin>>n>>k;
    long long int minm;
    int arr[1000000];
    for(int i =0;i<n;i++)
        cin>>arr[i];
    long long int dp[1000000] ;
    dp[0]=0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i=2;i<n;i++){
        minm = 1000000000;
        for(int j = 1;j<=k;j++){
            if(i-j>=0)
                minm = min(minm,dp[i-j]+abs(arr[i-j]-arr[i]));
        }
        dp[i]=minm;
    }
    cout<<dp[n-1]<<endl;
}


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

#include<iostream>
#include<vector>
using namespace std;
const int INF = 1e9+7;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:25:52: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   25 |                                         dp[i] = min(dp[i-j])+abs(h[i] - h[i-j])),dp[i]);
      |                                                 ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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
Language: C++

/*Author- Soumak Poddar*/

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

#define ll long long int
#define um unordered_map
#define mp make_pair
#define pb push_back

void solve();
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);

   #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("error.txt", "w", stderr);
      freopen("output.txt", "w", stdout);
   #endif
   
   int t=1;
   // cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"Time Taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
   return 0;
}
void solve()
{
   int n,k;
   cin>>n>>k;
   if(k>n)
   {
      cout<<"0";
      exit(0);
   }
   int h[n];
   for(int i=0;i<n;i++)
      cin>>h[i];
   int dp[n+1];
   memset(dp,INT_MAX,sizeof dp)
   dp[1]=0;
   for(int i=2;i<n;i++)
   {
      dp[i]=INT_MAX;
      for(int j=i-1;j>=max(0,i-k);j--)
      {
         dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
      }
   }
   cout<<dp[n];
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:47:32: error: expected ';' before 'dp'
   47 |    memset(dp,INT_MAX,sizeof dp)
      |                                ^
      |                                ;
   48 |    dp[1]=0;
      |    ~~
Language: Java

import java.util.*;

public class test {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int n = s.nextInt();
    int k = s.nextInt();
    int[] h = new int[n];
    for (int i=0;i<n;i++) {
      h[i] = s.nextInt();
    }
    int[] dp = new int[n];
    Arrays.fill(dp, 1000000000+5);
    dp[0] = 0;
    for (int i=0;i<n;i++) {
      for (int j=i+1; j<i+k+1; j++) {
        if (j<n) {
          dp[j] = Math.min(dp[j], dp[i]+Math.abs(h[i]-h[j]));
        }
      }
    }
    System.out.println(dp[n-1]);
  }
}


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

#include <iostream>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    int nums[n];
    for(int i=0;i<n;i++){
       int h;
       cin>>h;
       nums[i] = h;
    }
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(nums[0]-nums[1]);
    if(n>2){
    for(int i=2;i<k;i++){
        int val=INT_MAX;
        for(int j=0;j<i;j++){
            val = min(val,dp[j]+abs(nums[j]-nums[i]));
        }
        dp[i] = val;
    }
   for(int i=k;i<n;i++){
        int value = INT_MAX;
    for(int j=1;j<=k;j++){
        value = min(value,dp[i-j]+abs(nums[i-j]-nums[i]));
    }
   dp[i] = value;
   }
    }
   cout<<dp[n-1];

}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:17: error: 'INT_MAX' was not declared in this scope
   20 |         int val=INT_MAX;
      |                 ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | 
a.cc:27:21: error: 'INT_MAX' was not declared in this scope
   27 |         int value = INT_MAX;
      |                     ^~~~~~~
a.cc:27:21: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: Java

public class Main {
	public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    String firstLine = scanner.nextLine();
    String[] firstArgs = firstLine.split(" ");
    int N = Integer.parseInt(firstArgs[0]);
    int K = Integer.parseInt(firstArgs[1]);

    String secondLine = scanner.nextLine();
    String[] secondArgs = secondLine.split(" ");
    int[] H = new int[N];
    for (int i = 0; i < N; i++) {
      H[i] = Integer.parseInt(secondArgs[i]);
    }

    int[] minCumulativeCosts = new int[N];
    for (int i = 0; i < N; i++) {
      if (i == 0) {
        minCumulativeCosts[i] = 0;
        continue;
      }

      int minCost = Integer.MAX_VALUE;
      for (int j = Math.max(i - K, 0); j < i; j++) {
        int costBetweenNodes = Math.abs(H[i] - H[j]);
        int cumulativeCost = minCumulativeCosts[j];
        int totalCost = costBetweenNodes + cumulativeCost;
        minCost = Math.min(minCost, totalCost);
      }
      minCumulativeCosts[i] = minCost;
    }

    System.out.println(minCumulativeCosts[N - 1]);
  }
}

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

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    int stones[n+1],memo[n+1]; 
    for(int i = 1 ; i <= n ; i++) {
        cin >> stones[i];
        memo[i] = 1e7;  
    }

    memo[0] = 0;
    memo[1] = 0;
    for(int i =1; i<= n;i++){
        for(int j = 1; j <= k ; j++){
            if (i-j > 0){
                memo[i] = min(memo[i], abs(stones[i]-stones[i-j]) + memo[i-j]);
            }
            else{
                break
            }

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

}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:22: error: expected ';' before '}' token
   24 |                 break
      |                      ^
      |                      ;
   25 |             }
      |             ~
Language: Java

public class Main{
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N, K;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        K = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            int min= Integer.MAX_VALUE;
            for(int j = 1 ; j <= K  && (i-j)>=0; ++j){
                min = Math.min(dp[i-j]+Math.abs(stones[i]-stones[i-j]),
                    min);
            }
            dp[i] = min;
        }
    }
}

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

public class Frog2 {
    static int[]dp = new int[100000];
    static int[]stones = new int[100000];
    static int N, K;
    public static void main(String[]args){
        Scanner in = new Scanner(System.in);
        N = in.nextInt();
        K = in.nextInt();
        for(int i = 0 ; i < N ; ++i)
            stones[i] = in.nextInt();
        solve();
        System.out.println(dp[N-1]);
    }
    public static void solve(){
        dp[0] = 0;
        dp[1] = Math.abs(stones[1]-stones[0]);
        for(int i = 2 ; i < N ; ++i){
            int min= Integer.MAX_VALUE;
            for(int j = 1 ; j <= K  && (i-j)>=0; ++j){
                min = Math.min(dp[i-j]+Math.abs(stones[i]-stones[i-j]),
                    min);
            }
            dp[i] = min;
        }
    }
}

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

import java.util.Scanner;
import java.lang.Math;

class Main{
  
  	static int solve(int n, int k, int[] arr){
    	int[] dp = new int[n];
      	dp[0] = arr[0];
        dp[1] = arr[1];
      
      	for(int i = 2; i < n; i++){
        	int min = dp[i-1] + Math.abs(arr[i-1], arr[i]);
          
          	for(int j = 1; j <= k; j++){
            	if(i - j < 0)
                  	break;
              	h = dp[i-j] + Math.abs(arr[i], arr[i-j]);
              	min = (h <= min) ? h : min;
            }
          	dp[i] = min;
        }
      
      	return dp[n-1];
    }

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

Compiler output:
Main.java:12: error: no suitable method found for abs(int,int)
        	int min = dp[i-1] + Math.abs(arr[i-1], arr[i]);
        	                        ^
    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)
Main.java:17: error: cannot find symbol
              	h = dp[i-j] + Math.abs(arr[i], arr[i-j]);
              	^
  symbol:   variable h
  location: class Main
Main.java:17: error: no suitable method found for abs(int,int)
              	h = dp[i-j] + Math.abs(arr[i], arr[i-j]);
              	                  ^
    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)
Main.java:18: error: cannot find symbol
              	min = (h <= min) ? h : min;
              	       ^
  symbol:   variable h
  location: class Main
Main.java:18: error: cannot find symbol
              	min = (h <= min) ? h : min;
              	                   ^
  symbol:   variable h
  location: class Main
Main.java:29: error: cannot find symbol
      	int k = scanner.nextInt(); scanner.nextLint();
      	                                  ^
  symbol:   method nextLint()
  location: variable scanner of type Scanner
6 errors
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.14159265359
#define all(v) v.begin(),v.end()
#define vil vector<long int>
#define vi vector<int> 
#define pb(x) push_back(x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define INF 1000000007 
#define MOD 998244353
void solve(ll T){
    ll n,k;
    cin>>n>>k;
    vil a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
  ll dp[n+1];
  dp[0]=0;
  dp[1]=0;
  dp[2]=abs(a[1]-a[0]);
  for(int i=3;i<=n;i++){
      dp[i]=INF;
      for(int j=1;j<=k&&j<i;j++){
          dp[i]=min(dp[i],dp[i-j]+abs(a[i-1]-a[i-1-j]));
      }
  }
cout<<dp[n]<<endl;
   return;
}
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
ll T;
T=1;
//cin>>T;
while(T--){
   solve(T);
return 0;
}
}#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.14159265359
#define all(v) v.begin(),v.end()
#define vil vector<long int>
#define vi vector<int> 
#define pb(x) push_back(x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ub upper_bound
#define lb lower_bound
#define INF 1000000007 
#define MOD 998244353
void solve(ll T){
    ll n,k;
    cin>>n>>k;
    vil a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
  ll dp[n+1];
  dp[0]=0;
  dp[1]=0;
  dp[2]=abs(a[1]-a[0]);
  for(int i=3;i<=n;i++){
      dp[i]=INF;
      for(int j=1;j<=k&&j<i;j++){
          dp[i]=min(dp[i],dp[i-j]+abs(a[i-1]-a[i-1-j]));
      }
  }
cout<<dp[n]<<endl;
   return;
}
int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
ll T;
T=1;
//cin>>T;
while(T--){
   solve(T);
return 0;
}
}

Compiler output:
a.cc:45:2: error: stray '#' in program
   45 | }#include<bits/stdc++.h>
      |  ^
a.cc:45:3: error: 'include' does not name a type
   45 | }#include<bits/stdc++.h>
      |   ^~~~~~~
a.cc:59:6: error: redefinition of 'void solve(long long int)'
   59 | void solve(ll T){
      |      ^~~~~
a.cc:15:6: note: 'void solve(long long int)' previously defined here
   15 | void solve(ll T){
      |      ^~~~~
a.cc:79:5: error: redefinition of 'int main()'
   79 | int main(){
      |     ^~~~
a.cc:35:5: note: 'int main()' previously defined here
   35 | int main(){
      |     ^~~~
Language: C++

#include<bits/stdc++.h>

using namespace std ; 
int one =0, tow=0;
int done[1000001], H[1000001];
int n ,k ;
long long  calc(int step){
 // cout<<Min <<endl;
  long long  Min=1000001;
   if(step==n-1)
    return 0 ;
   else if(step>=n)
    return 0;
   if(done[step]!=-1)  
    return done[step];
  for(int i =1;i<=k;i++){
   if(step+i<n){ 

      int one =calc(step+i)+abs(H[step]-H[step+i]);
      Min=min(one,Min); }
   }return done[step]=Min; 
}
int main () { 
  
  cin>>n>>k;
  
  memset(done ,-1,sizeof done);
  for(int i =0;i<n;i++){
    cin>>H[i];

  }
  cout<<calc(0);
  
  return 0;}

Compiler output:
a.cc: In function 'long long int calc(int)':
a.cc:20:14: error: no matching function for call to 'min(int&, long long int&)'
   20 |       Min=min(one,Min); }
      |           ~~~^~~~~~~~~
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:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   20 |       Min=min(one,Min); }
      |           ~~~^~~~~~~~~
/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:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |       Min=min(one,Min); }
      |           ~~~^~~~~~~~~
Language: C++

v#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll pw(ll a, ll b) {
    if (b == 0) return 1;
    ll t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
int main()
{
	int n,k;cin>>n>>k;
	int a[n+1];for(int i=0;i<n;i++)cin>>a[i];
	int dp[n];for(int i=0;i<n;i++)dp[i]=1e9+7;
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=1;i-j>=0&&j<=k;j++)
		{
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n-1]<<endl;
}


Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | v#include<bits/stdc++.h>
      |  ^
a.cc:1:1: error: 'v' does not name a type
    1 | v#include<bits/stdc++.h>
      | ^
a.cc: In function 'int main()':
a.cc:19:17: error: 'cin' was not declared in this scope
   19 |         int n,k;cin>>n>>k;
      |                 ^~~
a.cc:27:49: error: 'abs' was not declared in this scope
   27 |                         dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
      |                                                 ^~~
a.cc:27:31: error: 'min' was not declared in this scope; did you mean 'main'?
   27 |                         dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
      |                               ^~~
      |                               main
a.cc:30:9: error: 'cout' was not declared in this scope
   30 |         cout<<dp[n-1]<<endl;
      |         ^~~~
a.cc:30:24: error: 'endl' was not declared in this scope
   30 |         cout<<dp[n-1]<<endl;
      |                        ^~~~
Language: C++

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];
int dp[N];

void solve(){
  int n, k;
  cin >> n >> k;
  for(int i = 0; i < n; i++) cin >> arr[i];
  dp[0] = 0;
  for(int i = 1; i < n; i++){
    dp[i] = INT_MAX;
    for(int j = i - 1; j >= max(i - k, 0); j--){
      dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
    }
  }
  cout << dp[n - 1];

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:101:13: error: 'INT_MAX' was not declared in this scope
  101 |     dp[i] = INT_MAX;
      |             ^~~~~~~
a.cc:14:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   13 | #include <algorithm>
  +++ |+#include <climits>
   14 | #include <sstream>
Language: C++

    #include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
     
    int main() {
      ll n, k;
      cin >> n >> k;
      ll ar[n+1];
      for(ll x = 1; x <= n; x++) {
      	cin >> ar[x];
      }
      
      ll dp[n+1];
      dp[1] = 0;
      dp[2] = abs(ar[2]-ar[1]);
      for(ll x = 3; x <= n; x++) {
        ll r = INT_MAX;
        for(ll y = x-1; y >= max(x-k, 1); y--) {
        	r = min(r, dp[y] + abs(ar[x] - ar[y]));
        }
        dp[x] = r;
      }
      
      cout << dp[n];
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:18:33: error: no matching function for call to 'max(long long int, int)'
   18 |         for(ll y = x-1; y >= max(x-k, 1); y--) {
      |                              ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:18:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         for(ll y = x-1; y >= max(x-k, 1); y--) {
      |                              ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:18:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         for(ll y = x-1; y >= max(x-k, 1); y--) {
      |                              ~~~^~~~~~~~
Language: C++

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

int main() {
  ll n;
  cin >> n;
  ll ar[n+1];
  for(ll x = 1; x <= n; x++) {
  	cin >> ar[x];
  }
  
  ll dp[n+1];
  dp[1] = 0;
  dp[2] = abs(ar[2]-ar[1]);
  for(ll x = 3; x <= n; x++) {
    ll r = INT_MAX;
    for(ll y = x-1; y >= max(x-k, 0); y--) {
    	r = min(r, dp[y] + abs(ar[x] - ar[y]));
    }
    dp[x] = r;
  }
  
  cout << dp[n];
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()

using namespace std;



int main() {
    int n,k;
    cin>>n>>k;
    vector<int>h(110000);
    rep(i,n)cin>>h[i];

    vector<int>dp(110000,999999);
    dp[0] = 0;
    rep(i,n){
        rrep(j,k){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout<<dp[n-1]<<endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'cin' was not declared in this scope
   13 |     cin>>n>>k;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #define rep(i,n) for(int i = 0; i < (n); i++)
a.cc:14:5: error: 'vector' was not declared in this scope
   14 |     vector<int>h(110000);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | #define rep(i,n) for(int i = 0; i < (n); i++)
a.cc:14:12: error: expected primary-expression before 'int'
   14 |     vector<int>h(110000);
      |            ^~~
a.cc:15:18: error: 'h' was not declared in this scope
   15 |     rep(i,n)cin>>h[i];
      |                  ^
a.cc:17:12: error: expected primary-expression before 'int'
   17 |     vector<int>dp(110000,999999);
      |            ^~~
a.cc:18:5: error: 'dp' was not declared in this scope
   18 |     dp[0] = 0;
      |     ^~
a.cc:21:43: error: 'h' was not declared in this scope
   21 |             dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
      |                                           ^
a.cc:21:39: error: 'abs' was not declared in this scope
   21 |             dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
      |                                       ^~~
a.cc:21:21: error: 'min' was not declared in this scope; did you mean 'main'?
   21 |             dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
      |                     ^~~
      |                     main
a.cc:24:5: error: 'cout' was not declared in this scope
   24 |     cout<<dp[n-1]<<endl;
      |     ^~~~
a.cc:24:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:24:20: error: 'endl' was not declared in this scope
   24 |     cout<<dp[n-1]<<endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | #define rep(i,n) for(int i = 0; i < (n); i++)
Language: Java

class Main{
   static Integer[]cache;
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int []x=new int[n];
    cache=new Integer[n];
    for(int i=0;i<n;i++){
      x[i]=sc.nextInt();
    }
    System.out.println(ans1(x,0,k));
  }
 
    public static int ans1(int []h,int index,int k){
        if(index==h.length-1) return 0;
        if(cache[index]!=null) return cache[index];
        int current=Integer.MAX_VALUE;
        for(int i=1;i<=k;i++){
            if(index+i<h.length) {
                current = Math.min(current, Math.abs(h[index] - h[index + i]) + ans1(h, index + i, k));
            }
        }

        return cache[index]=current;
    }

}

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

import java.util.*;
public class Flog_2 {
    public static void main(String argd[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int asi[] = new int[N];
        int dp[] = new int[N];
        for(int i = 0; i < N; i++){
            asi[i] = sc.nextInt();
            dp[i] = 100000000;
        }
        dp[0] = 0;
        for(int i = 0; i < N - 1; i++){
            for(int j = i + 1; j <= K + i && j < dp.length; j++){
                if(dp[j] > dp[i] + Math.abs(asi[i] - asi[j])) dp[j] =  Math.abs(asi[i] - asi[j]) + dp[i];
            }
        }
        System.out.println(dp[N - 1]);
        
    }
    
}

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

#include<iostream>
using namespace std;

int n,k;
int arr[100005];


int f(){

	int dp[n+1]={0};
	dp[0]=0;
	dp[1] = abs(arr[1]-arr[0]);


	for(int i=2;i<n;i++)
	{
		dp[i] = INT_MAX;
		for(int j=i-1;j>=0&&j>=i-k;j--){
			dp[i] = min(dp[i],(abs(arr[j]-arr[i])+dp[j]));
		}
	}

	return dp[n-1];
}


int main(){

	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
  
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>arr[i];


	cout<<f()<<endl;
}




Compiler output:
a.cc: In function 'int f()':
a.cc:17:25: error: 'INT_MAX' was not declared in this scope
   17 |                 dp[i] = INT_MAX;
      |                         ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

#include<iostream>
using namespace std;


int n,k;
int arr[100005];


int f(){

	int dp[n+1]={0};
	dp[0]=0;
	dp[1] = abs(arr[1]-arr[0]);


	for(int i=2;i<n;i++)
	{
		dp[i] = INT_MAX;
		for(int j=i-1;j>=0&&j>=i-k;j--){
			dp[i] = min(dp[i],(abs(arr[j]-arr[i])+dp[j]));
		}
	}

	return dp[n-1];
}


int main(){

	
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>arr[i];


	cout<<f()<<endl;
}




Compiler output:
a.cc: In function 'int f()':
a.cc:18:25: error: 'INT_MAX' was not declared in this scope
   18 |                 dp[i] = INT_MAX;
      |                         ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include<iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

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

	int h[n];
	int dp[n];

	for(int i=-;i<n;i++)
		dp[i]=INT_MAX;

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

	dp[0]=0;
	

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: expected primary-expression before ';' token
   11 |         for(int i=-;i<n;i++)
      |                    ^
a.cc:22:32: error: 'k' was not declared in this scope
   22 |                 for(int j=1;j<=k;j++)
      |                                ^
a.cc:25:76: error: expected ';' before '}' token
   25 |                                 dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]))
      |                                                                            ^
      |                                                                            ;
   26 |                 }
      |                 ~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int min(ll a,ll b){
  if(a<b)
  return a;
  return b;
}
int main(){
  ll n;
  cin>>n;
  vector<ll>v(n,0);
  int dp[100001];
  for(int i=0;i<100001;i++){
    dp[i]=INT_MAX;
  }
  dp[0]=0;
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=k;j++){
      if(j<n){
        dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
      }
    }
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

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