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

#include <iostream>
#include <cstdlib>

using namespace std;

int Minimum(int min[],int k,int n,int arr[],int i)
{
    int range;
    vector<int> a;
    if(i+k > n-1)
    {
        range = n-1;
    }
    else
    {
        range = i+k;
    }
    for(int j=range;j>i;j--)
    {
        a.push_back(abs(arr[j]-arr[i]) + min[j]);
    }
    return *min_element(a.begin(), a.end());
}
int FindMin(int n,int k,int arr[])
{
    int min[n];
    min[n-1] = 0;
    min[n-2] = abs(arr[n-1]-arr[n-2]);
    for(int i=n-3; i>=0; i--)
    {
        min[i] = Minimum(min,k,n,arr,i);
    }
    return min[0];
}
int main()
{
    int n,k,ans;
    cin>>n>>k;
    int arr[n];
    {
        for(int i=0; i<n; i++)
        {
            cin>>arr[i];
        }
    }
    ans=FindMin(n,k,arr);
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int Minimum(int*, int, int, int*, int)':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<int> a;
      |     ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <cstdlib>
  +++ |+#include <vector>
    3 | 
a.cc:9:12: error: expected primary-expression before 'int'
    9 |     vector<int> a;
      |            ^~~
a.cc:20:9: error: 'a' was not declared in this scope
   20 |         a.push_back(abs(arr[j]-arr[i]) + min[j]);
      |         ^
a.cc:22:25: error: 'a' was not declared in this scope
   22 |     return *min_element(a.begin(), a.end());
      |                         ^
a.cc:22:13: error: 'min_element' was not declared in this scope
   22 |     return *min_element(a.begin(), a.end());
      |             ^~~~~~~~~~~
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
#include <bits/stdc++.h>
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;
ll dp[100005];
ll h[100005];
ll c[100005];
int main() {
		int n, k;
		cin >> n >> k;

		
		rep(i, n) cin >> h[i]; 

		ll INF = 1e13;
		ll c[n];
		rep(i, n) c[i] = INF;
		c[0] = 0;

		for (int i = 1; i < n; i++) {
			for (int j = max(i - k, 0); j < i; j++) {
				c[i] = min(c[i], c[j] + abs(h[j] - h[i]));
			}
		}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: 'i' was not declared in this scope
   16 |                 rep(i, n) cin >> h[i];
      |                     ^
a.cc:5:22: note: in definition of macro 'rep'
    5 | #define rep(i,n) FOR(i,0,n)
      |                      ^
a.cc:5:18: error: 'FOR' was not declared in this scope
    5 | #define rep(i,n) FOR(i,0,n)
      |                  ^~~
a.cc:16:17: note: in expansion of macro 'rep'
   16 |                 rep(i, n) cin >> h[i];
      |                 ^~~
Language: C++

#include<iostream>
#include<cmath>
#include<algorithm>
#include <bits/stdc++.h>
#define rep(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;
ll dp[100005];
ll h[100005];
ll c[100005];
int main() {
		int n, k;
		cin >> n >> k;

		
		rep(i, n) cin >> h[i]; 

		ll INF = 1e13;
		ll c[n];
		rep(i, n) c[i] = INF;
		c[0] = 0;

		for (int i = 1; i < n; i++) {
			for (int j = max(i - k, 0); j < i; j++) {
				c[i] = min(c[i], c[j] + abs(h[j] - h[i]));
			}
		}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:21: error: 'i' was not declared in this scope
   16 |                 rep(i, n) cin >> h[i];
      |                     ^
a.cc:5:22: note: in definition of macro 'rep'
    5 | #define rep(i,n) FOR(i,0,n)
      |                      ^
a.cc:5:18: error: 'FOR' was not declared in this scope
    5 | #define rep(i,n) FOR(i,0,n)
      |                  ^~~
a.cc:16:17: note: in expansion of macro 'rep'
   16 |                 rep(i, n) cin >> h[i];
      |                 ^~~
a.cc: At global scope:
a.cc:31:1: error: expected declaration before '}' token
   31 | }
      | ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:13:23: error: 'INF' was not declared in this scope
   13 |     vector<int> dp(n, INF);
      |                       ^~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> n;
      |     ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<int> h(n);
      |     ^~~~~~
a.cc:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> h(n);
      |            ^~~
a.cc:8:16: error: 'h' was not declared in this scope
    8 |         cin >> h[i];
      |                ^
a.cc:10:12: error: expected primary-expression before 'int'
   10 |     vector<int> dp(n, INF);
      |            ^~~
a.cc:11:5: error: 'dp' was not declared in this scope
   11 |     dp[0] = 0;
      |     ^~
a.cc:15:48: error: 'h' was not declared in this scope
   15 |                 dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
      |                                                ^
a.cc:15:44: error: 'abs' was not declared in this scope
   15 |                 dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
      |                                            ^~~
a.cc:15:25: error: 'min' was not declared in this scope; did you mean 'main'?
   15 |                 dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
      |                         ^~~
      |                         main
a.cc:19:5: error: 'cout' was not declared in this scope
   19 |     cout << dp[n-1];
      |     ^~~~
Language: C++

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



long long a[100009];
long long dp[100009];
long long f( long long x)
{
    dp[n-1]=0;
    dp[n-2]=abs(a[n-1]-a[n-2]);
    if(dp[x]!=-1)
        return dp[x];
    long long y=100000000009;
    for(int i=1; i<=k; i++)
    {
        y=min(y,(f(x+i)+abs(a[x]-a[x+i]))) ;
    }

    dp[x]=y;
    return y;


}
int main()
{
memset(dp,-1,sizeof dp);
    cin>>n;
    cin>>k;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
  cout<< f(0);
    return 0;
}


Compiler output:
a.cc: In function 'long long int f(long long int)':
a.cc:10:8: error: 'n' was not declared in this scope
   10 |     dp[n-1]=0;
      |        ^
a.cc:15:21: error: 'k' was not declared in this scope
   15 |     for(int i=1; i<=k; i++)
      |                     ^
a.cc: In function 'int main()':
a.cc:28:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   28 |     cin>>n;
      |          ^
      |          yn
a.cc:29:10: error: 'k' was not declared in this scope
   29 |     cin>>k;
      |          ^
Language: Java

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = sc.nextInt();
        }

        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            dp[i] = Integer.MAX_VALUE;
        }
        
        dp[0] = 0;

        for (int i = 1; i < n; i++) {
            for (int j=Math.max(i - k, 0); j < i; j++) {
                dp[i] = Math.min(dp[i], dp[j] + Math.abs(heights[i] - heights[j]));
            }
        }
        System.out.println(dp[n - 1]);
    }
}

