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

#include <algorithm>
#include <cmath>
#include <iostream>
int main()
{
    int n = 0;
    int k = 0;
    std::cin >> n >> k;
    std::vector<int> scaffoldCost(n);
    int inputCost = 0;
    for(int i = 0; i < n; ++i)
    {
        std::cin >> inputCost;
        scaffoldCost.at(i) = inputCost;
    }
    
    std::vector<long long> minCosts(n);
    long long tempMinCost = 0;
    
    for(int index = 1; index < n; ++index)
    {
        tempMinCost = 1000000000;
        for(int diff = 0; diff < k; ++diff)
        {
            if(index - diff < 1)
            {
                break;
            }
            tempMinCost = std::min(tempMinCost,
                minCosts.at(index - diff - 1) 
                + std::abs(scaffoldCost.at(index) - scaffoldCost.at(index - diff - 1))
                );
        }
        minCosts.at(index) = tempMinCost;
    }
    std::cout << minCosts.back() << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: 'vector' is not a member of 'std'
    9 |     std::vector<int> scaffoldCost(n);
      |          ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <iostream>
  +++ |+#include <vector>
    4 | int main()
a.cc:9:17: error: expected primary-expression before 'int'
    9 |     std::vector<int> scaffoldCost(n);
      |                 ^~~
a.cc:14:9: error: 'scaffoldCost' was not declared in this scope
   14 |         scaffoldCost.at(i) = inputCost;
      |         ^~~~~~~~~~~~
a.cc:17:10: error: 'vector' is not a member of 'std'
   17 |     std::vector<long long> minCosts(n);
      |          ^~~~~~
a.cc:17:10: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:17:17: error: expected primary-expression before 'long'
   17 |     std::vector<long long> minCosts(n);
      |                 ^~~~
a.cc:30:17: error: 'minCosts' was not declared in this scope
   30 |                 minCosts.at(index - diff - 1)
      |                 ^~~~~~~~
a.cc:31:28: error: 'scaffoldCost' was not declared in this scope
   31 |                 + std::abs(scaffoldCost.at(index) - scaffoldCost.at(index - diff - 1))
      |                            ^~~~~~~~~~~~
a.cc:34:9: error: 'minCosts' was not declared in this scope
   34 |         minCosts.at(index) = tempMinCost;
      |         ^~~~~~~~
a.cc:36:18: error: 'minCosts' was not declared in this scope
   36 |     std::cout << minCosts.back() << std::endl;
      |                  ^~~~~~~~
Language: C++

/*#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")*/
#include <bits/stdc++.h>
//#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define rep(i,j,k) for(int i=j;i<k;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1LL;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
main(){
    fastio;
    int h[n+1], custo[n+1];
    int menor = 100000000;
    
    for(int i=1;i<=n;i++) {
        cin >> h[i]; 
    }
    
    custo[1] = 0;
    custo[2] = abs(h[2]-h[1]);

    for( int i=3;i<=n;i++ ) {
        menor = 100000000;
        for(int j=1;j<=k;j++){
            if( i-j>0 ){
            custo[i]=custo[i-j] + abs(h[i]-h[i-j]);
 if( custo[i]<menor ){
                menor = custo[i];
            }
            }
           
        }
        custo[i] = menor;
    }
    cout << custo[n] << endl;
    return 0;
}   

Compiler output:
a.cc:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:34:11: error: 'n' was not declared in this scope; did you mean 'yn'?
   34 |     int h[n+1], custo[n+1];
      |           ^
      |           yn
a.cc:38:16: error: 'h' was not declared in this scope
   38 |         cin >> h[i];
      |                ^
a.cc:41:5: error: 'custo' was not declared in this scope
   41 |     custo[1] = 0;
      |     ^~~~~
a.cc:42:20: error: 'h' was not declared in this scope
   42 |     custo[2] = abs(h[2]-h[1]);
      |                    ^
a.cc:46:24: error: 'k' was not declared in this scope
   46 |         for(int j=1;j<=k;j++){
      |                        ^
Language: C++

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

using namespace std;

int min(vector<int> p)
{
  	sort(p.begin(),p.end());
    return p[0];
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h;
    for(int  i = 0 ; i < n ; i++ )
    {
      	int l;
        cin >> l;
      	h.push_back(l);
    }

    vector<int> dp;
    dp.push_back(0);

    for(int i = 1 ; i < n ; i++)
    {
      vector<int> possible;
      
      int x = 1;
      while((i - x) >= 0 && x <= k)
      {
          int pos = abs(h[i] - h[i-x]) + dp[i-x];
          possible.push_back(pos);
          x += 1;
      }
      sum = min(possible);
      dp.push_back(sum);
    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:7: error: 'sum' was not declared in this scope
   40 |       sum = min(possible);
      |       ^~~
Language: C++

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

using namespace std;

int min(vector<int> p)
{
  	sort(p.begin(),p.end());
    return p[0];
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h;
    for(int  i = 0 ; i < n ; i++ )
    {
      	int l;
        cin >> l;
      	h.push_back(l);
    }

    vector<int> dp;
    dp.push_back(0);

    for(int i = 1 ; i < n ; i++)
    {
      vector<int> possible;
      
      int x = 1;
      while((i - x) >= 0 && x <= k)
      {
          pos = abs(h[i] - h[i-x]) + dp[i-x];
          possible.push_back(pos);
          x += 1;
      }
      sum = min(possible);
      dp.push_back(sum);
    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:11: error: 'pos' was not declared in this scope
   36 |           pos = abs(h[i] - h[i-x]) + dp[i-x];
      |           ^~~
a.cc:40:7: error: 'sum' was not declared in this scope
   40 |       sum = min(possible);
      |       ^~~
Language: C++

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

using namespace std;

int min(vector<int> p)
{
  	p.sort();
    return p[0];
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h;
    for(int  i = 0 ; i < n ; i++ )
    {
      	int l;
        cin >> l;
      	h.push_back(l);
    }

    vector<int> dp;
    dp.push_back(0);

    for(int i = 1 ; i < n ; i++)
    {
      vector<int> possible;
      
      int x = 1;
      while((i - x) >= 0 && x <= k)
      {
          pos = abs(h[i] - h[i-x]) + dp[i-x];
          possible.push_back(pos);
          x += 1;
      }
      sum = min(possible);
      dp.push_back(sum);
    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc: In function 'int min(std::vector<int>)':
a.cc:10:11: error: 'class std::vector<int>' has no member named 'sort'
   10 |         p.sort();
      |           ^~~~
a.cc: In function 'int main()':
a.cc:36:11: error: 'pos' was not declared in this scope
   36 |           pos = abs(h[i] - h[i-x]) + dp[i-x];
      |           ^~~
a.cc:40:7: error: 'sum' was not declared in this scope
   40 |       sum = min(possible);
      |       ^~~
Language: C++

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

using namespace std;

int min(vector<int> p)
{
  	sort(p);
    return p[0];
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h;
    for(int  i = 0 ; i < n ; i++ )
    {
      	int l;
        cin >> l;
      	h.push_back(l);
    }

    vector<int> dp;
    dp.push_back(0);

    for(int i = 1 ; i < n ; i++)
    {
      vector<int> possible;
      
      int x = 1;
      while((i - x) >= 0 && x <= k)
      {
          pos = abs(h[i] - h[i-x]) + dp[i-x];
          possible.push_back(pos);
          x += 1;
      }
      sum = min(possible);
      dp.push_back(sum);
    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc: In function 'int min(std::vector<int>)':
a.cc:10:13: error: no matching function for call to 'sort(std::vector<int>&)'
   10 |         sort(p);
      |         ~~~~^~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 1 provided
a.cc: In function 'int main()':
a.cc:36:11: error: 'pos' was not declared in this scope
   36 |           pos = abs(h[i] - h[i-x]) + dp[i-x];
      |           ^~~
a.cc:40:7: error: 'sum' was not declared in this scope
   40 |       sum = min(possible);
      |       ^~~
Language: C++

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

using namespace std;

int min(vetor<int> p)
{
  	sort(p);
    return p[0];
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h;
    for(int  i = 0 ; i < n ; i++ )
    {
      	int l;
        cin >> l;
      	h.push_back(l);
    }

    vector<int> dp;
    dp.push_back(0);

    for(int i = 1 ; i < n ; i++)
    {
      vector<int> possible;
      
      int x = 1;
      while((i - x) >= 0 && x <= k)
      {
          pos = abs(h[i] - h[i-x]) + dp[i-x];
          possible.push_back(pos);
          x += 1;
      }
      sum = min(possible);
      dp.push_back(sum);
    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc:8:9: error: 'vetor' was not declared in this scope
    8 | int min(vetor<int> p)
      |         ^~~~~
a.cc:8:15: error: expected primary-expression before 'int'
    8 | int min(vetor<int> p)
      |               ^~~
a.cc: In function 'int main()':
a.cc:36:11: error: 'pos' was not declared in this scope
   36 |           pos = abs(h[i] - h[i-x]) + dp[i-x];
      |           ^~~
a.cc:40:7: error: 'sum' was not declared in this scope
   40 |       sum = min(possible);
      |       ^~~
a.cc:40:13: error: reference to 'min' is ambiguous
   40 |       sum = min(possible);
      |             ^~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidates are: '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:5686:5: note:                 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
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:281:5: note:                 '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:233:5: note:                 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:8:5: note:                 'int min'
    8 | int min(vetor<int> p)
      |     ^~~
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 x;
        cin >> x;
        h.push_back(x);
    }
    vector<int> a(n, 0);
    a[0] = 0;
    for (int i = 1; i < n; i++) {
        int m = INT_MAX;
        for (int j = max(i - k, 0); j < i; j++) {
            m = min(m, abs(h[i] - h[j]) + a[j]);
        }
        a[i] = m;
    }
    cout << a[n - 1] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:17: error: 'INT_MAX' was not declared in this scope
   16 |         int m = 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

import java.util.Scanner;

import java.lang.Math;

public class Main {
	private static int n_pedras, pulo_maximo;
	private static Integer[] altura_pedras;
	private static Integer[][] custos;
	
	public static void main(String[] args) {

			Scanner scanner = new Scanner(System.in);
			
			n_pedras = scanner.nextInt();
		
		    pulo_maximo = scanner.nextInt();
		    
		    altura_pedras = new Integer[n_pedras + 1];
		    
		    custos = new Integer[n_pedras + 1][pulo_maximo + 1];
		    
		    for(int i = 1; i <= n_pedras; i++){
		    	altura_pedras[i] = scanner.nextInt();
		    }

		    for(int i = 1; i <= n_pedras; i++){
		        for(int j = 1; j <= pulo_maximo; j++){
		            custos[i][j] = -1;
		        }
		    }

		    int custo_minimo = path(1);

		    System.out.println(custo_minimo);
	}
	
	private static int path(int pedra){
	    if(pedra == n_pedras){
	        return 0;
	    }

	    int custo_minimo = abs(altura_pedras[pedra] - altura_pedras[pedra + 1]) + path(pedra + 1);

	    for(int i = 2; i <= pulo_maximo; i++){
	        if(pedra + i <= n_pedras){
	            if(custos[pedra][i] == -1){
	                custos[pedra][i] = Math.abs(altura_pedras[pedra] - altura_pedras[pedra + i]) + path(pedra + i);
	            }

	            custo_minimo = Math.min(custo_minimo, custos[pedra][i]);
	        }
	    }

	    return custo_minimo;
	}
}

Compiler output:
Main.java:42: error: cannot find symbol
	    int custo_minimo = abs(altura_pedras[pedra] - altura_pedras[pedra + 1]) + path(pedra + 1);
	                       ^
  symbol:   method abs(int)
  location: class Main
1 error
Language: C++

#include <iostream>
#include <algorithm>

#define INF 999999

using namespace std;

typedef long long int ll;

int values[100009];
int n, k;
ll dp[100009];

int main() {
  memset(dp, INF, sizeof(dp));

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

  dp[0] = 0;

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

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

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


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

#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

vector<long long> vec(110000);

int main() {
 long long dp[110000];
 int a,b;
 cin>>a>>b;
 rep(i,a){
   cin>>vec.at(i);
 }
 rep(i,110000){
   dp[i]=1000000000;
 }
 dp[0]=0;
 rep(i,a){
   for(long long j=1;j<=b;j++){
     chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(i+j)))
   }
 }
 cout<<dp[a-1]<<endl;
 

}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:6: error: 'chmin' was not declared in this scope
   25 |      chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(i+j)))
      |      ^~~~~
Language: C++

#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

vector<long long> vec(110000);

int main() {
 long long dp[110000];
 int a,b;
 cin>>a>>b;
 rep(i,a){
   cin>>vec.at(i);
 }
 rep(i,110000){
   dp[i]=1000000000;
 }
 dp[0]=0;
 rep(i,a){
   for(long long j=1;j<=b;j++){
     chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(h+i)))
   }
 }
 cout<<dp[a-1]<<endl;
 

}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:47: error: 'h' was not declared in this scope
   25 |      chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(h+i)))
      |                                               ^
a.cc:25:6: error: 'chmin' was not declared in this scope
   25 |      chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(h+i)))
      |      ^~~~~
Language: C++

#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

vector<long long> vec(110000);

int main() {
 long long dp[110000];
 int a,b;
 cin>>a>>b;
 rep(i,a){
   cin>>vec.at(i);
 }
 rep(i,110000){
   dp[i]=1000000000;
 }
 dp[0]=0;
 rep(i,a){
   for(long long j=1;j<=k;j++){
     chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(h+i)))
   }
 }
 cout<<dp[a-1]<<endl;
 

}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:25: error: 'k' was not declared in this scope
   24 |    for(long long j=1;j<=k;j++){
      |                         ^
a.cc:25:47: error: 'h' was not declared in this scope
   25 |      chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(h+i)))
      |                                               ^
