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

/*
    It’s Always Darkest Before the Dawn
                This Time is that Darkness in you Life
                                                            */
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define pb push_back  
#define F first
#define S second
#define pii pair<int,int>
#define all(a) a.begin(),a.end()
 
const ll mod=1e9+7,di=998244353,N=3e5+1;
 
bool IsQuery=false; 
ll q=1,a[N];
 
map<int,vector<int>> edge;
map<int,bool> occ;
 
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
void solve(){
 	
  	ll n,k;
  	cin>>n>>k;
  
  	for(int i=0;i<n;i++)
      cin>>a[i];
  	
    ll dp[n];
  	
  	memset(dp,-1,sizeof(dp));
  	
  	dp[0]=0;
  
  	for(int i=0;i<n;i++){
      
    	for(int j=1;j<=k && i+j<n;j++){
          
          if(dp[i+j]==-1)
            dp[i+j]=dp[i]+abs(a[j]-a[i]);
          
          dp[i+j]=min(dp[i+j],dp[i]+abs(a[j]-a[i]);
        }
    }
                    
     	cout<<dp[n-1];
    return;   
} 
int main(){
    
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    if(IsQuery)
    cin>>q;
 
    for(int i=0;i<q;i++){
        solve();
        cout<<"\n";
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:48:51: error: expected ')' before ';' token
   48 |           dp[i+j]=min(dp[i+j],dp[i]+abs(a[j]-a[i]);
      |                      ~                            ^
      |                                                   )
Language: C++

#include <iostream>
#include <vector>

using namespace std;

const int INF = 1e7;
int n,k;
vector<long long> h, dp;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	h = vector<long long>(n );
	dp = vector<long long>(n, INF);
	for(auto &it : h) cin >> it;
	DP[0] = 0;
	for(long long i=1 ; i<n ; i++){
		for(long long j = 1 ; j <= k ; j++){
			if( i - j >= 0){
				dp[i] = min(dp[i],dp[i - j] + abs(h[i] - h[i - j]));
			}
		}
	}
	cout << dp[n - 1] <<"\n";
	

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'DP' was not declared in this scope; did you mean 'dp'?
   16 |         DP[0] = 0;
      |         ^~
      |         dp
Language: C++

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

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



#include <bits/stdc++.h>

using namespace std;


#define ll              long long
#define pb              push_back
#define nn           cout << "\n";



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t,a,b,i,j,c,d,e,f,n,k,m,w;

    memset(dp,0,sizeof(dp));
      
    cin>>n>>k;
    
      int dp[n+5],ht[n+5];
    for(i=1;i<=n;i++)
    {
        cin>>a;
        ht[i]=a;

    }

    dp[n]=0;
    for(i=n-1;i>=1;i--)
    {
        dp[i]=INT32_MAX;
        for(j=1;j<=k&&(i+j)<=n;j++)
        {


        dp[i]=min(dp[i],(dp[i+j]+abs(ht[i]-ht[i+j])));
        }
    }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:21:12: error: 'dp' was not declared in this scope; did you mean 'd'?
   21 |     memset(dp,0,sizeof(dp));
      |            ^~
      |            d
Language: C++

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

const int N = 1e5 + 3;
const int INF = 1e9 + 5;
vector<int> dp(N, INF);

ll frog_2(int n, int k, ll ht[])
{
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<=i+k; j++)
            dp[j] = min(dp[j], (dp[i] + abs(ht[j] - ht[i])));
    }

    return dp[n-1];
}

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

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

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

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

const int N = 1e5 + 3;
const int INF = 1e9 + 5;
vector<int> dp(N, INF);

ll frog_2(int n, int k, ll ht[])
{
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<=i+k; j++)
            dp[j] = min(dp[j], dp[i] + abs(ht[j] - ht[i]));
    }

    return dp[n-1];
}

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

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

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

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

const int N = 1e5 + 3;
const int INF = 1e9 + 5;
vector<int> dp(N, INF);

ll frog_2(int n, int k, ll ht[])
{
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<=i+k; j++)
            dp[j] = min(dp[j], dp[i] + abs(ht[j] - ht[i]));
    }

    return dp[n];
}

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

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

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

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

