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

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chMin(T& a,T b){if(a>b){a=b;return true;}else{return false;}};
const inf=1e9;
  
int main(){
    int N,K;
    cin >>N >>K;
    vector<int> h(N);
    for (int i=0;i<N;i++)cin >>h[i];
    vector<int> mem(100200); 
  	for(int i:mem)mem[i]=inf;
    mem[0]=0;
    for(int i=0;i<N;i++){
        for(int j;j<K;j++){
            chMin(mem[i+j+1],mem[i]+abs(h[j]-h[i])));
        }
    }
    cout <<mem[N-1]<<endl;
}

Compiler output:
a.cc:4:7: error: 'inf' does not name a type; did you mean 'int'?
    4 | const inf=1e9;
      |       ^~~
      |       int
a.cc: In function 'int main()':
a.cc:12:30: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   12 |         for(int i:mem)mem[i]=inf;
      |                              ^~~
      |                              ynf
a.cc:16:52: error: expected ';' before ')' token
   16 |             chMin(mem[i+j+1],mem[i]+abs(h[j]-h[i])));
      |                                                    ^
      |                                                    ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chMin(T& a,T b){if(a>b){a=b;return true;}else{return false;}};

int main(){
    int N,K;
    cin >>N >>K;
    vector<int> h(N);
    for (int i=0;i<N;i++)cin h[i];
    vector<int> mem(100200); 
    mem[0]=0;
    for(int i=0;i<N;i++){
        for(int j;j<K;j++){
            mem[i+j]=mem[i]+h[j];
        }
    }
    cout <<mem[n-1]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:29: error: expected ';' before 'h'
    9 |     for (int i=0;i<N;i++)cin h[i];
      |                             ^~
      |                             ;
a.cc:17:16: error: 'n' was not declared in this scope
   17 |     cout <<mem[n-1]<<endl;
      |                ^
Language: C++

#include <iostream>
#include <algorithm>
#include <climts>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int h[n],dp[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[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(h[i]-h[i+j]));
                }
        }
    }
    cout<<dp[n-1];
}

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
int main(){
    long long n,k,h[200000],dp[200000]={0};
    cin>>n>>k;
    rep(i,n) cin>>h[i];
    rep(i,n){
        long long m=10000000;
        rep(j,min(i+1,k)){
            long long p=dp[i-j]+max(h[i+1]-h[i-j],h[i-j]-h[i+1]);
            if(p<m) m=p;
        }
        dp[i+1]=m;
    }
    cout<<dp[n-1]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: no matching function for call to 'min(int, long long int&)'
   10 |         rep(j,min(i+1,k)){
      |               ~~~^~~~~~~
a.cc:3:38: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(int i = 0; i < n; i++)
      |                                      ^
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:10:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   10 |         rep(j,min(i+1,k)){
      |               ~~~^~~~~~~
a.cc:3:38: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(int i = 0; i < n; i++)
      |                                      ^
/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:10:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   10 |         rep(j,min(i+1,k)){
      |               ~~~^~~~~~~
a.cc:3:38: note: in definition of macro 'rep'
    3 | #define rep(i, n) for(int i = 0; i < n; i++)
      |                                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,M;
int dp[100100];
int main(){
    ll N,K; cin >> N >> K;
    ll h[N];
    for(ll i = 0; i < N; i++){
        cin >> h[i];
    }
    for(ll i = 0; i < 100000; i++) dp[i] = INF;
    dp[0] = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = 1; j <= K; j++){
            if(i+j < N){
                dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]), dp[i+j]);
            }
        }
    }
    cout << dp[N-1] << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:28:30: error: no matching function for call to 'min(long long int, int&)'
   28 |                 dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]), dp[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: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:28:30: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |                 dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]), 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:
/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:28:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |                 dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]), dp[i+j]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

#define MAXN 100020

#define INF 1000000010

int N,K;
long long dp[MAXN];
long long h[MAXN];