a.cc:25:6: error: 'chmin' was not declared in this scope
   25 |      chmin(dp[i+j],dp[i]+abs(vec.at(i)-vec.at(h+i)))
      |      ^~~~~
Language: C++

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


int findMin(int h[], int n, int k) {
	int cost[n];
	cost[0] = 0;
	cost[1] = abs(h[0] - h[1]);

	for(int i=2; i<n; i++) {
		int minCost = INT_MAX;
		for(int j=1; j<=k; j++) {
			int tp = INT_MAX;
			if(i >= j) {
				tp = cost[i-j] + abs(h[i] - h[i-j]);
				//cout<<tp<<" ";
			}
			minCost = min(minCost, tp);
		}
		cost[i] = minCost;
		//cout<<"----"<<i<<" :"<<cost[i]<<endl;
	}

	return cost[n-1];
}

int main() {
	int n,k;
	int h[100000];
	cin>>n>>k;
	for(int i=0;i <n; i++)
		cin>>h[i];


	cout<<findMin(h, n, k)<<endl;
}

Compiler output:
a.cc: In function 'int findMin(int*, int, int)':
a.cc:12:31: error: 'INT_MAX' was not declared in this scope
   12 |                 int minCost = INT_MAX;
      |                               ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <limits>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

include <iostream>
#include <climits>
using namespace std;
int min_arr(int arr[],int len){
  int ans=arr[0];
  for(int i=1;i<len;i++){
    ans=min(ans,arr[i]);
  }
  return ans;
}
int main(){
  int n,k,i;
  cin>>n>>k;
  int h[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  int dp[n],tmp[k+1];
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(i=2;i<n;i++){
    tmp[0]=INT_MAX;
    for(int j=1;j<=k;j++){
      if(j>i){
        tmp[j]=INT_MAX;
        continue;
      }
      tmp[j]=dp[i-j]+abs(h[i]-h[i-j]);
    }
    dp[i]=min_arr(tmp,k+1);
  }
  cout<<dp[n-1];
  return 0;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <iostream>
      | ^~~~~~~
a.cc: In function 'int min_arr(int*, int)':
a.cc:7:9: error: 'min' was not declared in this scope
    7 |     ans=min(ans,arr[i]);
      |         ^~~
a.cc: In function 'int main()':
a.cc:13:3: error: 'cin' was not declared in this scope
   13 |   cin>>n>>k;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <climits>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:20:9: error: 'abs' was not declared in this scope
   20 |   dp[1]=abs(h[0]-h[1]);
      |         ^~~
a.cc:32:3: error: 'cout' was not declared in this scope
   32 |   cout<<dp[n-1];
      |   ^~~~
a.cc:32:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include <iostream>
#define ffor(a, b, c) for (int a=b; a<=c; a++)
using namespace std;

int n, k, h[100007], dp[100007];

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:25: error: 'INT_MAX' was not declared in this scope
   12 |                 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 | #define ffor(a, b, c) for (int a=b; a<=c; a++)
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:20: error: expected ';' before 'i'
   12 |         for(int i=1 i<n; i++)
      |                    ^~
      |                    ;
a.cc:15:36: error: expected ';' before numeric constant
   15 |       for(int j=i-1; j>= (i-k < 0 ) 0 ? i - k; j--)
      |                                    ^~
      |                                    ;
a.cc:15:46: error: expected ':' before ';' token
   15 |       for(int j=i-1; j>= (i-k < 0 ) 0 ? i - k; j--)
      |                                              ^
      |                                              :
a.cc:15:46: error: expected primary-expression before ';' token
a.cc:15:46: error: expected ')' before ';' token
   15 |       for(int j=i-1; j>= (i-k < 0 ) 0 ? i - k; j--)
      |          ~                                   ^
      |                                              )
a.cc:15:48: error: 'j' was not declared in this scope
   15 |       for(int j=i-1; j>= (i-k < 0 ) 0 ? i - k; j--)
      |                                                ^
Language: C++

#include <cstdio>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> heights(n);
    for (int i = 0; i < n; i++)
    {
        int h;
        scanf("%d", &h);
        heights.push_back(h)
    }
    vector<int> dp(n, 1e9 + 5);
    dp[0] = 0;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'vector' was not declared in this scope
   13 |     vector<int> heights(n);
      |     ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include <iostream>
  +++ |+#include <vector>
    6 | 
a.cc:13:12: error: expected primary-expression before 'int'
   13 |     vector<int> heights(n);
      |            ^~~
a.cc:18:9: error: 'heights' was not declared in this scope
   18 |         heights.push_back(h)
      |         ^~~~~~~
a.cc:20:12: error: expected primary-expression before 'int'
   20 |     vector<int> dp(n, 1e9 + 5);
      |            ^~~
a.cc:21:5: error: 'dp' was not declared in this scope
   21 |     dp[0] = 0;
      |     ^~
a.cc:29:48: error: 'h' was not declared in this scope
   29 |                 dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
      |                                                ^
Language: C++

#include <cstdio>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
    int n, K, h[10000], dp[10000];
    scanf("%d %d", &n, &K);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    for (int i = 0; i < n; i++)
    {
        dp[i] = 1e9 + 5;
    }
    dp[0] = 0;

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

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

#include <cstdio>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <iostream>

using namespace std;

int main()
{
    int N, K, h[10000], dp[10000];
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++)
    {
        dp[i] = 1e9 + 5;
    }
    dp[0] = 0;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:23:25: error: 'n' was not declared in this scope
   23 |     for (int i = 0; i < n; ++i)
      |                         ^
a.cc:25:38: error: 'k' was not declared in this scope
   25 |         for (int j = i + 1; j <= i + k; ++j)
      |                                      ^
a.cc:33:23: error: 'n' was not declared in this scope
   33 |     printf("%d\n", dp[n - 1]);
      |                       ^
Language: C++

#include <cstdio>
#include <climits>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
    int N, K, h[10000], dp[10000];
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    for (int i = 0; i < N; i++)
    {
        dp[i] = 1e9 + 5;
    }
    dp[0] = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j <= i + K; j++)
        {
            if (j < N)
            {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[N - 1]);
    return 0;
}

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