const int N = 1e5 + 3;
const int INF = 1e9 + 5
vector<int> dp(N, INF);

ll frog_2(int n, int k, ll ht[])
{
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<=i+k; j++)
            dp[j] = min(dp[j], dp[i] + abs(ht[j] - ht[i]));
    }

    return dp[n];
}

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

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

Compiler output:
a.cc:7:1: error: expected ',' or ';' before 'vector'
    7 | vector<int> dp(N, INF);
      | ^~~~~~
a.cc: In function 'long long int frog_2(int, int, long long int*)':
a.cc:11:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   11 |     dp[0] = 0;
      |     ^~
      |     dup
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long int N,K;
    cin >> N >> K;
    vector<int>dp(N,2e9);
    vector<int>h(N);
    for(long long int i=0;i<N;i++){
        cin >> h.at(i);
    }
    dp.at(0)=0;
    for(long long int i=1;i<N;i++){
        for(long long int m=1;m<=K;m++){
            if(i-m >=0){
                dp.at(i) = min(dp.at(i),dp.at(i-m)+abs(h.at(i-m)-h.at(i)));
            }
        }
    }
    cout << dp.at(N-1) << endl;
 

Compiler output:
a.cc: In function 'int main()':
a.cc:20:32: error: expected '}' at end of input
   20 |     cout << dp.at(N-1) << endl;
      |                                ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
 
int main(){
    long long int N,K;
    cin >> N >> K;
    vector<int>dp(N,2e9);
    vector<int>h(N);
    for(long long int i=0;i<N;i++){
        cin >> h.at(i);
    }
    dp.at(0)=0;
    for(long long int i=1;i<N;i++){
        for(long long int m=1;m<=K;m++){
            if(i-m >=0){
                dp.at(i) = min(dp.at(i-1),dp.at(i-m)+abs(h.at(i-m)-h.at(i)));
            }
        }
    }
    cout << dp.at(N-1) << endl;
 

Compiler output:
a.cc: In function 'int main()':
a.cc:20:32: error: expected '}' at end of input
   20 |     cout << dp.at(N-1) << endl;
      |                                ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++


#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<cassert>
#include<algorithm>
using namespace std;
typedef long long  ll;
typedef long double ld;
//typedef vector<int>        vi;
//typedef vector<ll>        vl;
//#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
//#define pb    push_back;
//#define fo(i,n) for(int i=0;i<n;i++)
int dp[100005];
int arr[100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=INT_MAX;
    }
    for(int i=3;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(j<i)
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i-j]-arr[i]));
        }
    }
    cout<<dp[n]<<endl;
   
    return 0;
}
 


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

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

