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

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; // Long long
const int INF = 90000;
const ll INFL = 900000;

#define vi vector<int>
#define vii vector<vector<int> >
#define vi_(n) vector<int>((n))
#define vii_(n,m) vector<vector<int> >((n), vector<int>((m)))
#define vi_def(n, def) vector<int>((n), (def))
#define vii_def(n, m, def) vector<vector<int> >((n), vector<int>((m), (def)))

#define rep(i, n) for(int i=0; i < (n); ++i)
#define per(i, n) for(int i=(n)-1; i >= 0; --i)
#define range(i, begin, end) for(int i=(begin); i < (end); ++i)

int N, K;
vi H;
//vi dp;

int main(){
	cin >> N >> K;
	H = vi(N);
	rep(i, N){
		int h;
		cin >> h;
		H[i] = h;
	}

	//dp = vi_def(100100, INF); // dp[i] := 0番目からi番目にジャンプするときの最小値
	long long dp[100100];
	dp[0] = 0;
	rep(i, N){
		range(j, 1, K+1){
			int c = dp[i] + abs(H[i] - H[i+j]);
			dp[i+j] = min(dp[i+j], c);
		}
	}

	int ans = dp[N-1];
	cout << ans << endl;
}


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

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

int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
  int N,K; cin>>N>>K;
  int A[N] , dp[N];
  for(int i = 0;i<N; i++) cin>>A[i];
  dp[0] = 0;
  for(int i = 1; i < N ; i++){
    int ans = INT_MAX;
    int m = max(i-K,0)
  	for(int j = i-1; j >= m ; j--){
    	ans = min(dp[j] + abs(A[i] - A[j]) , ans);
    }
    dp[i] = ans;
  }
  cout<<dp[N-1];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: expected ',' or ';' before 'for'
   13 |         for(int j = i-1; j >= m ; j--){
      |         ^~~
a.cc:13:26: error: 'j' was not declared in this scope
   13 |         for(int j = i-1; j >= m ; j--){
      |                          ^
Language: C++

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

int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
  int N,K; cin>>N>>K;
  int A[N] , dp[N];
  for(int i = 0;i<N; i++) cin>>A[i];
  dp[0] = 0;
  for(int i = 1; i < N ; i++){
    int ans = INT_MAX;
    int m = max(i-k,0)
  	for(int j = i-1; j >= m ; j--){
    	ans = min(dp[j] + abs(A[i] - A[j]) , ans);
    }
    dp[i] = ans;
  }
  cout<<dp[N-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:19: error: 'k' was not declared in this scope
   12 |     int m = max(i-k,0)
      |                   ^
a.cc:13:26: error: 'j' was not declared in this scope
   13 |         for(int j = i-1; j >= m ; j--){
      |                          ^
Language: C++

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

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


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

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

const long long INF=1LL<<60
const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    for(int i=0;i<101000;i++) {
        dp[i]=INF;
    }

    dp[0]=0;


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

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

 return 0;
}

Compiler output:
a.cc:8:1: error: expected ',' or ';' before 'const'
    8 | const int N_MAX=100000;
      | ^~~~~
a.cc: In function 'int main()':
a.cc:13:11: error: 'N_MAX' was not declared in this scope; did you mean 'NL_NMAX'?
   13 |     int h[N_MAX];
      |           ^~~~~
      |           NL_NMAX
a.cc:15:22: error: 'h' was not declared in this scope
   15 |     rep(i,N)    cin>>h[i];
      |                      ^
a.cc:27:37: error: 'h' was not declared in this scope
   27 |                 dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
      |                                     ^
Language: C++

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

const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    rep(i,101000) {
        dp[i]=INF;
    }

    dp[0]=0;


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

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

 return 0;
}

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

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

const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    rep(i,K) {
        dp[i]=abs(h[i]-h[0]);
    }  

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

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

 return 0;
}

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

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

const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    rep(i,K) {
        dp[i]=abs(h[i]-h[0]);
    }  

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

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

 return 0;
}

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

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

const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    rep(i,K) {
        dp[i]=abs(h[i]-h[0]);
    }

    int mini[N_MAX];
    rep(i,N)    mini[i]=10000000;    

    for(int i=0; i<N-K; ++i) {
        for(int j=i;j<K;j++) {
            mini[i]=min(dp[j]+abs(h[j+K]-h[j]),mini); 
        }
        dp[i+K]=mini[i]; 
    }

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

 return 0;
}

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

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