// IN THE NAME OF GOD
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long unsigned int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD 1e9+7
#define print printf
#define in scanf
using namespace std;
template<class type>
void displaySingle(type &arr)
{
for(auto i:arr)
cout<<i<<" ";
cout<<endl;
}
template<class type>
void displayDouble(type &arr)
{
for(auto i:arr)
cout<<i.first<<" "<<i.second<<endl;
}
int main()
{
int n,k,i;
in("%d %d",&n,&k);
vector<ll>input(n);
REP(i,n)
in("%lld",&input[i]);
vector<ll>dp(n,INF);
dp[0]=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<=i+k && j<input.size();j++)
{
dp[j]=min(dp[j],dp[i]+abs(input[i]-input[j]));
}
}
print("%lld\n",dp[dp.size()-1]);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:26: error: call of overloaded 'abs(__gnu_cxx::__alloc_traits<std::allocator<long long unsigned int>, long long unsigned int>::value_type)' is ambiguous
   40 | dp[j]=min(dp[j],dp[i]+abs(input[i]-input[j]));
      |                       ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C++

// IN THE NAME OF GOD
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long unsigned int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD 1e9+7
#define print printf
#define in scanf
using namespace std;
template<class type>
void displaySingle(type &arr)
{
for(auto i:arr)
cout<<i<<" ";
cout<<endl;
}
template<class type>
void displayDouble(type &arr)
{
for(auto i:arr)
cout<<i.first<<" "<<i.second<<endl;
}
int main()
{
int n,k,i;
in("%d %d",&n,&k);
vector<ll>input(n);
REP(i,n)
in("%d",&input[i]);
vector<ll>dp(n,INF);
dp[0]=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<=i+k && j<input.size();j++)
{
dp[j]=min(dp[j],dp[i]+abs(input[i]-input[j]));
}
}
print("%d\n",dp[dp.size()-1]);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:26: error: call of overloaded 'abs(__gnu_cxx::__alloc_traits<std::allocator<long long unsigned int>, long long unsigned int>::value_type)' is ambiguous
   40 | dp[j]=min(dp[j],dp[i]+abs(input[i]-input[j]));
      |                       ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~
