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

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

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

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

#define int long long

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

const int INF = 1001001001;

signed main(){

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0, i_len = (int)n; i < i_len; ++i) cin >> a[i];
    
    vector<int> dp(n+1, INF);

    dp[0] = 0;

    for(int i = 1; i < n; ++i){
        for(int j = 1; j < k; ++k){
            amin(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:22:28: error: 'k' was not declared in this scope
   22 |         for(int j = 1; j < k; ++k){
      |                            ^
Language: Java

import java.util.*;
public class Main{

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=sc.nextInt();
		}
		int min[]=new int[n];
		min[0]=0;
		min[1]=(int)Math.abs(h[1]-h[0]);
		for(int i=2;i<n;i++)
		{
          int m=99999999;
          for(int j=1;j<=k;j++)
          {
            if((i-k)>=0)
            {int h1=(int)Math.abs(h[i]-h[i-j])+min[i-j];
			m=h1<m?h1:m;}
          }
          min[i]=m;
		}
		System.out.println(min[n-1]);
	}

}


Compiler output:
Main.java:19: error: cannot find symbol
          for(int j=1;j<=k;j++)
                         ^
  symbol:   variable k
  location: class Main
Main.java:21: error: cannot find symbol
            if((i-k)>=0)
                  ^
  symbol:   variable k
  location: class Main
2 errors
Language: Java

import java.util.*;
public class Main{

	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int h[]=new int[n];
		for(int i=0;i<n;i++)
		{
			h[i]=sc.nextInt();
		}
		int min[]=new int[n];
		min[0]=0;
		min[1]=(int)Math.abs(h[1]-h[0]);
		for(int i=2;i<n;i++)
		{
          int m=99999999;
          for(int j=1;j<=k;j++)
          {
			int h1=(int)Math.abs(h[i]-h[i-j])+min[i-j];
			m=h1<m?h1:m;
          }
          min[i]=m;
		}
		System.out.println(min[n-1]);
	}

}


Compiler output:
Main.java:19: error: cannot find symbol
          for(int j=1;j<=k;j++)
                         ^
  symbol:   variable k
  location: class Main
1 error
Language: Java

import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int h[]=new int[n];
    for(int i=0;i<n;i++)
    {
      h[i]=sc.nextInt();
    }
    long best[]=new long[n];
    best[0]=h[0];
    best[1]=(long)Math.abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
      int min=9999999;
      for(int j=1;j<=k;j++)
      {
        if((i-j)>=0)
        {int t=best[i-j]+(long)Math.abs(h[i]-h[i-j]);
        if(t<min)
        {
          min=t;
        }
        }
      }
      best[i]=min;
    }
    System.out.println(best[n-1]);
  }
}


Compiler output:
Main.java:23: error: incompatible types: possible lossy conversion from long to int
        {int t=best[i-j]+(long)Math.abs(h[i]-h[i-j]);
                        ^
1 error
Language: Java

import java.util.*;
public class main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int h[]=new int[n];
    for(int i=0;i<n;i++)
    {
      h[i]=sc.nextInt();
    }
    int best[]=new int[n];
    best[0]=h[0];
    best[1]=(int)Math.abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
      int min=9999999;
      for(int j=1;j<=k;j++)
      {
        if((i-j)>=0)
        {int t=best[i-j]+(int)Math.abs(h[i]-h[i-j]);
        if(t<min)
        {
          min=t;
        }
        }
      }
      best[i]=min;
    }
    System.out.println(best[n-1]);
  }
}


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

import java.util.*;
public class main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int h[]=new int[n];
    for(int i=0;i<n;i++)
    {
      h[i]=sc.nextInt();
    }
    int best[]=new int[n];
    best[0]=h[0];
    best[1]=(int)Math.abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
      int min=9999999;
      for(int j=1;j<=k;j++)
      {
        if(i-j>=0)
        {int t=best[i-j]+(int)Math.abs(h[i]-h[i-j]);
        if(t<min)
        {
          min=t;
        }
        }
      }
      best[i]=min;
    }
    System.out.println(best[n-1]);
  }
}


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

//
//  main.cpp
//  B - Frog 2
//
//  Created by Hashizo on 2019/06/12.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REPLACE(s, f, t) regex_replace(s, regex(f), t)

