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

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e2+10;




    




int main(int argc,const char** argv){

	//fastio;

	int N,Kesimo;

	cin >> N;
	cin >> Kesimo;

	vector<int>; v(N),Costos(N,INF);

	Costos[0] = 0;

	for(int &x:v) {
        cin >> x;
    }
 for(int i =0; i < N; (i)++){
		for(int j=i+1;j <= i+Kesimo && j < N ;j++){
			if(j < N) Costos[j] = min(Costos[j],Costos[i] + abs(v[i]-v[j]));
		}
	}

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

	return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:27:9: error: declaration does not declare anything [-fpermissive]
   27 |         vector<int>; v(N),Costos(N,INF);
      |         ^~~~~~~~~~~
a.cc:27:22: error: 'v' was not declared in this scope
   27 |         vector<int>; v(N),Costos(N,INF);
      |                      ^
a.cc:27:27: error: 'Costos' was not declared in this scope
   27 |         vector<int>; v(N),Costos(N,INF);
      |                           ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;


const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e2+10;




    




int main(int argc,const char** argv){

	//fastio;

	int N,Kesimo;

	cin >> N;
	cin >> Kesimo;

	vector<int>; v(N),Costos(N,INF);

	Costos[0] = 0;

	for(int &x:v) {
        cin >> x;
    }
 for(int i =0; i < N; (i)++){
		for(int j=i+1;j <= i+Kesimo && j < N ;j++){
			if(j < N) Costos[j] = min(Costos[j],Costos[i] + abs(v[i]-v[j]));
		}
	}

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

	return 0;
}

Compiler output:
a.cc:7:7: error: 'll' does not name a type
    7 | const ll LINF = 0x3f3f3f3f3f3f3fLL;
      |       ^~
a.cc: In function 'int main(int, const char**)':
a.cc:27:9: error: declaration does not declare anything [-fpermissive]
   27 |         vector<int>; v(N),Costos(N,INF);
      |         ^~~~~~~~~~~
a.cc:27:22: error: 'v' was not declared in this scope
   27 |         vector<int>; v(N),Costos(N,INF);
      |                      ^
a.cc:27:27: error: 'Costos' was not declared in this scope
   27 |         vector<int>; v(N),Costos(N,INF);
      |                           ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
  
int mood(int a){
if(a>0)return a;
a=a*(-1);
return a;
}
  
  int main(){
int n,k,mn=1000000;
cin>>n>>k;
int arr[n];
for(int i=0;i<n;i++)cin>>arr[i];
int cost [n];
cost[0]=0;
cost[1]=mood(arr[0]-arr[1]);
for(int i=2;i<n;i++){mn=INTMAX;
  for(int j=1;j<k && i-j>=1;j++){
  mn=min(mn,min( cost[i-j]+mood(arr[i]-arr[i-j])  ,  cost[i-j-1]+mood(arr[i]-arr[i-j-1])));
  }cost[i]=mn;
}
  cout<<cost[n-1];
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:25: error: 'INTMAX' was not declared in this scope; did you mean 'INT_MAX'?
   18 | for(int i=2;i<n;i++){mn=INTMAX;
      |                         ^~~~~~
      |                         INT_MAX
Language: C++

n = int(raw_input())
arr = map(int,raw_input().split())
dp = [float("inf")]*(n)
dp[0]=0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j < n: 
            dp[j] = min(dp[j], dp[i]+abs(arr[i]-arr[j]))
print dp[n-1]

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = int(raw_input())
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

int k;
vector<int> h;
vector<int> dp;
int cost(int i, int j) {
	return abs(h[i] - h[j]);
}
// bottom up
// int main() {
// 	int n;
// 	cin>>n;
// 	h.resize(n);
// 	for(int i=0; i<n; i++) {
// 		cin>>h[i];
// 	}
// 	dp.resize(n);
// 	dp[0] = 0;
// 	dp[1] = abs(h[0]-h[1]);
// 	for(int i=2; i<n; i++) {
// 		dp[i] = min(dp[i-1] + cost(i,i-1), dp[i-2] + cost(i,i-2));
// 	}
// 	cout<<dp[n-1]<<endl;
// 	return 0;
// }

//top down
int func(int idx) {
	if(idx>=dp.size() || idx<0)
		return INT_MAX;
	if(dp[idx]!=-1)
		return dp[idx];
	if(idx==0)
		return dp[0] = 0;
	dp[idx] = func(idx-1) + cost(idx,idx-1)
	for(int i=2; i<=k; i++)
		dp[idx] = min(dp[idx], func(idx-i) + cost(idx,idx-i));
	return dp[idx];
}

int main() {
	int n;
	cin>>n>>k;
	h.resize(n);
	for(int i=0; i<n; i++) {
		cin>>h[i];
	}
	dp.resize(n,-1);
	cout<<func(n-1)<<endl;
	return 0;
}



Compiler output:
a.cc: In function 'int func(int)':
a.cc:37:48: error: expected ';' before 'for'
   37 |         dp[idx] = func(idx-1) + cost(idx,idx-1)
      |                                                ^
      |                                                ;
   38 |         for(int i=2; i<=k; i++)
      |         ~~~                                     
a.cc:38:22: error: 'i' was not declared in this scope
   38 |         for(int i=2; i<=k; i++)
      |                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1LL << 60
template<class T> inline bool chmin(T& a,T b){
    if( a > b) {a = b; return 1; } return 0;
}
int dp[100001];
int h[100001];
signed main(){
    int n,k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < 100001; i++){
        dp[i] == INF;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            chmin(dp[i + j],dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1] << endl;
}

Compiler output:
a.cc:5:1: error: expected ',' or ';' before 'template'
    5 | template<class T> inline bool chmin(T& a,T b){
      | ^~~~~~~~
a.cc: In function 'int main()':
a.cc:22:13: error: 'chmin' was not declared in this scope
   22 |             chmin(dp[i + j],dp[i] + abs(h[i] - h[i + j]));
      |             ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF = 1LL << 60
template<class T> inline bool chmin(T& a,T b){
    if( a > b) {a = b; return 1; } return 0;
}
int dp[100001];
int h[100001];
signed main(){
    int n,k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < 100001; i++){
        dp[i] == INF;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            chmin(dp[i + j],dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:13: error: expected primary-expression before '=' token
    4 | #define INF = 1LL << 60
      |             ^
a.cc:17:18: note: in expansion of macro 'INF'
   17 |         dp[i] == INF;
      |                  ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int n = 100005,k;
vector<int> h(n);
vector<int> dp(n,-1);

int dfs(int i){
  int res = INF;
  for(int j=1;j<=k;j++){
    if(i-j>=0){
      if(dp.at(i-j) == -1) dp.at(i-j) = dfs(i-j);
      res = min(res,dp.at(i-j)+abs(h.at(i)-h.at(i-j)));
    }
  }
  return res;
}
  




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

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> v(n),dp(n,1e9);
    for(int i=0;i<n;i++)
        cin>>v[i];
    dp[0]=0;
    for(int i=1;i<n;i++)
        for(int j=1;j<=k;j++)
            if(i-j>=0) dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
    cout<<dp[n-1]<<'\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
    4 |     cin>>n>>k;
      |     ^~~
a.cc:5:5: error: 'vector' was not declared in this scope
    5 |     vector<int> v(n),dp(n,1e9);
      |     ^~~~~~
a.cc:5:12: error: expected primary-expression before 'int'
    5 |     vector<int> v(n),dp(n,1e9);
      |            ^~~
a.cc:7:14: error: 'v' was not declared in this scope
    7 |         cin>>v[i];
      |              ^
a.cc:8:5: error: 'dp' was not declared in this scope
    8 |     dp[0]=0;
      |     ^~
a.cc:11:46: error: 'v' was not declared in this scope
   11 |             if(i-j>=0) dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
      |                                              ^
a.cc:11:42: error: 'abs' was not declared in this scope
   11 |             if(i-j>=0) dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
      |                                          ^~~
a.cc:11:30: error: 'min' was not declared in this scope; did you mean 'main'?
   11 |             if(i-j>=0) dp[i]=min(dp[i-j]+abs(v[i]-v[i-j]),dp[i]);
      |                              ^~~
      |                              main
a.cc:12:5: error: 'cout' was not declared in this scope
   12 |     cout<<dp[n-1]<<'\n';
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll arr[100001];
vector<ll> cache(100001,-1);
ll n,k;

ll frog(ll i)
{
	if(cache[i]!=-1)
		return cache[i];
	if(i==n-1)
		return 0;
	if(i>=n)
		return INT_MAX;
	ll cache[i]=INT_MAX;
	for(int j=1;j<=k && j+i<n;j++)
	{
		cache[i] = min(cache[i], abs(arr[i+j]-arr[i]) + frog(i+j));
	}
	return cache[i];
}

int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	cout<<frog(0)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int frog(long long int)':
a.cc:16:21: error: array must be initialized with a brace-enclosed initializer
   16 |         ll cache[i]=INT_MAX;
      |                     ^~~~~~~
Language: C++

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

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

#include <bits/stdc++.h>

#define ll int64
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
     
using namespace std;

const int maxn=110000;
int n,h[maxn],f[maxn];
int main(){
    IO;    
    scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	memset(f,0x3f,sizeof(f)),f[1]=0;
	for(int i=2;i<=n;i++) for(int j=1;j<i&&j<=k;j++) f[i]=min(f[i],f[i-j]+abs(h[i]-h[i-j]));
	printf("%d",f[n]);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:22: error: 'k' was not declared in this scope
   20 |     scanf("%d%d",&n,&k);
      |                      ^
Language: Java

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

public class Frog2 {
    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+1];
        h[0] = 0;

        for(int i=1;i<=N;++i)
            h[i] = sc.nextInt();

        System.out.println(solution(N, K, h));
    }

    private static int solution(int n, int k, int[] heights) {
        int[] A = new int[n+1];
        A[0] = 0;
        A[1] = heights[1-1];
        A[2] = Math.abs(heights[2] - heights[1]);

        for(int i=3;i<n+1;++i) {
            Integer[] possibilities = new Integer[k];
            for(int j=0;j<k;++j)
                possibilities[j] = Integer.MAX_VALUE;
            for(int j=0;j<k;++j) {
                if (i-j-1 < 0)
                    break;
                possibilities[j] = Math.abs(heights[i] - heights[i - j - 1]) + A[i - j - 1];
            }

            A[i] = Collections.min(Arrays.asList(possibilities));
        }

        return A[n];
    }
}


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

#include<bits/stdc++.h>

using namespace std;
int a[100010],dp[100010];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=1000101;
        for(int j=1;j<=k;j++)
        {
            if(i-j<=0)
              break;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    	
		cout<<dp[i]<<endl;
	
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:26: error: 'i' was not declared in this scope
   23 |                 cout<<dp[i]<<endl;
      |                          ^
Language: C++

#include<iostream>
#include<cmath>
using namespace std;
int a[100010],dp[100010];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=10001010;
        for(int j=1;j<=k;j++)
        {
            if(i-j<=0)break;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
        }
    }
    	
		cout<<dp[i]<<endl;
	
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:22:26: error: 'i' was not declared in this scope
   22 |                 cout<<dp[i]<<endl;
      |                          ^
Language: C++

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

Compiler output:
a.cc:9:18: error: exponent has no digits
    9 |   vector<ll>dp(n,1ef+9);
      |                  ^~~
a.cc:3:1: error: 'typdef' does not name a type; did you mean 'typedef'?
    3 | typdef long long int ll;
      | ^~~~~~
      | typedef
a.cc: In function 'int main()':
a.cc:6:3: error: 'll' was not declared in this scope
    6 |   ll n,k;
      |   ^~
a.cc:7:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |   cin>>n>>k;
      |        ^
      |        yn
a.cc:7:11: error: 'k' was not declared in this scope
    7 |   cin>>n>>k;
      |           ^
a.cc:8:12: error: template argument 2 is invalid
    8 |   vector<ll>v(n,0);
      |            ^
a.cc:8:18: error: expression list treated as compound expression in initializer [-fpermissive]
    8 |   vector<ll>v(n,0);
      |                  ^
a.cc:9:12: error: template argument 2 is invalid
    9 |   vector<ll>dp(n,1ef+9);
      |            ^
a.cc:9:23: error: expression list treated as compound expression in initializer [-fpermissive]
    9 |   vector<ll>dp(n,1ef+9);
      |                       ^
a.cc:10:9: error: expected ';' before 'i'
   10 |   for(ll i=0;i<n;i++)
      |         ^~
      |         ;
a.cc:10:14: error: 'i' was not declared in this scope
   10 |   for(ll i=0;i<n;i++)
      |              ^
a.cc:14:5: error: invalid types 'int[int]' for array subscript
   14 |   dp[0]=0;
      |     ^
a.cc:15:9: error: expected ';' before 'i'
   15 |   for(ll i=1;i<n;i++)
      |         ^~
      |         ;
a.cc:15:14: error: 'i' was not declared in this scope
   15 |   for(ll i=1;i<n;i++)
      |              ^
a.cc:17:11: error: expected ';' before 'j'
   17 |     for(ll j=1;j<=k;j++)
      |           ^~
      |           ;
a.cc:17:16: error: 'j' was not declared in this scope
   17 |     for(ll j=1;j<=k;j++)
      |                ^
Language: C++

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

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

  dp[0] = 0;
  for(int i = 1; i < n; i++) {
    dp[i] = INT_MAX;
    for(int j = 1; j <= k; j++) {
      int cost = i-k >= 0 ? dp[i-k] + abs(h[i-k]-h[1]) : INT_MAX;
      dp[i] = min(dp[i], cost); 
    }a
  } 
  
  cout << dp[n-1];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:6: error: 'a' was not declared in this scope
   15 |     }a
      |      ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string>
#include <utility>
#include <functional>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
int dp[100200]{999999};

int main(){
    int N,K;
    cin>>N>>K;
    vector<int>h(N+1);
    rep(i,N) cin>>h[i+1];
    for(int i=1;i<N;i++){
        for(int k=1;k<=K;k++){
            dp[i+k]=min(dp[i+k],dp[i]+abs(h[i]-h[i+k]));
        }
    }
    cout<<dp[N];


Compiler output:
a.cc: In function 'int main()':
a.cc:23:17: error: expected '}' at end of input
   23 |     cout<<dp[N];
      |                 ^
a.cc:13:11: note: to match this '{'
   13 | int main(){
      |           ^
Language: C++

	int n;
	int k;
	int x;
	cin>>n>>k;
	int a[n] = {0};
	for(int i = 0; i < n; i++) {
	    cin>>a[i];
	}
	int min = INT_MAX;
	int dp[n] = {0};
	dp[0] = a[0];
	dp[1] = abs(a[1] - a[0]);
	for(int i = 2; i < n; i++) {
	     min = INT_MAX;
	    for(int j = i - 1; j >= i - k && j >= 0; j--) {
	        
	         if(j == 0) x = abs(a[i] - a[j]);
	         else {
	             x = abs(a[i] - a[j]) + dp[j];
	             
	         }
	         if(x < min) min = x;
	    
	}   dp[i] = min;
	
	}

	cout<<dp[n - 1];
	
	
	
	
	


Compiler output:
a.cc:4:9: error: 'cin' does not name a type
    4 |         cin>>n>>k;
      |         ^~~
a.cc:5:15: error: size of array 'a' is not an integral constant-expression
    5 |         int a[n] = {0};
      |               ^
a.cc:6:9: error: expected unqualified-id before 'for'
    6 |         for(int i = 0; i < n; i++) {
      |         ^~~
a.cc:6:24: error: 'i' does not name a type
    6 |         for(int i = 0; i < n; i++) {
      |                        ^
a.cc:6:31: error: 'i' does not name a type
    6 |         for(int i = 0; i < n; i++) {
      |                               ^
a.cc:9:19: error: 'INT_MAX' was not declared in this scope
    9 |         int min = INT_MAX;
      |                   ^~~~~~~
a.cc:1:8: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
  +++ |+#include <climits>
    1 |         int n;
a.cc:10:16: error: size of array 'dp' is not an integral constant-expression
   10 |         int dp[n] = {0};
      |                ^
a.cc:11:9: error: 'dp' does not name a type
   11 |         dp[0] = a[0];
      |         ^~
a.cc:12:9: error: 'dp' does not name a type
   12 |         dp[1] = abs(a[1] - a[0]);
      |         ^~
a.cc:13:9: error: expected unqualified-id before 'for'
   13 |         for(int i = 2; i < n; i++) {
      |         ^~~
a.cc:13:24: error: 'i' does not name a type
   13 |         for(int i = 2; i < n; i++) {
      |                        ^
a.cc:13:31: error: 'i' does not name a type
   13 |         for(int i = 2; i < n; i++) {
      |                               ^
a.cc:28:9: error: 'cout' does not name a type
   28 |         cout<<dp[n - 1];
      |         ^~~~
Language: C++

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

long long n,a,m,b,qq,k;
string ss;
int main() {
    cin>>n>>k;
    long long l[n],l1[n];
    for (int i=0; i<=n; i++){
        l[i]=0;
        l1[i]=0;
    }
    for (int i=0; i<n; i++){
        cin>>l[i];
    }
    for (int i=1; i<n; i++){
        l1[i]=l1[i-1]+abs(l[i-1]-l[i]);
        for (int j=1; j<=min(i,k); j++){
            l1[i]=min(l1[i], l1[i-j]+abs(l[i-j]-l[i]));
        }
    }
    cout<<max(0*1ll,l1[n-1])<<endl;
}


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

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

long long n,a,m,b,qq,k;
string ss;
int main() {
    cin>>n>>k;
    long long l[n],l1[n];
    for (int i=0; i<=n; i++){
        l[i]=0;
        l1[i]=0;
    }
    for (int i=0; i<n; i++){
        cin>>l[i];
    }
    for (int i=1; i<n; i++){
        l1[i]=l1[i-1]+abs(l[i-1]-l[i]);
        for (int j=1; j<=k; j++){
            l1[i]=min(l1[i], l1[i-j]+abs(l[i-j]-l[i]));
        }
    }
    cout<<max(0,l1[n-1])<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:14: error: no matching function for call to 'max(int, long long int&)'
   22 |     cout<<max(0,l1[n-1])<<endl;
      |           ~~~^~~~~~~~~~~
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:22:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   22 |     cout<<max(0,l1[n-1])<<endl;
      |           ~~~^~~~~~~~~~~
/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:22:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |     cout<<max(0,l1[n-1])<<endl;
      |           ~~~^~~~~~~~~~~
Language: C

#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,k,t;
  scanf("%d %d",&n,&k);
  int arr[n],min;
  int dp[n];
  for(int i=0;i<n;i++){
  scanf("%d",&arr[i]);
  }
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++){
    min=INT_MAX;
  for(int j=i-1;j>=i-k&&j>=0;j--){
  t=abs(arr[i]-arr[j])+dp[j];
    if(t<min){
    min=t;
    }
  }
    dp[i]=min;
  }
  printf("%d",dp[n-1]);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:14:9: error: 'INT_MAX' undeclared (first use in this function)
   14 |     min=INT_MAX;
      |         ^~~~~~~
main.c:3:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    2 | #include<stdlib.h>
  +++ |+#include <limits.h>
    3 | int main(){
main.c:14:9: note: each undeclared identifier is reported only once for each function it appears in
   14 |     min=INT_MAX;
      |         ^~~~~~~
Language: C++

#include <iostream>
using namespace std;
int n, k;
int dp[10000];
int a[10000];
int frog2(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+frog2(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+frog2(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) {cin>>a[i]; dp[i]=-1;}

	cout<<f(0)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:15: error: 'f' was not declared in this scope
   19 |         cout<<f(0)<<endl;
      |               ^
Language: C++

#include <iostream>

using namespace std;
const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) {cin>>a[i]; dp[i]=-1}

	cout<<f(0)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:52: error: expected ';' before '}' token
   19 |         for(int i=0; i<n; i++) {cin>>a[i]; dp[i]=-1}
      |                                                    ^
      |                                                    ;
Language: C++

#include <iostream>

using namespace std;
const int nax = 1e5+103;
int n, k;
int dp[nax];
int a[nax];
int f(int i){
	if (i==n-1) return 0;
	if(dp[i]!=-1) return dp[i];
	int ans = abs(a[i]-a[i+1])+f(i+1);
	for(int j=2; j<=k; j++){
		if(i+j<n) ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}
int main(){
	cin>>n>>k;
	for(int i=0; i<n; i++) cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:9: error: 'memset' was not declared in this scope
   20 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  
 long long int n,k;
  cin>>n>>k;
 long long int arr[n+1];
  for(int i=1;i<=n;i++)
    cin>>arr[i];
 long long int minm[n+1];
  minm[2]=abs(arr[2]-arr[1]);
  minm[1]=0;
  for(int j=3;j<=n;j++)
  {
    long long int h=j-k;
    h=max(1,h);
    minm[j]=pow(10,8);
    while(h<j)
    {
     minm[j]=min(minm[h]+abs(arr[h]-arr[j]),minm[j]);
      h++;
    }
  }
  cout<<minm[n]<<endl;
  return 0;
}

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

import java.util.Arrays;
import java.util.Scanner;
public class Solution
{
	static final long mod=(long)1e18;
	public static void main(String [] args)
	{
		Scanner s=new Scanner(System.in);    
		int N=s.nextInt();		
		int K=s.nextInt();	
		int h[]=new int[N];
		for(int i=0;i<N;i++)
		{
			h[i]=s.nextInt();
		}
		int dp[]=new int[N];
		Arrays.fill(dp,-1);
		dp[0]=0;
		int i=0,d=0;
		while(i<N-1)
		{
			int j=1;
			while(j<=K)
			{
				if(i+j<N)
				{
					d=Math.abs(h[i]-h[i+j])+dp[i];
					if(dp[i+j]==-1)
						dp[i+j]=d;
					else
						if(dp[i+j]>d)
							dp[i+j]=d;
				}
				else
					break;
				j+=1;
			}
			i+=1;
		}
		System.out.println(dp[N-1]);

	}
}




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

import java.util.*;
import java.io.*;
public class Solution
{
	static final long mod=(long)1e18;
	public static void main(String [] args)
	{
		Scanner s=new Scanner(System.in);    
		int N=s.nextInt();		
		int K=s.nextInt();	
		int h[]=new int[N];
		for(int i=0;i<N;i++)
		{
			h[i]=s.nextInt();
		}
		int dp[]=new int[N];
		Arrays.fill(dp,-1);
		dp[0]=0;
		int i=0,d=0;
		while(i<N-1)
		{
			int j=1;
			while(j<=K)
			{
				if(i+j<N)
				{
					d=Math.abs(h[i]-h[i+j])+dp[i];
					if(dp[i+j]==-1)
						dp[i+j]=d;
					else
						if(dp[i+j]>d)
							dp[i+j]=d;
				}
				else
					break;
				j+=1;
			}
			i+=1;
		}
		System.out.println(dp[N-1]);

	}
}




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

import java.util.*;
import java.io.*;
public class Solution
{
	static final long mod=(long)1e18;
	public static void main(String [] args)
	{
		FastReader s=new FastReader();    
		int N=s.nextInt();		
		int K=s.nextInt();	
		int h[]=new int[N];
		for(int i=0;i<N;i++)
		{
			h[i]=s.nextInt();
		}
		int dp[]=new int[N];
		Arrays.fill(dp,-1);
		dp[0]=0;
		int i=0,d=0;
		while(i<N-1)
		{
			int j=1;
			while(j<=K)
			{
				if(i+j<N)
				{
					d=Math.abs(h[i]-h[i+j])+dp[i];
					if(dp[i+j]==-1)
						dp[i+j]=d;
					else if(dp[i+j]>d)
							dp[i+j]=d;
				}
				else
					break;
				j+=1;
			}
			i+=1;
		}
		System.out.println(dp[N-1]);

	}
}


public class FastReader
{
	BufferedReader br;
	StringTokenizer st;
	public FastReader()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	String next()
	{
		while(st==null || !st.hasMoreElements())
		{
			try
			{
				st =new StringTokenizer(br.readLine());
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}
	String nextLine()
	{
		String str=" ";
		try
		{
			str=br.readLine();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
		return str;
	}
	int nextInt()
	{
		return Integer.parseInt(next());
	}
	long nextLong()
	{
		return Long.parseLong(next());
	}
	float nextFloat()
	{
		return Float.parseFloat(next());
	}
	double nextDouble()
	{
		return Double.parseDouble(next());
	}
}

Compiler output:
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution
       ^
Main.java:45: error: class FastReader is public, should be declared in a file named FastReader.java
public class FastReader
       ^
2 errors
Language: Java

import java.util.*;
import java.io.*;
public class Solution
{
	static final long mod=(long)1e18;
	public static void main(String [] args)
	{
		FastReader s=new FastReader();    
		int N=s.nextInt();		
		int K=s.nextInt();	
		int h[]=new int[N];
		for(int i=0;i<N;i++)
		{
			h[i]=s.nextInt();
		}
		int dp[]=new int[N];
		Arrays.fill(dp,-1);
		dp[0]=0;
		int i=0,d=0;
		while(i<N-1)
		{
			int j=1;
			while(j<=K)
			{
				if(i+j<N)
				{
					d=Math.abs(h[i]-h[i+j])+dp[i];
					if(dp[i+j]==-1)
						dp[i+j]=d;
					else
						if(dp[i+j]>d)
							dp[i+j]=d;
				}
				else
					break;
				j+=1;
			}
			i+=1;
		}
		System.out.println(dp[N-1]);

	}
}


class FastReader
{
	BufferedReader br;
	StringTokenizer st;
	public FastReader()
	{
		br=new BufferedReader(new InputStreamReader(System.in));
	}
	String next()
	{
		while(st==null || !st.hasMoreElements())
		{
			try
			{
				st =new StringTokenizer(br.readLine());
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}
		}
		return st.nextToken();
	}
	String nextLine()
	{
		String str=" ";
		try
		{
			str=br.readLine();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
		return str;
	}
	int nextInt()
	{
		return Integer.parseInt(next());
	}
	long nextLong()
	{
		return Long.parseLong(next());
	}
	float nextFloat()
	{
		return Float.parseFloat(next());
	}
	double nextDouble()
	{
		return Double.parseDouble(next());
	}
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:7:38: error: expected ';' before 'for'
    7 |     memset(dp, sizeof(dp), 100000000)
      |                                      ^
      |                                      ;
    8 |     for(i=0;i<n;++i) cin >> h[i];
      |     ~~~                               
a.cc:8:20: error: expected ';' before ')' token
    8 |     for(i=0;i<n;++i) cin >> h[i];
      |                    ^
      |                    ;
Language: C++

#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];
  if(n<k){
      cout<<"0";
  }
  else if(n==k || n==k+1){
      cout<<"a[n-1]-a[0]";
  }
  else{
  int b[n];
  b[0]=0;
  for(int i=1;i<=k;i++){
  b[i]=abs(a[i]-a[0]); 
  }  
  for(int i=2;i<n;i++){
    b[i]=100002;
    for(int j=1;j<=k;j++){
      if(i-j>=0){
      b[i]=min(b[i]b[i-j]+abs(a[i]-a[i-j]));
      }
    }
    //b[i]=min;
    }
  cout<<b[n-1];
  }
}

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

#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 dp[n+1];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=INT_MAX;
    for(int j=1;j<=k;j++)
    {
      if((i-j)>=0)
      {
        dp[i]=min(dp[i],dp[i-j]+abs(a[i]+a[i-j]);
      }
    }
   }
     cout<<dp[n-1]<<"\n";
        
  
}

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

    b=c;
    c=a%b;
  }
  return b;
}

//最小公倍数
int lcm(int a,int b){
  return (a*b)/gcd(a,b);
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b[1000000],d,e;
    int c[100000]={};
    cin>>a>>d;
    for(int i=0;i<a;i++) cin>>b[i];
    c[1]=abs(b[0],b[1]);
    for(int i=2;i<a;i++){
      for(int j=1;j<=d;j++){
	if(j==1) e=abs(b[i],b[i-j])+c[i-j];
	else{
	  e=min(e,abs(b[i],b[i-j])+c[i-j]);
	}
      }
      c[i]=e;
    }
    cout<<c[a-1]<<"\n";
}


Compiler output:
a.cc:1:5: error: 'b' does not name a type
    1 |     b=c;
      |     ^
a.cc:2:5: error: 'c' does not name a type
    2 |     c=a%b;
      |     ^
a.cc:3:3: error: expected declaration before '}' token
    3 |   }
      |   ^
a.cc:4:3: error: expected unqualified-id before 'return'
    4 |   return b;
      |   ^~~~~~
a.cc:5:1: error: expected declaration before '}' token
    5 | }
      | ^
a.cc: In function 'int lcm(int, int)':
a.cc:9:16: error: 'gcd' was not declared in this scope
    9 |   return (a*b)/gcd(a,b);
      |                ^~~
a.cc: In function 'int main()':
a.cc:12:5: error: 'cin' was not declared in this scope
   12 |     cin.tie(0);
      |     ^~~
a.cc:13:5: error: 'ios' has not been declared
   13 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:18:10: error: 'abs' was not declared in this scope
   18 |     c[1]=abs(b[0],b[1]);
      |          ^~~
a.cc:23:13: error: 'min' was not declared in this scope; did you mean 'main'?
   23 |           e=min(e,abs(b[i],b[i-j])+c[i-j]);
      |             ^~~
      |             main
a.cc:28:5: error: 'cout' was not declared in this scope
   28 |     cout<<c[a-1]<<"\n";
      |     ^~~~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:14:50: error: expected ';' before '}' token
   14 |         dp[i]=min(dp[i],abs(h[i]-h[i-j])+dp[i-j])
      |                                                  ^
      |                                                  ;
   15 |           }
      |           ~                                       
a.cc:18:2: error: expected '}' at end of input
   18 | }
      |  ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

int a[nax];

int f(int i)
{
	if (i==n-1) 
                  return ;
 
	if(dp[i]!=-1) 
                  return dp[i];

	int ans = abs(a[i]-a[i+1])+f(i+1);

	for(int j=2; j<=k; j++)
        {
		if(i+j<n) 
                         ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
	}
	return dp[i]=ans;
}

void main()
{
	cin>>n>>k;
 	for(int i=0; i<n; i++) 
                 cin>>a[i];
	memset(dp, -1, sizeof dp);
	cout<<f(0)<<endl;
	return 0;
}

Compiler output:
a.cc:1:7: error: 'nax' was not declared in this scope
    1 | int a[nax];
      |       ^~~
a.cc: In function 'int f(int)':
a.cc:5:16: error: 'n' was not declared in this scope
    5 |         if (i==n-1)
      |                ^
a.cc:6:19: error: return-statement with no value, in function returning 'int' [-fpermissive]
    6 |                   return ;
      |                   ^~~~~~
a.cc:8:12: error: 'dp' was not declared in this scope
    8 |         if(dp[i]!=-1)
      |            ^~
a.cc:11:23: error: 'a' was not declared in this scope
   11 |         int ans = abs(a[i]-a[i+1])+f(i+1);
      |                       ^
a.cc:11:19: error: 'abs' was not declared in this scope; did you mean 'ans'?
   11 |         int ans = abs(a[i]-a[i+1])+f(i+1);
      |                   ^~~
      |                   ans
a.cc:13:25: error: 'k' was not declared in this scope
   13 |         for(int j=2; j<=k; j++)
      |                         ^
a.cc:15:24: error: 'n' was not declared in this scope
   15 |                 if(i+j<n)
      |                        ^
a.cc:16:32: error: 'min' was not declared in this scope
   16 |                          ans = min(ans, abs(a[i]-a[i+j])+f(i+j));
      |                                ^~~
a.cc:18:16: error: 'dp' was not declared in this scope
   18 |         return dp[i]=ans;
      |                ^~
a.cc: At global scope:
a.cc:21:1: error: '::main' must return 'int'
   21 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:23:9: error: 'cin' was not declared in this scope
   23 |         cin>>n>>k;
      |         ^~~
a.cc:23:14: error: 'n' was not declared in this scope
   23 |         cin>>n>>k;
      |              ^
a.cc:23:17: error: 'k' was not declared in this scope
   23 |         cin>>n>>k;
      |                 ^
a.cc:25:23: error: 'a' was not declared in this scope
   25 |                  cin>>a[i];
      |                       ^
a.cc:26:16: error: 'dp' was not declared in this scope
   26 |         memset(dp, -1, sizeof dp);
      |                ^~
a.cc:26:9: error: 'memset' was not declared in this scope
   26 |         memset(dp, -1, sizeof dp);
      |         ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | int a[nax];
a.cc:27:9: error: 'cout' was not declared in this scope
   27 |         cout<<f(0)<<endl;
      |         ^~~~
a.cc:27:21: error: 'endl' was not declared in this scope
   27 |         cout<<f(0)<<endl;
      |                     ^~~~
Language: C++

// 写経AC

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

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

int N;
int K;
long long h[100010];

//DP table
long long dp[100010];

void input(void){
    cin >> N;
    cin >> K;
    for(int i=0; i< N; i++){
        cin >> h[i];
    }
    return;
}

void init(void){
    for(int i=0; i< 100010; i++){
        dp[i]= INF;
    }
    return;
}

void solve(){
    //初期条件
    dp[0] = 0;

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

//            for(int k=0; k<N;k++){
//                cout << " " << dp[k] ;
//            }
//            cout << endl;
//        }
//        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
//        if(i>1){
//            chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
//        }
    }

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

int main(void){
    input();
    init();
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:63:15: error: a function-definition is not allowed here before '{' token
   63 | int main(void){
      |               ^
a.cc:68:2: error: expected '}' at end of input
   68 | }
      |  ^
a.cc:36:13: note: to match this '{'
   36 | void solve(){
      |             ^
Language: C++

#include <iostream>
#define ll long long int
#define endl "\n"

using namespace std;

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

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

#include <bits/stdc++.h>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*(10e5+3))
#define fim '\n'
#define ll long long
#define f first
#define s second
#define debug(x) cout << "DEBUG " << x << endl
using namespace std;
typedef pair<int, int> pii;

int vet[MAXN], dp[MAXN];
int n, c, k;


int main(){
	cin.tie(NULL);
	cout.tie(NULL);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> vet[i];
	
	for(int i = 2; i <= n; i++) {
		for(int j = 1; j <= k && j < i; j++)
		dp[i] = min(dp[i], dp[i-k]+abs(vet[i]-vet[i-k]);
	}
	cout << dp[n] << endl;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:29:64: error: expected ')' before ';' token
   29 |                 dp[i] = min(dp[i], dp[i-k]+abs(vet[i]-vet[i-k]);
      |                            ~                                   ^
      |                                                                )