Compiler output:
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
        Scanner sc = new Scanner(System.in);
                         ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

# include <iostream>
# include <cstdio>
# include <cstring>
# include <vector>
# include <string>
# include <cmath>
# include <map>
# include <unordered_map>
# include <set>
# include <queue>
# include <deque>

using namespace std;

int f(int k, const vector < int > & h, vector < int > & res, int max_step) {
    if (k == 0) return 0;

    if (res[k] == -1) {
        
        res[k] = f(k - 1, h, res, max_step) + abs(h[k] - h[k - 1]);
            
            for(int step=2; step < min(k, max_step); step++)
            {
                if (k >= step) {
                    tmp = min(res[k], f(k - step, h, res, max_step) + abs(h[k] - h[k - step]));
                    if (tmp < res[k]) {
                        res[k] = tmp
                    }
                }
            }
        }
        
        return res[k];
    }


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

  // lets start from 0, to n-1
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  
  vector<int> res(n, -1);
  
  cout << f(n - 1, h, res, max_step);

  return 0;
}

Compiler output:
a.cc: In function 'int f(int, const std::vector<int>&, std::vector<int>&, int)':
a.cc:25:21: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   25 |                     tmp = min(res[k], f(k - step, h, res, max_step) + abs(h[k] - h[k - step]));
      |                     ^~~
      |                     tm
Language: C++

# include <iostream>
# include <cstdio>
# include <cstring>
# include <vector>
# include <string>
# include <cmath>
# include <map>
# include <unordered_map>
# include <set>
# include <queue>
# include <deque>

using namespace std;