int main(){
    long long int N,K;
    cin >> N >> K;
    int MAX = pow(10,9);
    vector<int>dp(MAX);
    vector<int>h(N);
    for(long long int i=0;i<N;i++){
        cin >> h.at(i);
    }
    dp.at(0)=0;
    for(long long int i=1;i<N;i++){
        for(long long int m=1;m<=K;m++){
            if(i-m >=0){
                dp.at(i) = min(dp.at(i-1)+abs(h.at(i-1)-h.at(i)),dp.at(i-m)+abs(h.at(i-m)-h.at(i)));
            }
        }
    }
    cout << dp.at(N-1) << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:21:32: error: expected '}' at end of input
   21 |     cout << dp.at(N-1) << endl;
      |                                ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
    long long int N,K;
    cin >> N >> K;
    vector<int>dp(N);
    vector<long long int>h(N);
    for(long long int i=0;i<N;i++){
        cin >> h.at(i);
    }
    dp.at(0)=0;
    for(long long int i=1;i<N;i++){
        for(long long int m=1;m<=K;m++){
            if(i-m >=0){
                dp.at(i) = min(dp.at(i-1)+abs(h.at(i-1)-h.at(i)),dp.at(i-m)+abs(h.at(i-m)-h.at(i)));
            }else{
                dp.at(i) = dp.at(i-1) + abs(h.at(i-1)-h.at(i));
            }
        }
    }
    cout << dp.at(N-1) << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:22:32: error: expected '}' at end of input
   22 |     cout << dp.at(N-1) << endl;
      |                                ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^
Language: C++

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

int main(){
    int N,K;
    cin >> N >> K;
    vector<int>dp(N);
    vector<int>h(N);
    for(int i=0;i<N;i++){
        cin >> h.at(i);
    }
    dp.at(0)=0;
    for(int i=0,i<N;i++){
        for(int m=1;m<=K;m++){
            if(i-m >=0){
                dp.at(i) = min(dp.at(i-1)+abs(h.at(i-1)-h.at(i)),dp.at(i-m)+abs(h.at(i-m)-h.at(i)));
            }
        }
    }
    cout << dp.at(N) << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:18: error: expected ';' before '<' token
   13 |     for(int i=0,i<N;i++){
      |                  ^
      |                  ;
a.cc:13:18: error: expected primary-expression before '<' token
Language: C++

#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}




using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> vec(n),dp(n);

    REP(i,n){
        cin >> vec[i];
    }

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

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





Compiler output:
a.cc: In function 'int main()':
a.cc:76:24: error: expected ';' before 'dp'
   76 |             if((i-j>=1)dp[i] = min(dp[i], (dp[i-j] + abs(vec[i] - vec[i-j])));
      |                        ^~
      |                        ;
a.cc:77:9: error: expected primary-expression before '}' token
   77 |         }
      |         ^
a.cc:76:79: error: expected ')' before '}' token
   76 |             if((i-j>=1)dp[i] = min(dp[i], (dp[i-j] + abs(vec[i] - vec[i-j])));
      |               ~                                                               ^
      |                                                                               )
   77 |         }
      |         ~                                                                      
a.cc:77:9: error: expected primary-expression before '}' token
   77 |         }
      |         ^
Language: C++

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>

#define FASTREAD      ios_base::sync_with_stdio(0);cin.tie(nullptr);
#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,a,b)    for(ll i=a;i<=b;i++)
#define FORr(i,a,b)   for(ll i=a;i>=b;i--)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second

using namespace std;

int main()
{
    ll n,h[100005],dp[100110],k;
    scl(n);
    scl(k);
    FOR(i,1,n)
    {
        scl(h[i]);
    }
    FOR(i,1,n+k+2)
    {
        if(i!=n)
        dp[i]=LONG_MAX;
    }
    dp[n]=0;
    FORr(i,n-1,1)
    {
        FOR(j,1,k)
        {
           dp[i]=min(dp[i],dp[i+j]+abs(h[i]-h[i+j]));
        }
      //  cout<<i<<" "<<dp[i]<<endl;
    }
    ptl(dp[1]);
    nline;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:45:15: error: 'LONG_MAX' was not declared in this scope
   45 |         dp[i]=LONG_MAX;
      |               ^~~~~~~~
a.cc:10:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include<math.h>
  +++ |+#include <climits>
   10 |
Language: C++

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

int min_cost(int k,int n,int* arr){
    int dp[n+1];
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++){
        int j=1;
        dp[i]=100000;
        while(j<=k){
            if(i-j<=0){
                break;
            }
            int x=0;
            if(arr[i-1]>=arr[i-1-j]){
                x= dp[i-j] +(arr[i-1]-arr[i-1-j]);}
            else{
                x= dp[i-j] +(arr[i-1-j]-arr[i-1]);
           }
           dp[i]=min(dp[i],x);
           j++;
        }
    }
    return dp[n];

}

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


Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: 'K' was not declared in this scope
   31 |     cin>>n>>K
      |             ^
a.cc:34:13: error: 'arr' was not declared in this scope
   34 |      cin >> arr[i];
      |             ^~~
a.cc:36:24: error: 'arr' was not declared in this scope
   36 |     cout<<min_cost(k,n,arr);
      |                        ^~~
Language: C++

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

using namespace std;

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

using namespace std;

//State
//dp[i] The minimum cost to reach the i-th step from 1st step

//Initialization
//dp[1] = 0, dp[2] = abs(h[1] - h[0])

//Transitions
//dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),	dp[i-2]+abs(h[i]-h[i-2]))

//Order of evaluation
// i = 1...N

//Answer
//return dp[N]

//Time Complexity = O(N*K) but this can also be solved in O(N) using prefix sums

const int inf = 1e9 + 5;

int main(){
	int N, K;
	cin >> N >> K;
	int h[N];
	int dp[N+1]; int h[N+1];
	for(int i=1; i<=N; i++){
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	dp[1] = 0;
	for(int i=2; i<=N; i++){
		for(int j=i-K; j<= i-1; j++){
			if(j>=1){
				dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]));
			}
		}
	}
	cout << dp[N] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:26: error: conflicting declaration 'int h [(N + 1)]'
   34 |         int dp[N+1]; int h[N+1];
      |                          ^