const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    rep(i,K) {
        dp[i]=abs(h[i]-h[0]);
    }

    ll mini[N_MAX];
    rep(i,N)    mini[i]=1000000000;    

    for(int i=0; i<N-K; ++i) {
        for(int j=i;j<K;j++) {
            mini[i]=min(dp[j]+abs(h[j+K]-h[j]),mini); 
        }
        dp[i+K]=mini[i]; 
    }

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

 return 0;
}

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

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

const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    rep(i,K) {
        dp[i]=abs(h[i]-h[0]);
    }

    ll mini[N_MAX]={1000000000};

    for(int i=0; i<N-K; ++i) {
        for(int j=i;j<K;j++) {
            mini[i]=min(dp[j]+abs(h[j+K]-h[j]),mini); 
        }
        dp[i+K]=mini[i]; 
    }

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

 return 0;
}

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

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

const int N_MAX=100000;
ll dp[101000];

int main() {
    int N,K;
    int h[N_MAX];
    cin>>N>>K;
    rep(i,N)    cin>>h[i];

    rep(i,K) {
        dp[i]=abs(h[i]-h[0]);
    }
    
    ll mini=1000000000;

    for(int i=0; i<N-K; ++i) {
        for(int j=i;j<K;j++) {
            dp[i+K]=min(dp[j]+abs(h[j+K]-h[j]),mini)
        }
        
    }
    cout<<dp[N-1]<<endl;

 return 0;
}

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

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

int main()
{
  int n;
  cin>>n;
  int k;
  cin>>k;
  int arr[n];
  int dp[n];
  
  for(int i=0 ; i<n; i++)
  {
    cin>>arr[i];
  }
  dp[0] = 0;
  dp[1] = fabs(arr[1] - arr[0]);
  for(int i=2 ; i<n ; i++)
  {
    int count = 2;
    dp[i] = dp[i-1] + fabs(arr[i] - arr[i-1]);
    while(count<=k && i-count>=0)
    {
      dp[i] = min(dp[i-count] + fabs(arr[i] - arr[i-count]) , dp[i]);
      count++;
    }
    
  }
  cout<<dp[n-1];
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:18: error: no matching function for call to 'min(__gnu_cxx::__enable_if<true, double>::__type, int&)'
   25 |       dp[i] = min(dp[i-count] + fabs(arr[i] - arr[i-count]) , dp[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:25:18: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   25 |       dp[i] = min(dp[i-count] + fabs(arr[i] - arr[i-count]) , dp[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:25:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   25 |       dp[i] = min(dp[i-count] + fabs(arr[i] - arr[i-count]) , dp[i]);
      |               ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

const ll MAXN = 1e5;
const ll INF = 1e7;
vector<ll> dp(MAXN+5, INF);

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


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

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

using namespace std;

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


Compiler output:
a.cc: In function 'int main()':
a.cc:15:3: error: expected ';' before '}' token
   15 |   }
      |   ^
Language: C++

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

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n],count[n],x;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  if(n<k)
    cout<<0<<endl;
  else
  {
    count[0] = 0;
  	count[1] = abs(arr[0]-arr[1]);
  for(int i=2;i<n;i++)
  {
  	count[i] = 100000000;
  	for(int j=0;j<k;j++)
  	{
  		if(i-j<0)
          break;
       	count[i] = min(count[i],abs(arr[i-j]-arr[i])+count[i-j]));  	
	}
	count[i] = x;
  }
  cout<<count[n-1]<<endl;
  
}
return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:65: error: expected ';' before ')' token
   28 |         count[i] = min(count[i],abs(arr[i-j]-arr[i])+count[i-j]));
      |                                                                 ^
      |                                                                 ;
Language: C++

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

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n],count[n],x;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  if(n<k)
    cout<<0<<endl;
  else
  {
    count[0] = 0;
  count[1] = abs(arr[0]-arr[1]);
  for(int i=2;i<k;i++)
  {
  	x = 100000000;
  	for(int j=0;j<i;j++)
  	{
  		int y = abs(arr[j]-arr[i])+count[j];
  		if(y<x)
  			x = y;	  	
	}
	count[i] = x;
  }
  for(int i=k;i<n;i++)
  {
    x = 100000;
  	for(int j=i-k;j<i;j++)
  	{
  		int y = abs(arr[j]-arr[i])+count[j];
  		if(y<x)
  			x = y;	  	
	}
	count[i] = x;
  }
  cout<<count[n-1]<<endl;
  return 0;
  
}


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