int main(int argc, const char * argv[]) {
	int n,k;
	cin >> n >> k;

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


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:31:23: error: 'INT_MAX' was not declared in this scope
   31 |                 dp[i]=INT_MAX;
      |                       ^~~~~~~
a.cc:14:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   13 | #include <regex>
  +++ |+#include <climits>
   14 |
Language: C++

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

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

import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] arr = new int[n];
  int[] ans = new int[n];
  int k = sc.nextInt();
  for(int i = 0; i<n;i++)
  {arr[i] = sc.nextInt();
  ans[i] = Integer.MAX_VALUE;
  }
  ans[0] = 0;
  ans[1] = arr[1];
  for(int i = 2;i<k;i++)
    ans[i] = arr[i]
    for(int i = k; i<n;i++)
    {
      for(int j = 0 ; j<k;j++)
        ans[i] = Integer.min((ans[i-j] + Math.abs(arr[i] - arr[i-j]),ans[i]);
    }
  System.out.println(ans[n-1]);
}
}

Compiler output:
Main.java:18: error: ';' expected
    ans[i] = arr[i]
                   ^
Main.java:22: error: ')' expected
        ans[i] = Integer.min((ans[i-j] + Math.abs(arr[i] - arr[i-j]),ans[i]);
                                                                    ^
2 errors
Language: Java

import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int[] arr = new int[n];
  int[] ans = new int[n];
  int k = sc.nextInt();
  for(int i = 0; i<n;i++)
  {arr[i] = sc.nextInt();
  ans[i] = Integer.MAX_VALUE;
  }
  ans[0] = 0;
  ans[1] = arr[1];
  for(int i = 2;i<k;i++)
    ans[i] = arr[i]
    for(int i = k; i<n;i++)
    {
      for(int j = 0 ; j<k;j++)
        ans[i] = Integer.min(ans[i-j] + Math.abs(arr[i] - arr[i-j]),ans[i]);
    }
  System.out.println(ans[n-1]);
}
}

Compiler output:
Main.java:18: error: ';' expected
    ans[i] = arr[i]
                   ^
1 error
Language: Java

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

Compiler output:
Main.java:17: error: ';' expected
    ans[i] = arr[i]
                   ^
Main.java:21: error: ';' expected
        ans[i] = Integer.min(ans[i-j] + Math.abs(arr[i] - arr[i-j]),ans[i])
                                                                           ^
2 errors
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'INF' was not declared in this scope
   13 |     dp[i]=INF;
      |           ^~~
Language: C

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

#define INF 100000000;
long dp[100005];

int main(void){
  int N,K,h[100005],i,j;
  char str[1000000],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  K=atoi(p);
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  h[1]=atoi(p);
  for(i=2;i<N+1;i++){
    p=strtok(NULL," \n");
  	h[i]=atoi(p);
  }
  
  for(i=2;i<N+1;i++){
    dp[i]=INF;
    for(j=1;j<K+1;j++){
      if(i-j>0){
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  
  printf("%ld\n",dp[N]);
  
  
  return 0;
}

long min(long a,long b){
  if(a<=b){
    return a;
  }else{
    return b;
  }
}

Compiler output:
main.c: In function 'main':
main.c:30:15: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
   30 |         dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      |               ^~~
      |               main
main.c: At top level:
main.c:41:6: error: conflicting types for 'min'; have 'long int(long int,  long int)'
   41 | long min(long a,long b){
      |      ^~~
main.c:30:15: note: previous implicit declaration of 'min' with type 'int()'
   30 |         dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      |               ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=1234567890123;
int main()
{
  ll i,n,k;
  cin>>n>>k;
  ll arr[n],dp[n];
  
  for(i=0;i<n;i++)
  {cin>>arr[i];dp[i]=bg;}
  dp[0]=0;
  for(i=0;i<n;i++)
  {
    for(j=1,j<=k,j++)
    if(i+j<n)
       dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
      }
  cout<<dp[n-1]<<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=1,j<=k,j++)
      |         ^
a.cc:19:7: error: expected primary-expression before '}' token
   19 |       }
      |       ^
a.cc:18:56: error: expected ';' before '}' token
   18 |        dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
      |                                                        ^
      |                                                        ;
   19 |       }
      |       ~                                                 
a.cc:19:7: error: expected primary-expression before '}' token
   19 |       }
      |       ^
a.cc:18:56: error: expected ')' before '}' token
   18 |        dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
      |                                                        ^
      |                                                        )
   19 |       }
      |       ~                                                 
