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

#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int arr[n],i,j,k1;
  for(i=0;i<n;i++){
    cin>>arr[i];
  }
  int h[n],m,mm=100000,k1;
  for(i=0;i<n;i=k1){
    for(j=i+1;j<=k;j++){
      m=abs(arr[i]-arr[j]);
      mm=min(mm,m);
      if(m<=mm)
        k1=j;
    }
    s+=mm;
  }
  cout<<s;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:24: error: redeclaration of 'int k1'
   10 |   int h[n],m,mm=100000,k1;
      |                        ^~
a.cc:6:18: note: 'int k1' previously declared here
    6 |   int arr[n],i,j,k1;
      |                  ^~
a.cc:18:5: error: 's' was not declared in this scope
   18 |     s+=mm;
      |     ^
a.cc:20:9: error: 's' was not declared in this scope
   20 |   cout<<s;
      |         ^
Language: Java

import java.util.Arrays;
import java.util.Scanner;

public class Frog2 {
	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			int N = in.nextInt();
			int K = in.nextInt();
			int[] h = new int[N];
			for (int i = 0; i < N; i++) {
				h[i] = in.nextInt();
			}
			int[] dp = new int[N];
			Arrays.fill(dp, Integer.MAX_VALUE);
			dp[0] = 0;
			for (int i = 1; i < N; i++) {
				for (int j = Math.max(0, i - K); j < i; j++) {
					if (dp[j] == Integer.MAX_VALUE) continue;
					dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[j] - h[i]));
				}
			}
			System.out.println(dp[N - 1]);
		}
	}
}


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

public class Frog2 {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int K = in.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = in.nextInt();
		}
		int[] dp = new int[N];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0] = 0;
		for (int i = 1; i < N; i++) {
			for (int j = Math.max(0, i - K); j < i; j++) {
				if (dp[j] == Integer.MAX_VALUE) continue;
				dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[j] - h[i]));
			}
		}
		System.out.println(dp[N - 1]);
	}
}

