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

#include <bits/stdc++.h>
using namespace std;
int h[8100010];
int f[8110000];
int jd(int a)
{
	if(a>=0)
		return a;
	else 
		return -a;
}
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	f[1]=0;
	f[2]=jd(h[2]-h[1]);
	long m;
	for(int i=3;i<=n;i++)
	{
		m=99999999999;
		for(int j=1;j<=k;j++)
		{
			if(j<=i)
			m=min(m,f[i-j]+jd(h[i]-h[i-j]));
		}
		f[i]=m;
	}
	cout<<f[n];
	return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
long int h[8100010];
long int f[8110000];
long int jd(int a)
{
	if(a>=0)
		return a;
	else 
		return -a;
}
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>h[i];
	}
	f[1]=0;
	f[2]=jd(h[2]-h[1]);
	int m;
	for(int i=3;i<=n;i++)
	{
		m=999999;
		for(int j=1;j<=k;j++)
		{
			if(j<=i)
			m=min(m,f[i-j]+jd(h[i]-h[i-j]));
		}
		f[i]=m;
	}
	cout<<f[n];
	return 0;
}


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

#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include<bits/stdc++.h>
#include<deque> 
#include<bitset>
#include<string>
#define N 40
#define K 300005
#define MOD 1e9+7
#define int long long 
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

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

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

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

int MinCostPathVariation(int * arr,int n,int k)
{
	// Base Case
	if (n<=1)
	{
		return 0;
	}

	// Our Calculation
	int minCostPath=INT_MAX;
    int onePossibleAns;
	for (int pos=1;pos<=k;pos++)
	{
      onePossibleAns=(abs(arr[0]-arr[pos]) + MinCostPathVariation(arr+pos,n-pos,k));
      if (onePossibleAns < minCostPath)
      {
      	minCostPath=onePossibleAns;
      }
	}

	return minCostPath;
}