int main() {
	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] = INF;
      	for (int j = max(0,i-K); j < i; j++) {
			dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]);
                        }
                        }
                        cout << dp[N-1] << endl;
                        }

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

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int n, k;
int a[100003];
int s[100003];

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

	for (int i = 1; i <= n; i++)
	{
		scanf_s("%d", &a[i]);

		if (i == 1)
		{
			s[i] = 0;
		}

		if (i != 1)
		{
			int res = 1000000007;

			for (int j = 1; j <= k; j++)
			{
				if (i == j) break;
				res = min(res, s[i - j] + abs(a[i - j] - a[i]));
			}

			s[i] = res;
		}
	}

	printf("%d", s[n]);

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   17 |                 scanf_s("%d", &a[i]);
      |                 ^~~~~~~
      |                 scanf
Language: C++

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL

struct Edge {
	int from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;

signed main(void) {
	int n;
	cin >> n;
	vector<int> h(n  +103);
	REP(i, n) {
		cin >> h[i];
	}

	int dp[100103] = {};
	Fill(dp, INT_MAX);
	dp[0] = 0;
	REP(i, n) {
		REP(j,k)
			dp[i + k] = min(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
	}


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



Compiler output:
a.cc: In function 'int main()':
a.cc:74:23: error: 'k' was not declared in this scope
   74 |                 REP(j,k)
      |                       ^
a.cc:18:38: note: in definition of macro 'rep'
   18 | #define rep(i,s,n) for(int i = (s); (n) > i; i++)
      |                                      ^
a.cc:74:17: note: in expansion of macro 'REP'
   74 |                 REP(j,k)
      |                 ^~~
Language: C++

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long> vec(n), dp(n,INF);
    for(int i=0; i<n; i++)
    {
        cin >> vec[i];
    }

    dp[0] = 0;
    dp[1] = abs(vec[1] - vec[0]);

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

    cout << dp[n-1];

}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:24: error: expected ')' before ';' token
    3 | #define INF 10000000000;
      |                        ^
a.cc:9:31: note: in expansion of macro 'INF'
    9 |     vector<long> vec(n), dp(n,INF);
      |                               ^~~
a.cc:9:28: note: to match this '('
    9 |     vector<long> vec(n), dp(n,INF);
      |                            ^
a.cc:9:34: error: expected primary-expression before ')' token
    9 |     vector<long> vec(n), dp(n,INF);
      |                                  ^
Language: C++

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

int main(){

    ll n;
    cin>>n;
  	ll k;
  cin>>k;
     ll a[n];
    for( ll i =0 ; i<n ;i++)cin>>a[i];


    ll ans[n+1];
    memset(ans,0,sizeof(ans));
    ans[0]=0;
  	ans[1]= abs(a[1]-a[0]);
    for(ll i=2;i<n;i++)
    {
     	ans[i] = ans[i-1] +abs (a[i]-a[i-1]);
      	for(ll j = 2;  j<k && i-j >=1; j++)
        {
          ans[i] = min(ans[i],ans[i-j] +abs(a[i]-a[i-j]));
    }

    cout<<ans[n-1];


}

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

import sys
from collections import defaultdict as dd

n, k = [int(i) for i in input().split()]
l = [0] + [int(i) for i in input().split()]

dp = [0] * (n + 1)

for i in range(2, n + 1):
	dp[i] = dp[i - 1] + abs(l[i] - l[i - 1])
	for j in range(2, min(k, i - 1) + 1):
		dp[i] = min(dp[i], dp[i - j] + abs(l[i] - l[i - j]))

print(dp[n])

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: Java

// CCC 2004
// Problem S2 TopYodeller
//
// given multiple series of integers, maintain cummulative totals,
// rankings and worse ranking.
//
// simple 1D integer arrays handle this

import java.awt.*;

import java.util.*;
public class DP_Practice
{


    public static void main (String[] args)
    {

       Scanner c = new Scanner(System.in);
        int n = c.nextInt();
        int k = c.nextInt();
        int [] cost = new int[n];
        int[] dp = new int[n];
        for(int i = 0; i<n; i++){
            dp[i] = Integer.MAX_VALUE;
            cost[i] = c.nextInt();
        }
        dp[0] = 0;
        for(int i = 0; i<n; i++){
            for(int j = 1; j<=k; j++) {
                if (i >= j) {
                    dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(cost[i] - cost[i - j]));
                }

            }
        }


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

}


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

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int>a (n);
  for (auto &x : a) {
    cin >> x;
  }
  vector<int>dp (n, 1e9 + 2);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      int cur = i + j;
      if (cur < n) {
        dp[cur] = min (dp[cur], dp[i] + abs (a[i] - a[j]) );
      }
    }
  }
  cout << dp[n - 1];
  return 0;
}


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