int f(int k, const vector < int > & h, vector < int > & res, int max_step) {
    if (k == 0) return 0;

    if (res[k] == -1) {
        
        res[k] = f(k - 1, h, res, max_step) + abs(h[k] - h[k - 1]);
            
            for(int step=2; step < min(k, max_step); step++)
            {
                if (k >= step) {
                    res[k] = min(res[k], min(res[k], f(k - step, h, res, max_step) + abs(h[k] - h[k - step]));)
                }
            }
        }
        
        return res[k];
    }


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

  // lets start from 0, to n-1
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  
  vector<int> res(n, -1);
  
  cout << f(n - 1, h, res, max_step);

  return 0;
}

Compiler output:
a.cc: In function 'int f(int, const std::vector<int>&, std::vector<int>&, int)':
a.cc:25:110: error: expected ')' before ';' token
   25 |                     res[k] = min(res[k], min(res[k], f(k - step, h, res, max_step) + abs(h[k] - h[k - step]));)
      |                                 ~                                                                            ^
      |                                                                                                              )
a.cc:25:111: error: expected primary-expression before ')' token
   25 |                     res[k] = min(res[k], min(res[k], f(k - step, h, res, max_step) + abs(h[k] - h[k - step]));)
      |                                                                                                               ^
Language: C++

# include <iostream>
# include <cstdio>
# include <cstring>
# include <vector>
# include <string>
# include <cmath>
# include <map>
# include <unordered_map>
# include <set>
# include <queue>
# include <deque>

using namespace std;

int f(int k, const vector < int > & h, vector < int > & res, int max_step) {
    if (k == 0) return 0;

    if (res[k] == -1) {
        
        res[k] = f(k - 1, h, res, max_step) + abs(h[k] - h[k - 1]);
            
            for(int step=2; step < min(k, max_step); step++)
            {
                if (k >= step) {
                    res[k] = min(res[k], f(k - step, h, res, max_step) + abs(h[k] - h[k - step]));
                }
            }
        }
        
        return res[k];
    }


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

  // lets start from 0, to n-1
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  
  vector<int> res(n, -1);
  
  cout << f(n - 1, h, res, max_step);

  return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:50:12: error: expected '}' at end of input
   50 |   return 0;
      |            ^