a.cc:33:13: note: previous declaration as 'int h [N]'
   33 |         int h[N];
      |             ^
Language: C++

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

using namespace std;

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

using namespace std;

//State
//dp[i] The minimum cost to reach the i-th step from 1st step

//Initialization
//dp[1] = 0, dp[2] = abs(h[1] - h[0])

//Transitions
//dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),	dp[i-2]+abs(h[i]-h[i-2]))

//Order of evaluation
// i = 1...N

//Answer
//return dp[N]

//Time Complexity = O(N*K) but this can also be solved in O(N) using prefix sums

const int inf = 1e9 + 5;

int main(){
	int N, K;
	cin >> N >> K;
	int h[N];
	int dp[N]; int h[N];
	for(int i=1; i<=N; i++){
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	dp[1] = 0;
	for(int i=2; i<=N; i++){
		for(int j=i-K; j<= i-1; j++){
			if(j>=1){
				dp[i] = min(dp[i], dp[j]+abs(h[j]-h[i]));
			}
		}
	}
	cout << dp[N] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:24: error: redeclaration of 'int h [N]'
   34 |         int dp[N]; int h[N];
      |                        ^
a.cc:33:13: note: 'int h [N]' previously declared here
   33 |         int h[N];
      |             ^
Language: C++

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

using namespace std;

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

using namespace std;

//State
//dp[i] The minimum cost to reach the i-th step from 1st step

//Initialization
//dp[1] = 0, dp[2] = abs(h[1] - h[0])

//Transitions
//dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),	dp[i-2]+abs(h[i]-h[i-2]))

//Order of evaluation
// i = 1...N

//Answer
//return dp[N]

//Time Complexity = O(N*K) but this can also be solved in O(N) using prefix sums

int dp[100005]; //Max value of N is 10^5
int h[100005]; //Max value of h is 10^5
const int inf = 1e9 + 5;

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

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

#include <iostream>
#include <vector>

using namespace std;

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

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

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

#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long 
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod 1000000009
using namespace std;
bool isprime(ll n)
{
    //if(n<2)
    //return false;
    if(n==1)
    return true;
    if(n==2 || n==3)
    return true;
    if(n%2==0)return false;
    for(ll i=3;i*i<=n;i+=2)
    {
        if(n%i==0)
        return false;
        
    }
    return true;
}
int gcd(ll a,ll b)
{
    if(a==0)
    return b;
    return gcd(b%a,a);
}
int lcm(ll a,ll b)
{
    return a*(b/gcd(a,b));
}
 set<ll> fac;
void allFactors(ll n)
{
   // set<ll> fac;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            fac.insert(i);
            if(i!=n/i)
            {
                fac.insert(n/i);
               
            }
        }
    }
    //return fac.size();
}
bool threefactors(ll n)//when you have need of a no which is divisible by 1,itself,any other one no.
{
    ll p=sqrt(n);
    if(p*p==n)
    {
        if(isprime(p))
        return 1;
        else
        return 0;
    }
    else
    return 0;
}
unsigned int countSetBits(unsigned int n) //no. of 1's in a binary representation of a number
{ 
    unsigned int count = 0; 
    while (n) { 
        count += n & 1; 
        n >>= 1; 
    } 
    return count; 
} 
int main()
{
     IOS
     int testcases;
    // cin>>testcases;
     //while(testcases--)
     {
       
            int n;
            cin>>n;
           int h[n];
           for(int i=0;i<n;i++)
           {
               cin>>h[i];
           }
           ll dp[n];
           for(int i=0;i<n;i++)
           {
               dp[i]=mod;
           }
           dp[0]=0;
           for(int i=0;i<n;i++)
           {
               for(int j=i+1;j<i+k;j++)
               {
               if(j<n)
               {
               dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
               }
               }
           }
           cout<<dp[n-1];
     }
     return 0;
} 
//ascii of a=97
//ascii of A=65
//ascii of 0=48

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