#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<vector>
using namespace std;
int main()
{
    long long int n,k;
    cin>>n>>k;
    vector<long long int> v(n);
    for(long long int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    long long int arr[n];
    arr[0] = 0;
    for(long long int j=1;j<n;j++)
    {
        long long int min = LLONG_MAX;
        long long int t = k;
        long long int i = j-1;
        while(i>=0 && t)
        {
            if((abs(v[j]-v[i])+arr[i])<min)
            {
                min = (abs(v[j]-v[i])+arr[i]);
            }
            t--;
            i--;
        }
        arr[j] = min;
    }
    cout<<arr[n-1]<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:21:29: error: 'LLONG_MAX' was not declared in this scope
   21 |         long long int min = LLONG_MAX;
      |                             ^~~~~~~~~
a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<vector>
  +++ |+#include <climits>
    7 | using namespace std;
Language: Java

import java.util.Scanner;

public class Main{
  static int N;
  static int K;
  static int A[];
  static int DP[];
  static int DPK[];
  static int ans;
  public static void main(String args[]){
    int ans = 100000000;
   Scanner sc = new Scanner(System.in);
   N = sc.nextInt();
   K = sc.nextInt();
   A = new int[N];
   DP = new int[N];
   DPK = new int[N];
   for(int i=0;i<N;i++){
     A[i]=sc.nextInt();
   }
   DP[0]=0;
   DP[1]=Math.abs(A[0]-A[1]);
   if(N==2){
     System.put.println(DP[1]);
   }
   else{
   for(int i=2;i<N;i++){
     for(int j=i-1;j>i-K-1;j--){
       if(j<0){}
         else{
           DPK[j]=DP[j]+Math.abs(A[j]-A[i]);
           if(ans>=DPK[j]){
             ans=DPK[j];
           }
         }
     }
     DP[i]=ans;
     ans = 100000000;
   }
   System.out.println(DP[N-1]);
 }
}

}


Compiler output:
Main.java:24: error: cannot find symbol
     System.put.println(DP[1]);
           ^
  symbol:   variable put
  location: class System
1 error
Language: Java

import java.util.Scanner;

public class MainMain{
  static int N;
  static int K;
  static int A[];
  static int DP[];
  static int DPK[];
  static int ans;
  public static void main(String args[]){
    int ans = 10000000;
   Scanner sc = new Scanner(System.in);
   N = sc.nextInt();
   K = sc.nextInt();
   A = new int[N];
   DP = new int[N];
   DPK = new int[N];
   for(int i=0;i<N;i++){
     A[i]=sc.nextInt();
   }
   DP[0]=0;
   DP[1]=Math.abs(A[0]-A[1]);
   for(int i=2;i<N;i++){
     for(int j=i-1;j>i-K-1;j--){
       if(j<0){}
         else{
           DPK[j]=DP[j]+Math.abs(A[j]-A[i]);
           if(ans>=DPK[j]){
             ans=DPK[j];
           }
         }
     }
     DP[i]=ans;
     ans = 100000000;
   }
   System.out.println(DP[N-1]);
 }

}

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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 100
#define MAX_N 100000;
#define Pair pair<int,int>
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int dist[MAP][MAP];
int h[MAX_N];
int dp[MAX_N];
int main(){
    int n,k; cin >> n >> k;
    int h[n];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    fill(dp, dp+n, MAX_N);
    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(h[i]-h[i+j]));
            }
        }
    }
    cout << dp[n-1] << endl;
}



Compiler output:
a.cc:8:21: error: expected ']' before ';' token
    8 | #define MAX_N 100000;
      |                     ^
