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

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

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


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

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

typedef long double LD;
typedef long long ll;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define mod             1000000007
#define INF             2147483647
#define Endl            "\n"
#define FasterIO        ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0) ;
#define precision(a)    cout << fixed << setprecision(a)
#define bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define reset(a,b)      memset(a,b,sizeof(a));
#define srt(a)      sort(a.begin(),a.end());

const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);
const int sz=1e5+9;

int strtoint(string str){
    stringstream ss(str);
    int x = 0;
    ss >> x ;
    return x ;
}
string intostr(int x){
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}
void rem(string &s, const string &c) {
	auto pos = s.find(c);
	if (pos == string::npos) {
		cout << -1 << endl;
		exit(0);
	}
	s.erase(0, pos + 1);
}
void println (int n){
    cout<<n<<"\n";
}
void printvec(vector <int> &a){
    for (int i=0;i<a.size();i++){
        cout<<a[i]<<" ";
    }
    cout<<"\n";
}

void printgraph(vector <int> g[],int e){
    for (int i=0;i<e;i++){
        cout<<i<<" --> ";
        for (int j=0;j<g[i].size();j++){
            cout<<g[i][j]<<" ";
        }
        cout<<"\n";
    }
}

void printmap (map <int,int> &mymap){
    for (auto itr = mymap.begin(); itr != mymap.end(); ++itr) {
        cout << '\t' << itr->first
             << '\t' << itr->second << '\n';
    }
    cout << "\n";
}

int n,x,arr[sz],dp[sz];


int rec (int i){
    if (i==n) return 0;
    if (dp[i]!=-1) return dp[i];

    int ret1=INF;
    for(int j=1;j<=k && i+j<=n;j++){
        ret1=min(ret1,abs(arr[i]-arr[i+j])+rec(i+j));
    }
    return dp[i]=ret1;
}


void solve(){

    cin>>n;
    reset (dp,-1);
    for (int i=1;i<=n;i++)cin>>arr[i];


    cout << rec (1) << Endl;

    //printvec(v);
}


int main(){
    //FasterIO;

    solve();
    return 0;
}

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

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

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

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

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

    dp[0] = 0;
    // dp[1] = abs( ht[1] - ht[0] );

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

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

    // main();

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:49: error: expected primary-expression before ')' token
   25 |         for(int j = i-1; j <= i-k && j >= 0; j==)
      |                                                 ^
Language: C++

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

const long long INF = 1LL << 60;

int N;
long long h[110000];

long long dp[110000];

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

]    for (int i = 0; i < 110000; ++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] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:1: error: expected primary-expression before ']' token
   19 | ]    for (int i = 0; i < 110000; ++i) dp[i] = INF;
      | ^
a.cc:19:22: error: 'i' was not declared in this scope
   19 | ]    for (int i = 0; i < 110000; ++i) dp[i] = INF;
      |                      ^
a.cc:21:1: error: expected primary-expression before ']' token
   21 | ]    dp[0] = 0;
      | ^
