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

//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define maxn 100001
#define pb push_back
using namespace std;
void solve(){
    ll n,k,mi;
    cin>>n>>k;
    ll a[n],dp[n+1];
    for(int i=0;i<n;i++)cin>>a[i];
    dp[0]=dp[1]=0;
    for(int i=2;i<=n;i++){
        mi=INT_MAX;
        for(int j=1;j<=min(k,i);j++){
            //cout<<i<<" "<<j<<"\n";
            mi=min(mi,dp[i-j]+abs(a[i-j-1]-a[i-1]));
        }
        dp[i]=mi;
    }
    cout<<dp[n];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


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

#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n,k;
  	cin>>n>>k;
  	vector<int> h;
  	for(int i=0; i<n; i++) {
      	int temp;
      	cin>>temp;
      	h.push_back(temp);
    }
  	vector<int> dp(n,INT_MAX);
  	dp[0] = 0;
  	dp[1] = abs(dp[0]-h[1]);
  	for(int i=2; i<n; i++) {
      for(int j=i+1; j<=i+k; j++) {
        if(j<n) dp[j] = min(dp[j],abs(h[i]-h[j])+dp[i]);
    	}
   	}
  		cout<<dp[n-1];
}

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

public class Main {

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int arr[]=new int[n];
		int dp[]=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
		}
		Arrays.fill(dp, -1);
		int ans=rec(dp,arr,0,k);
		System.out.println(ans);
		
		//dp[0]=0;
		//dp[1]=Math.abs(arr[0]-arr[1]);
//		for(int i=1;i<n;i++)rr
//		{
//			int min=Integer.MAX_VALUE;
//			for(int j=1;j<=k&&i-j>=0;j++)
//			{
//				//System.out.println(i+" "+j);
//				int temp=dp[i-j]+Math.abs(arr[i]-arr[i-j]);
//			min=Math.min(temp, min);
//			}
//			dp[i]=min;
//			//System.out.println(dp[i]);
//		}
//		System.out.println(dp[n-1]);
	}

	private static int rec(int[] dp, int[] arr, int ind, int k) {
		// TODO Auto-generated method stub
		if(ind==arr.length-1)
		{
			return 0;
		}
		if(ind>arr.length)
		{
			return 100000;
		}
		if(dp[ind]!=-1)
		{
			
			return dp[ind];
		}
		int ans=1000000;
		for(int i=1;i<=k&&ind+i<arr.length;i++)
		{
		//	System.out.println(i+" "+ind);
			
			int temp=Math.abs(arr[ind]-arr[ind+i])+rec(dp,arr,ind+i,k);
			
			ans=Math.min(ans, temp);
		}
		dp[ind]=ans;
		return ans;
	}
}


Compiler output:
Main.java:5: error: cannot find symbol
		Scanner sc=new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
		Scanner sc=new Scanner(System.in);
		               ^
  symbol:   class Scanner
  location: class Main
Main.java:14: error: cannot find symbol
		Arrays.fill(dp, -1);
		^
  symbol:   variable Arrays
  location: class Main
3 errors
Language: C

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

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


Compiler output:
main.c:2:10: fatal error: algorithm: No such file or directory
    2 | #include <algorithm>
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<vector>

using namespace std;

int main(){
    int n,k;

    cin >> n;
    cin >> k;

    vector<int> v(n);
    vector<int> dp(n, INT_MAX);

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

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

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

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

#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<long long> h(100200);
    rep(i,n) {
     cin >> h[i];
    }
    
    
   const long long INF = 1LL << 60;
   long long dp[100200];
   
    
    for(int i = 0;i < 100200;i++) {
     dp[i] = INF;
    }
    dp[0] = 0;
    
    for(int i = 0;i<n;i++) {
        for(int j = 1;j<=k;j++)
     chmin(dp[i+j], dp[i]+abs(h[i] - h[i+j]));
     }
    
    cout << dp[n-1];
}

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

#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<long long> h(100010);
    rep(i,n) {
     cin >> h[i];
    }
    
    
   const long long INF = 1LL << 60;
   long long dp[100010];
   
    
    for(int i = 0;i < 100010;i++) {
     dp[i] = INF;
    }
    dp[0] = 0;
    
    for(int i = 0;i<n;i++) {
        for(int j = 1;j<=k;j++)
     chmin(dp[i+j], dp[i]+abs(h[i] - h[i+j]));
     }
    
    cout << dp[n-1];
}

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

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