a.cc:13:7: note: in expansion of macro 'MAX_N'
   13 | int h[MAX_N];
      |       ^~~~~
a.cc:13:12: error: expected unqualified-id before ']' token
   13 | int h[MAX_N];
      |            ^
a.cc:8:21: error: expected ']' before ';' token
    8 | #define MAX_N 100000;
      |                     ^
a.cc:14:8: note: in expansion of macro 'MAX_N'
   14 | int dp[MAX_N];
      |        ^~~~~
a.cc:14:13: error: expected unqualified-id before ']' token
   14 | int dp[MAX_N];
      |             ^
a.cc: In function 'int main()':
a.cc:21:10: error: 'dp' was not declared in this scope; did you mean 'dy'?
   21 |     fill(dp, dp+n, MAX_N);
      |          ^~
      |          dy
a.cc:8:21: error: expected ')' before ';' token
    8 | #define MAX_N 100000;
      |                     ^
a.cc:21:20: note: in expansion of macro 'MAX_N'
   21 |     fill(dp, dp+n, MAX_N);
      |                    ^~~~~
a.cc:21:9: note: to match this '('
   21 |     fill(dp, dp+n, MAX_N);
      |         ^
a.cc:21:25: error: expected primary-expression before ')' token
   21 |     fill(dp, dp+n, MAX_N);
      |                         ^
Language: C++

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

using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 4e18;
const ll MOD = 1e9+7;

int dp[100110];
int h[100110];
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n >> k;
  
  for (int i = 1; i <= n; i++) {
    dp[i] = inf;
    cin >> h[i];
  }
  
  dp[1] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
    }
  }

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


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

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<n;(i)++ )
#define FOR(i,m,n) for(int (i)=m;(i)<n;(i)++)


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

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

/*
ID: allengu01
TASK: 
LANG: C++
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <unordered_map>
using namespace std;

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



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

/*
ID: allengu01
TASK: 
LANG: C++
*/

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <unordered_map>
using namespace std;
unordered_map<int, int> q;

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



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

#include <iostream>
#include <vector>

using namespace std;

int main() {
 int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  vector<int> dp(n, INT_MAX);
  
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= max(0, i - k); 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:14:21: error: 'INT_MAX' was not declared in this scope
   14 |   vector<int> dp(n, INT_MAX);
      |                     ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <vector>
  +++ |+#include <climits>
    3 |
Language: C++

#include <iostream>

using namespace std;

int main() {
 int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  vector<int> dp(n, INT_MAX);
  
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= max(0, i - k); 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:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> a(n);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> a(n);
      |          ^~~
a.cc:10:12: error: 'a' was not declared in this scope
   10 |     cin >> a[i];
      |            ^
a.cc:13:10: error: expected primary-expression before 'int'
   13 |   vector<int> dp(n, INT_MAX);
      |          ^~~
a.cc:15:3: error: 'dp' was not declared in this scope
   15 |   dp[0] = 0;
      |   ^~
a.cc:18:37: error: 'a' was not declared in this scope
   18 |      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
      |                                     ^
Language: C++

#include <iostream>

using namespace std;

int main() {
 int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  vector<int> dp(n, INT_MAX);
  
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i - 1; j >= max(0, i - k); j--) {
     dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j])); 
    }
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
    8 |   vector<int> a(n);
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | 
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> a(n);
      |          ^~~
a.cc:10:12: error: 'a' was not declared in this scope
   10 |     cin >> a[i];
      |            ^
a.cc:13:10: error: expected primary-expression before 'int'
   13 |   vector<int> dp(n, INT_MAX);
      |          ^~~
a.cc:15:3: error: 'dp' was not declared in this scope
   15 |   dp[0] = 0;
      |   ^~
a.cc:18:37: error: 'a' was not declared in this scope
   18 |      dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
      |                                     ^
Language: C++

#include<bits/stdc++.h>
 
using namespace std;
 
int N;
int arr[100123];
int memo[100123];
 