#include <iostream>
using namespace std;

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

    if(k >= n) {
        cout << abs(A[0] - A[n-1]);
        return 0;
    }

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

    for(int i = k; i < n; i++){
        int temp = INT_MAX;
        for(int j = i-k; j < i; j++){
            temp = min(B[j] + abs(A[i]-A[j]), temp);
        }
        B[i] = temp;
    }
    cout << B[n-1];
}




Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: 'INT_MAX' was not declared in this scope
   23 |         int temp = 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 <iostream>
#include <queue>
#include <set>
#include <list>
#include <deque>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <iterator>
#define ll long long
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define powr(x,n,p) for(int axy=0 ; axy<p ; axy++){x=x*n;}
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nl printf("\n")
#define fr0(n,q) for(q=0 ; q<n ; q++)
#define fr1(n,q) for(q=1 ; q<=n ; q++)
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define lst(x) x[x.size()-1]
#define llst(x) x[x.size()-2]
#define md 1000000007
#define check(x,y) (x&(1<<y))
#define set(x,y) x=x|(1<<y)
using namespace std;
int dp[100005];
int arr[100005];
int n,k;
int solve(int x){
	if(x>=n) return 0;
	if(dp[x]!=-1) return dp[x];
	int ret=INT_MAX;
	for(int i=1 ; i<=k && x+i<=n ; i++){
		ret=min(ret, abs(arr[x+i]-arr[x])+solve(x+i));
	}
	return dp[x]=ret;
}
int main()
{
	int i;
	cin>>n>>k;
	for(i=0 ; i<100005 ; i++) dp[i]=-1;
	for(i=1 ; i<=n ; i++) cin>>arr[i];
	cout<<solve(1);
	nl;
	return 0;
}


Compiler output:
a.cc: In function 'int solve(int)':
a.cc:44:17: error: 'INT_MAX' was not declared in this scope
   44 |         int ret=INT_MAX;
      |                 ^~~~~~~
a.cc:14:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   13 | #include <iterator>
  +++ |+#include <climits>
   14 | #define ll long long
Language: C++

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

using ll = long long;
template<class T>
using V = vector<T>;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for(int i=m; i<n; i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = b - 1; i >= int(a); i--)

int main(){
    int N, K;
    cin >> N >> K;
    V<int> H(N);
    rep(i, N) cin >> H.at(i);

    V<ll> dp(N);
    dp.at(N-1) = 0;
    for(int i=N-2; i>=N-1-K && i>=0; i--) dp.at(i) = abs(H.at(N-1) - H.at(i));

    for(int i=N-2-K; i>=0; i--){
        ll min = 1000000000;
        for(int j=i+1; j<=i+K && j<N; j++){
            ll cost = dp.at(j) + abs(H.at(j) - H.at(i));
            if(cost < min) min = cost;
        }
        dp.at(i) = min;
    }
    
    cout << dp.at(0) << endl;
}

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