Language: C

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

int main(){

    int ashiba_num, jump_num;
    int i,j;
    int dP_min,dP_now;

    scanf("%d", &ashiba_num);
    scanf("%d", &jump_num);

    int ashiba_cost[ashiba_num];
    int dP[ashiba_num + 1];

    for (i = 0 ; i < ashiba_num ; i++){
        scanf("%d" , &ashiba_cost[i]);         
    }

    dP[0] = 0;
    dP[1] = abs(ashiba_cost[1] - ashiba_cost[0]);

    for (i = 2 ; i <= ashiba_num - 1 ; i++){
        dP_min = 10000;

        for (j = 1 ; j <= jump_num ; j++){
            if (i - j >= 0){
                dP_now = dP[i - j] + abs(ashiba_cost[i] - ashiba_cost[i - j]);
            }else{
                dP_now = abs(ashiba_cost[move] - ashiba_cost[0]);
            }

            if ( dP_min >= dP_now || dP_min < 0 ){
                dP_min = dP_now;
            }
        }
        dP[i] = dP_min;
    }
    printf("%d\n", dP[ashiba_num - 1]);
}

Compiler output:
main.c: In function 'main':
main.c:32:42: error: 'move' undeclared (first use in this function)
   32 |                 dP_now = abs(ashiba_cost[move] - ashiba_cost[0]);
      |                                          ^~~~