#include <bits/stdc++.h>

int main(){
    int n,k;
    scanf("%d%d", &n, &k);
    std::vector<int> s(n);
    for(int &x : s){
        scanf("%d", &x);
    }
    std::vector<int> dp(n, INT_MAX);
    for(int i=0; i<n; ++i){
        for(j=1; j<=k; ++j){
            if(i + j < n){
                dp[i+j] = std::min(dp[i+j], dp[i] + std::abs(s[i] - s[i+j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
    return 0;
}


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

#include <bits/stdc++.h>

int main(){
    int n,k;
    scanf("%d%d", &n, &k);
    std::vector<int> s(n);
    for(int &x : s){
        scanf("%d", &x);
    }
    std::vector<int> dp(n);
    for(int i=0; i<n; ++i){
        for(j=0; j<k; ++j){
            if(i + j < n){
                dp[i+j] = std::min(dp[i+j], dp[i] + std::abs(s[i] - s[i+j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
    return 0;
}


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

#include<iostream>
#include<cmath>

using namespace std;

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


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

#include<iostream>
#include<cmath>

using namespace std;

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


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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
void chmin(int a,int b){if(b<a)a=b;}
void chmax(int a,int b){if(a<b)a=b;}

int main(){
  int n,k;cin>>n>>k;
  vi v(n);
  rep(i,n)cin>>v[i];
  vector<ll> dp(n,9999999999);
  dp[0]=0;
  dp[1]=abs(v[1]-v[0]);
  for(int i=2;i<n;i++){
    rep(i,k){
      dp[i]=chmin(dp[i],dp[i-k-1]+abs(v[i]-v[i-k-1]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:18: error: void value not ignored as it ought to be
   22 |       dp[i]=chmin(dp[i],dp[i-k-1]+abs(v[i]-v[i-k-1]));
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
void chmin(int a,int b){if(b<a)a=b;}
void chmax(int a,int b){if(a<b)a=b;}

int main(){
  int n;cin>>n;
  vi v(n);
  rep(i,n)cin>>v[i];
  vector<ll> dp(n,9999999999);
  dp[0]=0;
  dp[1]=abs(v[1]-v[0]);
  for(int i=2;i<n;i++){
    rep(i,k){
      dp[i]=chmin(dp[i],dp[i-k-1]+abs(v[i]-v[i-k-1]));
    }
  }
  cout<<dp[n-1]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:11: error: 'k' was not declared in this scope
   21 |     rep(i,k){
      |           ^
a.cc:3:57: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
      |                                                         ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;
 
int dp[200001];
 
signed main(){
	r(i,100009)dp[i]=1e15;
	int n,k;
	cin>>n>>k;
	int a[n];
	r(i,n)cin>>a[i];
	dp[0]=0;
	r(i,n){
		r(j,k){
			dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(a[i]-a[i+j+1]));
		}
	}
	cout<<dp[n-1]<<endl;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
typedef pair<int,int>P;

int dp[200001];

signed main(){
	r(i,100009)dp[i]=1e15;
	int n,k;
	cin>>n>>k;
	int a[n];
	r(i,n)cin>>a[i];
	dp[0]=0;
	r(i,n){
		r(j,k){
			dp[i+j+1]=min(dp[i+j+1],dp[i]+abs(a[i]-a[i+j+1]));
		}
	}
	cout<<dp[n-1]<<endl;
}


Compiler output:
a.cc:29:5: error: redefinition of 'long long int dp [200001]'
   29 | int dp[200001];
      |     ^~
a.cc:7:5: note: 'long long int dp [200001]' previously declared here
    7 | int dp[200001];
      |     ^~
a.cc:31:8: error: redefinition of 'int main()'
   31 | signed main(){
      |        ^~~~
a.cc:9:8: note: 'int main()' previously defined here
    9 | signed main(){
      |        ^~~~
Language: C++

import sys

inf = sys.maxsize
N, K = map(int, input().split())
heights = list(map(int, input().split()))

dp = [inf]*N
dp[0] = 0


def chmin(a, b, diff):
    if dp[a] > dp[b] + diff:
        dp[a] = dp[b] + diff
    return


for i in range(N):
    for j in range(1, K+1):
        if i-j >= 0:
            chmin(i, i-j, abs(heights[i]-heights[i-j]))

print(dp[N-1])

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

import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve2(scanner, writer);
        scanner.close();
        writer.close();
    }
  
	public static void solve2(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();
        int[] stones = new int[n];
        for (int i = 0; i < n; i++) {
            stones[i] = scanner.nextInt();
        }

        int[] dp = new int[n];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;

        for (int i = 0; i < n; i++) {
            if (i+1 < n) {
                dp[i+1] = Math.min(dp[i+1], dp[i] + Math.abs(stones[i+1] - stones[i]));
            }
            if (i+2 < n) {
                dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(stones[i+2] - stones[i]));
            }
        }

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


Compiler output:
Main.java:23: error: cannot find symbol
        Arrays.fill(dp, Integer.MAX_VALUE);
        ^
  symbol:   variable Arrays
  location: class Main
1 error
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

	long *x = new long[n];
	long *cost = new long[n];

	for(long i = 0; i < n; i++){
		cin >> x[i];
		cost[i] = LONG_MAX;
	}
	
	cost[n - 1] = 0;

	for(long i = 1; i <= k; i++){
		for(long j = n - 1 - i; j >= 0; j--){
			cost[j] = min(cost[j], cost[j + i] + abs(x[j] - x[j + i]));
		}
	}

	for(long i = 1; i <= k; i++){
		for(long j = n - 1 - i; j >= 0; j--){
			cost[j] = min(cost[j], cost[j + i] + abs(x[j] - x[j + i]));
		}
	}

	cout << cost[0] <<endl;

	delete x, cost;
	return 0;
}

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

#include<iostream>
using namespace std;


int main(){
	long long int n,k;cin>>n>>k;
  long long int h[n+k+10],dp[n+k+10];for(int i=1;i<n+1;i++)cin>>h[i];
  for(int i=n;i<n+k+8;i++)h[i]=10000*i
  for(int i=0;i<n+1;i++) dp[i]=10*10*10*10*10*10;dp[1]=0;
  
  for(int j=1;j<n+1;j++){
  for(int i=1;i<k+2;i++){
    dp[i+j]=min(dp[i+j],(dp[j] + abs(h[j]-h[i+j])));
   //cout<<"dp["<<i+j<<"]= "<<dp[i+j]<<endl;
  }
  }
  
  
  cout<<dp[n]<<endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:39: error: expected ';' before 'for'
    8 |   for(int i=n;i<n+k+8;i++)h[i]=10000*i
      |                                       ^
      |                                       ;
    9 |   for(int i=0;i<n+1;i++) dp[i]=10*10*10*10*10*10;dp[1]=0;
      |   ~~~                                  
a.cc:9:15: error: 'i' was not declared in this scope
    9 |   for(int i=0;i<n+1;i++) dp[i]=10*10*10*10*10*10;dp[1]=0;
      |               ^
Language: C++

import sys
import unittest
import collections


def frog_k(h, n, k):
	"""
	Errichto's code
	""" 
	dp = [float("inf")] * n 
	dp[0] = 0
	for i in xrange(0, n):
		for j in xrange(i+1, i+k+1):
			if j < n:
				dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
	return (dp[n-1])


def frog_k_1(h, n, k): 
	"""
	#This is top down approach
	"""
	dp = [float("inf")] * n 
	dp[0] = 0
	dp[1] = abs(h[0] - h[1])
	
	for i in xrange(2, n):
		for j in xrange(1, k+1):
			if i-j >= 0:
				dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]))
	return (dp[n-1])

def read_input():
	#Read the input N
	a = sys.stdin.readline().split()
	n = int(a[0])
	k = int(a[1])
	#Read the height line
	a = sys.stdin.readline().split()
	 
	#Convert into int List
	h = []
	for i in range(0, n):
		h.append(int(a[i]))

	result = frog_k(h, n, k)
	print result
	
class TestFrogJump(unittest.TestCase):
	def test_1(self):
		res = frog_k([10,30,40,50,20], 5, 3)
		self.assertEqual(res, 30)
		
	def test_2(self):
		res = frog_k([10, 20, 10], 3, 1)
		self.assertEqual(res, 20)
	
	def test_3(self):
		res = frog_k([10, 10], 2, 100)
		self.assertEqual(res, 0)
	
	def test_4(self):
		res = frog_k([40,10,20,70,80,10,20,70,80,60], 10, 4)
		self.assertEqual(res, 40)
	
if __name__ == '__main__':
	 read_input()
	 #unittest.main()


Compiler output:
a.cc:7:11: warning: missing terminating " character
    7 |         """
      |           ^
a.cc:7:11: error: missing terminating " character
a.cc:8:17: warning: missing terminating ' character
    8 |         Errichto's code
      |                 ^
a.cc:8:17: error: missing terminating ' character
    8 |         Errichto's code
      |                 ^~~~~~~
a.cc:9:11: warning: missing terminating " character
    9 |         """
      |           ^
a.cc:9:11: error: missing terminating " character
    9 |         """
      |           ^ 
a.cc:20:11: warning: missing terminating " character
   20 |         """
      |           ^
a.cc:20:11: error: missing terminating " character
a.cc:21:10: error: invalid preprocessing directive #This
   21 |         #This is top down approach
      |          ^~~~
a.cc:22:11: warning: missing terminating " character
   22 |         """
      |           ^
a.cc:22:11: error: missing terminating " character
a.cc:34:10: error: invalid preprocessing directive #Read
   34 |         #Read the input N
      |          ^~~~
a.cc:38:10: error: invalid preprocessing directive #Read
   38 |         #Read the height line
      |          ^~~~
a.cc:41:10: error: invalid preprocessing directive #Convert
   41 |         #Convert into int List
      |          ^~~~~~~
a.cc:66:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   66 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:68:11: error: invalid preprocessing directive #unittest
   68 |          #unittest.main()
      |           ^~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long long chmin(long long a, long long b){
    if(a > b) return b;
    return a;
}

int main() {
    int i, j;
    int n;
    long long  h[100001] = {0};
    long long dp[100001] = {pow(10,9)+1};

    scanf("%d\n", &n);
    for(i = 0; i < n; i++){
        scanf("%lld", &h[i]);
    }
    dp[1] = abs(h[0] - h[1]);
    for(i = 2; i < n; i++){
        for(j = i - 1; j < n - 1; j++){
        dp[i] = chmin(dp[i], abs(h[i-j] - h[i-j]));
    }

    printf("%lld\n", dp[n-1]);

    return 0;
}


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

#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;cin>>n;
  int k;cin>>k;
  vector<int> stones(n,0);
  vector<int> dp(k,0);
  for(int& i:stones)cin>>i;
  for(int i=k+1;i<n;i++) {
  	int min=INT_MAX;
    for(int j=1;j<=k;j++) {
    	int tmp=dp[i-j]+abs(stones[i]-stones[i-j]);
      	min=tmp<min?tmp:min;
    }
    dp[i]=min;
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'INT_MAX' was not declared in this scope
   11 |         int min=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<algorithm>
#include<vector>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
const int INF=200000;
#define int long long
int main(){
	int n,K;
	
	cin>>n>>K;
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	vector<int>dp(2*n,INF);
	dp[0]=0;
	for(int i=1;i<n;i++){
		int k=1;
		while(i-k>=0&&k<=K){
			dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]));
			k++;
		}
	}
	
	cout<<dp[n-1]<<endl;
}


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

#include<iostream>
#include<algorithm>
#include<vector>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
const int INF=INT_MAX;

int main(){
	int n,K;
	
	cin>>n>>K;
	int h[n];
	for(int i=0;i<n;i++)cin>>h[i];
	vector<int>dp(2*n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++){
		int k=1;
		while(i-k>=0&&k<=K){
			dp[i]=min(dp[i],dp[i-k]+abs(h[i]-h[i-k]));
			k++;
		}
	}
	
	cout<<dp[n-1]<<endl;
}


Compiler output:
a.cc:8:15: error: 'INT_MAX' was not declared in this scope
    8 | const int INF=INT_MAX;
      |               ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <iomanip>
  +++ |+#include <climits>
    7 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define F first
#define S second

using namespace std;
int main()
{	
	int dp[100007],H[100007],n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> H[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
      for(int j = 1; j + i < n && j <= k;j++) 
			dp[i + j] = min(dp[i + j], dp[i] + abs(H[i] - H[j]));
      
	}
	cout << dp[n-1];
	return 0;
}
/*
1
3 3 1
0 1
1 2
0 2
1
4 4 1
0 1
1 2
0 2
2 3

*/

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

#include<bits/stdc++.h>
using namespace std;
const int INF = 10000000007;

// helper function to find minimum cost to reach end
int minCost(int* arr, int n, int k)
{
	int *dp = new int[n];

	// fills dp array with INT_MAX
	for(int i = 0; i < n; i++)
	  dp[i] = 100000007;


    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(arr[i] - arr[j]))
    	}
    }
    
     return dp[n-1];
}


// function to handle input and output
int main()
{
  int n, k;
  cin >> n >> k;

  int a[n];

  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  
  cout << minCost(a, n, k);

  return 0;
}


Compiler output:
a.cc:3:17: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000007' to '1410065415' [-Woverflow]
    3 | const int INF = 10000000007;
      |                 ^~~~~~~~~~~
a.cc: In function 'int minCost(int*, int, int)':
a.cc:22:65: error: expected ';' before '}' token
   22 |                 dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]))
      |                                                                 ^
      |                                                                 ;
   23 |         }
      |         ~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int N,K;
  cin >>N>>K;
  vector<int> h(N);
  rep (i, N) cin >> h[i];//h[i]は足場i+1の高さ。
  vector<int> dp(N,INF);
  //vector dp[i]には、足場i+1まで到達した場合の最小コストを記入する。
  dp[0]=0;//足場1にいるとき(i=0)、コストは0
  rep(i,N){
      for(int j=1;j<=K;j++){//足場2以上のとき(i>=1)、i-1, i-2...i-Kの時を調べる
        dp[i+j]=min(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:9:20: error: 'INF' was not declared in this scope
    9 |   vector<int> dp(N,INF);
      |                    ^~~
Language: C++

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <climits>
using namespace std; 

const int INF = 1 << 29;

int main(){

    int n;
    cin >> n>>k;
    vector<int> h(n);
    for(int& i : h){
        cin >> i;
    }

    vector<int> cache(n,INT_MAX);

    cache[0] = 0;
    cache[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; ++i){
      	for(int j = 1; j<=k; j++)
        {
          	if((i-j)<0)
            {
              break;
            }
        	cache[i] = min(cache[i],cache[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << cache[n - 1];
    return 0;
}


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

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 

const int INF = 1 << 29;

int main(){

    int n;
    cin >> n>>k;
    vector<int> h(n);
    for(int& i : h){
        cin >> i;
    }

    vector<int> cache(n,INF);

    cache[0] = 0;
    cache[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; ++i){
      	for(int j = 1; j<k; j++)
        {
          	if((i-j)<0)
            {
              break;
            }
        	cache[i] = min(cache[i],cache[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << cache[n - 1];
    return 0;
}


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

#include<iostream>
#include<vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
typedef vector<int> VI;
typedef vector<VI> VVI;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,k; 
    cin >> n >>k;
    VI frog(n,0);
    rep(i,n) cin >> frog[i];
    VI dp(n,INT_MAX);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= k; j++){
            if(i - j < 0) break;
            dp[i] = min(dp[i-j] + abs(frog[i] - frog[i-j]),dp[i]);
        }
    }
    cout << dp[n-1] << endl;
    
    return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define int long long
typedef vector<int> VI;
typedef vector<VI> VVI;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,k; 
    cin >> n >>k;
    VI frog(n,0);
    rep(i,n) cin >> frog[i];
    VI dp(n,0);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        if(i <= k) dp[i] = abs(frog[i] - frog[0]);
        for(int j = i; j <= i + k; && j < n; j++) dp[j] = min(dp[i] + abs(frog[i] - frog[j]),dp[j]);
    }
    cout << dp[n-1] << endl; 
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:41: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |         for(int j = i; j <= i + k; && j < n; j++) dp[j] = min(dp[i] + abs(frog[i] - frog[j]),dp[j]);
      |                                    ~~~~~^~~
a.cc:26:44: error: expected ')' before ';' token
   26 |         for(int j = i; j <= i + k; && j < n; j++) dp[j] = min(dp[i] + abs(frog[i] - frog[j]),dp[j]);
      |            ~                               ^
      |                                            )
a.cc:26:46: error: 'j' was not declared in this scope
   26 |         for(int j = i; j <= i + k; && j < n; j++) dp[j] = min(dp[i] + abs(frog[i] - frog[j]),dp[j]);
      |                                              ^
a.cc:26:39: error: label 'j' used but not defined
   26 |         for(int j = i; j <= i + k; && j < n; j++) dp[j] = min(dp[i] + abs(frog[i] - frog[j]),dp[j]);
      |                                       ^