Language: C++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int         long long   
#define double      long double
#define endl        "\n"
#define pb          push_back
#define PI          3.1415926535897932384626433832795l
#define F           first
#define S           second
#define mp          make_pair
#define f(i,n)      for(int i=0;i<n;i++)
#define fastio      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)      (v).begin(),(v).end()
#define sort(v)     sort((v).begin(),(v).end())
#define rall(v)     (v).rbegin(),(v).rend()
#define rsort(v)     sort((v).rbegin(),(v).rend())
#define gcd(a,b)    __gcd((a),(b))
#define minn(v)     *min_element(v.begin(), v.end());
#define maxx(v)     *max_element(v.begin(), v.end());
#define print(x)    cout<<(x)<<endl;
typedef pair<int,int> pii;  
typedef vector<int> vi;
//x.substr(start, length);
struct type{
    int k, i, j;
};
//to check if a no is prime or not?
bool isPrime(int n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

// minimum subaaray sum of size k-sliding window approach
int findSubarray(int arr[], int n, int k)
{
	int window_sum = 0;
	int min_window = INT_MAX;
	int last = 0;
	for (int i = 0; i < n; i++)
	{
		window_sum += arr[i];
		if (i + 1 >= k)
		{
			if (min_window > window_sum)
			{
				min_window = window_sum;
				last = i;
			}
			window_sum -= arr[i + 1 - k];
		}
	}
	int sum=0;
	for(int i=last-k+1;i<=last;i++)
	{
	    sum+=arr[i];
	}
	return sum;
}
signed main() 
{
    fastio;
    int n,k;
    cin>>n>>k;
    vi a(n);
    f(i,n)cin>>a[i];
    vi dp(n);
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=dp[i-1]+abs(a[i]-a[i-1])
        for(int j=2;j<=min(k,i);j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:39: error: expected ';' before 'for'
   83 |         dp[i]=dp[i-1]+abs(a[i]-a[i-1])
      |                                       ^
      |                                       ;
   84 |         for(int j=2;j<=min(k,i);j++)
      |         ~~~                            
a.cc:84:21: error: 'j' was not declared in this scope
   84 |         for(int j=2;j<=min(k,i);j++)
      |                     ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int  long long 
#define tc(t)  int t; cin>>t; while(t--) 
#define f(n)    for(int i=0;i<n;i++)

#define endl   "\n" 


void i_o_f()
{
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}



minimum_cost(int *arr,int n,int k)
{
  int dp[n+1];

  dp[0]=0;
  dp[1]=0;

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

                    



         }






  }

  for(int i=0;i<=n;i++) cout<<dp[i]<<" ";
    cout<<endl;
  return dp[n];






}




int32_t main()
{
  //i_o_f();
  int n,k;
  cin>>n>>k;
  int *arr=new int[n];

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





}

Compiler output:
a.cc:22:1: error: ISO C++ forbids declaration of 'minimum_cost' with no type [-fpermissive]
   22 | minimum_cost(int *arr,int n,int k)
      | ^~~~~~~~~~~~
Language: C++

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


int main(){
  int n,k;
  cin>>n>>k;
  int h[n];
  for (int i=0;i<n;i++)
    cin>>h[i];
  int a[n+1][k+1],b[n+1];
  b[0]=0;
  for (int i=0;i<=n;i++){
    if (i)
    b[i]=INT_MAX;
    for (int j=0;j<=min(i,k);j++){
      if (i==0||j==0)
         a[i][j]=0;
      else {
         a[i][j]=b[i-j]+abs(h[i-1]-h[i-j-1]);
          b[i]=min(b[i],a[i][j]);}
    }
    for (int l=j;l<=k;l++)
      a[i][l]=0;
  }
   cout<<b[n]<<endl;
  
  return 0;
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: expected primary-expression before '>=' token
   25 |           if(i-j)>=0)
      |                  ^~
Language: C++

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

using i64 = int64_t;
i64 INF = 1ll << 60;

template<class T> inline bool  chmin(i64 &a, i64 b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(110000);
  for(int i = 0; i < n; i++)
    cin >> h[i];
  
  vector<i64> cost(110000);
  for(int i = 0; i < cost.size(); i++)
    cost[i] = INF;
  cost[0] = 0;
  
  for(int i = 0; i < n; i++){
    for(int j = 1; j <= k; j++)
      chmin(cost[i+j], cost[i]+abs(h[i]-h[i+j]));
  }
  
  cout << cost[n-1] << endl;
  
  return 0;
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:12: error: no matching function for call to 'chmin(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
   30 |       chmin(cost[i+j], cost[i]+abs(h[i]-h[i+j]));
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:8:32: note: candidate: 'template<class T> bool chmin(i64&, i64)'
    8 | template<class T> inline bool  chmin(i64 &a, i64 b){
      |                                ^~~~~
a.cc:8:32: note:   template argument deduction/substitution failed:
a.cc:30:12: note:   couldn't deduce template parameter 'T'
   30 |       chmin(cost[i+j], cost[i]+abs(h[i]-h[i+j]));
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:22:25: error: expected '}' at end of input
   22 |     cout<<dp[n-1]<<endl;
      |                         ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++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] << endl;
}


Compiler output:
main.c:1:1: error: unknown type name 'using'
    1 | using namespace std;
      | ^~~~~
main.c:1:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
    1 | using namespace std;
      |                 ^~~
main.c:2:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    2 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
      |         ^
main.c:3:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
    3 | template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
      |         ^
main.c: In function 'main':
main.c:15:15: error: 'cin' undeclared (first use in this function)
   15 |     int N, K; cin >> N >> K;
      |               ^~~
main.c:15:15: note: each undeclared identifier is reported only once for each function it appears in
main.c:27:13: error: implicit declaration of function 'chmin' [-Wimplicit-function-declaration]
   27 |             chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      |             ^~~~~
main.c:27:38: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
   27 |             chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      |                                      ^~~
main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
  +++ |+#include <stdlib.h>
    1 | using namespace std;
main.c:27:47: warning: 'abs' argument 1 type is 'long long int' where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
   27 |             chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      |                                          ~~~~~^~~~~~~~~~
<built-in>: note: built-in 'abs' declared here
main.c:32:5: error: 'cout' undeclared (first use in this function)
   32 |     cout << dp[N-1] << endl;
      |     ^~~~
main.c:32:24: error: 'endl' undeclared (first use in this function)
   32 |     cout << dp[N-1] << endl;
      |                        ^~~~
Language: C++

using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++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] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:15: error: 'cin' was not declared in this scope
   15 |     int N, K; 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 | using namespace std;