main.c:32:42: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;

const long long inf = 1LL << 60;

int n,k;
ll h[inf];
ll dp[inf];

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

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

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            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:8:4: error: size '9223372036854775808' of array 'h' exceeds maximum object size '9223372036854775807'
    8 | ll h[inf];
      |    ^
a.cc:9:4: error: size '9223372036854775808' of array 'dp' exceeds maximum object size '9223372036854775807'
    9 | ll dp[inf];
      |    ^~
a.cc: In function 'int main()':
a.cc:13:39: error: 'h' was not declared in this scope
   13 |     for(int i = 0; i < n; i++) cin >> h[i];
      |                                       ^
a.cc:15:34: error: 'dp' was not declared in this scope
   15 |     for(int i = 0; i < inf; i++) dp[i] = inf;
      |                                  ^~
a.cc:17:5: error: 'dp' was not declared in this scope
   17 |     dp[0] = 0;
      |     ^~
a.cc:20:51: error: 'h' was not declared in this scope
   20 |             dp[i + j] = min(dp[i + j],dp[i] + abs(h[i + j] - h[i]));
      |                                                   ^
Language: C++

#include <iostream>
using namespace std;
typedef long long ll;

const ll inf = 1LL << 60;

int n,k;
ll h[inf];
ll dp[inf];

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

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

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            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:8:4: error: size '9223372036854775808' of array 'h' exceeds maximum object size '9223372036854775807'
    8 | ll h[inf];
      |    ^