int solve(int n) {
  if (n == N - 1) return 0;
  if (n == N - 2) return abs(arr[n] - arr[n + 1]);
  if (memo[n] != -1) return memo[n];
  int best = 190000000;
  for (int j = n + 1; j <= min(N - 1, n + K); ++j) {
    best = min(best, abs(arr[n] - arr[n + j]));
  }
  return memo[n] = best;
}
int main() {
  ios_base::sync_with_stdio(false);
  memset(memo, -1, sizeof memo);
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> arr[i];
  
  int ans = solve(0);
  cout << ans << '\n';
}

Compiler output:
a.cc: In function 'int solve(int)':
a.cc:14:43: error: 'K' was not declared in this scope
   14 |   for (int j = n + 1; j <= min(N - 1, n + K); ++j) {
      |                                           ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
using namespace std;

const int MOD=1e9+7;
const int N=2e5+7;
int a[N],dp[N];


int32_t main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	for (int i = 1; i <= n ; ++i)
	{
		cin>>a[i];
	}
	for (int i = 1; i <= n ; ++i)
	{
		dp[i]=N*(i!=1);
		for (int j = max(0,i-k); j < i; j++)
		{
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
		//cout<<dp[i]<<" "<<(((i-k)>=0)*(i-k))<<"\n";
	}
	cout<<dp[n];
	return 0;
}



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

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 100005;
ll cost[maxn],dp[maxn];

int N;

int main(){
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++){
        scanf("%lld", &cost[i]);
        dp[i] = maxn*10000;
    }
    dp[0] = 0;
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++){
            if(i-j >= 0){
                dp[i] = min(dp[i], dp[i-j] + abs(cost[i] - cost[i-j]));
            }
        }
    }
    printf("%lld", dp[N-1]);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:25: error: 'K' was not declared in this scope
   11 |     scanf("%d %d", &N, &K);
      |                         ^
Language: C

 int N, K, H[101010], dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];
    
    rep(i, 0, N) dp[i] = inf;
    dp[0] = 0;
 
    rep(i, 0, N) {
        rep(k, 1, K + 1) chmin(dp[i + k], dp[i] + abs(H[i] - H[i + k]));
    }
 
    cout << dp[N - 1] << endl;
}

Compiler output:
main.c: In function '_main':
main.c:4:5: error: 'cin' undeclared (first use in this function)
    4 |     cin >> N >> K;
      |     ^~~
main.c:4:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:5:5: error: implicit declaration of function 'rep' [-Wimplicit-function-declaration]
    5 |     rep(i, 0, N) cin >> H[i];
      |     ^~~
main.c:5:9: error: 'i' undeclared (first use in this function)
    5 |     rep(i, 0, N) cin >> H[i];
      |         ^
main.c:5:17: error: expected ';' before 'cin'
    5 |     rep(i, 0, N) cin >> H[i];
      |                 ^~~~
      |                 ;
main.c:7:17: error: expected ';' before 'dp'
    7 |     rep(i, 0, N) dp[i] = inf;
      |                 ^~~
      |                 ;