a.cc:16:8: note: to match this '('
   16 |     for(j=1,j<=k,j++)
      |        ^
a.cc:19:7: error: expected primary-expression before '}' token
   19 |       }
      |       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=1234567890123;
int main()
{
  ll i,n;
  cin>>n;
  ll arr[n],dp[n];
  
  for(i=0;i<n;i++)
  {cin>>arr[i];dp[i]=bg;}
  dp[0]=0;
  for(i=0;i<n;i++)
  {
    for(j=1,j<=k,j++)
    if(i+j<n)
       dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
      }
  cout<<dp[n-1]<<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=1,j<=k,j++)
      |         ^
a.cc:16:16: error: 'k' was not declared in this scope
   16 |     for(j=1,j<=k,j++)
      |                ^
a.cc:19:7: error: expected primary-expression before '}' token
   19 |       }
      |       ^
a.cc:18:56: error: expected ';' before '}' token
   18 |        dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
      |                                                        ^
      |                                                        ;
   19 |       }
      |       ~                                                 
a.cc:19:7: error: expected primary-expression before '}' token
   19 |       }
      |       ^
a.cc:18:56: error: expected ')' before '}' token
   18 |        dp[i+j]=min(dp[i+j],dp[i]+abs(arr[i+j]-arr[i]));
      |                                                        ^
      |                                                        )
   19 |       }
      |       ~                                                 
a.cc:16:8: note: to match this '('
   16 |     for(j=1,j<=k,j++)
      |        ^
a.cc:19:7: error: expected primary-expression before '}' token
   19 |       }
      |       ^
Language: C++

#include<bits/stdc++.h>
#define ll long long 
#define dll long double
#define fli(j,n) for(int i=j;i<n;i++)
#define flj(i,n) for(int j=i;j<n;j++)
#define pb push_back
using namespace std;

auto fast_io =[]()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    return nullptr;
}();
ll n;

const int N=1e5+5;
ll has[N],h[N];
ll rec(ll curr){
	if(curr>n)return INT_MAX;
	if(curr==n)return 0;
	ll ans=has[curr];
	if(ans!=-1)return ans;
	ans=INT_MAX;
	for(ll i=1;i<=k && i+curr<=n;i++){
         ans=min(ans,abs(h[curr]-h[curr+i])+rec(curr+i));
    }
    return ans;
    
}
int main() {
	cin>>n>>k;
	memset(has,-1,sizeof(has));
	h.pb(0);
    for(ll i=1;i<=n;i++){
		cin>>h[i];
	}
//	n--;
	cout<<rec(1);
	return 0;
}


