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

#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
#define ll long long
const int inf = 1e9;
const int mod = 1e9 + 7;
using namespace std;
int main(){
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, a[100005], b[100005], k;
    cin>>n>>k;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    b[0] = 0;
    b[1] = 0;
    for(int i = 2; i <= n; i++){
        ll mn = 100 * inf;
        for(int j = 1; j <= min(i, k); j++){
            mn = min((ll)abs(a[i] - a[i - j]) + b[i - j], mn);
        }
        b[i] = mn;
    }
    cout<<b[n]<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:21: warning: integer overflow in expression of type 'int' results in '1215752192' [-Woverflow]
   19 |         ll mn = 100 * inf;
      |                 ~~~~^~~~~
a.cc:20:32: error: no matching function for call to 'min(int&, long long int&)'
   20 |         for(int j = 1; j <= min(i, k); j++){
      |                             ~~~^~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: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:20:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   20 |         for(int j = 1; j <= min(i, k); j++){
      |                             ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:20:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |         for(int j = 1; j <= min(i, k); j++){
      |                             ~~~^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main(){
  int n; cin >> n;
  int k; cin >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  //i番目に到達するために必要なコストの最小値をdp[i]とする。
  int dp[n];
  for(int i=0;i<n;i++){
    dp[i]=1000000000;
  }
  //dpテーブルの初期化
  dp[1]=0;
  for(int i=1;i<n;i++){
    for(int j=1;j<=min(k,n-i);j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j-1]-h[i-1]);
    }
  }
  cout << dp[n] << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
#ifdef LOCAL
#include "1.h"
#else
#define dbg(...) 
#endif
ll n,m,i,j,k,in,cnt = 0,l,r,u,v,x,y,tc = 1,mod = 1000000007 ,ans,inf = 1e18;
const ll  mx = 100001 ;
vector<ll> a(mx);
vector<int> dp(mx,-1);
ll foo(int src){

    if(dp[src]!=-1)
        return dp[src];
    if(src==(n-1)){
        return 0;
    }
    else{
        ll ans = inf;
        for (int i = src+1; i <= min(src+k,n-1); ++i)
        {
            ll ans_here = abs(a[src]-a[i]) + foo(i);
            dbg(ans_here , ans , src);
            ans = min(ans,ans_here);

        }
    
        return dp[src]=ans;
    }
}
void solve(){
    cin>>n>>k;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    cout<<foo(0)<<endl;
    db(dp,0,n);
}
signed main(){                                          //F
    clock_t time = clock();                             //A
    ios_base::sync_with_stdio(0);                       //S
    cin.tie(0);                                         //T
    cout.tie(0);                                        //I
    cerr.tie(0);                                        //O
    if(0) cin>>tc;
    while(tc--)
        solve();
    dbg("Author - Amit dwivedi");
    return 0&fprintf(stderr, "Time ::%.3lf ms.\n",((clock() - time)*1000.0)/CLOCKS_PER_SEC);
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:40:5: error: 'db' was not declared in this scope; did you mean 'dp'?
   40 |     db(dp,0,n);
      |     ^~
      |     dp
Language: C++

#include <iostream>
#include <cmath>

using namespace std;
long long n, k;
long long A[100001];
long long F[100001];

void input()
{
    cin>>n>>k;
    for(long long i=1; i<=n; i++) cin>>A[i];
}

int main()
{
    input();
    if(k>n) k=n;
    F[1]=0;
    F[2]=abs(A[1]-A[2]);
    for(long long i=3; i<=k; i++)
    {
        F[i]=LONG_LONG_MAX;
        for(long long j=1; j<=i-1; j++)
        {
            long long tmp=F[j]+abs(A[i]-A[j]);
            F[i]=min(F[i],tmp);
        }
    }
    for(long long i=k+1; i<=n; i++)
    {
        F[i]=LONG_LONG_MAX;
        for(long long j=i-k; j<=i-1; j++)
        {
            long long tmp=F[j]+abs(A[i]-A[j]);
            F[i]=min(F[i],tmp);
        }
    }
    cout<<F[n];
    return 0;
}


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

#include <iostream>
#include <math.h>
#include <stdlib.h>
using namespace std;
long long n,k,i,j,a[100004],f[100005];
int main()
{
    cin>>n;
    cin>>k;
    for (i=1;i<=n;i++)
        cin>>a[i];
    f[1]=0;
    f[2]=abs(a[2]-a[1]);
    for (i=3;i<=n;i++)
    {
        f[i]=LONG_LONG_MIN;
        for (j=i-1;j>=i-k;j--)
        {
            if (j>=1) if (f[i]>f[j]+abs(a[i]-a[j])) f[i]=f[j]+abs(a[i]-a[j]);
        }
    }
    cout<<f[n];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:14: error: 'LONG_LONG_MIN' was not declared in this scope
   16 |         f[i]=LONG_LONG_MIN;
      |              ^~~~~~~~~~~~~
Language: C++

//
//  main.cpp
//  B-Frog_2
//
//  Created by david chong on 10/30/19.
//  Copyright © 2019 david chong. All rights reserved.
//

#include <iostream>
#include <vector>

using namespace std;

int solve(int k, vector<int> & inVec) {
    
    vector<int> dp(inVec.size());
    
    dp[0] = 0;
    
    vector<int> tempVec;
    
    int count = 1;
    int myMin = INT_MAX;
    
    for(int i = 1; i < inVec.size(); i++) {
        
        count = 1;
        myMin = INT_MAX;
        
        while(count <= k && (i - count >= 0) ) {
            myMin = min(myMin, abs(inVec[i] - inVec[i-count]) + dp[i-count]);
            count++;
        }
        dp[i] = myMin;
    }
    
        
    return dp.back();
}


int main(int argc, const char * argv[]) {
    
//    freopen("input.in", "r", stdin);
    
    int n, k;
    
    cin >> n >> k;
    
    vector<int> inVec(n);
    
    for(int i = 0; i < n; i++) {
        cin >> inVec[i];
    }
    
    printf("%i\n", solve(k, inVec));
    
    return 0;
}


Compiler output:
a.cc: In function 'int solve(int, std::vector<int>&)':
a.cc:23:17: error: 'INT_MAX' was not declared in this scope
   23 |     int myMin = INT_MAX;
      |                 ^~~~~~~
a.cc:11:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <vector>
  +++ |+#include <climits>
   11 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
int min(int a,int b)
{
  if(a<b)
return a;
  return b;
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:26:52: error: expected ')' before ';' token
   26 | v[i]=min(v[i],v[i-k+1-j]+abs(cost[i]-cost[i-k+1-j]);
      |         ~                                          ^
      |                                                    )
Language: C++

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<stdbool.h>
#define int long long
#define elif else if
#define mod 1000000007

int abbs(int a)
{
	return a>0?a:(-1*a);
}

int main(void)
{
	int n,k;
	scanf("%lld %lld",&n, &k);
	int a[n];
	for(int i = 0;i<n;i++)	
		scanf("%lld",a+i);
	int dp[n][k+1];

	for(int i = 0; i<n ; i++)
	{
		for(int j = 0;j<k+1;j++)
		{
			dp[i][j] = 0;
		}	
	}
	for(int i = 1; i<n ; i++)
	{
		int max = 1000000; 
		for(int j = 0; j<k ;j++)
		{
			if(i>j)
			{		
				dp[i][j] =  abbs(a[i] - a[i-j-1]) + dp[i-1-j][k];
				if(max>dp[i][j])
					max = dp[i][j];
			}
		}
		dp[i][k] = max;	
	}

	printf("%lld\n", dp[n-1][k]);
	return 0;
}


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

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<stdbool.h>
#define int long long
#define elif else if
#define mod 1000000007

int abbs(int a)
{
	return a>0?a:(-1*a);
}

int main(void)
{
	int n,k;
	scanf("%lld %lld",&n, &k);
	int a[n];
	for(int i = 0;i<n;i++)	
		scanf("%lld",a+i);
	int dp[n][k+1];

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

	for(int i =0;i<=k;i++)
	{
		dp[1][i] = 0;
	}
	for(int i = 1; i<n ; i++)
	{
		int max = -1; 
		for(int j = 0; j<k ;j++)
		{
			if(i>j)
			{		
				dp[i][j] =  abbs(a[i] - a[i-j-1]) + dp[i-1-j][k];
				if(max<dp[i][j])
					max = dp[i][j];
			}
		}
		dp[i][k] = max;	
	}

	printf("%lld\n", dp[n-1][k]);
	return 0;
}


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

#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int N;
long long h[100010];
long long dp[100010];
int main(){
  int N,K;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    cin >> h[i];
  }
  for(int i=0;i<100010;i++){
    dp[i] = 100010;
  }
  dp[0]=0;
  for(int i=0;i<N;i++){
    for(int i=0;j<=K){
      chmin(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[N-1] << endl;
}
    
    

Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'j' was not declared in this scope
   21 |     for(int i=0;j<=K){
      |                 ^
a.cc:21:21: error: expected ';' before ')' token
   21 |     for(int i=0;j<=K){
      |                     ^
      |                     ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long dp[100007]={};
int main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  for(int i=0;i<N;i++) cin >> h[i];
  dp[0]=0;
  for(int i=0;i<N;i++){
    int minc = 100007;
    for(int j=0;j<K;j++) minc = min((dp[i-j]+abs(h[i+1]-h[i-j])),minc);
    dp[i+1] = minc;
  }
  cout << dp[N-1] << endl;
}


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

#include "iostream"
#include "cmath"
#include "vector"
using namespace std;

int n, k;
vector <int> h;
vector <long long> cost;

long long solve(int x) {
    if (cost[x] != -1) {
        return cost[x];
    }

    if (x == 1) {
        cost[x] = 0;
    }
    else {
        cost[x] = INT_MAX;
        for (int i=x-1; (x - i) <= k && i >= 1; i--) {
            long long jump_i = solve(i) + abs(h[x] - h[i]);
            cost[x] = min(cost[x], jump_i);
        }
    }

    return cost[x];
}

int main() {
    cin >> n >> k;
    h.resize(n + 1);
    cost.resize(n + 1, -1LL);
    for (int i=1; i<=n; i++) cin >> h[i];
    solve(n);
    cout << cost[n] << '\n';
}


Compiler output:
a.cc: In function 'long long int solve(int)':
a.cc:19:19: error: 'INT_MAX' was not declared in this scope
   19 |         cost[x] = INT_MAX;
      |                   ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include "vector"
  +++ |+#include <climits>
    4 | using namespace std;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}


int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,0,n)
        cin>>h[i];
    int dp[100001];
    for(int i=0;i<n;i++)
        dp[i]=10e5;
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i>=k)
        {
            for(int j=1;j<=k;j++)
                dp[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
        else
        {
            for(int j=1;j<=i;j++)
                dp[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:32: error: 'd' was not declared in this scope
   32 |                 dp[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
      |                                ^
a.cc:37:32: error: 'd' was not declared in this scope
   37 |                 dp[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
      |                                ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
typedef long long int ll;
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}


int main()
{
    int n,k;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,0,n)
        cin>>h[i];
    int dp[100001];
    for(int i=0;i<n;i++)
        dp[i]=10e5;
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        if(i>=k)
        {
            for(int j=1;j<=k;j++)
                d[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
        else
        {
            for(int j=1;j<=i;j++)
                d[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:32:17: error: 'd' was not declared in this scope
   32 |                 d[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
      |                 ^
a.cc:37:17: error: 'd' was not declared in this scope
   37 |                 d[i]=std::min(d[i],dp[i-j]+abs(h[i]-h[i-j]));
      |                 ^
Language: Java


import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LENONO
 */
public class NewClass4 {
        

    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();

        int[] a = new int[n];
        int[] h = new int[n];
        for(int i=0;i<n;i++) {
                h[i] = in.nextInt();
        }
        for(int i=0;i<n;i++) {
                a[i] = Integer.MAX_VALUE;
        }
        a[0] = 0;
        for(int i=0;i<n;i++) {
            for(int j = 0; j<k; j++){
                
                if(i <n-j)a[i+j] = Math.min(a[i+j], a[i]+Math.abs(h[i]-h[i+j]));
            }
        }
        System.out.println(a[n-1]);
    }

}

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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100001];
ll n;ll a[100001];
ll ans(ll ind){
  if(ind>=n-1)return 0;
  if(dp[ind]!=-1)return dp[ind];
  dp[ind] = numeric_limits<ll>::max();
  for(ll i=1;i<=k;i++){
    if(ind+i<n)
  		dp[ind] = min(ans(ind+i) + abs(a[ind]-a[ind+i]),dp[ind]);
    else break;
  }
  return dp[ind];
}
int main(){
  memset(dp,-1,sizeof(dp));
  cin>>n;for(ll i=0;i<n;i++)cin>>a[i];
  cout<<ans(0)<<endl;
  return 0;
}


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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:23: error: 'INT_MAX' was not declared in this scope
   12 |     vector<int> 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: Java

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

public class Main {

    private static int[] dp = null;

    //https://atcoder.jp/contests/dp/tasks/dp_b
    public static void main( String[] args ) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        dp = new int[n + 1];
        //Arrays.fill(dp, -1);

        int val1 = solveBottomUp(arr, k);
        System.out.println(val1);
    }

     private static int solveBottomUp( int[] arr, int k ) {

        //INF : bcz we are comparing Math.min(dp[j] here..
        Arrays.fill(dp, INF);

        //this indicate to reach first stone cost is zero..
        dp[0] = 0;

        for (int i = 0; i < arr.length; i++) {

            //from each stone : frog can jump to next k stones.
            for (int j = i + 1; j <= i + k; j++) {

                if (j < arr.length) {
                    dp[j] = Math.min(dp[j]
                            , dp[i] + Math.abs(arr[i] - arr[j]));
                }
            }
        }

        return dp[arr.length - 1];
    }
}

Compiler output:
Main.java:30: error: cannot find symbol
        Arrays.fill(dp, INF);
                        ^
  symbol:   variable INF
  location: class Main
1 error
Language: Java

public class Main {

    private static int[] dp = null;

    //https://atcoder.jp/contests/dp/tasks/dp_b
    public static void main( String[] args ) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }

        dp = new int[n + 1];
        Arrays.fill(dp, -1);

        int val = solveTopDown(n - 1, arr, k);
        System.out.println(val);
    }

    private static int solveTopDown( int i, int[] arr, int k ) {
        if (dp[i] != -1) {
            return dp[i];
        }

        if (i == 0) { //if one element left
            dp[i] = 0;
            return dp[i];
        }

        int min = Integer.MAX_VALUE;

        //for each stone frog want to Jump K steps..
        for (int p = k; p >= 1; p--) {

            //if frog can jump at-least one stone..using zero bcz we are using zero based indexing
            if (i - p >= 0) {
                min = Math.min(min, solveTopDown(i - p, arr, k) + Math.abs(arr[i] - arr[i - p]));
            }
        }

        return dp[i] = min;
    }
}

Compiler output:
Main.java:8: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:8: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
Main.java:18: error: cannot find symbol
        Arrays.fill(dp, -1);
        ^
  symbol:   variable Arrays
  location: class Main
3 errors
Language: C++

#include<iostream>
#define maxi 1000000007
#define ll long
#define pb emplace_back
#define mp make_pair
#define tc while(t--)
#define fo(n) for(int i=0;i<n;i++)
#define foj(m,n) for(int j=m;j<n;j++)
#define INF 9999999999
#define vp vector<pair<int,int>>
#define vc vector<int>
#define ispow2(x)  x && (!(x&(x-1)))
#define copy(a,b,n) copy_n(a,n,b) 
#define create(a,m,n) iota(a,a+n,m)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define maximum(a,n)  ll* i1,maxi; i1 = std::max_element(a, a+n);maxi=*i1 
#define minimum(a,n)  ll* i1,mini; i1 = std::min_element(a, a+n);mini=*i1 
using namespace std;
int solve()
{
};
int main()
{//fio
ll n,k;
cin>>n>>k;
ll a[n+1];
foj(1,n+1)
cin>>a[j];
ll dp[n+1];
fo(n+1)
dp[i]=9999999;
dp[1]=0;
dp[2]=abs(a[2]-a[1]);
for(int i=3;i<=n;i++)
{for(int j=max(0,i-k);j<i;j++)
{dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));}}
cout<<dp[n]<<endl;



return 0;}

Compiler output:
a.cc: In function 'int solve()':
a.cc:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | };
      | ^
a.cc: In function 'int main()':
a.cc:35:15: error: no matching function for call to 'max(int, long int)'
   35 | {for(int j=max(0,i-k);j<i;j++)
      |            ~~~^~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   35 | {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
Language: C++

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

int main() {
int N, K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i, N)
    cin >> h.at(i);
  vector<int> pro(N, 0);
  rep(i, N){
  if(i == 0)
    continue;
    else if(i <= K){
    pro[i] = abs(h[0] - h[i]);
    }
    else if(i > K){
       int prov = 1000010;
      rep2(j, i-K, i){
      prov = min(prov, pro[j]+abs(h[i]-h[j]));
      pro[i] = prov;
    }
  }
  cout << pro[N-1] << endl;
}

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

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const INF 1e9+7;
int main(){ IOS;
  int n;
  cin>>n;
  vector<int>dp(n,INF);
  vector<int>h(n);
  dp[0]=0;
  for(int i=0;i<n;i++)
    cin>>h[i];
  for(int i=0;i<n;i++){
    for(int j:{i+1,i+2}){
      dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
    }
  }
  cout<<dp[n-1];
}


Compiler output:
a.cc:4:7: error: 'INF' does not name a type
    4 | const INF 1e9+7;
      |       ^~~
a.cc: In function 'int main()':
a.cc:8:19: error: 'INF' was not declared in this scope
    8 |   vector<int>dp(n,INF);
      |                   ^~~
Language: C++

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

int main(){
  int n,k;
  cin>>n>>k;
  int A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  int B[n];
  for(int i=0;i<n;i++){
    B[i]=INT_MAX;
  }
  B[0]=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=i+k;i++){
      if(j<n){
      B[j]=min(B[j],A[i]+abs(A[i]-A[j]);
               }
               }
               }
    cout<<B[n-1]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:40: error: expected ')' before ';' token
   21 |       B[j]=min(B[j],A[i]+abs(A[i]-A[j]);
      |               ~                        ^
      |                                        )
Language: Java

import java.util.ArrayList;
import java.util.Scanner;

public class main
{
    public static void main(String argp[])
    {
        Scanner in=new Scanner(System.in);
        int N,K;
        N=in.nextInt();
        K=in.nextInt();
        ArrayList<Integer> H=new ArrayList<>();
        ArrayList<Integer> dp=new ArrayList<>();
        for(int i=0;i<N;i++)
        {
            dp.add(1000000);
            H.add(in.nextInt());
        }
        dp.set(0,0);
        for(int i=0;i<N;i++)
        {
            for(int j=1;j<=K;j++)
            {
                if(j+i<N)
                {
                    dp.set(i+j,Math.min(dp.get(i+j),dp.get(i)+Math.abs(H.get(i)-H.get(i+j))));
                }
            }
        }
        System.out.println(dp.get(N-1));
    }
}


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

import java.util.ArrayList;
import java.util.Scanner;

public class Frog_2
{
    public static void main(String argp[])
    {
        Scanner in=new Scanner(System.in);
        int N,K;
        N=in.nextInt();
        K=in.nextInt();
        ArrayList<Integer> H=new ArrayList<>();
        ArrayList<Integer> dp=new ArrayList<>();
        for(int i=0;i<N;i++)
        {
            dp.add(1000000);
            H.add(in.nextInt());
        }
        dp.set(0,0);
        for(int i=0;i<N;i++)
        {
            for(int j=1;j<=K;j++)
            {
                if(j+i<N)
                {
                    dp.set(i+j,Math.min(dp.get(i+j),dp.get(i)+Math.abs(H.get(i)-H.get(i+j))));
                }
            }
        }
        System.out.println(dp.get(N-1));
    }
}


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

import java.util.Scanner;

public class B {
    public  static  void main(String args[]){
        Scanner sc= new Scanner(System.in);
        int n= sc.nextInt();
        int k=sc.nextInt();
        int h []=new int[n];
        for(int j=0;j<n;j++)
            h[j]=sc.nextInt();
        int cost[]= new int [n];
        for(int i=0;i<k&&i<n;i++){
            cost[i]=Math.abs(h[i]-h[0]);
        }
        if(k<n)
            for (int i=k;i<n;i++){
            int j=1,temp,val=Integer.MAX_VALUE;
            while(j<=k){
                temp=cost[i-j]+Math.abs(h[i]-h[i-j]);
                if(temp<val){
                    val=temp;
                }
                j++;
            }
            cost[i]=val;
        }
        System.out.println(cost[n-1]);
    }
}


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: expected '}' before 'else'
   20 |        else{
      |        ^~~~
a.cc:16:13: note: to match this '{'
   16 |     if(i>=k){
      |             ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: expected '}' before 'else'
   20 |        else{
      |        ^~~~
a.cc:16:13: note: to match this '{'
   16 |     if(i>=k){
      |             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int frog(vector<int> A,int k)
{
  int n=A.size();
  if(n<=1)
    return 0;
  if(n==2)
    return abs(A[0]-A[1]);
  int dp[n];
  memset(dp,0,sizeof(dp));
  dp[n-1]=0;
  dp[n-2]=abs(A[n-1]-A[n-2]);
  for(int i=n-3;i>=0;i--)
  {
    int mini=INT_MAX;
    for(int j=1;j<=k && i+j<n;j++)
    {
      mini=min(mini,abs(A[i]-A[i+j]+dp[i+j]);
    }
    dp[i]=mini;
  }
   return dp[0];
}
int main()
{
  int N,k;
  cin>>N>>k;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin>>A[i];
  cout<<frog(A,k);
  return 0;
}

Compiler output:
a.cc: In function 'int frog(std::vector<int>, int)':
a.cc:19:45: error: expected ')' before ';' token
   19 |       mini=min(mini,abs(A[i]-A[i+j]+dp[i+j]);
      |               ~                             ^
      |                                             )
Language: C++

#include <bits/stdc++.h>
using namespace std;
int frog(vector<int> A)
{
  int n=A.size();
  if(n<=1)
    return 0;
  if(n==2)
    return abs(A[0]-A[1]);
  int dp[n];
  memset(dp,0,sizeof(dp));
  dp[n-1]=0;
  dp[n-2]=abs(A[n-1]-A[n-2]);
  for(int i=n-3;i>=0;i--)
  {
    int mini=INT_MAX;
    for(int j=1;j<=k && i+j<n;j++)
    {
      mini=min(mini,abs(A[i]-A[i+j]+dp[i+j]);
    }
    dp[i]=mini;
  }
   return dp[0];
}
int main()
{
  int N,k;
  cin>>N>>k;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin>>A[i];
  cout<<frog(A);
  return 0;
}

Compiler output:
a.cc: In function 'int frog(std::vector<int>)':
a.cc:17:20: error: 'k' was not declared in this scope
   17 |     for(int j=1;j<=k && i+j<n;j++)
      |                    ^
a.cc:19:45: error: expected ')' before ';' token
   19 |       mini=min(mini,abs(A[i]-A[i+j]+dp[i+j]);
      |               ~                             ^
      |                                             )
Language: C++

#include <iostream>
#include <cmath>
using namespace std;
int v[500001],n,k;
int pd[1000001] = {INT_MAX};
main ()
{
    cin>>n>>k;
    for (int i = 1;i<=n;++i)
        cin>>v[i];
    pd[1]=0;
    for (int i = 2;i<=n;++i)
    {
        pd[i]=INT_MAX;
        for (int j = 1;j<=k;++j)
            if (i>j)
                pd[i]=min(pd[i],pd[i-j]+(int)abs(v[i]-v[i-j]));
    }
    cout<<pd[n];
    return 0;
}


Compiler output:
a.cc:5:20: error: 'INT_MAX' was not declared in this scope
    5 | int pd[1000001] = {INT_MAX};
      |                    ^~~~~~~
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 | using namespace std;
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main ()
      | ^~~~
a.cc: In function 'int main()':
a.cc:14:15: error: 'INT_MAX' was not declared in this scope
   14 |         pd[i]=INT_MAX;
      |               ^~~~~~~
a.cc:14:15: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: C++

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

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


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

#include <iostream> 
#include <algorithm> 
#include <vector> 

using namespace std; 
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int n,k; 
	cin>>n>>k; 
	vector <int> a(n); 
	for (int i=0; i<n; i++) cin>>a[i]; 
	vector <int> dp(n, 10000); dp[0]=0; 
	for (int i=0; i<n; i++){
		for (int j=1; j<k && (i+j)<n; j++){
			dp[i+j]=min(dp[i+j], dp[i]+abs(a[i+j]-a[i]); 
		}
	}
	cout<<dp[n-1]<<"\n"; 
	return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:68: error: expected ')' before ';' token
   17 |                         dp[i+j]=min(dp[i+j], dp[i]+abs(a[i+j]-a[i]);
      |                                    ~                               ^
      |                                                                    )
Language: Java

import java.util.*;
import java.io.*;
import java.lang.*;
public class attack{
    public static void main(String []args){
        Scanner in = new Scanner (System.in);
        int n;
        long k;
        n = in.nextInt();
        k = in.nextLong();
        int []arr = new int[n+5];
        arr[0] = 0;
        for(int i=1;i<=n;i++)
            arr[i] = in.nextInt();
        long []dp = new long[n+5];
        for(int i=0;i<n+5;i++)
            dp[i] = 1000000007;
        dp[0] = 0;
        dp[1] = 0;
        dp[2] = Math.abs(arr[2] - arr[1]);
        for(int i=3;i<=n;i++){
            for(int j=1;j<=k;j++){
                if(i-j >= 1)
                dp[i] = Math.min(dp[i-j]+Math.abs(arr[i] - arr[i-j]), dp[i]);
            }

            //System.out.println("Final value --> " + dp[i] + " ");
        }
        //System.out.println();
        System.out.println(dp[n]);
    }
}

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

#include <iostream> 
#include <algorithm> 
#include <vector> 

using namespace std; 
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int n,k; 
	cin>>n>>k; 
	vector <int> a(n); 
	for (int i=0; i<n; i++) cin>>a[i]; 
	vector <int> dp(n, 10000); dp[0]=0; 
	for (int i=0; i<n; i++){
		for (int j=1; j<=k && (i+j)<n; j++){
			dp[i+j]=min(dp[i+j], dp[i]+abs(a[i+j]-a[i]); 
		}
	}
	cout<<dp[n-1]<<"\n"; 
	return 0; 
}


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

#include <iostream> 
#include <algorithm> 
#include <vector> 

using namespace std; 
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); 
	int n,k; 
	cin>>n>>k; 
	vector <int> a(n); 
	for (int i=0; i<n; i++) cin>>a[i]; 
	vector <int> dp(n, 10000); dp[0]=0; 
	for (int i=0; i<n; i++){
		for (int j=1; j<k && (i+j)<n; j++){
			dp[i+j]=min(dp[i+j], dp[i]+abs(a[i+j]-a[i]); 
		}
	}
	cout<<dp[n-1]<<"\n"; 
	return 0; 
}


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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n,k; 
	cin>>n>>k;
	vector<ll> v(n),dp(n,99999);
	for(int i=0; i<n; i++)
		cin>>v[i]; a
	dp[0]=0;
	for(ll i=0; i<n; i++)
	{
		for(ll j=i+1; j<=i+k; j++)
			if(j<n)
				dp[j] = min(dp[j],dp[i] + abs(v[i]-v[j]));
	}
	cout<<dp[n-1];
	return 0;
}
	

Compiler output:
a.cc: In function 'int main()':
a.cc:28:28: error: 'a' was not declared in this scope
   28 |                 cin>>v[i]; a
      |                            ^
Language: C++

#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
int h[200000];
int dp[200000];
 
int main()
{
  int n=0,k=0;scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)scanf("%d",&h[i]);
  dp[1]=0;
  for(int i=2;i<=n;i++)
  {
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    for(int j=2;j<=k&&j<i;j++)dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
  printf("%d",dp[n]);return 0;
}

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

#include <iostream>
#include <vector>
using namespace std;
 
#define INF 1050000000
 
int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }
  vector<int>c(N,INF);
  c[0]=0;
  for (int i=0;i<N;i++){
    for (int k=0;k<=min(i,K);k++){
      c[i]=min(c[i],c[i-k]+abs(h[i]-h[i-k]));
    }
  }
  cout<<N[N-1]<<endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:21:10: error: invalid types 'int[int]' for array subscript
   21 |   cout<<N[N-1]<<endl;
      |          ^
Language: Java

import java.util.*;
import java.io.*;

public class frog2 {
    static int k;
    static int[] heights;
    static int[] dp;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //BufferedReader br = new BufferedReader(new FileWriter("frog2.in");
        //StringTokenizer st = new StringTokenizer(br.readLine());
        //PrintWriter pw = new PrintWriter("frog2.out");

        int n = sc.nextInt();
        k = sc.nextInt();

        heights = new int[n+1];
        dp = new int[n+1];
        Arrays.fill(dp, -1);
        for(int x = 1; x<=n; x++){
            heights[x] = sc.nextInt();
        }
        System.out.println(jump(n));
        //System.out.println(Arrays.toString(heights));


    }

    public static int jump(int n){
        if(dp[n] != -1)
            return dp[n];
        if(n == 1)
            return dp[n] = 0;
        int min = Integer.MAX_VALUE;
        for(int x = k; x >= 1; x--){
            if(n - x >= 1){
                min = Math.min(min, jump(n - x) + Math.abs(heights[n] - heights[n - x]));
            }
        }

        return dp[n] = min;
    }
}


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

#include<iostream>
#include<cstring>
using namespace std;
int n,m;
int a[100005],b[100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i];
	b[0]=b[1]=0;
	for(int i=2;i<=n;i++){
		b[i]=INT_MAX;
		for(int j=1;j<=m&&j<=n;j++){
			b[i]=min(b[i],b[i-j]+abs(a[i-j]-a[i]));
		}
	}
	cout<<b[n];
	return 0;
}

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

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>

using namespace std;

typedef long long ll;

#define rep(i,n) for(int i=0;i<(n);i++)


vector<ll> cost(100007,-1);
vector<ll> memo(100007,-1);
ll K;

ll dp(ll n){
    ll c=K,check=9999999;
    if(n<=0) return 0;
    if(memo[n]!=-1) return memo[n];
    else memo[n]=check;
    else if(n<K) c=n;
    for(ll i=1;i<=c;i++){
        memo[n]=min(dp(n-i)+abs(cost[n]-cost[n-i]),memo[n]);
    }
    return memo[n]=check;
}

int main(){
    int N;
    cin>>N>>K;
    rep(i,N) cin>>cost[i];
    memo[0]=0;
    cout<<dp(N-1)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'll dp(ll)':
a.cc:28:5: error: 'else' without a previous 'if'
   28 |     else if(n<K) c=n;
      |     ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define pint pair<int,int>
#define Lower(v,X) lower_bound(v.begin(),v.end(),X)-v.begin();
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(){
   lli A,B,C,L,R,N,M,K,X=0,Y=0,W,H=INF,sum=0,num=0,flag=0;string S,T,O;
   cin >> N >> M;
   Vec(P,lli,N,0);
   Vec(DP,lli,10000,INF);
   DP[0]=0;
   rep(i,0,N)cin >> P[i];
   rep(i,0,N){
      rep(j,1,M+1){
         if(i+j>N-1)continue;
         chmin(DP[i+j],DP[i]+abs(P[i+j]-P[i]));
      }
      Out(DP[N-1]);
   }

Compiler output:
a.cc: In function 'int main()':
a.cc:39:5: error: expected '}' at end of input
   39 |    }
      |     ^
a.cc:26:11: note: to match this '{'
   26 | int main(){
      |           ^