Compiler output:
Main.java:1: error: class Frog2 is public, should be declared in a file named Frog2.java
public class Frog2 {
       ^
Main.java:3: error: cannot find symbol
		Scanner in = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Frog2
Main.java:3: error: cannot find symbol
		Scanner in = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Frog2
Main.java:11: error: cannot find symbol
		Arrays.fill(dp, Integer.MAX_VALUE);
		^
  symbol:   variable Arrays
  location: class Frog2
4 errors
Language: C++

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

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

//
// Created by 13783 on 2020/4/1.
//

#include<iostream>
using namespace std;
const int N=1e5+5;
const int K=100;
int h[N];
int dp[N];
int n;
int k;
void solve(){
    dp[1]=0;
    for(int i=2;i<=n;i++){
        dp[i]=INT_MAX;
    }
    //dp[i]为跳到第i步的最小代价
    for(int i=2;i<=n;i++){
      for(int j=1;j<=k&&i>=j;j++){
          dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
      }
    }
    cout<<dp[n];
}
int main(){
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:16:15: error: 'INT_MAX' was not declared in this scope
   16 |         dp[i]=INT_MAX;
      |               ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include<iostream>
  +++ |+#include <climits>
    6 | using namespace std;
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <cassert>
#include <array>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using ti = tuple<int, int, int>;

#define FOR(i,m,n) for(int i=(m); i<(n); i++)
#define REP(i,n) for(int i=0; i<(n); i++)
#define RFOR(i,n,m) for(int i=(n);i>=(m); i--)
#define RREP(i,n) for(int i=(n-1); (i)>=0; i--)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << endl
// #define int long long 

const double eps=1e-14;
const int mod = 1e9 + 7;
const int inf = 100100100;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct mint 
{
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int h[n];
    REP(i,n) cin >> h[i];
    int dp[n];
    REP(i,n) dp[i] = inf;
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    FOR(i,2,n)
    {
        RFOR(j,i-1,i-k))
        {
            if(i-k>=0)
            {
                dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
            }
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:90:24: error: expected primary-expression before ')' token
   90 |         RFOR(j,i-1,i-k))
      |                        ^
Language: C

#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define S 10001
#define M 1000000007
#define nl cout<<"\n";
#define error  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x) cerr << #x << " is " << x << endl;
#define test lli t;  cin>>t; while(t--)
int main()
{
    lli i,j,n,k;
    cin>>n>>k;
    lli a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    lli dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(i=3;i<=n;i++)
    {
         for(j=1;j<=k&&i-j>=1;j++)
         {
            if(j==1)
            {
                dp[i]=dp[i-1]+abs(a[i]-a[i-j]);
            } 
            else
            {
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
         }
        
    }
    cout<<dp[n];
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#define vi vector<int>
using namespace std;
vi heights, solutions;
vector<bool> sol_ready;
int minimum_cost_to(int position, int max_step)
{
	if (sol_ready[position])
		return solutions[position];
	int min_cost = INT_MAX;
	int current_height = heights[position];
	for (int new_position = position-1; new_position >= 0 && new_position >= position-max_step; new_position--)
	{
		int new_height = heights[new_position];
		int new_cost = minimum_cost_to(new_position, max_step) + abs(current_height - new_height);
		min_cost = min(min_cost, new_cost);
	}
	solutions[position] = min_cost;
	sol_ready[position] = true;
	return min_cost;
}
int main()
{
	ios::sync_with_stdio(false);
	int n, max_step; cin >> n >> max_step;
	solutions = vi(n); heights = vi(n);
	sol_ready = vector<bool>(n);
	for (size_t i = 0; i < n; i++)
		cin >> heights[i];
	sol_ready[0] = true;
	cout << minimum_cost_to(n - 1, max_step);
	return 0;
}

Compiler output:
a.cc: In function 'int minimum_cost_to(int, int)':
a.cc:12:24: error: 'INT_MAX' was not declared in this scope
   12 |         int min_cost = INT_MAX;
      |                        ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | #define vi vector<int>
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define mi INT_MAX
int main()
{int n,i,j,k,p,mi;
 cin>>n>>k;
 int a[n+1],d[n+1];
 for(i=1;i<=n;i++)
 {
   cin>>a[i];
 }
a[0]=a[1];
 d[0]=0;
 d[1]=0;
/*for(j=0;j<=n;j++)
 {
     cout<<a[j]<<" ";
 }*/
 for(j=2;j<=n;j++)
 { d[j]=mi
   for(p=j-1;p>=j-k&p>=0;p--)
 { d[j]=min(d[j],abs(a[j]-a[p])+d[p]);
 }
   //d[j]=min(abs(a[j]-a[j-1])+d[j-1],abs(a[j]-a[j-2])+d[j-2]);
  // cout<<d[j]<<endl;
    
            }
            cout<<d[n]<<endl;
 return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:3:12: error: expected unqualified-id before numeric constant
    3 | #define mi INT_MAX
      |            ^~~~~~~
a.cc:5:16: note: in expansion of macro 'mi'
    5 | {int n,i,j,k,p,mi;
      |                ^~
a.cc:21:4: error: expected ';' before 'for'
   21 |    for(p=j-1;p>=j-k&p>=0;p--)
      |    ^~~
a.cc:21:29: error: expected ';' before ')' token
   21 |    for(p=j-1;p>=j-k&p>=0;p--)
      |                             ^
      |                             ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#definr mi INT_MAX
int main()
{int n,i,j,k,p,mi;
 cin>>n>>k;
 int a[n+1],d[n+1];
 for(i=1;i<=n;i++)
 {
   cin>>a[i];
 }
a[0]=a[1];
 d[0]=0;
 d[1]=0;
/*for(j=0;j<=n;j++)
 {
     cout<<a[j]<<" ";
 }*/
 for(j=2;j<=n;j++)
 { d[j]=mi
   for(p=j-1;p>=j-k&p>=0;p--)
 { d[j]=min(d[j],abs(a[j]-a[p])+d[p]);
 }
   //d[j]=min(abs(a[j]-a[j-1])+d[j-1],abs(a[j]-a[j-2])+d[j-2]);
  // cout<<d[j]<<endl;
    
            }
            cout<<d[n]<<endl;
 return 0;
}



Compiler output:
a.cc:3:2: error: invalid preprocessing directive #definr; did you mean #define?
    3 | #definr mi INT_MAX
      |  ^~~~~~
      |  define
a.cc: In function 'int main()':
a.cc:20:11: error: expected ';' before 'for'
   20 |  { d[j]=mi
      |           ^
      |           ;
   21 |    for(p=j-1;p>=j-k&p>=0;p--)
      |    ~~~     
a.cc:21:29: error: expected ';' before ')' token
   21 |    for(p=j-1;p>=j-k&p>=0;p--)
      |                             ^
      |                             ;
Language: Java



import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class FrogJump {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String in[] = br.readLine().split(" ");
        int n = Integer.parseInt(in[0]);
        int k = Integer.parseInt(in[1]);
        in = br.readLine().split(" ");
        int arr[]=new int[n];
        int dp[] = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=Integer.parseInt(in[i]);
        }
        Arrays.fill(dp,Integer.MAX_VALUE);
        dp[0]=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<=Math.min(i+k,n-1);j++){
                dp[j]=Math.min(Math.abs(arr[i]-arr[j])+dp[i], dp[j]);
            }
        }
        System.out.println(dp[n-1]);
    }
}


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

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

void fnInput(vector<int>& rvnStage, int& rnJmpStage)
{
  int nStageSiz;
  cin >> nStageSiz >> rnJmpStage;
  rvnStage.resize(nStageSiz);

  for(int& rnStage : rvnStage)
    cin >> rnStage;
}
  
int fnDPCost(const vector<int>& cnrvnStage, nJmpStage)
{
  vector<int> vnDPCost(cnrvnStage.size(), INT_MAX);
  vnDPCost[0] = 0;

  for (int i = 0; i < cnrvnStage.size() - 1; i++)
    for (int j = 1;j < nJmpStage; j++)
      if (i + j < cnrvnStage.size())
        vnDPCost[i + j] = min(vnDPCost[i + j], vnDPCost[i] + abs(cnrvnStage[i + j] - cnrvnStage[i]));
  }

  return vnDPCost[cnrvnStage.size() - 1];
}
  
int main()
{
  vector<int> vnStage;
  int nJmpStage;
  fnInput(vnStage, nJmpStage);
  cout << fnDPCost(vnStage, nJmpStage) << endl;

  return 0;
}

Compiler output:
a.cc:14:45: error: 'nJmpStage' has not been declared
   14 | int fnDPCost(const vector<int>& cnrvnStage, nJmpStage)
      |                                             ^~~~~~~~~
a.cc: In function 'int fnDPCost(const std::vector<int>&, int)':
a.cc:20:24: error: 'nJmpStage' was not declared in this scope
   20 |     for (int j = 1;j < nJmpStage; j++)
      |                        ^~~~~~~~~
a.cc:23:3: warning: no return statement in function returning non-void [-Wreturn-type]
   23 |   }
      |   ^
a.cc: At global scope:
a.cc:25:3: error: expected unqualified-id before 'return'
   25 |   return vnDPCost[cnrvnStage.size() - 1];
      |   ^~~~~~
a.cc:26:1: error: expected declaration before '}' token
   26 | }
      | ^
Language: C++

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

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

#define _GLIBCXX_DEBUG
using ll=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin >> n >> k;
  vector<ll> cost(n+10,100000);
  vector<ll> height(n+10);
  rep(i,n) cin>>height[i+1];
  cost[1]=0;
  