Compiler output:
a.cc: In function 'long long int rec(long long int)':
a.cc:27:23: error: 'k' was not declared in this scope
   27 |         for(ll i=1;i<=k && i+curr<=n;i++){
      |                       ^
a.cc: In function 'int main()':
a.cc:34:17: error: 'k' was not declared in this scope
   34 |         cin>>n>>k;
      |                 ^
a.cc:6:12: error: request for member 'push_back' in 'h', which is of non-class type 'long long int [100005]'
    6 | #define pb push_back
      |            ^~~~~~~~~
a.cc:36:11: note: in expansion of macro 'pb'
   36 |         h.pb(0);
      |           ^~
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define dll long double
#define fli(j,n) for(int i=j;i<n;i++)
#define flj(i,n) for(int j=i;j<n;j++)
#define pb push_back
using namespace std;

auto fast_io =[]()
{
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    return nullptr;
}();
ll n;
vector<ll> h;
ll has[100001],k;
ll rec(ll curr){
	if(curr==n)return 0;
	if(curr>n)return INT_MAX;
	ll ans=has[curr];
	if(ans!=-1)return ans;
	ans=INT_MAX;
	for(ll i=1;i<=k && i+curr<=n;i++){
         y=min(y,abs(h[curr]-h[curr+i])+rec(curr+i));
    }
    return y;
    
}
int main() {
	cin>>n>>k;
	memset(has,-1,sizeof(has));
	h.pb(0);
    for(ll i=1;i<=n;i++){
		ll o;cin>>o;
		h.push_back(o);
	}
//	n--;
	cout<<rec(1);
	return 0;
}


Compiler output:
a.cc: In function 'long long int rec(long long int)':
a.cc:27:10: error: 'y' was not declared in this scope
   27 |          y=min(y,abs(h[curr]-h[curr+i])+rec(curr+i));
      |          ^
a.cc:29:12: error: 'y' was not declared in this scope; did you mean 'yn'?
   29 |     return y;
      |            ^
      |            yn
Language: C++

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

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

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

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

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

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

int main(){
  int N, K; cin >> N >> K;
  vector<long long> h(N,0); for(int i = 0; i < N; i++) cin >> h.at(i);
  vector<long long> DP(N,0);
  
  DP.at(1) = abs(h.at(1) - h.at(0));
  for(int i = 2; i < N; i++){
      int minh = 99999999;
      for(int j = max(0,i-K); j < i ; j++){
          long long dh = abs(h.at(i) - h.at(j)) + DP.at(j);
          minh = min(minh,dh);
      }
      DP.at(i) = minh;
  }
  cout << DP.at(N-1) << endl;
}



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

#include "pch.h"
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
	int N = 0, K = 0;
	cin >> N >> K;

	vector<int> costs;

	vector<int> previousHeights;

	int currentHeight = 0;

	// Fisrt stone is set to 0
	cin >> currentHeight;
	previousHeights.push_back(currentHeight);
	costs.push_back(0);

	for (int i = 1; i < N; i++) {
		cin >> currentHeight;
		int oneStepCost = abs(previousHeights[i - 1] - currentHeight) + costs[i - 1];
		costs.push_back(oneStepCost);
		for (int j = 1; j < K; j++) {
			if (i - j - 1 < 0) break;
			else {
				int heightDiff = abs(previousHeights[i - j - 1] - currentHeight);
				if (heightDiff + costs[i - j - 1] < costs[i]) costs[i] = heightDiff + costs[i - j - 1];
			}
		}

		previousHeights.push_back(currentHeight);
	}
	cout << costs[costs.size() - 1];
}

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

#include "pch.h"
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
	int N = 0, K = 0;
	cin >> N >> K;

	vector<int> costs;

	vector<int> previousHeights;

	int currentHeight = 0;

	// Fisrt stone is set to 0
	cin >> currentHeight;
	previousHeights.push_back(currentHeight);
	costs.push_back(0);

	for (int i = 1; i < N; i++) {
		cin >> currentHeight;
		costs.push_back(2147483646); // over the max so that we dont get artifically low outputs
		for (int j = 0; j < K; j++) {
			if (i - j - 1 < 0) break;
			else {
				int heightDiff = abs(previousHeights[i - j - 1] - currentHeight);
				if (heightDiff + costs[i - j - 1] < costs[i]) costs[i] = heightDiff + costs[i - j - 1];
			}
		}

		previousHeights.push_back(currentHeight);
	}
	cout << costs[costs.size() - 1];
}

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