a.cc:34:12: note: to match this '{'
   34 | int main() {
      |            ^
Language: C++

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

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

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

#include <stdio.h>
#include <stdlib.h>
 
int min(int a, int b)
{
	if (a<b)
		return a;
	else
		return b;
}
 
int main()
{
	int a[100001];
	int dp[100001];
	int n,k,i,j, min2;
	scanf("%d %d", &n, &k);
	for(i=0;i<n;i++)
		scanf("%d", &a[i]);
	for(i=1;i<n;i++){
		min2 = 999999;
		for(j=1;j<=k && i-j<0;j++){
			dp[i] = min(min2, dp[i-j] + abs(a[i] - a[i-j]));
			min2= dp[i];
		}
	}
	prnit("%d",dp[n-1]);
}

Compiler output:
main.c: In function 'main':
main.c:27:9: error: implicit declaration of function 'prnit'; did you mean 'printf'? [-Wimplicit-function-declaration]
   27 |         prnit("%d",dp[n-1]);
      |         ^~~~~
      |         printf
Language: C

#include <stdio.h>
#include <stdlib.h>
 
int *dp;
int *s;
int size;
 
int min(int a, int b){
	if (a<b)
		return a;
	else
		return b;
	
}
 
int main()
{
 
	int i,j,min2;
 
	scanf("%d", &size);
	dp = (int *) malloc(sizeof(int)*size);
	s = (int *) malloc(sizeof(int)*size);
 
	for(i=0;i<size;i++)
		scanf("%d", &s[i]);
 
	dp[0] = 0;
 
	for(i=1;i<size;i++)
	{
		min2 = 999999;
		for(j=1;j<k+1;j++)
			dp[i] = min(min2, dp[i-j] + abs(a[i] - a[a-j]));
			min2= dp[i];
	}
	
	printf("%d", dp[size-1]);
}

Compiler output:
main.c: In function 'main':
main.c:33:27: error: 'k' undeclared (first use in this function)
   33 |                 for(j=1;j<k+1;j++)
      |                           ^
main.c:33:27: note: each undeclared identifier is reported only once for each function it appears in
main.c:34:57: error: 'a' undeclared (first use in this function)
   34 |                         dp[i] = min(min2, dp[i-j] + abs(a[i] - a[a-j]));
      |                                                         ^
Language: C++

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

#define REP(i, x) for (int i = 0, i##_len = (int)(x); i < i##_len; i++)
#define REP1(i, x) for (int i = 1, i##_len = (int)(x); i <= i##_len; i++)
const int INF = (int)1e9 + 9;
using vint = vector<int>;

int main() {
    int N, K;
    cin >> N >> K;
    vint dp(N, INF);
    dp[0] = 0;
    REP(i, N) {
        REP1(j, K) {
            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: In function 'int main()':
a.cc:17:56: error: 'h' was not declared in this scope
   17 |                 dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      |                                                        ^
Language: C++

#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n; cin >> n ;
	int k; cin >> k;
	int h[n+1];
	//h[0]  = 0;
	rep(i,1,n) cin >> h[i];
	int val[n+1] ;
	for(int i=0;i<n+1;i++) val[i] = INF ;
	//val[0]=  0;
	val[1] = 0;
	val[2]= abs(h[2]-h[1]);
	rep(i,3,n){
		for(int j = i-1;j>=max(1,i-k);j--){
		
				val[i] = min(val[i],abs(h[i]-h[j]) + val[j]);
			
			
		}
	}
	cout << val[n];
	return 0;
}



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

#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n; cin >> n ;
	ll k; cin >> k;
	ll h[n+1];
	//h[0]  = 0;
	rep(i,1,n) cin >> h[i];
	ll val[n+1] ;
	for(ll i=0;i<n+1;i++) val[i] = INF ;
	//val[0]=  0;
	val[1] = 0;
	val[2]= abs(h[2]-h[1]);
	rep(i,3,n){
		for(ll j = i-1;j>=max(1,i-k);j--){
		
				val[i] = min(val[i],abs(h[i]-h[j]) + val[j]);
			
			
		}
	}
	cout << val[n];
	return 0;
}



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

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author hamaron
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits>

using namespace std;

class BFrog2 {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, K;
        in >> N >> K;

        int h[N+1];
        for (int i = 1; i < N+1; i++) {
            in >> h[i];
        }

        int dp[N+1];
        for (int j = 1; j < N+1; j++) {
            if (j == 1) {
                dp[j] = 0;
                continue;
            }

            if (j == 2) {
                dp[j] = abs(h[1] - h[2]);
                continue;
            }

            int temp = INT_MAX;
            for (int k = 1; k < K+1; k++) {
                if (j - k >= 1) {
                    temp = min(temp, dp[j-k] + abs(h[j-k] - h[j]));
                }
            }

            dp[j] = temp;
        }

        out << dp[N];
    }
};


int main() {
	BFrog2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Compiler output:
a.cc: In member function 'void BFrog2::solve(std::istream&, std::ostream&)':
a.cc:38:24: error: 'INT_MAX' was not declared in this scope
   38 |             int temp = INT_MAX;
      |                        ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <limits>
  +++ |+#include <climits>
   12 |
Language: C++

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author hamaron
 */

#include <iostream>
#include <fstream>

#include <iostream>

using namespace std;

class BFrog2 {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N, K;
        in >> N >> K;

        int h[N+1];
        for (int i = 1; i < N+1; i++) {
            in >> h[i];
        }

        int dp[N+1];
        for (int j = 1; j < N+1; j++) {
            if (j == 1) {
                dp[j] = 0;
                continue;
            }

            if (j == 2) {
                dp[j] = abs(h[1] - h[2]);
                continue;
            }

            int temp = INT_MAX;
            for (int k = 1; k < K+1; k++) {
                if (j - k >= 1) {
                    temp = min(temp, dp[j-k] + abs(h[j-k] - h[j]));
                }
            }

            dp[j] = temp;
        }

        out << dp[N];
    }
};


int main() {
	BFrog2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Compiler output:
a.cc: In member function 'void BFrog2::solve(std::istream&, std::ostream&)':
a.cc:37:24: error: 'INT_MAX' was not declared in this scope
   37 |             int temp = INT_MAX;
      |                        ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <fstream>
  +++ |+#include <climits>
    9 |
Language: C++

#include <iostream>
#include <climits>

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    for (int i = 0; i < n; ++i) cin >> h[i];
    int dp[100010];
    fill(dp[0], dp[0] + n, INT_MAX);
    for (int i = 0; i < n; ++i) for (int j = 1; j < K+1; ++j) chmin(dp[i + j], 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:16:53: error: 'K' was not declared in this scope
   16 |     for (int i = 0; i < n; ++i) for (int j = 1; j < K+1; ++j) chmin(dp[i + j], dp[i] + abs(h[i] - h[i + k]));
      |                                                     ^
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: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int; _Tp = int]'
  998 |     { std::__fill_a1(__first, __last, __value); }
      |       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int; _Tp = int]'
 1029 |       std::__fill_a(__first, __last, __value);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:15:9:   required from here
   15 |     fill(dp[0], dp[0] + n, INT_MAX);
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:9: error: invalid type argument of unary '*' (have 'int')
  952 |         *__first = __tmp;
      |         ^~~~~~~~
Language: C++

#include <bitsstdc++.h>
using namespace std;
#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)
#define ll long long
const int INF = 1e9;

int n, c;
int h[2 * 10 ^ 5];

int k;
int main() {
	cin >> n >> k;
	FOR(i, 1, n) cin >> h[i];
	vector<ll> dp(n,INF);
	dp[0] = 0;
	
	REP(i, n-1) {
		FOR(j, i + 1, min(n-1,i+k)) {
			dp[j] = min(dp[i] +abs(h[i+1]-h[j+1]) , dp[j]);
		}
		
	}
	cout << dp[n-1];
}

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

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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>h;
    vector<int>d;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        h.push_back(t);
    }
    /*for(int i=0;i<h.size();i++)
    {
        vector<int> temp;
        if(i==0)
        {
            for(int j=1;j<k && j<h.size();j++)
                temp.push_back(abs(h[i]-h[j]));
        }
        else
        {
            for(int j=1;j<k && j<h.size();j++)
                temp.push_back(d[i-1][j]+abs(h[i]-h[j]));
        }
        d1.push_back(temp);
    }
    int min=INT_MAX;
    for(int i=0;i<h.size()-1;i++)
    {
        for(int j=0;j<d1[i].size();j++)
        {
            if()
        }
    }*/
    d[0]=0;
    d[1]=abs(h[0]-h[1]);
    for(int i=2;i<k;i++)
    {
        for(int j=k-1;j<=0;j--)
        {
            int t=d[i-j]+abs(h[i-j]-h[i])
            if(min>t)
                min=t;
            
        }
    }
    int min=INT_MAX;
    for(int i=k;i<n;i++)
    {
        for(int j=1;j<k;j++)
        {
            d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]))
            int t=d[i-j]+abs(h[i]-h[i-j]);
            if(min>t)
                min=t;
        }
        d[i]=min;
        min=INT_MAX;
    }
    //int i=0;
    cout<<d[n-1];
    //cout<<min;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:13: error: expected ',' or ';' before 'if'
   46 |             if(min>t)
      |             ^~