a.cc:27:38: error: 'abs' was not declared in this scope
   27 |             chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      |                                      ^~~
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout << dp[N-1] << endl;
      |     ^~~~
a.cc:32:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:24: error: 'endl' was not declared in this scope
   32 |     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 | using namespace std;
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
int k;
cin>>k;
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    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:48:34: error: expected ')' before '}' token
   48 |         for(int j =i+1;j<=i+k;j++}) {
      |            ~                     ^
      |                                  )
a.cc:48:34: error: expected primary-expression before '}' token
a.cc:48:35: error: expected primary-expression before ')' token
   48 |         for(int j =i+1;j<=i+k;j++}) {
      |                                   ^
a.cc: At global scope:
a.cc:54:11: error: expected constructor, destructor, or type conversion before '(' token
   54 |     printf("%d\n", dp[n-1]);
      |           ^
a.cc:55:1: error: expected declaration before '}' token
   55 | }
      | ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    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:46:29: error: 'k' was not declared in this scope
   46 |         for(int j =i+1;j<=i+k;j++}) {
      |                             ^
a.cc:46:34: error: expected ')' before '}' token
   46 |         for(int j =i+1;j<=i+k;j++}) {
      |            ~                     ^
      |                                  )
a.cc:46:34: error: expected primary-expression before '}' token
a.cc:46:35: error: expected primary-expression before ')' token
   46 |         for(int j =i+1;j<=i+k;j++}) {
      |                                   ^
a.cc: At global scope:
a.cc:52:11: error: expected constructor, destructor, or type conversion before '(' token
   52 |     printf("%d\n", dp[n-1]);
      |           ^
a.cc:53:1: error: expected declaration before '}' token
   53 | }
      | ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j =i+1;j<=k;j++}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:27: error: 'k' was not declared in this scope
   46 |         for(int j =i+1;j<=k;j++}) {
      |                           ^
a.cc:46:32: error: expected ')' before '}' token
   46 |         for(int j =i+1;j<=k;j++}) {
      |            ~                   ^
      |                                )