#include <iostream>
using namespace std;
int dp[100001];
int main()
{
	int n;
	cin>>n;
	int ac; cin>>ac;
	int cost[n];
	for(int i=0;i<n;i++)
	{
		cin>>cost[i];
	}
	dp[0]=0;
	dp[1]=abs(cost[1]-cost[0]);
	for(int i=2;i<n;i++)
	{
			dp[i]=dp[i-1]+abs(cost[i]-cost[i-1]);
		for(int k=2;k<=ac;k++)
		{
			if(i-k>=){
		dp[i]=min(dp[i],dp[i-k]+abs(cost[i]-cost[i-k]));
            }
		}
	}
	cout<<dp[n-1];
	
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:33: error: expected primary-expression before ')' token
   21 |                         if(i-k>=){
      |                                 ^
Language: C++

// 問題文
// N個の足場があります。 足場には 1,2,…,N と番号が振られています。 各 i(1≤i≤N) について、足場 i の高さは hi です。
// 最初、足場 1にカエルがいます。 カエルは次の行動を何回か繰り返し、足場 Nまで辿り着こうとしています。足場 iにいるとき、足場 
// i+1,i+2,…,i+K のどれかへジャンプする。 このとき、ジャンプ先の足場を jとすると、コスト |hi−hj|を支払う。
// カエルが足場 Nに辿り着くまでに支払うコストの総和の最小値を求めてください。
// 制約
// 入力はすべて整数である。
// 2≤N≤105の5乗
// 1≤K≤100
// 1≤hi≤10の４乗
// 入力
// 入力は以下の形式で標準入力から与えられる。
// N K
// h1
// h2 
// … 
// hN
// 出力
// カエルが支払うコストの総和の最小値を出力せよ。
// 入力例 1 
// 5 3
// 10 30 40 50 20
// 出力例 1 
// 30
// 足場 
// 1→ 2 → 5と移動すると、コストの総和は |10−30|+|30−20|=30となります。
// 入力例 2 
// 3 1
// 10 20 10
// 出力例 2 
// 20
// 足場 
// 1→ 2 → 3と移動すると、コストの総和は |10−20|+|20−10|=20 となります。
// 入力例 3 
// 2 100
// 10 10
// 出力例 3 
// 0
// 足場 1→ 2と移動すると、コストの総和は |10−10|=0となります。
// 入力例 4 
// 10 4
// 40 10 20 70 80 10 20 70 80 60
// 出力例 4 
// 40
// 足場 
// 1 → 4 → 8 → 10と移動すると、コストの総和は |40−70|+|70−70|+|70−60|=40となります。
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	int N,H[100100],K=0;
	long long dp[100100];
	long long inf=1e12;
	cin>>N>>K;
	for(int i=0;i<N;i++){
		cin>>H[i];
	}
	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]-H[i+J]));
		}
	}
	cout<<dp[N-1]<<endl;
	return 0;
}

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

/*Frog2*/

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

#define rep(i, N) for(int i = 0; i < (int)N; i++)
#define INF 1000000

const long long INF = 1LL << 60;