a.cc:56:21: error: 'min' cannot be used as a function
   56 |             d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]))
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:58:20: error: 't' was not declared in this scope
   58 |             if(min>t)
      |                    ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define inf 1012345678
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define next_permutation nxt_p
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a*b/gcd(a,b);};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	int h[100010];
	rep(i, h) cin >> h[i];
	int dp[100010];
	Fill(dp, INF);
	dp[0] = 0;

	rep(i, n) {
		REP(j, 1, k + 1) {
			chmin(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:5:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    5 | #define rep(i,n) for(int (i)=0;i<(n);i++)
      |                                 ^
a.cc:39:9: note: in expansion of macro 'rep'
   39 |         rep(i, h) cin >> h[i];
      |         ^~~
Language: C

#include<stdio.h>
    #include<stdlib.h>
    
    
    int min(int a,int b){
    	if(a<b){
    		return a;
		}else{
			return b;
		}
	
	
	int main(void){
		
      int n,m,i,j,h[100010],d[100010]={};
      
      	scanf("%d %d",&n,&m);
      	
      	for(i=0;i<n;i++)scanf("%d",&h[i]);
      		for(i=1;i<n;i++){
				d[i]=1e9;
		}
      		
			  
			for(i=0;i<n;i++){
        		for(j=0;j<m && i+j+1<n;j++){
        			d[i+j+1]=min(d[i+j+1],d[i]+abs(h[i]-h[i+j+1]));	
				}
        		
      }
      
      printf("%d\n",d[n-1]);
      
    }

Compiler output:
main.c: In function 'min':
main.c:34:5: error: expected declaration or statement at end of input
   34 |     }
      |     ^
Language: C

#include<stdio.h>
    #include<stdlib.h>
    
    
    int min(int a,int b){
    	if(a<b){
    		return a;
		}else{
			return b;
		}
	
	
	int main(){
		
      int n,m,i,j,h[100010],d[100010]={};
      
      	scanf("%d %d",&n,&m);
      	
      	for(i=0;i<n;i++)scanf("%d",&h[i]);
      		for(i=1;i<n;i++){
				d[i]=1e9;
		}
      		
			  
			for(i=0;i<n;i++){
        		for(j=0;j<m && i+j+1<n;j++){
        			d[i+j+1]=min(d[i+j+1],d[i]+abs(h[i]-h[i+j+1]));	
				}
        		
      }
      
      printf("%d\n",d[n-1]);
      return 0;
      
    }

Compiler output:
main.c: In function 'min':
main.c:35:5: error: expected declaration or statement at end of input
   35 |     }
      |     ^
Language: C

#include<stdio.h>
    #include<stdlib.h>
    
    
    int MIN(int a,int b){
    	if(a<b){
    		return a;
		}else{
			return b;
		}
	
	
	int main(){
      int n,m,i,j,h[100010],d[100010]={};
      scanf("%d %d",&n,&m);
      for(i=0;i<n;i++)scanf("%d",&h[i]);
      for(i=1;i<n;i++)d[i]=1e9;
      for(i=0;i<n;i++){
        for(j=0;j<m&&i+j+1<n;j++)d[i+j+1]=MIN(d[i+j+1],d[i]+abs(h[i]-h[i+j+1]));
      }
      printf("%d\n",d[n-1]);
      return 0;
    }

Compiler output:
main.c: In function 'MIN':
main.c:23:5: error: expected declaration or statement at end of input
   23 |     }
      |     ^
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <fstream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>
#include <list>

using namespace std; 

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

Compiler output:
a.cc: In function 'int main()':
a.cc:32:24: error: 'INT_MAX' was not declared in this scope
   32 |         fill(ans,ans+n,INT_MAX);
      |                        ^~~~~~~
a.cc:22:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   21 | #include <list>
  +++ |+#include <climits>
   22 |
Language: C++

#include<bits/stdc++.h>

using ll = long long;
using namespace std;

int N, K, h[1e5];
ll dp[1e5];

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

	for(int i = 0; i < N; ++i) dp[i] = LONG_MAX;
	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(h[i]-h[i-j]));
			}
		}
	}
	cout << dp[N-1] << endl;
}