Compiler output:
a.cc: In function 'int solve(int*, int, int)':
a.cc:11:33: error: expected ';' before ')' token
   11 |         dp[i]=min(option1,dp[i]));
      |                                 ^
      |                                 ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
int solve(int a[],int n,int k){
	int dp[n+1];
  	dp[1]=0;
    for(int i=2;i<=n;i++){
      for(int j=1;j<=k;j++){
        int option1=(i==2)?inf:abs(a[i]-a[i-j])+dp[i-j];
      	//int option2=(i==2)?inf:abs(a[i]-a[i-j])+dp[i-j];
      	dp[i]=min(option1,dp[i]));
      }
      
    }
    return dp[n];
}
int main(){
	int n,k;
  	cin>>n>>k;
    int a[n+1];
  	for(int i=1;i<=n;i++)cin>>a[i];
  	cout<<solve(a,n,k)<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int solve(int*, int, int)':
a.cc:11:33: error: expected ';' before ')' token
   11 |         dp[i]=min(option1,dp[i]));
      |                                 ^
      |                                 ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX;
int solve(int a[],int n,int k){
	int dp[n+1];
  	dp[1]=0;
    for(int i=2;i<=n;i++){
      for(int j=1;j<=k;j++){
        int option1=abs(a[i]-a[i-1])+dp[i-1];
      	int option2=(i==2)?inf:abs(a[i]-a[i-2])+dp[i-2];
      	dp[i]=min(option1,min(option2,dp[i]));
      }
      
    }
    return dp[n];
}
int main(){
	int n,k;
  	cin>>n>>k;
    int a[n+1];
  	for(int i=1;i<=n;i++)cin>>a[i];
  	cout<<solve(a,n,k)<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int solve(int*, int, int)':
a.cc:3:20: error: expected ':' before ';' token
    3 | #define inf INT_MAX;
      |                    ^
a.cc:10:28: note: in expansion of macro 'inf'
   10 |         int option2=(i==2)?inf:abs(a[i]-a[i-2])+dp[i-2];
      |                            ^~~
a.cc:3:20: error: expected primary-expression before ';' token
    3 | #define inf INT_MAX;
      |                    ^
a.cc:10:28: note: in expansion of macro 'inf'
   10 |         int option2=(i==2)?inf:abs(a[i]-a[i-2])+dp[i-2];
      |                            ^~~
a.cc:10:31: error: expected primary-expression before ':' token
   10 |         int option2=(i==2)?inf:abs(a[i]-a[i-2])+dp[i-2];
      |                               ^
Language: C++

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	int j,i;
	for(i=0;i<n;i++)
	cin>>a[i];
	int dp[0]=0;
	for(i=1;i<n;i++)
	{
		dp[i]=INT_MAX;
		for(j=1;j<=k && i-j>=0;j++)
		dp[i]=min(dp[i],dp[i-j]);	
	}
	cout<<dp[n-1]<<endl;
	return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:14:19: error: array must be initialized with a brace-enclosed initializer
   14 |         int dp[0]=0;
      |                   ^
Language: C++


using namespace std;

int main()
{
	long long n,k,j,i;
	cin>>n>>k;
	vector<long long> h(n),dp(n,100000);
	for(i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(i=2;i<n;i++)
	{
		for(j=i-1;j>=0&&j>=i-k;j--)
			dp[i]=min(abs(h[i]-h[j])+dp[j],dp[i]);	
	}
	cout<<dp[n-1]<<endl;
  /*	for(i=0;i<n;i++)
      cout<<dp[i]<<" ";*/
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         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 | 
a.cc:8:9: error: 'vector' was not declared in this scope
    8 |         vector<long long> h(n),dp(n,100000);
      |         ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | 
a.cc:8:16: error: expected primary-expression before 'long'
    8 |         vector<long long> h(n),dp(n,100000);
      |                ^~~~
a.cc:10:22: error: 'h' was not declared in this scope
   10 |                 cin>>h[i];
      |                      ^
a.cc:11:9: error: 'dp' was not declared in this scope
   11 |         dp[0]=0;
      |         ^~
a.cc:12:19: error: 'h' was not declared in this scope
   12 |         dp[1]=abs(h[0]-h[1]);
      |                   ^
a.cc:12:15: error: 'abs' was not declared in this scope
   12 |         dp[1]=abs(h[0]-h[1]);
      |               ^~~
a.cc:16:31: error: 'min' was not declared in this scope; did you mean 'main'?
   16 |                         dp[i]=min(abs(h[i]-h[j])+dp[j],dp[i]);
      |                               ^~~
      |                               main
a.cc:18:9: error: 'cout' was not declared in this scope
   18 |         cout<<dp[n-1]<<endl;
      |         ^~~~
a.cc:18:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:18:24: error: 'endl' was not declared in this scope
   18 |         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 |
Language: C++

#include<iostream>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<climits.h>
using namespace std;
 
int main()
{
  int n,k;
  cin>>n>>k;
  int * arr= new int [n];
  int *dp = new int[n];
 
 
  for(int i=0;i<n;i++)
  cin>>arr[i];
  for(int i=0;i<n;i++)
  dp[i]=INT_MAX;
  
  dp[0]=0;
  
   for(int i=0;i<n;i++)
   {
     for(int j=1;j<=k;j++)
     {   
       if(i+j>=n)
         break;
       dp[i+j]=min(dp[i]+abs(arr[i]-arr[i+j]),dp[i+j]);
      }
     
   }
   cout<<dp[n-1]<<endl;

    return 0;
}

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

#include<iostream>
#include<math.h>
#include<stdio.h>
#include<string.h>
using namespace std;
 
int main()
{
  int n,k;
  cin>>n>>k;
  int * arr= new int [n];
  int *dp = new int[n];
 
 
  for(int i=0;i<n;i++)
  cin>>arr[i];
  for(int i=0;i<n;i++)
  dp[i]=INT_MAX;
  
  dp[0]=0;
  
   for(int i=0;i<n;i++)
   {
     for(int j=1;j<=k;j++)
     {   
       if(i+j>=n)
         break;
       dp[i+j]=min(dp[i]+abs(arr[i]-arr[i+j]),dp[i+j]);
      }
     
   }
   cout<<dp[n-1]<<endl;

    return 0;
}

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

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



Compiler output:
a.cc:3:1: error: 'typedf' does not name a type; did you mean 'typeof'?
    3 | typedf long long int ll;
      | ^~~~~~
      | typeof
a.cc: In function 'int main()':
a.cc:6:5: error: 'll' was not declared in this scope
    6 |     ll n,k;
      |     ^~
a.cc:7:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |     cin>>n>>k;
      |          ^
      |          yn
a.cc:7:13: error: 'k' was not declared in this scope
    7 |     cin>>n>>k;
      |             ^
a.cc:8:7: error: expected ';' before 'h'
    8 |     ll h[n];
      |       ^~
      |       ;
a.cc:9:11: error: expected ';' before 'i'
    9 |     for(ll i=0;i<n;i++)cin>>h[i];
      |           ^~
      |           ;
a.cc:9:16: error: 'i' was not declared in this scope
    9 |     for(ll i=0;i<n;i++)cin>>h[i];
      |                ^
a.cc:9:29: error: 'h' was not declared in this scope
    9 |     for(ll i=0;i<n;i++)cin>>h[i];
      |                             ^
a.cc:10:7: error: expected ';' before 'dp'
   10 |     ll  dp[n];
      |       ^ ~~
      |       ;
a.cc:11:11: error: expected ';' before 'i'
   11 |     for(ll  i=0;i<n;i++)dp[i]=1e6;
      |           ^ ~
      |           ;
a.cc:11:17: error: 'i' was not declared in this scope
   11 |     for(ll  i=0;i<n;i++)dp[i]=1e6;
      |                 ^
a.cc:11:25: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |     for(ll  i=0;i<n;i++)dp[i]=1e6;
      |                         ^~
      |                         dup
a.cc:12:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 |     dp[0]=0;
      |     ^~
      |     dup
a.cc:13:15: error: 'h' was not declared in this scope
   13 |     dp[1]=abs(h[1]-h[0]);
      |               ^
a.cc:14:11: error: expected ';' before 'i'
   14 |     for(ll i=2;i<n;i++)
      |           ^~
      |           ;
a.cc:14:16: error: 'i' was not declared in this scope
   14 |     for(ll i=2;i<n;i++)
      |                ^
a.cc:16:11: error: expected ';' before 'j'
   16 |     for(ll j=1;j<=k;j++)
      |           ^~
      |           ;
a.cc:16:16: error: 'j' was not declared in this scope; did you mean 'jn'?
   16 |     for(ll j=1;j<=k;j++)
      |                ^
      |                jn
Language: C++

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

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

    return 0;
}


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

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <math.h>
#include <string>
using namespace std;
 
const double PI = acos(-1);
const int M=1e9+7;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define oo 1e9

int n,k;
vi a;
vector <int> dP;

void solve(){
	cin>>n>>k;
	a.resize(n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&a[i]);
	}
	dP.resize(n);
	for (int i = 1; i < n; ++i)
	{
		dP[i]=oo;
		for (int j = 1; j <= min(i,k); ++j)
		{
			dP[i]=min(dP[i], dP[i-j] + abs(v[i-j]-v[i]));
		}
	}
	printf("%d\n", dP[n-1]);
}

int main()
{

	int t;
	t=1;
	while(t--){
		solve();
	}

	return 0;
}




Compiler output:
a.cc: In function 'void solve()':
a.cc:42:56: error: 'v' was not declared in this scope
   42 |                         dP[i]=min(dP[i], dP[i-j] + abs(v[i-j]-v[i]));
      |                                                        ^
Language: C++

// Created by Bingoo on 7/8/2020.
#include"bits/stdc++.h"
using namespace std ;
#define ll  long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

template <class ...Args>
auto &see(const Args &...args) {return ((cerr << " " << args), ...) << '\n';}
#define bug(...)  cerr << "[ "#__VA_ARGS__" ] = "; see(__VA_ARGS__) << '\n';
//C++17
template<typename... Args>
void read(Args&... args){((cin >> args), ...);}
template<typename... Args>
void write(Args... args){((cout << args << " "), ...);}


vector<int> dp(100005) ;
vector<int> h(100005);
int N , k ;

int solve(int n){
    if(n==N)return 0 ;

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

    int ans=INT_MAX;

    for(int i = 1 ; i <= k && n+i <= N ; i++)ans= min(abs(h[n]-h[n+i])+solve(n+i),ans);


    return dp[n] = ans;
}

int main(){
    IOS

    cin >> N >> k;

    for (int i = 1; i <= N; ++i) {
     cin >> h[i];
    }
    memset(dp , -1 , sizeof dp);

    cout << solve(1) <<'\n' ;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:12: error: cannot convert 'std::vector<int>' to 'void*'
   42 |     memset(dp , -1 , sizeof dp);
      |            ^~
      |            |
      |            std::vector<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:2:
/usr/include/string.h:61:28: note:   initializing argument 1 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 n,k, arr[1000000];
long long dp[1000000];

long long solve(int i) {
	dp[0]=0;
  	dp[1]=abs(arr[0]-arr[1]);
  
  	for(int i=2;i<n;i++){
      dp[i]=1000000000000;
      for(int j=1;j<=k;j++){
        if((i-j)>0){
        	dp[i] = min(dp[i] , abs(arr[i]-arr[i-j])+dp[i-1]);
        }
    }
      
    return dp[n-1];
	
}

int main() {
	cin >> n >>k;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	cout << solve(0);

	return 0;
}


Compiler output:
a.cc: In function 'long long int solve(int)':
a.cc:22:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   22 | int main() {
      |         ^~
a.cc:22:9: note: remove parentheses to default-initialize a variable
   22 | int main() {
      |         ^~
      |         --
a.cc:22:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:22:12: error: a function-definition is not allowed here before '{' token
   22 | int main() {
      |            ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:6:24: note: to match this '{'
    6 | long long solve(int i) {
      |                        ^
a.cc:31:2: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      |  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k, arr[1000000];
long long dp[1000000];

long solve(int i) {
	dp[0]=0;
  	dp[1]=abs(arr[0]-arr[1]);
  
  	for(int i=2;i<n;i++){
     // dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
      for(int j=1;j<=k;j++){
        if((i-j)>0)
        	dp[i] = min(dp[i] , abs(arr[i]-arr[i-j])+dp[i-1]);
    }
      
      return dp[n-1];
	
}

int main() {
	cin >> n >>k;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	memset(dp, 10000000000000000, sizeof(dp));
	cout << solve(0);

	return 0;
}


Compiler output:
a.cc: In function 'long int solve(int)':
a.cc:21:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   21 | int main() {
      |         ^~
a.cc:21:9: note: remove parentheses to default-initialize a variable
   21 | int main() {
      |         ^~
      |         --
a.cc:21:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:21:12: error: a function-definition is not allowed here before '{' token
   21 | int main() {
      |            ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:6:19: note: to match this '{'
    6 | long solve(int i) {
      |                   ^
a.cc:31:2: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      |  ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,k, arr[1000000];
long long dp[1000000];

long solve(int i) {
	dp[0]=0;
  	dp[1]=abs(arr[0]-arr[1]);
  
  	for(int i=2;i<n;i++){
     // dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
      for(int j=1;j<=k;j++){
        if((i-j)>0)
        	dp[i] = min(dp[i] , abs(arr[i]-ar[i-j])+dp[i-1]);
    }
      
      return dp[n-1];
	
}

int main() {
	cin >> n >>k;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	memset(dp, 10000000000000000, sizeof(dp));
	cout << solve(0);

	return 0;
}


Compiler output:
a.cc: In function 'long int solve(int)':
a.cc:14:48: error: 'ar' was not declared in this scope; did you mean 'arr'?
   14 |                 dp[i] = min(dp[i] , abs(arr[i]-ar[i-j])+dp[i-1]);
      |                                                ^~
      |                                                arr
a.cc:21:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   21 | int main() {
      |         ^~
a.cc:21:9: note: remove parentheses to default-initialize a variable
   21 | int main() {
      |         ^~
      |         --
a.cc:21:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:21:12: error: a function-definition is not allowed here before '{' token
   21 | int main() {
      |            ^
a.cc:31:2: error: expected '}' at end of input
   31 | }
      |  ^
a.cc:6:19: note: to match this '{'
    6 | long solve(int i) {
      |                   ^
a.cc:31:2: warning: control reaches end of non-void function [-Wreturn-type]
   31 | }
      |  ^
Language: C++

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


Compiler output:
a.cc:4:1: error: 'll' does not name a type
    4 | ll INF=100007;
      | ^~
a.cc: In function 'int main()':
a.cc:7:6: error: expected ';' before 'n'
    7 |    ll n,i,k,j;
      |      ^~
      |      ;
a.cc:8:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |    cin>>n>>k;
      |         ^
      |         yn
a.cc:8:12: error: 'k' was not declared in this scope
    8 |    cin>>n>>k;
      |            ^
a.cc:9:6: error: expected ';' before 'arr'
    9 |    ll arr[n+1],dp[n+1];
      |      ^~~~
      |      ;
a.cc:10:8: error: 'i' was not declared in this scope
   10 |    for(i=1;i<=n;i++)
      |        ^
a.cc:12:14: error: 'arr' was not declared in this scope
   12 |         cin>>arr[i];
      |              ^~~
a.cc:13:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |         dp[i]=INF;
      |         ^~
      |         dup
a.cc:13:15: error: 'INF' was not declared in this scope
   13 |         dp[i]=INF;
      |               ^~~
a.cc:15:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |     dp[1]=0;
      |     ^~
      |     dup
a.cc:16:9: error: 'i' was not declared in this scope
   16 |     for(i=2;i<=n;i++)
      |         ^
a.cc:20:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   20 |             for(j=1;j<=k;j++)
      |                 ^
      |                 jn
a.cc:22:45: error: 'arr' was not declared in this scope
   22 |                 dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
      |                                             ^~~
a.cc:27:17: error: 'j' was not declared in this scope; did you mean 'jn'?
   27 |             for(j=1;j<i;j++)
      |                 ^
      |                 jn
a.cc:29:43: error: 'arr' was not declared in this scope
   29 |                 dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
      |                                           ^~~
Language: Java

import java.io.*;
import java.util.*;
public class Main{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      int arr[]=new int[size];
      for(int i=0;i<size;i++)
        arr[i]=sc.nextInt();
      
      int dp[] =  new int[size];
      Arrays.fill(dp, Integer.MAX_VALUE);
      
      return minCost(arr, 0, dp, k);
      
    }
  
  public static int minCost(int arr[], int pos, int dp[], int k){
  	if(pos >= arr.length)
      return Integer.MAX_VALUE;
    
     if(pos == arr.length -1)
      return 0;
    
    if(dp[pos] != Integer.MAX_VALUE)
      	return dp[pos];
    
    for(int i = pos+1; i<=pos+k; i++){
    if(i < arr.length)
      dp[pos] = Math.min(dp[pos], Math.abs(arr[pos] - arr[i]) + minCost(arr, i,dp, k));
    }
   
      return dp[pos];
    
  }
}


Compiler output:
Main.java:15: error: cannot find symbol
      int arr[]=new int[size];
                        ^
  symbol:   variable size
  location: class Main
Main.java:16: error: cannot find symbol
      for(int i=0;i<size;i++)
                    ^
  symbol:   variable size
  location: class Main
Main.java:19: error: cannot find symbol
      int dp[] =  new int[size];
                          ^
  symbol:   variable size
  location: class Main
Main.java:22: error: incompatible types: unexpected return value
      return minCost(arr, 0, dp, k);
                    ^
4 errors
Language: C++

N, K = map(int, input().split())
h = tuple(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
def chmin(i, j):
  if dp[i] > j: dp[i] = j
def cost(i, j):
  return dp[i-j] + abs(h[i]-h[i-j])
for i in range(N):
  for j in range(1, K+1):
    if i+j < N:
      chmin(i+j, cost(i, j))
print(dp[-1])

Compiler output:
a.cc:3:13: warning: multi-character character constant [-Wmultichar]
    3 | dp = [float('inf')] * N
      |             ^~~~~
a.cc:1:1: error: 'N' does not name a type
    1 | N, K = map(int, input().split())
      | ^
Language: Java

import java.util.Scanner;

public class A {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] dp = new int[n];
		int[] frog = new int[n];
		for(int i=0; i<n; i++) {
			frog[i] = sc.nextInt();
		}
		for(int i=1; i<n; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		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(frog[i]-frog[j]));
			}
		}
		System.out.println(dp[n-1]);

	}

}


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

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

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

int main() {
  int n, k;
  cin >> n >> k;
  int arr[n+1];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int dp[n+1] = {0};
  foo();
  cout << dp[n];
  return 0;
}

Compiler output:
a.cc: In function 'void foo(int*, int*, int)':
a.cc:7:48: error: 'k' was not declared in this scope
    7 |       for (int j = i - 1; j >= 1 && (i - j) <= k; j--) {
      |                                                ^
a.cc: In function 'int main()':
a.cc:21:6: error: too few arguments to function 'void foo(int*, int*, int)'
   21 |   foo();
      |   ~~~^~
a.cc:4:6: note: declared here
    4 | void foo(int arr[], int dp[], int n) {
      |      ^~~
Language: C++

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

vector<int> dp(100000, INT_MAX);
int minCost(vector<int> &stones,int k, int dest){
  dp[0] = 0;
  for(int i=1;i<=k;i++){
    dp[i] = abs(stones[k] - stones[i]);
  }
  for(int i=k+1;i<dest;i++){
    for(int j=1;j<=k;j++){
      dp[i] = min(dp[i], abs(stones[i] - stones[i-j]) + dp[i-j])
    }
  }
  return dp[dest];
}



int main(){
  int n,k;
  cin>>n>>k;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  cout<<minCost(vec, k,vec.size()-1)<<endl;
  
}

Compiler output:
a.cc: In function 'int minCost(std::vector<int>&, int, int)':
a.cc:12:65: error: expected ';' before '}' token
   12 |       dp[i] = min(dp[i], abs(stones[i] - stones[i-j]) + dp[i-j])
      |                                                                 ^
      |                                                                 ;
   13 |     }
      |     ~
Language: C++

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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones,int k, int dest){
  cout<<dest<<endl;
  int ans = INT_MAX;
  if(dest == 0){
    dp[dest] = 0;
  }
  else if(dest < k){
    dp[dest] = abs(stones[dest] - stones[0]);
  }
  else{
     for(int i=1;i<=k;i++){
      if(dp[dest-i] == -1){
        dp[dest-i] = minCost(stones,k, dest -i);
      }
      int ans = min(abs(stones[dest] - stones[dest-i]) + dp[dest-i], ans);
    }
    dp[dest] = ans;
  }
 
  return dp[dest];	
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  vector<int> dp(vec.size(), -1);
  cout<<minCost(vec, k,vec.size()-1)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:22: error: 'k' was not declared in this scope
   39 |   cout<<minCost(vec, k,vec.size()-1)<<endl;
      |                      ^
Language: C++

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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones,int k, int dest){
  int ans = INT_MAX;
  if(dest == 0){
    dp[dest] = 0;
    return dp[dest];
  }
  if(dest < k){
    dp[dest] = abs(stones[dest] - stones[0]);
    return dp[dest];
  }
  for(int i=1;i<=k;i++){
    if(dp[dest-i] == -1){
      dp[dest-i] = minCost(stones,k, dest -i);
    }
    int ans = min(abs(stones[dest] - stones[dest-i]) + dp[dest-i], ans);
  }
  dp[dest] = ans;
  return ans;	
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  vector<int> dp(vec.size(), -1);
  cout<<minCost(vec, k,vec.size()-1)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:22: error: 'k' was not declared in this scope
   37 |   cout<<minCost(vec, k,vec.size()-1)<<endl;
      |                      ^
Language: C++

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

vector<int> dp(100000, -1);
int minCost(vector<int> &stones,int k, int dest){
  int ans = INT_MAX;
  if(dest = 0){
    dp[dest] = 0;
    return dp[dest];
  }
  if(dest < k){
    dp[dest] = abs(stones[dest] - stones[0]);
    return dp[dest];
  }
  for(int i=1;i<=k;i++){
    if(dp[dest-i] == -1){
      dp[dest-i] = minCost(stones,k, dest -i);
    }
    int ans = min(abs(stones[dest] - stones[dest-i]) + dp[dest-i], ans);
  }
  dp[dest] = ans;
  return ans;	
}



int main(){
  int n;
  cin>>n;
  vector<int> vec;
  for(int i=0;i<n;i++){
    int temp;
    cin>>temp;
    vec.push_back(temp);
  }
  vector<int> dp(vec.size(), -1);
  cout<<minCost(vec, k,vec.size()-1)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:22: error: 'k' was not declared in this scope
   37 |   cout<<minCost(vec, k,vec.size()-1)<<endl;
      |                      ^
Language: C++

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

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i = 0;i<n;i++)
    cin >> v[i];
  vector<int> dp(n,INT_MAX);
  dp[0] = 0;
  for(int i = 0 ;i<n;i++)
  {
    for(int j = 1;j<=k;j++)
    {
      if(i+j < n)
      	dp[i+j] = min(dp[i+j],dp[i] + (v[i+j] - v[i]); 
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:54: error: expected ')' before ';' token
   18 |         dp[i+j] = min(dp[i+j],dp[i] + (v[i+j] - v[i]);
      |                      ~                               ^
      |                                                      )
Language: C++

#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int> 
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define um unordered_map<int,int>
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n) 
 vector<int> adj[1000001];    
 int v[1000001]={0};
int32_t main()
{
 int n,d=0,x=1000001,k;
 cin>>n>>k;
 vll a(n);
 for(int i=0;i<n;i++)
 cin>>a[i];
 int dp[n]={0};
 if(n<=k)
 cout<<a[n-1]-a[0]<<endl;
 else
 {
 dp[0]=0;
 for(int i=1;i<=k;i++)
 {
     dp[i]=abs(a[i]-a[0]);
 }
 for(int i=k+1;i<n;i++)
 {
   x=100000;
  for(int j=1;j<=k;j++)
  {
d=dp[i-j]+abs(a[i]-a[i-j]);
//cout<<d<<" ";
if(d<x)
{
    x=d;
}
  }
  dp[i]=x;
 // cout<<endl;
 }
 
 cout<<dp[n-1];
}
}'

Compiler output:
a.cc:55:2: warning: missing terminating ' character
   55 | }'
      |  ^
a.cc:55:2: error: missing terminating ' character
Language: Java

//greedy is not applicable here as even if select min "diff" at each step then
//also final ans will not be optimal min possible of all answers
//eg: 30 20 50 10 50 70
//greedy: 60
//bruteforce (mainly dp): 40
import java.io.*;
import java.util.*;
public class Main1{
  	/*public int minRec(int a[],int dp[],int i,int j)
    {
      if(i==n && j==n)
        	return dp[n][n];
      if(
        return Math.min( Math.abs(a[]
    }*/
	public static void main(String args[]) throws IOException{
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      String st[]=br.readLine().trim().split("\\s+");
      int n=Integer.parseInt(st[0]);
      int k=Integer.parseInt(st[1]);
      String s[]=br.readLine().trim().split("\\s+");
      int size=s.length;
      int arr[]=new int[size];
      for(int i=0;i<size;i++)
        arr[i]=Integer.parseInt(s[i]);
      int ans=0;
      //int dp[][]=new int[][];
      //ans=minRec(a,dp,0,0);

      //if define dp[i] as "the minimum total cost to reach nth (i.e. last) stone from ith stone"
      // long dp[]=new long[size];
      // dp[n-1]=0;
      // dp[n-2]=(long)Math.abs((long)arr[n-1]-(long)arr[n-2]);
      // for(int i=n-3;i>=0;i--)
      //   dp[i]=(long)Math.min( dp[i+1]+Math.abs((long)arr[i]-(long)arr[i+1]), dp[i+2]+Math.abs((long)arr[i]-(long)arr[i+2]) );
      // System.out.println(dp[0]);
      //correct


      //if define dp[i] as "the minimum total cost to reach ith stone"
      long dp[]=new long[size];
      dp[0]=0;
      dp[1]=(long)Math.abs((long)arr[1]-(long)arr[0]);
      for(int i=2;i<size;i++)
        dp[i]=Integer.MAX_VALUE;
      for(int i=2;i<n;i++)
        for(int j=i-1;j>=i-k && j>=0;j--)
          dp[i]=(long)Math.min( dp[j]+Math.abs((long)arr[i]-(long)arr[j]), dp[i] );
      System.out.println(dp[n-1]);
      //correct
    }
}

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

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

public class Main {
  
   public static void main(String[]abc){
      Main ans = new Main();
      int sol = ans.solve();
      System.out.println(sol);
   }
  
   private int solve() {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      int [] array = new int[N+1];
      for(int i=1;i<=N;i++) {
         array[i] = sc.nextInt();        
      }
      int [] dp = new int[N+1];
      Arrays.fill(dp, Integer,MAX_VALUE);
      dp[1]=0;
      dp[0]=0;
      for(int i=2;i<=N;i++){
         for(int j=0;j<=K;j++){
            if (i-j>=1 && i+j<=N){
                int diff = Math.abs(array[i+j]-array[i]);
            	dp[i] = Math.min(dp[i], dp[i-j]+ diff);
 			}
         }
      }
     return dp[N];
      
      
   }
}

Compiler output:
Main.java:21: error: cannot find symbol
      Arrays.fill(dp, Integer,MAX_VALUE);
                      ^
  symbol:   variable Integer
  location: class Main
Main.java:21: error: cannot find symbol
      Arrays.fill(dp, Integer,MAX_VALUE);
                              ^
  symbol:   variable MAX_VALUE
  location: class Main
2 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	// your code goes here
	ll n,k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll ans =0;
	ll dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
   // cout<<dp[1]<<endl;
    for(int i=2;i<n;i++)
    {
      dp[i]=10000000*10000000;
    for(int j=1;j<=min(i,k);j++){
    {
    //	cout<<dp[i]<<" "<<j<<" "<<dp[i-j]+abs(a[i]-a[i-j])<<endl;
    	dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        
    }
    
   // cout<<dp[i]<<endl;
    }
    
    }
    cout<<dp[n-1];
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:21: warning: integer overflow in expression of type 'int' results in '276447232' [-Woverflow]
   20 |       dp[i]=10000000*10000000;
      |             ~~~~~~~~^~~~~~~~~
a.cc:21:23: error: no matching function for call to 'min(int&, long long int&)'
   21 |     for(int j=1;j<=min(i,k);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:21:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   21 |     for(int j=1;j<=min(i,k);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:21:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |     for(int j=1;j<=min(i,k);j++){
      |                    ~~~^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int ans =0;
	int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
   // cout<<dp[1]<<endl;
    for(int i=2;i<n;i++)
    {
      dp[i]=10000000*10000000;
    for(int j=1;j<=min(i,k);j++){
    {
    //	cout<<dp[i]<<" "<<j<<" "<<dp[i-j]+abs(a[i]-a[i-j])<<endl;
    	dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        
    }
    
   // cout<<dp[i]<<endl;
    }
    
    }
    cout<<dp[n-1];
	return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:20:21: warning: integer overflow in expression of type 'int' results in '276447232' [-Woverflow]
   20 |       dp[i]=10000000*10000000;
      |             ~~~~~~~~^~~~~~~~~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:2: error: expected '}' at end of input
   16 | }
      |  ^
a.cc:3:12: note: to match this '{'
    3 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<math.h>
#include<string>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;

int main()
{
	int n;
	int k;
	std::cin >> n;
	std::cin >> k;
	int* arr = new int[n];
	for (int i = 0; i < n; i++)
	{
		std::cin >> arr[i];
	}
	int* dp = new int[n];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; i++)
	{
		int s = k;
		int mix = INT_MAX;
		s = min(i, s);
		s++;
		while (s--)
		{
			int x = abs(arr[i] - arr[i - s]) + dp[i - s];
			if (mix > x)
			{
				mix = x;
			}
			dp[i] = mix;
		}
	}
	std::cout << dp[n - 1] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:27: error: 'INT_MAX' was not declared in this scope
   33 |                 int mix = INT_MAX;
      |                           ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include<math.h>
  +++ |+#include <climits>
    9 | #include<string>
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: no matching function for call to 'min(int&, long long int)'
   15 |             add=min(add, dp[i-k] + abs(a[i]-a[i-k]));
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:15:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   15 |             add=min(add, dp[i-k] + abs(a[i]-a[i-k]));
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:15:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   15 |             add=min(add, dp[i-k] + abs(a[i]-a[i-k]));
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~