  for(ll i=1;i<=n-1;i++){
    for(ll j=i+1;j<=min(n,i+k);j++){
      cost[j]=min(cost[i]+abs(height[j]-height[i]),cost[j]);
    }
  }
  cout << cost[n] <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:3: error: 'cin' was not declared in this scope
    5 |   cin.tie(0);
      |   ^~~
a.cc:6:3: error: 'ios' has not been declared
    6 |   ios::sync_with_stdio(false);
      |   ^~~
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<ll> cost(n+10,100000);
      |   ^~~~~~
a.cc:9:12: error: expected primary-expression before '>' token
    9 |   vector<ll> cost(n+10,100000);
      |            ^
a.cc:9:14: error: 'cost' was not declared in this scope; did you mean 'const'?
    9 |   vector<ll> cost(n+10,100000);
      |              ^~~~
      |              const
a.cc:10:12: error: expected primary-expression before '>' token
   10 |   vector<ll> height(n+10);
      |            ^
a.cc:10:14: error: 'height' was not declared in this scope
   10 |   vector<ll> height(n+10);
      |              ^~~~~~
a.cc:11:7: error: 'i' was not declared in this scope
   11 |   rep(i,n) cin>>height[i+1];
      |       ^
a.cc:11:3: error: 'rep' was not declared in this scope
   11 |   rep(i,n) cin>>height[i+1];
      |   ^~~
a.cc:15:21: error: 'min' was not declared in this scope; did you mean 'main'?
   15 |     for(ll j=i+1;j<=min(n,i+k);j++){
      |                     ^~~
      |                     main
a.cc:16:27: error: 'abs' was not declared in this scope
   16 |       cost[j]=min(cost[i]+abs(height[j]-height[i]),cost[j]);
      |                           ^~~
a.cc:19:3: error: 'cout' was not declared in this scope
   19 |   cout << cost[n] <<endl;
      |   ^~~~
a.cc:19:21: error: 'endl' was not declared in this scope
   19 |   cout << cost[n] <<endl;
      |                     ^~~~
Language: C++

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin >> n >> k;
  vector<ll> cost(n+10,10000);
  vector<ll> height(n+10);
  rep(i,n) cin>>height[i+1];
  cost[1]=0;
  
  for(int ll=1;i<=n;i++){
    for(int ll=1;j<=min(j,k);j++){
      cost[i] = min(cost[i-j]+abs(height[i-j]-height[i]) ,cost[i]);
    }
  }
  cout << cost[n] <<endl;
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin >> n >> k;
  vector<ll> cost(n+10,10000);
  vector<ll> height(n+10);
  rep(i,n) cin>>height[i+1];
  cost[1]=0;
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=min(j,k);j++){
      cost[i] = min(cost[i-j]+abs(height[i-j]-height[i]) ,cost[i]);
    }
  }
  cout << cost[n] <<endl;
}

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

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vector<int> cost[n+10];
  vector<int> height[n+10];
  
  for(int i=1;i<=n;i++){
    for(int j=1;j<=k;j++){
      cost[i] = min(cost[i-j]+abs(heigh[j]-height[i]) , cost[i]);
    }
  }
  
  cout << cost[N] <<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:35: error: 'heigh' was not declared in this scope; did you mean 'height'?
   17 |       cost[i] = min(cost[i-j]+abs(heigh[j]-height[i]) , cost[i]);
      |                                   ^~~~~
      |                                   height