a.cc:46:32: error: expected primary-expression before '}' token
a.cc:46:33: error: expected primary-expression before ')' token
   46 |         for(int j =i+1;j<=k;j++}) {
      |                                 ^
a.cc: At global scope:
a.cc:52:11: error: expected constructor, destructor, or type conversion before '(' token
   52 |     printf("%d\n", dp[n-1]);
      |           ^
a.cc:53:1: error: expected declaration before '}' token
   53 | }
      | ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:17:30: error: no matching function for call to 'max(int, long long int)'
   17 |                 for(int j=max(0,i-k);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:17:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   17 |                 for(int j=max(0,i-k);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:17:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |                 for(int j=max(0,i-k);j<i;j++)
      |                           ~~~^~~~~~~
Language: C++

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;

const ll mod = 1e9+7;
const ll inf = 1e16;

#define loop(i,m,n) for(ll i=m;i<n;i++)
#define vloop(it,x) for(auto it=x.begin(); it!=x.begin(); it++)
#define all(x) x.begin(),x.end()
#define debug(x) cout << #x <<":"<< x <<endl	
#define showll(x) printf("%lld\n",x)
#define test(t) ll t;cin >> t;while(t--)
#define showc(x) printf("%c\n",x)
#define read(x) cin >> x
#define yes printf("YES\n")
#define no printf("NO\n")
#define pb push_back

void fast(){
ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
}

//////////////////////////////// - _ - \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

int main()
{
	fast();
	// debug(n);
	// showll(a);
	ll n,i,j,k,tmp;
	read(n);read(k);
	ll arr[n];
	loop(i,0,n)
	{
		cin >> arr[i];
		mini[i] = inf;
	}

	ll mini[n];
	mini[0] = 0;
	if(k<=n)
	{
		tmp = k;
	}
	else
	{
		tmp = n;
	}
	for(i=1;i<n;i++)
	{
		for(j=max(i-k,(ll)0);j<i;j++)
		{
			mini[i] = min(mini[i],abs(arr[i]-arr[j])+mini[j]);	 
		}
		
	}
	showll(mini[n-1]);
}	


Compiler output:
a.cc: In function 'int main()':
a.cc:42:17: error: 'mini' was not declared in this scope
   42 |                 mini[i] = inf;
      |                 ^~~~
Language: C++

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> h(n+1);
 for(int i= 1;i<=n;i++){
   cin >> h[i];
 }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> n >> k;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<int> h(n+1);
      |   ^~~~~~
a.cc:4:10: error: expected primary-expression before 'int'
    4 |   vector<int> h(n+1);
      |          ^~~
a.cc:6:11: error: 'h' was not declared in this scope
    6 |    cin >> h[i];
      |           ^
a.cc:9:9: error: expected primary-expression before 'int'
    9 |  vector<int> dp(n+1);
      |         ^~~
a.cc:11:5: error: 'dp' was not declared in this scope
   11 |     dp [i] = 1001001;
      |     ^~
a.cc:13:1: error: 'dp' was not declared in this scope
   13 | dp[1] = 0;
      | ^~
a.cc:15:27: error: 'h' was not declared in this scope
   15 |         dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
      |                           ^
a.cc:15:23: error: 'abs' was not declared in this scope
   15 |         dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
      |                       ^~~
a.cc:17:28: error: 'min' was not declared in this scope; did you mean 'main'?
   17 |            if(i-j>=1)dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
      |                            ^~~
      |                            main
a.cc:20:1: error: 'cout' was not declared in this scope
   20 | cout  << dp[n] << endl;
      | ^~~~
a.cc:20:19: error: 'endl' was not declared in this scope
   20 | cout  << dp[n] << endl;
      |                   ^~~~
Language: C++

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:28: error: 'INT_MAX' was not declared in this scope
   12 |     std::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: C++

}#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll H[100005];
ll dp[100005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> H[i];
    }
    REP(i, N) {
        dp[i] = INF;
    }
    dp[0] = 0;
    REP(i, N) {
        REP(j, K) {
            ll nxt = i + j + 1;
            if (nxt >= N)
                break;
            dp[nxt] = std::min(dp[nxt], dp[i] + abs(H[nxt] - H[i]));
        }
    }
    cout << dp[N - 1] << endl;

    return 0;
}

Compiler output:
a.cc:1:2: error: stray '#' in program
    1 | }#include <bits/stdc++.h>
      |  ^
a.cc:1:1: error: expected declaration before '}' token
    1 | }#include <bits/stdc++.h>
      | ^
a.cc:1:3: error: 'include' does not name a type
    1 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:6:9: error: 'pair' does not name a type
    6 | typedef pair<ll, ll> pll;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:19:5: error: 'cin' was not declared in this scope
   19 |     cin.tie(0);
      |     ^~~
a.cc:20:5: error: 'ios' has not been declared
   20 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:35:28: error: 'min' is not a member of 'std'
   35 |             dp[nxt] = std::min(dp[nxt], dp[i] + abs(H[nxt] - H[i]));
      |                            ^~~
a.cc:35:49: error: 'abs' was not declared in this scope
   35 |             dp[nxt] = std::min(dp[nxt], dp[i] + abs(H[nxt] - H[i]));
      |                                                 ^~~
a.cc:38:5: error: 'cout' was not declared in this scope
   38 |     cout << dp[N - 1] << endl;
      |     ^~~~
a.cc:38:26: error: 'endl' was not declared in this scope
   38 |     cout << dp[N - 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];
  int dp[n];
  dp[0]=0;
  for(int i=1;i<n;++i)
  {
    dp[i]=INT_MAX;
    for(int j=1;j<=k&&j<=i;j++)
      dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}
    