main.c:10:17: error: expected ';' before '{' token
   10 |     rep(i, 0, N) {
      |                 ^~
      |                 ;
Language: C++

int N, K, H[101010], dp[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> H[i];
    
    rep(i, 0, N) dp[i] = inf;
    dp[0] = 0;
 
    rep(i, 0, N) {
        rep(k, 1, K + 1) chmin(dp[i + k], dp[i] + abs(H[i] - H[i + k]);
    }
 
    cout << dp[N - 1] << endl;
}

Compiler output:
a.cc: In function 'void _main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin >> N >> K;
      |     ^~~
a.cc:5:9: error: 'i' was not declared in this scope
    5 |     rep(i, 0, N) cin >> H[i];
      |         ^
a.cc:5:5: error: 'rep' was not declared in this scope
    5 |     rep(i, 0, N) cin >> H[i];
      |     ^~~
a.cc:14:5: error: 'cout' was not declared in this scope
   14 |     cout << dp[N - 1] << endl;
      |     ^~~~
a.cc:14:26: error: 'endl' was not declared in this scope
   14 |     cout << dp[N - 1] << endl;
      |                          ^~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int N, K, dummy;
	dummy = scanf("%d %d", &N, &K);

	vector<int> vi;
	//map<int, int> mi;
	vector<int> mi;

	int tmp1;
	for (int i = 0; i < N; i++) {
		dummy = scanf("%d", &tmp1);
		vi.push_back(tmp1);
	}

	//mi[0] = 0;
	mi.push_back(0);

	for (int n = 1; n < N; n++) {
		int tmpMin = INT_MAX;
		for (int k = 1; k <= K; k++) {
			if (n < k) continue;
			int tmp = mi[n-k] + abs(vi[n] - vi[n-k]);
			tmpMin = min(tmpMin, tmp);
		}
		//mi[n] = tmpMin;
		mi.push_back(tmpMin);
	}
	
	printf("%d\n", mi[N-1]);
	
	return 0;
}


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

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	int N, K, dummy;
	dummy = scanf("%d %d", &N, &K);

	vector<int> vi;
	map<int, int> mi;

	int tmp1;
	for (int i = 0; i < N; i++) {
		dummy = scanf("%d", &tmp1);
		vi.push_back(tmp1);
	}

	mi[0] = 0;

	for (int n = 1; n < N; n++) {
		int tmpMin = INT_MAX;
		for (int k = 1; k <= K; k++) {
			if (n < k) continue;
			int tmp = mi[n-k] + abs(vi[n] - vi[n-k]);
			tmpMin = min(tmpMin, tmp);
		}
		mi[n] = tmpMin;
	}
	
	printf("%d\n", mi[N-1]);
	
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(int argc, const char* argv[])
{
    int N, K;
    cin >> N >> K;
    
    int h[N];
    for(int i = 0; i < N; i++)
        cin >> h[i];
    
    ll dp[N];
    dp[0] = 0;
    for(int i = 1; i < N; i++)
    {
        ll m = 100000;
        for(int k = 1; k <= K; k++)
        {
            if(k <= i)
            {
                ll tmp = dp[i-k] + (h[i] - h[i-k] > 0 ? h[i] - h[i-k] : h[i-k] - h[i]);
                if(tmp < m)
                    m = tmp;
            }
        }
        
        dp[i] = m;
    }
    
    cout << dp[N-1] << endl;
    
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> N >> K;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout << dp[N-1] << endl;
      |     ^~~~
a.cc:31:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:24: error: 'endl' was not declared in this scope
   31 |     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: Java

import java.util.Scanner;

public class DPs {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] heights = new int[N];
        for(int i=0;i<N;i++){
            heights[i] = sc.nextInt();
        }
        System.out.println(frog1(heights,K));
    }

    static int frog1(int[] heights,int K){
        int[] dp= new int[heights.length];
        dp[0]= 0;
        dp[1]= Math.abs(heights[1]-heights[0]);
        for(int i=2;i<heights.length;i++){
            int min = Integer.MAX_VALUE;
            for(int k=1;k<=K;k++){
                if(i-k>=0){
                    int cost = dp[i-k] +Math.abs(heights[i]-heights[i-k]);
                    min = (min > cost) ? cost: min;
                }
            }
            dp[i] = min;
        }
        return dp[heights.length-1];
    }
}


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

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:10:29: error: 'INT_MAX' was not declared in this scope
   10 |     vector<int> v(n), dp(n, 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 |
Language: C++

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

long long mx=100*1000+7;
 
int main()
{
	ios::sync_with_stdio(false);
	long long dp[mx];
	int a[mx];
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)	cin>>a[i];
	for(int i=2;i<=n;i++)
	{
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		for(int j=1;j<=k;j++)
		{
			if(i-j>=1)
				dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n];
	return 0;
}

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

#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn=100100;
 
long long dp[maxn];
long long h[maxn];
long long n,k;
 
int main () {
	memset(dp, -1, maxn);
	
	cin >> n >> k;
	for (int i=0;i<n;++i){
		cin >> h[i];
	}
	
	for (int i=0;i<k;++i){
		dp[i]=abs(h[i]-h[0]);
	}
		
	for (int i=2;i<n;++i){
		for (int j=1;j<=k;j++)
			if (j > i)continue;
			if (dp[i]!=-1){
				dp[i]=min(abs(h[i]-h[j])+dp[j], dp[i]);
			}
			else {
				dp[i]=abs(h[i]-h[j])+dp[j];
			}
	}
	cout << dp[n-1] << '/n';
	return 0;
}

Compiler output:
a.cc:33:28: warning: multi-character character constant [-Wmultichar]
   33 |         cout << dp[n-1] << '/n';
      |                            ^~~~
a.cc: In function 'int main()':
a.cc:27:54: error: 'j' was not declared in this scope
   27 |                                 dp[i]=min(abs(h[i]-h[j])+dp[j], dp[i]);
      |                                                      ^
a.cc:30:50: error: 'j' was not declared in this scope
   30 |                                 dp[i]=abs(h[i]-h[j])+dp[j];
      |                                                  ^
Language: C++

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

int main()
{
 //   freopen("Freog2.INP","r",stdin);
    long  n, i,k,j,intt;
    cin >> n>>k;
    long  a[n],b[n];
    for (int i=1;i<=n;i++)
        cin >> a[i];
    b[1]=h[1];

    for (i=2;i<=n;i++)
    {
        intt =9999999;
        for(j=1;j<=k;j++)
        {
            if(j<i)
            {
                intt=min(b[i-j ]+ abs(a[i]-a[i-j]),intt);
            }
            else break;
        }
        b[i]=intt;
    }
    cout<<b[n]-b[1];

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:10: error: 'h' was not declared in this scope
   12 |     b[1]=h[1];
      |          ^
Language: C++

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

int main()
{
 //   freopen("Freog2.INP","r",stdin);
    long  n, i,k,j,intt;
    cin >> n>>k;
    int a[n],b[n];
    for (int i=1;i<=n;i++)
        cin >> a[i];
    b[1]=0;

    for (i=2;i<=n;i++)
    {
        intt =9999999;
        for(j=1;j<=k;j++)
        {
            if(j<i)
            {
                intt=min(b[i-j ]+ abs(a[i]-a[i-j]),intt);
            }
            else break;
        }
        b[i]=intt;
    }
    cout<<b[n]-b[1];

    return 0;
}



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

#include <iostream>
#include <stdlib.h>
using namespace std;
long n,k,i,j,h[100001],b[100001];
int tmp;
int main()
{
    cin >> n >> k;
    for (i=1;i<=n;i++)
    {
        cin >> h[i];
    }
    b[1]=h[1];
    for (i=2;i<=n;i++)
    {
        tmp=999999999;
        for (j=1;j<=k;j++)
        {
            if (i>j)
            {
               tmp=min(b[i-j]+abs(h[i]-h[i-j]),tmp);
            }
            else
            {
                break;
            }
        }
        b[i]=tmp;
    }
    cout << b[n]-b[1];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:23: error: no matching function for call to 'min(long int, int&)'
   21 |                tmp=min(b[i-j]+abs(h[i]-h[i-j]),tmp);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:21:23: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   21 |                tmp=min(b[i-j]+abs(h[i]-h[i-j]),tmp);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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
Language: C++

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

int main() {
	// your code goes here
	
	int i,j,n,k;
	
	cin>>n>>k;
	int h[n];
	long long dp[n];
	for(i=0;i<n;i++)
	{
	    cin>>h[i];
	    
	}
	for(i=0;i<n;i++)
	{
	    dp[i]=1000000010
	}
	dp[0]=0;
	if(k>n)
	{
	    k=n;
	}
	for(i=1;i<k;i++)
	{
	   dp[i]=abs(h[i]-h[0]);
	  
	}
	dp[1]=abs(h[1]-h[0]);
	
	for(i=k;i<n;i++)
	{
	    for(j=i-k;j<i;j++)
	    {
	        dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
	    }
	    
	   if(i==(n-1))
	   {
	       cout<<dp[n-1];
	   }
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:29: error: expected ';' before '}' token
   19 |             dp[i]=1000000010
      |                             ^
      |                             ;
   20 |         }
      |         ~