#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<deque>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<map>
#include<stack>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn =1200100;
typedef pair<ll,ll>p1;
typedef pair<pair<ll,ll>,ll>p2;
map<pair<pair<ll,ll>,ll>,ll>m1;
map<pair<ll,ll>,ll>m2;
const int MOD = 1e9;
const int N=351;
const int inf = 0x3f3f3f3f;
typedef pair<char, int> PAIR;
map<string,int>mm;
ll a[maxn];
llt dp[maxn];
int main()
{
    int n,k;
    scanf("%lld %lld",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    dp[1] = 0;
    for(int i=2;i<=n;i++)
    {
        dp[i] = inf;
    }
    for(int i=2;i<=n;i++)
    {
        for(int j=max(1,j-k);j<=i-1;j++)
        {
            dp[i] = min(dp[j]+abs(a[j]-a[i]),dp[i]);
        }
    }
    cout<<dp[n]<<endl;
}

Compiler output:
a.cc:29:1: error: 'llt' does not name a type; did you mean 'll'?
   29 | llt dp[maxn];
      | ^~~
      | ll
a.cc: In function 'int main()':
a.cc:38:5: error: 'dp' was not declared in this scope
   38 |     dp[1] = 0;
      |     ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> height;
    int l;
  for(int i=0;i<n;i++){
    cin>>l;
    height.push_back(l);
  }
  vector<int> X(n,INT_MAX);
  X[0]=0;
 for(int i=0;i<n-1;i++){
 for(int j=1;j<=k;j++){
   if(i+j>=n){
     break;
 }
   X[i+j]=min(X[i+j],X[i]+abs(height[i]-height[i+j]))
 }}
  cout<<X[n-1]<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:54: error: expected ';' before '}' token
   19 |    X[i+j]=min(X[i+j],X[i]+abs(height[i]-height[i+j]))
      |                                                      ^
      |                                                      ;
   20 |  }}
      |  ~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iomanip>
#include <cmath>

#define vi vector<int>
#define tests int t; cin>>t; while(t--)
#define ll long long
#define vll vector<long long>
#define srt(v) sort(v.begin(), v.end())
#define srtg(v) sort(v.begin(), v.end(), greater<int> ())
#define FOR(k, n) for(int k=0; k<n; k++)



using namespace std;

char nums[10] = { '0','1','2','3','4','5','6','7','8','9' };
char alphsl[26] = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
const ll MOD = 1000000007;
char alphs[26] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