Compiler output:
a.cc: In function 'int main()':
a.cc:17:35: error: 'a' was not declared in this scope
   17 |       dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
      |                                   ^
Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    vector<int> ans(n);
    
    int k;
    cin>>k;
    
    vector<int> r(n);
    int e;
    cin>>e;
    r[0] = e;
    ans[0]= 0;
    for(int i=1; i<k; i++){
        cin>>e;
        int add = INT_MAX;
        for(int j=0; j<i; j++){
            if(ans[j]+abs(e-r[j])<add){
                add =ans[j]+abs(e-r[j]);
            }
        }
        r[i]=e;
        ans[i]=add;
    }
    
    for(int i = k; i<n;i++){
        cin>>e;
        r[i]=e;
        int add = INT_MAX;
        for(int j=i-k; j<i; j++){
            if(ans[j]+abs(e-r[j])<add){
                add =ans[j]+abs(e-r[j]);
            }
        }
        ans[i]=add;
    }
    cout<<ans[n-1]<<endl;
    
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:19: error: 'INT_MAX' was not declared in this scope
   37 |         int add = INT_MAX;
      |                   ^~~~~~~
a.cc:16:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   15 | #include <functional>
  +++ |+#include <climits>
   16 | using namespace std;
a.cc:50:19: error: 'INT_MAX' was not declared in this scope
   50 |         int add = INT_MAX;
      |                   ^~~~~~~
a.cc:50:19: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#define f(i,n) for(int i=0;i<n;i++)
#define mod 10007
#define chk(d) cout<<d<<endl
using namespace std;


int main()
{ long int n,m,k;
  cin>>n>>k;
  vector<long int>v;
  f(i,n)
  {
     long int a;
      cin>>a;
      v.push_back(a);
  }
  int dp[n+3];
  f(i,n)dp[i]=mod;
  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]+abs(v[i+j]-v[i]), dp[i+j]);

  }
 cout<<dp[n-1];

}



Compiler output:
a.cc: In function 'int main()':
a.cc:30:28: error: no matching function for call to 'min(long int, int&)'
   30 |      if(i+j<n)dp[i+j] = min(dp[i]+abs(v[i+j]-v[i]), dp[i+j]);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:30:28: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   30 |      if(i+j<n)dp[i+j] = min(dp[i]+abs(v[i+j]-v[i]), dp[i+j]);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/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:30:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   30 |      if(i+j<n)dp[i+j] = min(dp[i]+abs(v[i+j]-v[i]), dp[i+j]);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>     // std::cout
#include <algorithm>    // std::make_heap, std::pop_heap, std::push_heap, std::sort_heap
#include <vector>       // std::vector
//#include <stdio.h>

using namespace std;

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int N, x, k;
  cin >> N >> k;
  
  vector<int> jumpHeights;
  vector<int> jumpCost(N, 0);
  
  for(int i = 0; i < N; i++) {
	  cin >> x;
	  jumpHeights.push_back(x);
  }

  
  
  for(int i = 1; i<N;i++) {
	  int minCost = INT_MAX;
	  for(int j = 1; j <= k; j++) {
		if(i - j >= 0) {
			minCost = min(minCost, abs(jumpHeights[i] - jumpHeights[i -j]) + jumpCost[i-j]);
		}
		jumpCost[i] = minCost;
			
	  }
  }
  cout << jumpCost[N - 1] << "\n";
  

  return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:26:25: error: 'INT_MAX' was not declared in this scope
   26 |           int minCost = INT_MAX;
      |                         ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>       // std::vector
  +++ |+#include <climits>
    4 | //#include <stdio.h>
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:23: error: expected ';' before 'for'
   10 |   int dp[n]; dp[0] = 0
      |                       ^
      |                       ;
   11 |   for (int i = 0; i < n; i++) dp[i] = dp[i-1] + abs(height[i]-height[i-1]);
      |   ~~~                  
a.cc:11:19: error: 'i' was not declared in this scope
   11 |   for (int i = 0; i < n; i++) dp[i] = dp[i-1] + abs(height[i]-height[i-1]);
      |                   ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long INF=1LL<<60;

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