Compiler output:
a.cc:6:13: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    6 | int N, K, h[1e5];
      |             ^~~
a.cc:6:13: error: could not convert '1.0e+5' from 'double' to 'long unsigned int'
    6 | int N, K, h[1e5];
      |             ^~~
      |             |
      |             double
a.cc:6:13: error: size of array 'h' has non-integral type 'double'
a.cc:7:7: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    7 | ll dp[1e5];
      |       ^~~
a.cc:7:7: error: could not convert '1.0e+5' from 'double' to 'long unsigned int'
    7 | ll dp[1e5];
      |       ^~~
      |       |
      |       double
a.cc:7:7: error: size of array 'dp' has non-integral type 'double'
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |           dp[i+j]=min(abs(array[j+i]-array[i])+dp[i],dp[i+j]);
      |           ^~
      |           dup
a.cc:18:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   18 |     cout<<dp[n-1];
      |           ^~
      |           dup
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	
    int qtdPedras;
	int salto;
	int alt;
	int altura;
	int pulo;
	int last;

    scanf("%d", &qtdPedras);
    scanf("%d", &salto);  
	
	int v[qtdPedras];
	int high[qtdPedras]; 

    for(int i = 0; i <= qtdPedras; i++){
        if(i < qtdPedras){
            scanf("%d", &altura); 
            *(high + i) = altura;
        } else {
            printf("%d\n", *(v + (qtdPedras-1)));
        }
        
        if(i == 0){
            alt = altura; 
        } else if(i == 1){
            *(v + 1) = abs(alt - altura);
        }else {
            pulo = min(salto, min(qtdPedras, i));
            
            *(v + i) = INT_MAX;
            
            for(int j = 0; j < pulo; j++){
                if(j == i-1){
                    *(v + i) = min(*(v + i), abs(alt - altura));
                } else {
                    last = abs(altura - *(high + (i-j-1)));
                    *(v + i) = min(*(v + i), last + *(v + (i-j-1))); 
                }
            }
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:24: error: 'INT_MAX' was not declared in this scope
   36 |             *(v + i) = INT_MAX;
      |                        ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <algorithm>
  +++ |+#include <climits>
    3 |
Language: C++

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

//can use O(K) memory actually

int T, n, k;
const int maxn = 100000+5;
const ll INF = 1000000000+5;
ll h[maxn];
ll dp[maxn];

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


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

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

//can use O(1) memory actually

int T, n;
const int maxn = 100000+5;
const ll INF = 1000000000+5;
ll h[maxn];
ll dp[maxn];

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


Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: 'k' was not declared in this scope
   17 |         cin >> n >> k;
      |                     ^
a.cc:21:55: error: expected ';' before 'cout'
   21 |                 dp[i]=min(dp[i], dp[j]+abs(h[i]-h[j]))
      |                                                       ^
      |                                                       ;
   22 |         cout << dp[n];
      |         ~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

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

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

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

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:25: error: 'INF' was not declared in this scope
   15 |     rep(i,110000) dp[i]=INF;
      |                         ^~~
a.cc:18:24: error: 'K' was not declared in this scope
   18 |         for(int j=1;j<=K;++j){
      |                        ^
Language: C

#include <iostream>
#include <math.h>

using namespace std;

int menorCusto = 2000000000;
int dMax = 0;

void geraComb(int posAtual, int qtdCand, int passoMax, int *n, bool vBool[], int v[], int *dMax);
void verifSolucao(bool vBool[], int v[], int k, int *n);


int main(){
	int num;
	int n;
	int k;
	int high;
	
	//cin >> n >> k;
	scanf("%d",&n);
	scanf("%d",&k);
	
	int v[n];
	//vector <int> v;
	bool vBool[n];
	
	for(int i = 0; i < n; i++){
		//cin >> v[i];
		scanf("%d",&v[i]);
		//cin >> num;
		//v.push_back(num);
		vBool[i] = false;
	}
	
	geraComb(0, n, k, &n, vBool, v, &dMax);
	
	//cout << menorCusto << endl;
	printf("%d", menorCusto);
}

void geraComb(int posAtual, int qtdCand, int passoMax, int *n, bool vBool[], int v[], int *dM){
	//cout << *dMax << endl;
	if(*dM >= passoMax){
		//*dM -= 1;
		return;	
	}
	if(posAtual == *n /*- 1*/ && vBool[0] && vBool[*n - 1]) verifSolucao(vBool, v, passoMax, n);
	else{
		for(int i = 0; i < *n; i++){
			int aux = 0;
			if(posAtual + i + 1 <= *n){
				//cout << "\nposAtual + 1 = " << posAtual + 1 << " qtdCand - 1 = " << qtdCand - 1 << " passoMax = " << passoMax << " n = " << *n;
				vBool[posAtual /*+ i*/] = true;
				aux = *dM;
				*dM = 0; //cout << "T" << *dM << endl;
				geraComb(posAtual + 1, qtdCand - 1, passoMax, n, vBool, v, dM);
				if(vBool[posAtual]) *dM = aux;
				if(!vBool[0] || posAtual == (*n - 1)) return;
				vBool[posAtual /*+ i*/] = false;
				*dM += 1; //cout << "F" << *dM << endl;
				geraComb(posAtual + 1, qtdCand - 1, passoMax, n, vBool, v, dM);
				//if(*dM > 0) *dM -= 1;
				/*if(!vBool[0]) */return;
			}
		}
	}
	return;
}

void verifSolucao(bool vBool[], int v[], int k, int *n){
	int pedraAnt = 0;
	int custo = 0;
	
	/*for(int i = 0; i < *n; i++)
		cout << vBool[i];*/

	for(int i = 0; i < *n; i++){
		if (vBool[i] && vBool[*n - 1] && i > 0){
			custo += fabs(v[i] - v[pedraAnt]);
			//cout << "\npedraAnt = "<< pedraAnt << " pedraAtual = " << i << " custo += (v[i] - v[pedraAnt]) = " << custo - fabs(v[i] - v[pedraAnt]) << " += fabs(" << v[i] << " - " << v[pedraAnt] << ")";
			pedraAnt = i;
		}
	}
	
	if(custo < menorCusto) menorCusto = custo;
	
		//cout << menorCusto << endl;
	//}
	
	return;
}

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

#include <stdio.h>
#define ok printf("ok\n");

int max(int a, int b){
    if(a>b)
        return a;
    if(b>a)
        return b;
}

int min(int a, int b){
    if(a>b)
        return b;
    else
        return a;
}

int abs(int a){
    return max(a, -a);
}
int x[110000];
int dp[110000];

int main(){
    int a , b;
    scanf("%d%d", &a, &b);
    //printf("%d", a);

    for(int i=0; i<a; i++){
        scanf("%d", h+1);
    }

    for(int i=0; i<=a; i++){
        dp[i]=110000;
    }
    dp[0]=0;

    for(int i=0; i<a; i++){
        for(int j=1; j<=b; j++){
            if(i+j<a)
                dp[i+j]=min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }

    printf("%d", dp[a-1]);


}


Compiler output:
main.c: In function 'main':
main.c:30:21: error: 'h' undeclared (first use in this function)
   30 |         scanf("%d", h+1);
      |                     ^
main.c:30:21: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>
#define ok printf("ok\n");

int max(int a, int b){
    if(a>b)
        return a;
    if(b>a)
        return b;
}

int min(int a, int b){
    if(a>b)
        return b;
    else
        return a;
}

int abs(int a){
    return max(a, -a);
}
int h[110000];
int dp[110000];

int main(){
    int a,b; scanf("%d%d", a, b);
    for(int i=0; i<a; i++) scanf("%d", x+1);
    for(int i=0; i<=a; i++)dp[i]=110000;
    dp[0]=0;

    for(int i=0; i<=a; i++){
        for(int j=1; i<=b; j++){
            if(i+j<a)dp[i+j]=min(dp[i+j], dp[i]+abs(x[i]-x[i+k]));
        }
    }

    printf("%d", dp[a-1]);


}


Compiler output:
main.c: In function 'main':
main.c:26:40: error: 'x' undeclared (first use in this function)
   26 |     for(int i=0; i<a; i++) scanf("%d", x+1);
      |                                        ^
main.c:26:40: note: each undeclared identifier is reported only once for each function it appears in
main.c:32:62: error: 'k' undeclared (first use in this function)
   32 |             if(i+j<a)dp[i+j]=min(dp[i+j], dp[i]+abs(x[i]-x[i+k]));
      |                                                              ^
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<math.h>
#include<utility>

using namespace std;

int main(){
	int n,temp,k;
	cin>>n>>k;
	vector<int> cost;
	for(int i=0;i<n;i++){
		cin>>temp;
		cost.push_back(temp);
	}
	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(cost[1]-cost[0]);
	for(int i=2;i<n;i++){
		int temp = INT_MAX;
		for(int j=1;j<=k;j++){
			temp = min(temp, dp[i-j]+abs(cost[i]-cost[i-j]));
		}
		
		dp[i] = temp;
	}
	cout<<dp[n-1];
}

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

#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<math.h>
#include<utility>

using namespace std;

int main(){
	int n,temp;
	cin>>n;
	vector<int> cost;
	for(int i=0;i<n;i++){
		cin>>temp;
		cost.push_back(temp);
	}
	vector<int> dp(n,0);
	dp[0]=0;
	dp[1]=abs(cost[1]-cost[0]);
	for(int i=2;i<n;i++){
		int temp = INT_MAX;
		for(int j=1;j<=k;j++){
			temp = min(temp, dp[i-j]+abs(cost[i]-cost[i-j]));
		}
		
		dp[i] = temp;
	}
	cout<<dp[n-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:28: error: 'INT_MAX' was not declared in this scope
   22 |                 int temp = INT_MAX;
      |                            ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<utility>
  +++ |+#include <climits>
    7 | 
a.cc:23:32: error: 'k' was not declared in this scope
   23 |                 for(int j=1;j<=k;j++){
      |                                ^