a.cc:9:4: error: size '9223372036854775808' of array 'dp' exceeds maximum object size '9223372036854775807'
    9 | ll dp[inf];
      |    ^~
a.cc: In function 'int main()':
a.cc:13:39: error: 'h' was not declared in this scope
   13 |     for(int i = 0; i < n; i++) cin >> h[i];
      |                                       ^
a.cc:15:34: error: 'dp' was not declared in this scope
   15 |     for(int i = 0; i < inf; i++) dp[i] = inf;
      |                                  ^~
a.cc:17:5: error: 'dp' was not declared in this scope
   17 |     dp[0] = 0;
      |     ^~
a.cc:20:51: error: 'h' was not declared in this scope
   20 |             dp[i + j] = min(dp[i + j],dp[i] + abs(h[i + j] - h[i]));
      |                                                   ^
Language: Java

import java.io.*;
import java.util.*;
class Main
{
  public static void main(String args[])throws IOException
   {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tk;
     tk=new StringTokenizer(br.readLine());
    int n=Integer.parseInt(tk.nextToken());
    int k=Integer.parseInt(tk.nextToken());
    tk=new StringTokenizer(br.readLine());
    int a[]=new int[n];
    for(int i=0;i<n;i++)
    {
      a[i]=Integer.parseInt(tk.nextToken());
     }
    if(n<=2)
    {
      System.out.println(Math.abs(a[1]-a[0]));
      System.exit(0);
    }
    int prev[]=new int[n];
    prev[0]=0;
    prev[1]=Math.abs(a[1]-a[0]);
    int minCost=Integer.MAX_VALUE;
    for(int i=2;i<n;i++)
    {
      int minCost=Integer.MAX_VALUE;
      for(int j=Math.max(0,i-k);j<i;j++)
      {
         if(prev[j]+Math.abs(a[i]-a[j])<=minCost)
         {
           minCost=prev[j]+Math.abs(a[i]-a[j]);
         }
         prev[i]=minCost;
        
      }
      
      
    }
    System.out.println(prev[n-1]);
    
    
    
    
  }
  
}
 