main(){
int N,K;
cin>>N>>K;
long long dp [100010]={INF};
int h [10010];
for (int i=1;i<=N;i++)cin>>h[i];
dp[0]=0;
dp[1]=0;
h[0]=h[1];
for (int i=2;i<=N;++i){
for (int k=1;k<=K;++k){
	if (i-k<=0)continue;
	dp[i]=chmin(dp[i-k]+abs(h[i]-h[i-k]));
}
}
cout<<dp[N];
return 0;
}

Compiler output:
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:20:20: error: no matching function for call to 'chmin(long long int)'
   20 |         dp[i]=chmin(dp[i-k]+abs(h[i]-h[i-k]));
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:5:31: note: candidate: 'template<class T> bool chmin(T&, T)'
    5 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:5:31: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long INF=1LL<<60;

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


main(){
int N,K;
cin>>N>>K;
dp [100010]={INF};
int h [10010];
for (int i=1;i<=N;i++)cin>>h[i];
dp[0]=0;
dp[1]=0;
h[0]=h[1];
for (int i=2;i<=N;++i){
for (int k=1;k<=K;++k){
	if (i-k<=0)continue;
	dp[i]=chmin(dp[i-k]+abs(h[i]-h[i-k]));
}
}
cout<<dp[N];
return 0;
}

Compiler output:
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:11:1: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 | dp [100010]={INF};
      | ^~
      | dup
Language: C++

#include<bits/stdc++.h>
using namespace std;
const long long INF=1LL<<60;

main(){
int N,K;
cin>>N>>K;
dp [100010]={INF};
int h [10010];
for (int i=1;i<=N;i++)cin>>h[i];
dp[0]=0;
dp[1]=0;
h[0]=h[1];
for (int i=2;i<=N;++i){
for (int k=1;k<=K;++k){
	if (i-k<=0)continue;
	dp[i]=chmin(dp[i-k]+abs(h[i]-h[i-k]));
}
}
cout<<dp[N];
return 0;
}

Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:8:1: error: 'dp' was not declared in this scope; did you mean 'dup'?
    8 | dp [100010]={INF};
      | ^~
      | dup
a.cc:17:15: error: 'chmin' was not declared in this scope
   17 |         dp[i]=chmin(dp[i-k]+abs(h[i]-h[i-k]));
      |               ^~~~~
Language: C++

#include<bits/stdc++.h>

const long long INF=1LL<<60;

main(){
int N,K;
cin>>N>>K;
dp [100010]={INF};
int h [10010];
for (int i=1;i<=N;i++)cin>>h[i];
dp[0]=0;
dp[1]=0;
h[0]=h[1];
for (int i=2;i<=N;++i){
for (int k=1;k<=K;++k){
	if (i-k<=0)continue;
	dp[i]=chmin(dp[i-k]+abs(h[i]-h[i-k]));
}
}
cout<<dp[N];
return 0;
}

Compiler output:
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:7:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 | cin>>N>>K;
      | ^~~
      | std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:1: error: 'dp' was not declared in this scope; did you mean 'dup'?
    8 | dp [100010]={INF};
      | ^~
      | dup
a.cc:17:15: error: 'chmin' was not declared in this scope
   17 |         dp[i]=chmin(dp[i-k]+abs(h[i]-h[i-k]));
      |               ^~~~~
a.cc:20:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 | cout<<dp[N];
      | ^~~~
      | std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: C

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}
int main()
{
 int n,k;
 cin>>n>>k;
 int h[n];
   for(int i=0;i<n;i++)
   cin>>h[i];
   int dp[n];
   dp[0]=0;
   dp[1]=abs(h[1]-h[0]);
   for(int i=2;i<n;i++){
       dp[i]=100000000;
      for(int j=1;j<=min(k,i);j++){
         dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
   }
   cout<<dp[n-1];
   
    return 0;
}

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

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

const long long INF = 1LL << 60;

// 入力
int N, k;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < k; j++) {
        chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }

    // 答え
    cout << dp[N-1] << endl;
}

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

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

const long long INF = 1LL << 60;

// 入力
int N, k;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; i++) {
      for(int j = 1; j < k; j++) {
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }

    // 答え
    cout << dp[N-1] << endl;
}


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

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

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; i++) {
      for(int j = 1; j < k; j++) {
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }

    // 答え
    cout << dp[N-1] << endl;
}


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++) {
      |                          ^
a.cc:35:2: error: expected '}' at end of input
   35 | }
      |  ^
a.cc:17:12: note: to match this '{'
   17 | int main() {
      |            ^