int main()
{
    int N, K;
    cin >> N >> K;

    long long h[N];
    rep(i, N)   cin >> h[i];

    //DP配列の宣言
    long long dp[N + 100];
    rep(i, N + 100) dp[i] = INF;

    dp[0] = 0;

    rep(i, N)
    {
        for(int j = 1; j <= K; j++)
        {
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

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

Compiler output:
a.cc:7:13: error: expected unqualified-id before numeric constant
    7 | #define INF 1000000
      |             ^~~~~~~
a.cc:9:17: note: in expansion of macro 'INF'
    9 | const long long INF = 1LL << 60;
      |                 ^~~
Language: C++

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:6:21: error: 'k' was not declared in this scope
    6 |         cin >> n >> k;
      |                     ^
a.cc:12:21: error: 'j' was not declared in this scope
   12 |                 for(j=k;j>=1;j--){
      |                     ^
Language: C++

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

int main()
{
    int N, K;
    cin >> N >> K;
    
    int h[N+1];
    for(int i = 1; i <= N; i++) cin >> h[i];
    
    int A[N+1];
    A[1] = 0;
    for(int i = 2; i <= N; i++)
    {
        A[i] = INT_MAX;
        for(int j = max(i-K, 1); j < i; j++) A[i] = min(A[i], A[j] + abs(h[i] - h[j]));
    }
    
    cout << A[N] << '\n';
    return 0;
}

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

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

int main()
{
  int n;
  cin>>n>>k;
  ll h[n+1],dp[n+1];
  for(int i=1;i<=n;i++)cin>>h[i];
  dp[1]=0;
  dp[2]=abs(h[1]-h[2]);
  for(int i=3;i<=n;i++){
    ll cost=LLONG_MAX;
    for(int j=1;j<=k;j++){
      if(i-j<=0)break;
      else cost=min(cost,dp[i-j]+abs(h[i-j]-h[i]));
    }
    dp[i]=cost;
  }
  cout<<dp[n]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:11: error: 'k' was not declared in this scope
    8 |   cin>>n>>k;
      |           ^
Language: C++

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

int main()
{
  int n;
  cin>>n>>k;
  ll h[n+1],dp[n+1];
  for(int i=1;i<=n;i++)cin>>h[i];
  dp[1]=0;
  dp[2]=abs(h[1]-h[2]);
  for(int i=3;i<=n;i++){
    ll cost=LLONG_MAX;
    for(int j=1;j<=k;j++){
      if(i-j<=0)continue;
      else cost=min(cost,dp[i-j]+abs(h[i-j]-h[i]));
    }
    dp[i]=cost;
  }
  cout<<dp[n]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:11: error: 'k' was not declared in this scope
    8 |   cin>>n>>k;
      |           ^
Language: C++

#include <bits/stdc++.h>
#define f first
#define s second
#define mk make_pair
#define int long long
 
using namespace std;
 
const int N = 1e5 + 5;
 
int h[N], dp[N];
 
int32_t main()
{
    ios::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n,k;
    cin >> n >> k;
    for(int i = 0;i < n; ++i)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i = 1;i < n; ++i)
    {
        int t = 1e10, ind = -1;
        for(int j = i-1; j >= max(0, i - k); --j)
        {
            int x = abs(h[i] - h[j]);
            if(x < t)
            {
                ind = j;
                t = x;
            }
        }
        dp[i] = dp[ind] + t;
    }
    cout << dp[n-1];
}


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

#include <bits/stdc++.h>
#define f first
#define s second
#define mk make_pair

using namespace std;

const long long N = 1e5 + 5;

long long h[N], dp[N];

long long32_t main()
{
    ios::sync_with_stdio(false);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    long long n,k;
    cin >> n >> k;
    for(long long i = 0;i < n; ++i)
    {
        cin >> h[i];
    }
    dp[0] = 0;
    for(long long i = 1;i < n; ++i)
    {
        long long t = 1e10, ind = -1;
        for(long long j = i-1; j >= max(0 * 1ll, i - k); --j)
        {
            long long x = abs(h[i] - h[j]);
            if(x < t)
            {
                ind = j;
                t = x;
            }
        }
        dp[i] = dp[ind] + t;
    }
    cout << dp[n-1];
}

Compiler output:
a.cc:12:15: error: expected initializer before 'main'
   12 | long long32_t main()
      |               ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
static const int64_t MAX_N = 1E5, MAX_K = 100, INF = 1e7;
int64_t n, k, h[MAX_N], dp[MAX_N];

int64_t cost(int64_t i, int64_t j) {
	return abs(h[i] - h[j]);
}

void solve() {
	for(int64_t i = 0; i < n; i++) {
		dp[i] = INF;
	}
	dp[0] = 0;

	for(int64_t i = 0; i < n; i++)  {
	for(int64_t j = 1; j <= k; j++) {
		int64_t x = i - j;
		int64_t a = dp[x] + cost(i, x);
		if(0 <= x && x < n && dp[i] > a) dp[i] = a;
	}
	}
	cout << dp[n-1] << endl;
}

int64_t main() {
	cin >> n >> k;
	for (int64_t i = 0; i < n; i++) {
		cin >> h[i];
	}
	solve();
	return 0;
}

Compiler output:
a.cc:26:1: error: '::main' must return 'int'
   26 | int64_t main() {
      | ^~~~~~~
Language: C

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

int main(void){
    int n,k;
    scanf("%d", &n)
    scanf("%d", &k)

    
    int *input;
    int *min;
    input = (int *)malloc(n * sizeof(int));
    min = (int *)malloc(n * sizeof(int));

    for(int i = 0; i < n; i++){
        scanf("%d", &input[i])
    }
    min[0] = 0;
    min[1] = abs(input[1] -input[0]);

    for(int i = 2; i < n; i++){
        int smaller = abs(input[i] - input[i-1]) + min[i-1];
        for(int j = 2;j <  k + 1; j++){
            if(i - j > -1){
                if(abs(input[i] - input[i - j]) + min[i-j] < smaller){
                    smaller = abs(input[i] - input[i - j]) + min[i-j];
                }
            }
        }
        min[i] = smaller;
    }

    printf("%d", min[n-1]);

}

Compiler output:
main.c: In function 'main':
main.c:6:20: error: expected ';' before 'scanf'
    6 |     scanf("%d", &n)
      |                    ^
      |                    ;
    7 |     scanf("%d", &k)
      |     ~~~~~           
main.c:12:5: error: 'input' undeclared (first use in this function)
   12 |     input = (int *)malloc(n * sizeof(int));
      |     ^~~~~
main.c:12:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:16:31: error: expected ';' before '}' token
   16 |         scanf("%d", &input[i])
      |                               ^
      |                               ;
   17 |     }
      |     ~
Language: C++

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


int n, k;
std::vector<int> vec, dp;

int INF = 100000001;

int main() {
    std::cin >> n >> k;
    vec.assign(n+1, 0);
    dp.assign(n+1, INF);
    for (int i = 1; i <= n; i++) {
        std::cin >> vec[i];
    }
    dp[0] = 0;
    dp[1] = std::abs(vec[1]-vec[2]);
    for (int i = 1; i < n; i++) {
        for (int p = 1; p <= n; p++) {
            if (i+p <= n) {
                chmin(dp[i+p], dp[i]+std::abs(vec[i+p]-vec[i]));
            }
        }
    }
    std::cout << dp[n] << std::endl;
}

Compiler output:
a.cc:12:6: error: 'vector' in namespace 'std' does not name a template type
   12 | std::vector<int> vec, dp;
      |      ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | template <typename T>
a.cc: In function 'int main()':
a.cc:17:10: error: 'cin' is not a member of 'std'
   17 |     std::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 | template <typename T>
a.cc:18:5: error: 'vec' was not declared in this scope
   18 |     vec.assign(n+1, 0);
      |     ^~~
a.cc:19:5: error: 'dp' was not declared in this scope
   19 |     dp.assign(n+1, INF);
      |     ^~
a.cc:21:14: error: 'cin' is not a member of 'std'
   21 |         std::cin >> vec[i];
      |              ^~~
a.cc:21:14: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:24:18: error: 'abs' is not a member of 'std'
   24 |     dp[1] = std::abs(vec[1]-vec[2]);
      |                  ^~~
a.cc:28:43: error: 'abs' is not a member of 'std'
   28 |                 chmin(dp[i+p], dp[i]+std::abs(vec[i+p]-vec[i]));
      |                                           ^~~
a.cc:32:10: error: 'cout' is not a member of 'std'
   32 |     std::cout << dp[n] << std::endl;
      |          ^~~~
a.cc:32:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:32: error: 'endl' is not a member of 'std'
   32 |     std::cout << dp[n] << std::endl;
      |                                ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | template <typename T>
Language: C++

#include <bits/stdc++.h>

int n, k;
std::vector<int> vec, dp;

int INF = 100000001;

int main() {
    std::cin >> n >> k;
    vec.assign(n+1, 0);
    dp.assign(n+1, INF);
    for (int i = 1; i <= n; i++) {
        std::cin >> vec[i];
    }
    dp[0] = 0;
    dp[1] = std::abs(vec[1]-vec[2]);
    for (int i = 1; i < n; i++) {
        for (int p = 1; p <= n; p++) {
            if (i+p <= n) {
                chmin(dp[i+p], dp[i]+std::abs(vec[i+p]-vec[i]));
            }
        }
    }
    std::cout << dp[n] << std::endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:17: error: 'chmin' was not declared in this scope
   20 |                 chmin(dp[i+p], dp[i]+std::abs(vec[i+p]-vec[i]));
      |                 ^~~~~
Language: C++

#include <bits/stdc++.h>

int n, k;
std::vector<int> vec, dp;

int INF = 100000001;

int main() {
    std::cin >> n >> k;
    vec.assign(n+1, 0);
    dp.assign(n+1, INF);
    for (int i = 1; i <= n; i++) {
        std::cin >> vec[i];
    }
    dp[0] = 0;
    dp[1] = std::abs(vec[1]);
    for (int i = 1; i < n; i++) {
        for (int p = 1; p <= n; p++) {
            if (i+p <= n) {
                chmin(dp[i+p], dp[i]+std::abs(vec[i+p]-vec[i]));
            }
        }
    }
    std::cout << dp[n] << std::endl;[
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:17: error: 'chmin' was not declared in this scope
   20 |                 chmin(dp[i+p], dp[i]+std::abs(vec[i+p]-vec[i]));
      |                 ^~~~~
a.cc:25:1: error: expected identifier before '}' token
   25 | }
      | ^
a.cc:24:38: error: expected ']' before '}' token
   24 |     std::cout << dp[n] << std::endl;[
      |                                      ^
      |                                      ]
   25 | }
      | ~                                     
a.cc: In lambda function:
a.cc:25:1: error: expected '{' before '}' token
   25 | }
      | ^
a.cc: In function 'int main()':
a.cc:24:38: error: expected ';' before '}' token
   24 |     std::cout << dp[n] << std::endl;[
      |                                      ^
      |                                      ;
   25 | }
      | ~
Language: C++

#include <stdio.h>
const int N=1e5+10;
int n,k,a[N],f[N];
int min(int l,int r){return l>r?r:l;}
int dp(int pos){
  if(pos<=0)return INF;
  if(pos==1)return 0;
  if(f[pos]!=0)return f[pos];
  int ans=0;
  for(int i=1;i<=k;i++)if(pos-i>0)ans=min(ans,dp(pos-i)+abs(a[pos]-a[pos-i]));
  return f[pos]=ans;
}
int main(){
  scanf("%d%d",&n,&k);
  for(int i=1;i<=n;i++)scanf("%d",&a[i]);
  for(int i=1;i<=n;i++)f[i]=0;
  printf("%d\n",dp(n));
}

Compiler output:
a.cc: In function 'int dp(int)':
a.cc:6:20: error: 'INF' was not declared in this scope
    6 |   if(pos<=0)return INF;
      |                    ^~~
a.cc:10:57: error: 'abs' was not declared in this scope; did you mean 'ans'?
   10 |   for(int i=1;i<=k;i++)if(pos-i>0)ans=min(ans,dp(pos-i)+abs(a[pos]-a[pos-i]));
      |                                                         ^~~
      |                                                         ans
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<limits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int N,K;
	cin >> N >> K;

	vector<long long> h(N+K);
	rep(i, N) cin >> h[i];

	vector<long long> dp(N+K, LLONG_MAX);
	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:20:35: error: 'LLONG_MAX' was not declared in this scope
   20 |         vector<long long> dp(N+K, LLONG_MAX);
      |                                   ^~~~~~~~~
a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<limits>
  +++ |+#include <climits>
    7 | #define REP(i,m,n) for(int i = m; i < n; i++)
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:26:41: error: expected ';' before 'mn'
   26 |       if(mn > (abs(a[i] - a[j]) + dp[j])
      |                                         ^
      |                                         ;
   27 |         mn = abs(a[i] - a[j]) + dp[j];
      |         ~~                               
a.cc:28:15: error: expected ')' before ';' token
   28 |     dp[i] = mn;
      |               ^
      |               )
a.cc:26:9: note: to match this '('
   26 |       if(mn > (abs(a[i] - a[j]) + dp[j])
      |         ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:27:30: error: expected ';' before ')' token
   27 |         mn = abs(a[i] - a[j])) + dp[j];
      |                              ^
      |                              ;
Language: C++

#include <bits/stdc++.h>

#define ll long long 
#define ull unsigned long long
#define all(c) c.begin(),c.end()
#define pb push_back

const ll INF 1e9+5;

using namespace std;

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

Compiler output:
a.cc:8:14: error: expected initializer before numeric constant
    8 | const ll INF 1e9+5;
      |              ^~~
a.cc: In function 'int main()':
a.cc:15:31: error: 'INF' was not declared in this scope
   15 |         vector<ll>arr(n),dp(n,INF);
      |                               ^~~
Language: C++

#include <bits/stdc++.h>

#define ll long long 
#define ull unsigned long long
#define all(c) c.begin(),c.end()
#define pb push_back

const int INF 1e9+5;

using namespace std;

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

Compiler output:
a.cc:8:15: error: expected initializer before numeric constant
    8 | const int INF 1e9+5;
      |               ^~~
a.cc: In function 'int main()':
a.cc:15:31: error: 'INF' was not declared in this scope
   15 |         vector<ll>arr(n),dp(n,INF);
      |                               ^~~
Language: C++

#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int stones[100001];
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    int n , k;
    cin >> n >> k;

    rep(i, 0, n){
        cin >> stones[i+1];   
    }

    int dp[n+1];
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = dp[1] + abs(stones[2]-stones[1]);
    rep(i, 3, n+1){
        int cost = 1e9;
        rep(j, 1, k+1){
            if(i-j>=1 && ){
                cost = min( cost, dp[i-j]+abs(stones[i] - stones[i-j]));
                //cout << cost << endl;
            }
        }
        //cout << i << '-' << cost << endl; 

        dp[i] = cost;
    }
    // rep(i, 1, n+1){
    //     cout << dp[i] << " ";
    // }
    // cout << endl;
    cout << dp[n];
}



Compiler output:
a.cc: In function 'int32_t main()':
a.cc:80:26: error: expected primary-expression before ')' token
   80 |             if(i-j>=1 && ){
      |                          ^