Compiler output:
Main.java:29: error: variable minCost is already defined in method main(String[])
      int minCost=Integer.MAX_VALUE;
          ^
1 error
Language: C++

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

int main()
{
    
    int N, K, arr[100000], dp[100000];
    cin >> N >> K
    for (int i = 0; i < N; i++){
        cin >> arr[i];
        dp[i] = 1000000001;
    }
    dp[0] = 0;
    int i, j;
    for ( i = 0; i < N; i++){
        for ( j = i + 1; j < i + K; j++){
            if (j < N) {
                dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
            }
        }
    }
    cout << dp[N - 1];

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: expected ';' before 'for'
   12 |     cin >> N >> K
      |                  ^
      |                  ;
   13 |     for (int i = 0; i < N; i++){
      |     ~~~           
a.cc:13:21: error: 'i' was not declared in this scope
   13 |     for (int i = 0; i < N; i++){
      |                     ^
Language: C++

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

int main()
{
    
    int N, K, arr[100000], dp[100000];
    cin >> N >> K
    for (int i = 0; i < N; i++){
        cin >> arr[i];
        dp[i] = 1000000001;
    }
    dp[0] = 0;
    for (int i = 0; i < N; i++){
        for (int j = i + 1; j < i + K; j++){
            if (j < N) {
                dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
            }
        }
    }
    cout << dp[N - 1];

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:18: error: expected ';' before 'for'
   12 |     cin >> N >> K
      |                  ^
      |                  ;
   13 |     for (int i = 0; i < N; i++){
      |     ~~~           
a.cc:13:21: error: 'i' was not declared in this scope
   13 |     for (int i = 0; i < N; i++){
      |                     ^
Language: C++

#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int h[(int)1e5], dp[(int)1e5],t[(int)1e5] = {0}, K, N;


int main()
{
	K = N = 0;
	for(int j = 1;j <= 1e5;j++)
	{
		dp[j] = 1e9;
	}
	scanf("%d %d", &N, &K);
	for(int i = 1;i <= N;i++)
	{
		scanf("%d", &h[i]);		
	}
	dp[1] = 0;
	dp[2] = dp[1] + abs(h[1] - h[2]);
	for(int i = 1;i <= N;i++)
	{
		for(int j = 1;j <= K;j++)		
		{
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
		printf("%d\n", dp[i]);
	}
	printf("%d\n", dp[N]);
	return 0;	
}
/*
   唉，推一下，我好菜...
   dp[1+1] = min(dp[2], dp[1] + abs(h[1] - h[2]));从第一个石头跳到j个石头
   dp[1+2] = min(dp[3]，dp[1] + abs(h[1] - h[3]));
   dp[1+3] = min(dp[4], dp[1] + abs(h[1] - h[4]));

   dp[2+1] = min(dp[3], dp[2] + abs(h[2] - h[3]));
   dp[2+2] = min(dp[4], dp[2] + abs(h[2] - h[4]));
   dp[2+3] = min(dp[5], dp[2] + abs(h[2] - h[5]));

   dp[3+1] = min(dp[4], dp[3] + abs(h[3] - h[4]));
   dp[3+2] = min(dp[5], dp[3] + abs(h[3] - h[5]));
   dp[3+3] = min(dp[6], dp[3] + abs(h[3] - h[6]));

   dp[4+1] = min(dp[5], dp[4] + abs(h[4] - h[5]));
   dp[4+2] = min(dp[6], dp[4] + abs(h[4] - h[6]));
   dp[4+3] = min(dp[7], dp[4] + abs(h[4] - h[7]));
啊不推了，好像知道了

   .....

 *

Compiler output:
a.cc:34:1: error: unterminated comment
   34 | /*
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
/* Author : Ravikumar Navale */
#define fastIo() ios_base :: sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define pb push_back
#define endl  "\n"
typedef long long int ll;
vector<pair<ll,ll> >v1, v2, v3;
const ll MOD = 1e9 + 7;
const double peek = 1e7 ;

int main()
{
    fastIo();
    ll N, K;
    cin>> N >> K;
    ll A[N+1];
    ll DP[N+1];
    for(ll  i = 1;  i <=N ; i++)
    {
        cin >>A[i];
        DP[i] = 0;
    }
    
    
    for(ll i= 2; i <= N ; i++)
    {
        for(ll j = max(i-K,1); j<i ; j++)
        {
            DP[i] = min(DP[j] + abs(A[i]-A[j]),DP[i]);
            
        }
    }
    
    cout << DP[N] ;
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:23: error: no matching function for call to 'max(ll, int)'
   28 |         for(ll j = max(i-K,1); j<i ; j++)
      |                    ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:28:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |         for(ll j = max(i-K,1); j<i ; j++)
      |                    ~~~^~~~~~~
/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:28:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |         for(ll j = max(i-K,1); j<i ; j++)
      |                    ~~~^~~~~~~
Language: C++

#include <bits\stdc++.h>

using namespace std;
int n,k,a[1000],f[1000];
int main()
{
    cin>>n>>k;
    for (long i=1;i<=n;i++) cin>>a[i];
    f[1]=0;
    f[2]=abs(a[1]-a[2]);
    for (long i=3;i<=n ;i++)
    {
        f[i]=9999999999;
        for (long j=1;j<=k;j++)
        {
            if (i-j<=0) break;
            f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<f[n];
    return 0;
}


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

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

int dp[100002], c, k, yukseklik[100002];

int mutlak(int e, int r){
	if(e>r)return e-r;
	else return r-e;
}

int recursive(int n){
	if(dp[n])return dp[n];
	if(n==c)return 0;
	if(n>c)return 9999;
	int a=9999;
	for(int i=0;i<k;i++)
	a=recursive(n+1)+mutlak(yukseklik[n],yukseklik[n+1]);
	if(a<b){
		dp[n]=a;
		return dp[n];
	}else{
		dp[n]=b;
		return dp[n];
	}
}

int main(void){
	cin>>c>>k;
	for(int i=1;i<=c;i++)cin>>yukseklik[i];
	memset(dp, 99999, sizeof(int)*(c+1));
	dp[c]=0;
	//recursive(1);
	dp[c-1]=mutlak(yukseklik[c],yukseklik[c-1]);
	for(int i=c-2;i>0;i--)for(int j=1;j<=k;j++)dp[i]=min(mutlak(yukseklik[i], yukseklik[i+j])+dp[i+j],dp[i]);
	cout<<dp[1];
	return 0;
}

Compiler output:
a.cc: In function 'int recursive(int)':
a.cc:19:14: error: 'b' was not declared in this scope
   19 |         if(a<b){
      |              ^
a.cc:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^