void solve() {

    int n, k;
    cin >> n>>k;
    vi v(n);
    for (auto& x : v) cin >> x;
    vll dp(n);
    for (int i = n - 1; i >= n - k; i--) {
        dp[i] = abs(v[i] - v[n - 1]);
    }

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

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

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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

int main() {
  
  int numStones;
  cin >> numStones;
  int K;
  cin >> K;
  vector<int> heights(numStones);
  for(int& height : heights) {
      cin >> height;
  }
  vector<int> costs(numStones, INT_MAX);
  costs[0] = 0;

  for(int i = 1; i < costs.size(); i++) {
  	int step = K;
  	for(int j = i-1; j >= 0 && step > 0; j--, step--) {
      costs[i] = min(costs[i], costs[j] + abs(heights[i] - heights[j]));
    }
  }

  cout << costs[costs.size()-1];

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:32: error: 'INT_MAX' was not declared in this scope
   15 |   vector<int> costs(numStones, 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 <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;
 
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define t_times int t; cin >> t; while(t--)
#define fr(i, st, n) for(int i = (int )st; i < (int )n; i++)
#define rfr(i, en, st) for(int i = (int )en; i >= (int )st; i--)
#define all(c) (c).begin(), (c).end()
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
 
typedef long long int LL;
typedef pair< int, int> ii;
typedef vector< int> vi;
typedef vector< ii> vii;
typedef vector< vi> vvi;
 
const int mod = 1e9 + 7;
const LL INF = 9e18 + 2e17;
const int inf = 2e9;
const double eps = 1e-10;
 // START FROM HERE

int main(int argc, char const *argv[])
{
	fastio;

	int n, k; cin >> n >> k;
	vi h(n); fr(i,0,n) cin >> h[i];

	vi dp(n,INT_MAX);
	dp[0] = 0;
	fr(i,1,n) {
		fr(j,max(i-k,0),i) {
			dp[i] = min(dp[i], dp[j] + abs(h[j]-h[i]));
		}
	}
	cout<<dp[n-1]<<endl;




	return 0;
}

Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:40:17: error: 'INT_MAX' was not declared in this scope
   40 |         vi dp(n,INT_MAX);
      |                 ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include <algorithm>
  +++ |+#include <climits>
    8 |
Language: C++

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

Compiler output:
a.cc:19:5: error: 'cout' does not name a type
   19 |     cout<<cost[n-1];
      |     ^~~~
a.cc:20:3: error: expected unqualified-id before 'return'
   20 |   return 0;
      |   ^~~~~~
a.cc:21:1: error: expected declaration before '}' token
   21 | }
      | ^
Language: C++

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


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:17:18: error: no matching function for call to 'max(int, long long int)'
   17 |     for(int j=max(0,i-k);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:17:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   17 |     for(int j=max(0,i-k);j<i;j++)
      |               ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/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:17:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |     for(int j=max(0,i-k);j<i;j++)
      |               ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  vector<int>dp(n,0);
  for(int i=1;i<n;i++)
  {
    dp[i]=INT_MAX;
    
    for(int j=max(0,i-k);j<i;j++)
    {
      dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
    }
  }
  cout<<dp[n-1]<<"\n";
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:16:18: error: no matching function for call to 'max(int, long long int)'
   16 |     for(int j=max(0,i-k);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:16:18: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   16 |     for(int j=max(0,i-k);j<i;j++)
      |               ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/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:16:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   16 |     for(int j=max(0,i-k);j<i;j++)
      |               ~~~^~~~~~~
Language: C++

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

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

int path(int h[], int n){
  int dp[n], i, j, minval;
  dp[0]=0, dp[1]=h[1]-h[0];
  for(i=2; i<k+1; i++){
    minval=dp[0]+h[i]-h[0];
    for(j=0; j<i; j++){
      minval=min(minval, dp[j]+h[i]-h[j]);
    }
    dp[i]=minval;
  }
  for(i=k+1; i<n; i++){
    minval=dp[i-k]+h[i]-h[i-k];
    for(j=i-k; j<i; j++){
      minval=min(minval, dp[j]+h[i]-h[j]);
    }
    dp[i]=minval;
  }
  return dp[n-1];
}

int main(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0; i<n; i++){
    cin>>h[i];
  }
  int val = path(h,n);
  cout<<val<<endl;
}


Compiler output:
a.cc: In function 'int path(int*, int)':
a.cc:12:14: error: 'k' was not declared in this scope
   12 |   for(i=2; i<k+1; i++){
      |              ^
a.cc:19:9: error: 'k' was not declared in this scope
   19 |   for(i=k+1; i<n; i++){
      |         ^
Language: C

//
//  main.cpp
//  AtCoderDPPractice: A-Frog 1
//
//  Created by Glen Cahilly on 9/1/20.
//  Copyright © 2020 Glen Cahilly. All rights reserved.
//

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



int func(int h[], int n, int jumpSize) {
    int cost[n];
    cost[n-1]=0;
    cost[n-2]=abs(h[n-1]-h[n-2]);
    
    for (int k=n-3; k>=0; k--) {
        cost[k]=cost[k+1]+abs(h[k+1]-h[k]);
        for (int m=0; m<jumpSize; m++) {
            cost[k]=min(cost[k], cost[k+m+1]+abs(h[k+m+1]-h[k]));
        }
    }
    /*
    for (int value : cost) {
        cout << value << " ";
    }
    */
    return cost[0];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n; cin >> n; int h[n];
    int jumpSize; cin >> jumpSize;
    for (int k=0; k<n; k++) {
        int in; cin >> in;
        h[k]=in;
    }
    cout << func(h, n, jumpSize);
}


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

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

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

	long long n,k;
	cin>>n>>k;

	vector<long long> v(n+1);
	vector<long long> dp(n+1);
	
	for(long long i=1;i<=n;i++)
		cin>>v[i];
	

	for(long long i=2;i<=n;++i) {
		long long min_val=dp[i-1]+abs(v[i]-v[i-1]);

		for(long long j=max(1,i-k);j<i;++j) 
			min_val = min(min_val,dp[j]+abs(v[i]-v[j]));
	
		dp[i] = min_val;
	}

	cout<<dp[n];

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:36: error: no matching function for call to 'max(int, long long int)'
   20 |                 for(long long j=max(1,i-k);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:20:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   20 |                 for(long long j=max(1,i-k);j<i;++j)
      |                                 ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/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:20:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |                 for(long long j=max(1,i-k);j<i;++j)
      |                                 ~~~^~~~~~~