a.cc:21:16: error: 'N' was not declared in this scope
   21 |   cout << cost[N] <<endl;
      |                ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> dp;
int solve(vector<int>&ar ,int k ,int i )
{
   if( i == 0)
   	  return 0;
    if(dp[i] != -1)
    	return dp[i];    // prevent re-cal
    int res =INT_MAX;
    for(int j =1 ; j<= k ;j++)
    	if( i - j >= 0)
          res = min(res, solve(ar, k , i - j) + abs(ar[i] - ar[i-j]));
    
     return dp[i] = res;    // store 
}
int main(){
	int n , k;
	cin >> n >> k;
    dp.clear()
    dp.resize(n, -1);
	vector<int > ar(n);
	for(int i =0 ; i<n; i++ )
		cin>> ar[i];
	cout<< solve(ar, k, n-1) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:15: error: expected ';' before 'dp'
   20 |     dp.clear()
      |               ^
      |               ;
   21 |     dp.resize(n, -1);
      |     ~~
Language: C++

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

using namespace std;

int main() {
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for (auto &x : h) { cin >> x; }
	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(h[i] - h[j]));

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:27: error: 'INT_MAX' was not declared in this scope
   13 |         vector<int> DP(n, INT_MAX);
      |                           ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    5 | #include <algorithm>
  +++ |+#include <climits>
    6 |
Language: C++

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



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

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



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

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



Compiler output:
a.cc: In function 'int main()':
a.cc:10:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   10 |   dp[n+2]={0};
      |   ^~
      |   dup
a.cc:12:3: error: expected ',' or ';' before 'for'
   12 |   for(int i=2;i<=n;i++)
      |   ^~~
a.cc:12:23: error: expected ';' before ')' token
   12 |   for(int i=2;i<=n;i++)
      |                       ^
      |                       ;
Language: C++

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

Compiler output:
a.cc:15:2: error: stray '#' in program
   15 | }#include <bits/stdc++.h>
      |  ^