int main()
{
	int n,k;
	cin>>n>>k;
	int * arr=new int [n];
	for (int i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	cout<<MinCostPathVariation(arr,n,k);
}

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

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


int MinCostPathVariation(int * arr,int n,int k)
{
	// Base Case
	if (n<=1)
	{
		return 0;
	}

	// Our Calculation
	int minCostPath=INT_MAX;
    int onePossibleAns;
	for (int pos=1;pos<=k;pos++)
	{
      onePossibleAns=(abs(arr[0]-arr[pos]) + MinCostPathVariation(arr+pos,n-pos,k));
      if (onePossibleAns < minCostPath)
      {
      	minCostPath=onePossibleAns;
      }
	}

	return minCostPath;
}
int main()
{
	int n,k;
	cin>>n>>k;
	int * arr=new int [n];
	for (int i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	cout<<MinCostPathVariation(arr,n,k);
}

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

# include <iostream>
using namespace std;


int MinCostPathVariation(int * arr,int n,int k)
{
	// Base Case
	if (n<=1)
	{
		return 0;
	}

	// Our Calculation
	int minCostPath=INT_MAX;
    int onePossibleAns;
	for (int pos=1;pos<=k;pos++)
	{
      onePossibleAns=(abs(arr[0]-arr[pos]) + MinCostPathVariation(arr+pos,n-pos,k));
      if (onePossibleAns < minCostPath)
      {
      	minCostPath=onePossibleAns;
      }
	}

	return minCostPath;
}


int main()
{
	int n,k;
	cin>>n>>k;
	int * arr=new int [n];
	for (int i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	cout<<MinCostPathVariation(arr,n,k);
}


Compiler output:
a.cc: In function 'int MinCostPathVariation(int*, int, int)':
a.cc:14:25: error: 'INT_MAX' was not declared in this scope
   14 |         int minCostPath=INT_MAX;
      |                         ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | # include <iostream>
  +++ |+#include <climits>
    2 | using namespace std;
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

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

    // 初期条件
    dp[0] = 0;
    
    // ループ
    rep(i,N) {
        rep2(j,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:17:40: error: 'h' was not declared in this scope
   17 |     for (int i = 0; i < N; ++i) cin >> h[i];
      |                                        ^
a.cc:20:38: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |     for (int i = 0; i < 110000; ++i) dp[i] = INF;
      |                                      ^~
      |                                      dup
a.cc:23:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   23 |     dp[0] = 0;
      |     ^~
      |     dup
a.cc:27:50: error: 'h' was not declared in this scope
   27 |         rep2(j,K+1) chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
      |                                                  ^
Language: C++

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll dp[100001]={1e9};
ll ans=1e9;

ll fn(vi v,ll k){
	mset(dp,1000000);
dp[0]=0;	dp[1]=abs(v[1]-v[0]);
	rep(j,1,v.size())
	{
	rep(i,1,k+1){
	if(j>=i)
	{//cout<<dp[j]<<" "<<dp[j-i]<<" "<<dp[j-i]+abs(v[j]-v[j-i])<<" ";
	dp[j]=min(dp[j],dp[j-i]+abs(v[j]-v[j-i]));
	
	}else break;}}return dp[v.size()-1];
} 
int main(){
	ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        ll a,b;
        cin>>a>>b;
        vi v;
        int k;
        rep(i,0,a)
        {
        	cin>>k;
        	v.pb(k);
		}
		
		
		cout<<fn(v,b)<<endl;
return 0;}


Compiler output:
a.cc:23:16: error: narrowing conversion of '1.0e+9' from 'double' to 'long long int' [-Wnarrowing]
   23 | ll dp[100001]={1e9};
      |                ^~~
Language: C++

#include<bits/stdc++.h>
#include<cstdlib>
 
using namespace std;
 
int min(int a,int b){
  return a<b?a:b;
}
int main(){
	int n,p;
  	cin>>n>>p;
  	int wt[n];
  	for(int i=0;i<n;i++){
    	cin>>wt[i];
    }
  if(p>n) {cout<<0;}
  else{
  	int mn[n];
    for(int i=0;i<n;i++){
    	if(i==0) mn[i]=0;
      	else
          mn[i]=abs(wt[i]-wt[i-1]);
    }
    if(p<2){cout<<mn[n-1]; return 0;}
    for(int i=2;i<=p;i++){
      for(int j=0;j<n;j++){
      	if(j>=i){
        	mn[j]=min(mn[j],min(wt[j-i]+wt[j]);
        }
      }
    }
  	cout<<mn[n-1];
  }
  	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:36: error: no matching function for call to 'min(int)'
   28 |                 mn[j]=min(mn[j],min(wt[j-i]+wt[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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
a.cc:28:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |                 mn[j]=min(mn[j],min(wt[j-i]+wt[j]);
      |                                 ~~~^~~~~~~~~~~~~~~
/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:   candidate expects 2 arguments, 1 provided
a.cc:6:5: note: candidate: 'int min(int, int)'
    6 | int min(int a,int b){
      |     ^~~
a.cc:6:5: note:   candidate expects 2 arguments, 1 provided
Language: C++

#include<iostream>
#include<climits>
#include<cstdlib>
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[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
   int start;
  for(int i=2;i<n;i++)
  {
      m=INT_MAX;
		if(i<k)
         start=0;
    	else 
      	start=i-k;         
          for(int j=start;j<i;j++)
            if(dp[j]+abs(h[j]-h[i])<m)
              m=dp[j]+abs(h[j]-h[i]);
    
   dp[i]=m;
  }
     
   
         
  cout<<dp[n-1];
         
  return 0;
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:21:7: error: 'm' was not declared in this scope
   21 |       m=INT_MAX;
      |       ^
Language: C++

#include<iostream>
#include<climits>
#include<cstdlib>
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[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  
  for(int i=2;i<n;i++)
  {
      m=INT_MAX;
		if(i<k)
        {          
          for(int j=0;j<i;j++)
            if((dp[j]+abs(h[j]-h[i]))<m)
              m=dp[j]+abs(h[j]-h[i]);
         }
     
    else{
     
          for(int j=i-k;j<i;j++)
            if((dp[j]+abs(h[j]-h[i]))<m)
              m=dp[j]+abs(h[j]-h[i]);
         
    }
     dp[i]=m;
  }
  
         
  cout<<dp[n-1];
         
  return 0;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:21:7: error: 'm' was not declared in this scope
   21 |       m=INT_MAX;
      |       ^
Language: C++

#include<iostream>
#include<climits>
#include<cstdlib>
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[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  int m=INT_MAX;
  
  for(int i=1;i<k;i++)
  {
   for(int j=0;j<i;j++)
   {
	if((dp[j]+abs(h[i]-h[j]))<m)
      m=(dp[j]+abs(h[i]-h[j]);
    }
    dp[i]=m;
    }
   
  m=INT_MAX;
           
  for(int i=k;i<n;i++)
  {
   for(int j=i-k;j<i;j++)
   {
	if((dp[j]+abs(h[i]-h[j]))<m)
      m=(dp[j]+abs(h[i]-h[j]);
    }
    dp[i]=m;
    }
         
  cout<<dp[n-1];
         
  return 0;
  }
         


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

#include<iostream>
#include<climits>
#include<cstdlib>
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[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  
  int m=0;
  for(int i=2;i<n;i++)
  {
   m=INT_MAX;
   for(int j=i-k;j<i;j++)
   {
	if((dp[j]+abs(h[i]-h[j]))<m)
      m=(dp[j]+abs(h[i]-h[j]);
    }
    dp[i]=m;
    }
         
  cout<<dp[n-1];
         
  return 0;
  }
         

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

//
//  B.cpp
//  CodeForcesProblems
//
//  Created by Jacob Murry on 1/6/20.
//  Copyright © 2020 Jacob Murry. All rights reserved.
//

//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

class Solution {
    
};

int main(int argc, char * argv[]) {
    int N = 0, K=0;
    cin >> N >> K;
    vector<int> dp(N, 0);
    vector<int> stones(N, 0);
    cin>>stones[0];
    for(int i=1; i<N; ++i) {
        int h;
        cin>>h;
        stones[i] = h;
        //dp[n] = min(dp[i-1]+abs(stones[i-1]-h), dp[i-2]+abs(stones[i-2]-h),...,dp[i-k]+abs(stones[i-k]-h))
        //base case is i==0 or i==1
        int min_cost = INT_MAX;
        for(int k=1; k<=K; k++) {
            if(i-k>=0) {
                min_cost = min(min_cost, dp[i-k]+abs(stones[i-k]-h));
            } else {
                break;
            }
        }
        dp[i] = min_cost;
        
    }
    cout << dp.back() << "\n";
    return 0;
}



Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:32:24: error: 'INT_MAX' was not declared in this scope
   32 |         int min_cost = INT_MAX;
      |                        ^~~~~~~
a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <queue>
  +++ |+#include <climits>
   12 | #include <vector>
Language: C++

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

unsigned long int amin_cost(vector<int> cost, int k)
{
  int n = cost.size();
  int i,j;
  //cout << n << endl;
  
  vector<unsigned long int> min_cost_table(n);
  min_cost_table[0] = 0;
  min_cost_table[1] = abs(cost[1] - cost[0]);
  
  for(i=2; i<n; i++)
  {
	unsigned long int min_cost = min_cost_table[i-1] + abs(cost[i] - cost[i-1]);  
    for(j=2; j<n && j<=k; j++)
    	min_cost = min(min_cost, min_cost_table[i-j] + abs(cost[i] - cost[i-j]) ); 
      
    min_cost_table[i] = min_cost;
    
    //cout << i << " " << min_cost_table[i] << endl;
  }
  
  return min_cost_table[n-1];
}

int main()
{
  int i,k,n;
  cin >> n >> k;
  
  vector<int> cost(n);
  for(i=0; i<n; i++)
  	cin  >> cost[i];
  
  cout << min_cost(cost,k) << endl; 
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:11: error: 'min_cost' was not declared in this scope; did you mean 'amin_cost'?
   37 |   cout << min_cost(cost,k) << endl;
      |           ^~~~~~~~
      |           amin_cost
Language: C++

#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>

using namespace std;
typedef long long ll;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, K;
  cin >> n >> K;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

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

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

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

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] nums = new int[n];
    int[] dp = new int[n];
    for (int i = 0; i < n; i++) {
      nums[i] = sc.nextInt();
    }
    sc.close();
    Arrays.fill(dp, Integer.MAX_VALUE);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
      int min = Integer.MAX_VALUE;
      for (int j = 1; j <= k && i + j < n; j++) {
        int temp = dp[i] + Math.abs(nums[i] - nums[i + j]);
        min = Math.min(min, temp);
      }
      dp[i + j] = min;
    }
    System.out.println(dp[n - 1]);
  }
}

Compiler output:
Main.java:22: error: cannot find symbol
      dp[i + j] = min;
             ^
  symbol:   variable j
  location: class Main
1 error
Language: C++

#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define ll long long
using namespace std;
typedef pair<int, string> pii;

ll n, k, vet[100005], dp[100005];

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> vet[i];
    for(int i = 2; i <= n; i++) {
        ll jump = 2;
        dp[i] = dp[i-1] + abs(vet[i-1]-vet[i]);
        while(jump <= k && jump <= i)
            dp[i] = min(dp[i], dp[i-jump]+abs(vet[i]-vet[i-jump++]));
    }
    cout << dp[n] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:20:27: error: expected '}' at end of input
   20 |     cout << dp[n] << endl;
      |                           ^
a.cc:10:12: note: to match this '{'
   10 | int main() {
      |            ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;
const long NMAX = 1000000;
int dp[100000];

int main(){
  long n, k;
  cin >> n >> k;
  
  vector<int> h(NMAX);
  for(long i=1; i<=NMAX; i++){
    cin >> h.at(i);
  }
  
  dp[1] = 0;
  long st;
  
  for(long i=2; i<=n; i++){
    dp[i] = 9999999;
    st = max(1, i-k);
    
    for(long j=st; j<i; j++){
      dp[i] = min(dp[i], dp[j] + abs(h.at(j)-h.at(i)));
    }
//    cout << dp[i] << endl;
  }

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


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

#include<iostream>
#include<vector>
using namespace std;
const int NMAX = 100000;
int dp[100000];

int main(){
  long n, k;
  cin >> n >> k;
  
  vector<int> h(NMAX);
  for(int i=1; i<NMAX; i++){
    cin >> h.at(i);
  }
  
  dp[1] = 0;
  long st;
  
  for(int i=2; i<=n; i++){
    dp[i] = 9999999;
    st = max(1, i-k);
    
    for(int j=st; j<i; j++){
      dp[i] = min(dp[i], dp[j] + abs(h.at(j)-h.at(i)));
    }
//    cout << dp[i] << endl;
  }

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


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

#include<iostream>
#include<vector>
using namespace std;
const int NMAX = 100000;
int dp[100000];

int main(){
  long n, k;
  cin >> n >> k;
  
  vector<int> h(NMAX);
  for(int i=1; i<NMAX; i++){
    cin >> h.at(i);
  }
  
  dp[1] = 0;
  int st;
  
  for(int i=2; i<=n; i++){
    dp[i] = 9999999;
    st = max(1, i-k);
    
    for(int j=st; j<i; j++){
      dp[i] = min(dp[i], dp[j] + abs(h.at(j)-h.at(i)));
    }
//    cout << dp[i] << endl;
  }

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


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

#include <bits/stdc++.h>

using namespace std;

const int MAX = 1e5+10;

int stones[MAX], dp[MAX];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    for(int i=1; i<=n; i++) cin >> stones[i];

    for(int i=2; i<=n; i++) dp[i] = MAX;

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

    cout << dp[n] << "\n";

    return 0;
}

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

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

template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i=0; i<(int)(n); ++i)

template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}
const long long INF = 1LL << 60;

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

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

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

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

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

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

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

Compiler output:
a.cc:17:31: error: redefinition of 'template<class T> bool chmin(T&, T)'
   17 | template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
      |                               ^~~~~
a.cc:8:31: note: 'template<class T> bool chmin(T&, T)' previously declared here
    8 | template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
      |                               ^~~~~
a.cc:18:31: error: redefinition of 'template<class T> bool chmax(T&, T)'
   18 | template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}
      |                               ^~~~~
a.cc:9:31: note: 'template<class T> bool chmax(T&, T)' previously declared here
    9 | template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}
      |                               ^~~~~
Language: C++

public class Main {
		public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		sc.nextLine();
		int[] heights = new int[n];
		for(int i = 0; i < n; i++) {
			heights[i] = sc.nextInt();
		}
		
		int[] dp = new int[n]; //min number of cost before reaching i
		for (int i = 0; i < dp.length; i++) {
			dp[i] = Integer.MAX_VALUE;
		}
		dp[0] = 0;
		for (int i = 0; i < n; i++) {
			for(int j = i+1; j <= i+k; j++) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(heights[i] - heights[j]));
				}
			}
			
		}
		System.out.println(dp[n-1]);
	}
	 
}


Compiler output:
a.cc:1:1: error: expected unqualified-id before 'public'
    1 | public class Main {
      | ^~~~~~
Language: C++

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

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

const int INF = INT_MAX;

int main() {
	fastio;
	int n, k ; cin >> n >> k;
	vector < ll > v(n), dp(n, 0);
	
	k = min(k, n);
	
	for(int i = 0; i < n; ++i) cin >> v[i];

	for(int i = 1; i <= k; ++i) {
		dp[i] = abs(v[i] - v[0]);
	}

	for(int i = k + 1; i < n; ++i) {
		int mini = INF;
		for(int j = i - 1; j >= i - k; --j) {
			mini = min(mini, dp[j] + abs(v[j] - v[i]));
		}
		dp[i] = mini;
	}

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

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

#include <iostream>
#include <limits.h>
using namespace std;

int diff(int a, int b)
{
  return (a-b>0)?a-b:b-a;
}

int min(int a, int b)
{
  return (a<b)?a:b;
}

int main()
{
  int n,k;
  cin >> n;
  cin >> k;
  int ht[100001];
  for (int i =0 ; i < n; i++) {
       cin >> ht[i];
       min_cost[i] = 0;
}
  //for (int i =0 ; i < n; i++) 
    //cout << ht[i] << "--";
  
  if (n ==1 ){ cout << "0\n"; return 0;}
  int min_cost[100001];
  min_cost[0] = 0;
  min_cost[1] = diff(ht[1],ht[0]);
  if (n == 2) {cout << min_cost[1]; return 0;}
  else
     for (int i=2 ;i < n; i++) {
       min_cost[i] = INT_MAX;
        for (int j = 1; j<=k; j++){
           min_cost[i] = min(min_cost[i-k] + diff(ht[i],ht[i-k]),
                                 min_cost[i]);
        }
     }
  cout << min_cost[n-1];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:8: error: 'min_cost' was not declared in this scope
   23 |        min_cost[i] = 0;
      |        ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define infl LONG_MAX
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
     int n,k;
     cin>>n>>k;
     int h[n],dp[n]={infl};
     for(int i=0;i<n;i++)
     {
     	cin>>h[i];
     	dp[i]=infl;
	 }
     dp[0]=0;

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



Compiler output:
a.cc: In function 'int main()':
a.cc:2:14: error: narrowing conversion of '9223372036854775807' from 'long int' to 'int' [-Wnarrowing]
    2 | #define infl LONG_MAX
      |              ^~~~~~~~
a.cc:12:22: note: in expansion of macro 'infl'
   12 |      int h[n],dp[n]={infl};
      |                      ^~~~
a.cc:16:15: warning: overflow in conversion from 'long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow]
   16 |         dp[i]=infl;
      |               ^~~~
Language: C++

#include<bits/stdc++.h>
#define infl LONG_MAX
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
     int n,k;
     cin>>n>>k;
     int h[n],dp[n]={infl};
     for(int i=0;i<n;i++)
     {
     	cin>>h[i];
     	dp[i]=infl;
	 }
     dp[0]=0;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:2:14: error: narrowing conversion of '9223372036854775807' from 'long int' to 'int' [-Wnarrowing]
    2 | #define infl LONG_MAX
      |              ^~~~~~~~
a.cc:12:22: note: in expansion of macro 'infl'
   12 |      int h[n],dp[n]={infl};
      |                      ^~~~
a.cc:16:15: warning: overflow in conversion from 'long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow]
   16 |         dp[i]=infl;
      |               ^~~~
Language: C++

/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
const int INF=1e9+5;
int main()
{
	fast();
	int n;
	scanf("%d",&n);
	vector<int> h(n);
	for(int &x : h)
		scanf("%d",&x);
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k;j++)
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
	}
	printf("%d",dp[n-1]);
}

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

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n,k;
	cin >> n >>k;
	int arr[n],dp[n+1]={0};
	
	for (int i=0;i<n;++i)
	cin >> arr[i];
	
	dp[0]=0;
	dp[1]= abs(arr[1]-arr[0]);
	
	for (int i=2;i<n;++i)
	{
	   dp[i]=2e9;
	  for (int j=1;j<min(i,k);++j)
	  {
		dp[i] = min(dp[i-j]+abs(ar[i]-ar[i-j]), dp[i]);
	  }
	}
	cout<<dp[n]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:41: error: 'ar' was not declared in this scope; did you mean 'arr'?
   21 |                 dp[i] = min(dp[i-j]+abs(ar[i]-ar[i-j]), dp[i]);
      |                                         ^~
      |                                         arr
Language: C++

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int arr[n],dp[n+1]={0};
	
	for (int i=0;i<n;++i)
	cin >> arr[i];
	
	dp[0]=0;
	dp[1]= abs(arr[1]-arr[0]);
	
	for (int i=2;i<n;++i)
	{
	   dp[i]=2e9;
	  for (int j=1;j<min(i,k);++j)
	  {
		dp[i] = min(dp[i-j]+abs(ar[i]-ar[i-j]), dp[i]);
	  }
	}
	cout<<dp[n]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:32: error: 'k' was not declared in this scope
   19 |           for (int j=1;j<min(i,k);++j)
      |                                ^
a.cc:21:41: error: 'ar' was not declared in this scope; did you mean 'arr'?
   21 |                 dp[i] = min(dp[i-j]+abs(ar[i]-ar[i-j]), dp[i]);
      |                                         ^~
      |                                         arr
Language: C++

#include <iostream>
#include <math>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int arr[n],dp[n+1]={0};
	
	for (int i=0;i<n;++i)
	cin >> arr[i];
	
	dp[0]=0;
	dp[1]= abs(arr[1]-arr[0]);
	
	for (int i=2;i<n;++i)
	{
	   dp[i]=2e9;
	  for (int j=1;j<min(i,k);++j)
	  {
		dp[i] = min(dp[i-j]+abs(ar[i]-ar[i-j]), dp[i]);
	  }
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

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


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

 #include <bits/stdc++.h>
#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;
    cin>>n;
    int k;
    cin>>k;
    int arr[n];
    {
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
    }
    int ans;
    ans=findmin(n,k,arr);
    cout<<ans;
    return 0;

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

#include <iostream>
#include <cstdlib>
#include <vector>
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:22:13: error: 'min_element' was not declared in this scope
   22 |     return *min_element(a.begin(),a.end());
      |             ^~~~~~~~~~~
Language: C++

#include <iostream>
#include <cstdlib>
#include <vector>
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:22:13: error: 'min_element' was not declared in this scope
   22 |     return *min_element(a.begin(),a.end());
      |             ^~~~~~~~~~~
a.cc: In function 'int FindMin(int, int, int*)':
a.cc:33:16: error: 'minimum' was not declared in this scope; did you mean 'Minimum'?
   33 |         min[i]=minimum(min,k,n,arr,i);
      |                ^~~~~~~
      |                Minimum
a.cc: In function 'int main()':
a.cc:48:9: error: 'findmin' was not declared in this scope; did you mean 'FindMin'?
   48 |     ans=findmin(n,k,arr);
      |         ^~~~~~~
      |         FindMin