a.cc:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main () {
      | ^~~~
a.cc:15:3: error: 'include' does not name a type
   15 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:18:4: error: redefinition of 'long long int dp [100005]'
   18 | ll dp[100005],a[100005],n,k;
      |    ^~
a.cc:4:4: note: 'long long int dp [100005]' previously declared here
    4 | ll dp[100005],a[100005],n,k;
      |    ^~
a.cc:18:15: error: redefinition of 'long long int a [100005]'
   18 | ll dp[100005],a[100005],n,k;
      |               ^
a.cc:4:15: note: 'long long int a [100005]' previously declared here
    4 | ll dp[100005],a[100005],n,k;
      |               ^
a.cc:18:25: error: redefinition of 'long long int n'
   18 | ll dp[100005],a[100005],n,k;
      |                         ^
a.cc:4:25: note: 'long long int n' previously declared here
    4 | ll dp[100005],a[100005],n,k;
      |                         ^
a.cc:18:27: error: redefinition of 'long long int k'
   18 | ll dp[100005],a[100005],n,k;
      |                           ^
a.cc:4:27: note: 'long long int k' previously declared here
    4 | ll dp[100005],a[100005],n,k;
      |                           ^
a.cc:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   19 | main () {
      | ^~~~
a.cc:19:1: error: redefinition of 'int main()'
a.cc:5:1: note: 'int main()' previously defined here
    5 | main () {
      | ^~~~
Language: C++

#include <bits/stdc++.h>
#define int int64_t
#define M 1000000007
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;


int32_t main()
{
    //fastio;
    int t=1,n,k,i,j;
    //cin>>t;
    while (t--)
    {
        cin>>n>>k;

        int a[n],dp[n];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        dp[0]=0;
        dp[1]=abs(a[1]-a[0]);
        for(i=2;i<n;i++)
        {
        	dp[i]=1e15;
        	int lim=max(i-k,0ll);
        	for(j=lim;j<i;j++)
        	{
        		dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        	}
        }
        cout<<dp[n-1]<<"\n";

    }
    return 0;
}

/*
    ifstream cin("input.txt");
    ofstream cout("output.txt");

    string s;
    cin>>s;
*/

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:28:28: error: no matching function for call to 'max(int64_t, long long int)'
   28 |                 int lim=max(i-k,0ll);
      |                         ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:28:28: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
   28 |                 int lim=max(i-k,0ll);
      |                         ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:28:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   28 |                 int lim=max(i-k,0ll);
      |                         ~~~^~~~~~~~~
Language: C++

def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
n,k = MI()
h = LI()
h = h+ [float('INF')]*10000
dp = [float('INF')]*(10**5+1000)
dp[0] = 0
for i in range(n):
  for j in range(1,k+1):
    dp[i+j] = min(dp[i+j],dp[i] + abs(h[i+j] - h[i])) 
print(dp[n-1])

Compiler output:
a.cc:6:15: warning: multi-character character constant [-Wmultichar]
    6 | h = h+ [float('INF')]*10000
      |               ^~~~~
a.cc:7:13: warning: multi-character character constant [-Wmultichar]
    7 | dp = [float('INF')]*(10**5+1000)
      |             ^~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def I(): return int(input())
      | ^~~
Language: C++

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

int N, K;
int h[100005];
int dp[100005];

void solve() {
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < N; ++i) dp[i] = INT_MAX;
	for (int i = 2; i < N; ++i) {
		for (int j = 1; i - j >= 0 && j <= K; ++j) {
			dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
}

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
		cin >> h[i];
	solve();
	cout << dp[N - 1];
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:12:45: error: 'INT_MAX' was not declared in this scope
   12 |         for (int i = 2; i < N; ++i) dp[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 <vector>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include<iostream>
#include<string>
#include<limits>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include <algorithm>
#include<utility>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define vi  vector<int>
#define ll long long
#define pb push_back
#define ff first
#define ss second 
#define rep(n) for(int i=0; i<n ; i++)
#define input(n) for(int i=0; i<n ; i++){cin>>arr[i];}
#define output(n) for(int i=0; i<n ; i++){cout<<arr[i]<<" ";}
#define tc int t; cin>>t; while(t--)
using namespace std;
int32_t main()
{
	int n;
	cin>>n;
	int k ;
	cin>>k;
	int arr[n];
	input(n);
	vi dp(n,INT_MAX);
	dp[0]=0;

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

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

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

	return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:32:17: error: 'INT_MAX' was not declared in this scope
   32 |         vi dp(n,INT_MAX);
      |                 ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include<utility>
  +++ |+#include <climits>
   12 | #define pii pair<int,int>
Language: C++

#include<bits/stdc++.h>
#define w while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define ll long long
using namespace std;
int main()
 {  ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int n,k;
       cin>>n>>k;
        ll int a[n];
    ll   int dp[n+1];
       loop(i,0,n){
         ci a[i];
         dp[i]=0;
       }
       if(k>n){
         cout<<"0";
       }
       else {
      dp[n]=0;
      dp[0]=0;
      loop(i,1,k){
        dp[i]=abs(a[i]-a[0]);
      }
      loop(i,k,n){
            int mid=INT_MAX;
            loop(j,i-k,i)
                mid= min(mid,dp[j]+abs(a[i]-a[j]));
          dp[i]=mid;;
           }
      cout<<dp[n-1];
   }
 }


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

// youngjinp20
// 2020 03

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

typedef long long ll;

const int MAX = 1e5;
int N;
int h[MAX];

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

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

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

	return 0;
}


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

#include<math.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
 int dps(int x,int dp[],int vi[],int arr[],int k)
    {
        if(x<=0)
            return 0;
        if(vi[x]==1)
            return dp[x];
        vi[x]=1;
        long long int maxa=pow(10,8);
        for(int l=1;l<min(x+1,k+1);l++)
        {
            maxa=min((dps(x-l,dp,vi,arr,k)+abs(arr[x]-arr[x-l])),maxa);
        }
        dp[x]=maxa;
        return dp[x];
    }
int main(void)
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[n];
    int vi[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        dp[i]=0;
        vi[i]=0;
    }
   
    
    cout<<dps(2,dp,vi,arr,k);
    
}   

Compiler output:
a.cc: In function 'int dps(int, int*, int*, int*, int)':
a.cc:16:21: error: no matching function for call to 'min(int, long long int&)'
   16 |             maxa=min((dps(x-l,dp,vi,arr,k)+abs(arr[x]-arr[x-l])),maxa);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from /usr/include/c++/14/math.h:36,
                 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:16:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   16 |             maxa=min((dps(x-l,dp,vi,arr,k)+abs(arr[x]-arr[x-l])),maxa);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:16:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   16 |             maxa=min((dps(x-l,dp,vi,arr,k)+abs(arr[x]-arr[x-l])),maxa);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define Me3za() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL))
#define endl "\n"
int n,k;
int l;
int arr[100005];
long long mem[100005];
long long solve(int i,long long cur){
if(i>=n-1)return 0;
if(mem[i]!=-1)return mem[i];
mem[i]=LLONG_MAX;
for(int j=1;i+j<=min(i+k,n-1);j++){
   long long sol=solve(i+j,arr[i+j])+abs(cur-arr[i+j]);
   mem[i]=min(sol,mem[i]);
}
return mem[i];
}
int main() {
Me3za();
cin>>n>>k;
for(int i=0;i<n;i++){
    cin>>arr[i];
}
memset(mem,-1,sizeof mem);
cout<<solve(0,arr[0],0);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:12: error: too many arguments to function 'long long int solve(int, long long int)'
   26 | cout<<solve(0,arr[0],0);
      |       ~~~~~^~~~~~~~~~~~
a.cc:9:11: note: declared here
    9 | long long solve(int i,long long cur){
      |           ^~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    int heights[n];
    int costs[n];
    for(int i=0; i<n; ++i)
        cin>>heights[i];
    costs[0]=0;
    for(int i=1; i<n; ++i)
        costs[i]=INT_MAX;
    for(int i=1; i<n; ++i){
        for(int j=1; j<=k; ++j){
            if(i-j<0)
                break;
            costs[i]=min(costs[i], abs(heights[i]-heights[i-j])+costs[i-j]);
        }
    }
    cout<<costs[n-1]<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: 'INT_MAX' was not declared in this scope
   18 |         costs[i]=INT_MAX;
      |                  ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | #define endl "\n"
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#define endl "\n"
#define whats(x) cout<<#x<<" is: "<<x<<endl;
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, k;
    cin>>n>>k;
    int heights[n];
    int costs[n];
    for(int i=0; i<n; ++i)
        cin>>heights[i];
    costs[0]=0;
    for(int i=1; i<n; ++i)
        costs[i]=INT_MAX;
    cout<<costs[1]<<endl;
    for(int i=1; i<n; ++i){
        for(int j=1; j<=k; ++j){
            if(i-j<0)
                break;
            costs[i]=min(costs[i], abs(heights[i]-heights[i-j])+costs[i-j]);
        }
    }
    cout<<costs[n-1]<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:18: error: 'INT_MAX' was not declared in this scope
   18 |         costs[i]=INT_MAX;
      |                  ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 | #define endl "\n"