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

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


Compiler output:
a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:18:36: error: no matching function for call to 'max(int, long long int)'
   18 |          for(long long j=i-1;j>=max(1,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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:18:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   18 |          for(long long j=i-1;j>=max(1,i-k);j--)
      |                                 ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:18:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   18 |          for(long long j=i-1;j>=max(1,i-k);j--)
      |                                 ~~~^~~~~~~
Language: Java

import java.util.*;
public class Main{
    static long[] dp = new long[1000000];
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Arrays.fill(dp, Long.MAX_VALUE);
        dp[0] = 0;
        
        int n = sc.nextInt();
        int h[] = new int[n];

        for(int i=0; i<n; i++) h[i] = sc.nextInt();

        dp[1] = Math.abs(h[0]-h[1]);
        for(int i=2; i<n; i++){
            for(int j=1; j<=k; j++)
            dp[i+j] = Math.min(dp[i+j],dp[i]+Math.abs(h[i]-h[i+j]));
        }
        System.out.println(dp[n-1]);
        
    }
    
}


Compiler output:
Main.java:16: error: cannot find symbol
            for(int j=1; j<=k; j++)
                            ^
  symbol:   variable k
  location: class Main
1 error
Language: C++

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

constexpr int intMax = (1 << 31) - 1;
constexpr int intHalf = intMax / 2; // > 10^9

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> hls(n);
	for (auto& h : hls)cin >> h;
	vector<int> cost_dp(n);
	int minNum;
	cost_dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		minNum = intHalf;
		for (int j = max(0, i - k); j < i; ++j) {
			minNum = min(minNum, cost_dp[j] + abs(hls[i] - hls[j]));
		}
		cost_dp[i] = minNum;
	}

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

Compiler output:
a.cc:7:34: warning: integer overflow in expression of type 'int' results in '2147483647' [-Woverflow]
    7 | constexpr int intMax = (1 << 31) - 1;
      |                        ~~~~~~~~~~^~~
a.cc:7:34: error: overflow in constant expression [-fpermissive]
a.cc:7:36: error: overflow in constant expression [-fpermissive]
    7 | constexpr int intMax = (1 << 31) - 1;
      |                                    ^
Language: C++

import numpy as np
N, K = map(int, input().split(" "))
H = [int(i) for i in input().split(" ")]

cost = np.array([0] + [10**9 for _ in range(N-1)])
for i in range(1,N):
    for j in range(min(i, K)):
        cost[i] = np.min([cost[i], cost[i-j-1] + abs(H[i-j-1] - H[i])])

print(cost[-1])

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

#include <iostream>

int main(){
    long long int INF = 1LL << 60;

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

    long long dp[100100];

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

    for (int i=0; i < 100100; ++i) dp[i] = INF;

    dp[0] = 0;

    for (int i=1; i<N; ++I) {
        for (int j=1; j<=K; ++j) {
            if (dp[i] > dp[i-j] + abs(h[i]-h[i-j])
                dp[i] = dp[i-j] + abs(h[i]-h[i-j]);
        }
    }
    std::cout << dp[N-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:26: error: 'I' was not declared in this scope
   18 |     for (int i=1; i<N; ++I) {
      |                          ^
a.cc:20:51: error: expected ';' before 'dp'
   20 |             if (dp[i] > dp[i-j] + abs(h[i]-h[i-j])
      |                                                   ^
      |                                                   ;
   21 |                 dp[i] = dp[i-j] + abs(h[i]-h[i-j]);
      |                 ~~                                 
a.cc:22:9: error: expected primary-expression before '}' token
   22 |         }
      |         ^
a.cc:21:52: error: expected ')' before '}' token
   21 |                 dp[i] = dp[i-j] + abs(h[i]-h[i-j]);
      |                                                    ^
      |                                                    )
   22 |         }
      |         ~                                           
a.cc:20:16: note: to match this '('
   20 |             if (dp[i] > dp[i-j] + abs(h[i]-h[i-j])
      |                ^
a.cc:22:9: error: expected primary-expression before '}' token
   22 |         }
      |         ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:6: error: 'k' was not declared in this scope
   18 |   dp[k]=abs(niza[k]-niza[0]);
      |      ^
a.cc:21:53: error: no matching function for call to 'min(int)'
   21 |         dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2])),dp[i-k]+abs(niza[i]-niza[i-k]);
      |                                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:21:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   21 |         dp[i]=min(dp[i-1]+abs(niza[i]-niza[i-1]),min(dp[i-2]+abs(niza[i]-niza[i-2])),dp[i-k]+abs(niza[i]-niza[i-k]);
      |                                                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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++

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static int firstKMin = 0 ;
    static Map<Integer, Integer> map = new HashMap<>();
    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();
        }

        firstKMin = IntStream.range(0, k - 1)
                .map(i -> arr[i])
                .min().orElse(0);

        System.out.println(solve(arr, arr.length - 1, k));
    }

    public static int solve(int[] arr, int index, int k) {

        //memoization
        if (map.containsKey(index)) {
            return map.get(index);
        }

        //base case
        if (index <= k - 1) {
            return firstKMin;
        }


        //recursive case
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < k; i++) {
            min = Math.min(min, (solve(arr, index - i, k) + Math.abs(arr[index] - arr[index - i])));
        }
        map.putIfAbsent(index, min);
        return min;
    }


}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.HashMap;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Map;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.stream.IntStream;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 5;
int dp[N], a[N];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i<=n; i++)
        cin >> a[i];
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i<=n; i++) {
        dp[i] = INT_MAX;
        int limit = max(1, i-k);
        for (int j = 1; j<=k; j++) {
            dp[i] = min(dp[i], dp[i-j] + abs(a[i] - a[i-j]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <memory.h>
#include <fstream>

using namespace std;

const int N = 100005;
int n, k, a[N], dp[N];


int main()
{

	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		scanf_s("%d", a + i);
	}

	for (int i = n - 2; i >= 0; i--) 
	{
		dp[i] = 1e9;
		for (int j = 1; j <= k && i + j < n ; j++)
		{
			dp[i] = min(dp[i + j] + abs(a[i] - a[i + j]), dp[i]);
		}
	}

	printf("%d", dp[0]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   21 |                 scanf_s("%d", a + i);
      |                 ^~~~~~~
      |                 scanf
Language: Java

/*
 * 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.
 */
package javaapplication1;

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

/**
 *
 * @author 91968
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException{
        // TODO code application logic here
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
        StringTokenizer st;
        
        st = new StringTokenizer(in.readLine());
        
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        
        st = new StringTokenizer(in.readLine());
        
        int h[] = new int[n];
        
        for(int i = 0; i < n; i++){
        
            h[i] = Integer.parseInt(st.nextToken());
        }
        
        int dp[] = new int[n];
        for(int i = 1; i < n; i++)
            dp[i] = Integer.MAX_VALUE;
                    
        for(int i = 0; i < n; i++){
        
            for(int j = 1; j <= k; j++){
            
                if(i+j < n)
                    dp[i+j] = Math.min(dp[i+j], dp[i]+Math.abs(h[i+j] - h[i]));
            }
        }
        System.out.println(dp[n-1]);
    }
    
}


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

#include <bits/stdc++.h>
using namespace std;
int n,a[100050],dp[100400],k;
int main()
{
    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]=dp[i-1]+abs(a[i]-a[i-1]);
        if ( i > 2 ){
         for ( int j=2;j<=k;j++ ){
        dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
        }
    }
    cout << dp[n];
}
Kết thúc cuộc trò chuyện
Nhập tin nhắn...

Compiler output:
a.cc:20:1: error: 'K\U00001ebft' does not name a type
   20 | Kết thúc cuộc trò chuyện
      | ^~~
Language: C++

def main():
  N, K = map(int,input().split())
  H = list(map(int,input().split()))

  dp = [1e10]*N
  dp[0] = 0
  for i, h in enumerate(H):
    if i == 0:
      continue
    x = max(0, i-K)
    dp[i] = min([d+abs(h-ht) for d, ht in zip(dp[x:i], H[x:i])])
  print(dp[-1])

if __name__ == "__main__":
  main()

Compiler output:
a.cc:1:1: error: 'def' does not name a type
    1 | def main():
      | ^~~
Language: C++

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

int main(){
  int n=0,k=0;
  cin>>n>>k;
  int arr[n+1]={0};
  cin>>arr[1];
  for(int i=2;i<=n;i++){
    cin>>arr[i];
  }
  long long int dp[n+1]={0};
  arr[0]=1e5;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1]+abs(arr[i-1]-arr[i]);
    for(int j=2;j<=k;j++){
      if(dp[i]>dp[i-j]+abs(arr[i-j]-arr[i])) dp[i]=dp[i-j]+abs(arr[i-j]-arr[i])
    }
    
  }
  cout<<dp[n]<<endl;
  cin>>n;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:80: error: expected ';' before '}' token
   18 |       if(dp[i]>dp[i-j]+abs(arr[i-j]-arr[i])) dp[i]=dp[i-j]+abs(arr[i-j]-arr[i])
      |                                                                                ^
      |                                                                                ;
   19 |     }
      |     ~
Language: C++

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

int main(){
  int n=0,k=0;
  cin>>n>>k;
  int arr[n+1]={0};
  cin>>arr[1];
  pair<int,int> jumps[n+1]={};
  for(int i=2;i<=n;i++){
    cin>>arr[i];
    jumps[i-2].second=abs(arr[i-2]-arr[i]);
    jumps[i-1].first=abs(arr[i-1]-arr[i]);
  }
  long long int dp[n+1]={0};
  arr[0]=1e5;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1]+abs(arr[i-1]-arr[i]);
    for(int j=2;j<=k;j++){
      if(dp[i]>dp[i-j]+abs(arr[i-j]-arr[i])) dp[i]=dp[i-j]+abs(arr[i-j]-arr[i])
    }
    
  }
  cout<<dp[n]<<endl;
  cin>>n;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:80: error: expected ';' before '}' token
   21 |       if(dp[i]>dp[i-j]+abs(arr[i-j]-arr[i])) dp[i]=dp[i-j]+abs(arr[i-j]-arr[i])
      |                                                                                ^
      |                                                                                ;
   22 |     }
      |     ~
Language: C++

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

using namespace std;

int main(int argc, char *argv[])
{
  int N, K, h[100000];
  long long  ans[100000];

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

  ans[0] = 0;
  for (int i = 1; i < N; i++) {
    ans[i] = LLONG_MAX;
    for (int j = 1; j <= K && j <= i; j++) {
      ans[i] = min(ans[i], ans[i-j] + abs(h[i-j] - h[i]));
    }
  }

  cout << ans[N-1] << endl;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:27:14: error: 'LLONG_MAX' was not declared in this scope
   27 |     ans[i] = LLONG_MAX;
      |              ^~~~~~~~~
a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <set>
  +++ |+#include <climits>
   12 |
Language: C++

#include <bits/stdc++.h>
#define JN ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define mod 1000000007

#define pb push_back
#define mp make_pair

using namespace std;
typedef unsigned long long int ull;
typedef long long int          ll;




int main()
{

	ll n, k;
	cin >> n >> k;
	ll frog[n+2], cost[n+2];

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

	frog[1] =0;
	frog[2] = abs(cost[2]-cost[1]);
	for(int i=3; i<=n; i++)
	{
		frog[i] = 1e18;
		for(int j=1; j<=min(k, i); j++)
			frog[i] = min(frog[i], frog[i-j]+abs(cost[i]-cost[i-j]));
	}
	cout << frog[n] << endl;
	return 0;
}

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

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
  int H,K;
  cin>>H>>K;
  int H[N+1];
  long int dp[N+1];
  for(int i=1; i<=N; ++i) cin>>H[i];
  for(int i=1; i<=N; ++i) dp[i]=100000000;
  for(int i=1; i<N; ++i){
    for(int j=max(1,i-K); j<i; ++j){
      dp[i+1]=min(dp[i+1],dp[j]+abs(H[i+1]-H[j]));
    }
  }
  cout<<dp[N]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'N' was not declared in this scope
    9 |   int H[N+1];
      |         ^
a.cc:11:33: error: invalid types 'int[int]' for array subscript
   11 |   for(int i=1; i<=N; ++i) cin>>H[i];
      |                                 ^
a.cc:12:27: error: 'dp' was not declared in this scope
   12 |   for(int i=1; i<=N; ++i) dp[i]=100000000;
      |                           ^~
a.cc:15:7: error: 'dp' was not declared in this scope
   15 |       dp[i+1]=min(dp[i+1],dp[j]+abs(H[i+1]-H[j]));
      |       ^~
a.cc:15:38: error: invalid types 'int[int]' for array subscript
   15 |       dp[i+1]=min(dp[i+1],dp[j]+abs(H[i+1]-H[j]));
      |                                      ^
a.cc:15:45: error: invalid types 'int[int]' for array subscript
   15 |       dp[i+1]=min(dp[i+1],dp[j]+abs(H[i+1]-H[j]));
      |                                             ^
a.cc:18:9: error: 'dp' was not declared in this scope
   18 |   cout<<dp[N]<<endl;
      |         ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll inf = 1e18;
const int N = 1e5+10;
int n,k;
ll h[N];
ll dp[N];
int main(){
 	int n,k;
  	scanf("%d%d",&n,&k);
  	for(int i=1;i<=n;++i){
      cin>>h[i];
      dp[i] = inf;
    }
  	dp[1] = 0;
  	for(int i=1;i<=n;++i){
      for(int j=i+1;j<=min(i+k,n);++i){
        dp[j] = min(dp[j],dp[i]+1LL*abs(h[j]-h[i]);
		}
	}
	cout<<dp[n]<<endl;
                    return 0;
}

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

#include<bits/stdc++.h>
using namspace std;
#define ll long long
const ll inf = 1e18;
const int N = 1e5+10;
int n,k;
ll h[N];
ll dp[N];
int main(){
 	int n,k;
  	scanf("%d%d",&n,&k);
  	for(int i=1;i<=n;++i){
      cin>>h[i];
      dp[i] = inf;
    }
  	dp[1] = 0;
  	for(int i=1;i<=n;++i){
      for(int j=i+1;j<=min(i+k,n);++i){
        dp[j] = min(dp[j],dp[i]+abs(h[j]-h[i]);
		}
	}
	cout<<dp[n]<<endl;
                    return 0;
}

Compiler output:
a.cc:2:7: error: expected nested-name-specifier before 'namspace'
    2 | using namspace std;
      |       ^~~~~~~~
a.cc: In function 'int main()':
a.cc:13:7: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   13 |       cin>>h[i];
      |       ^~~
      |       std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
                 from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:18:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   18 |       for(int j=i+1;j<=min(i+k,n);++i){
      |                        ^~~
      |                        std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:19:47: error: expected ')' before ';' token
   19 |         dp[j] = min(dp[j],dp[i]+abs(h[j]-h[i]);
      |                    ~                          ^
      |                                               )
a.cc:22:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   22 |         cout<<dp[n]<<endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:22:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   22 |         cout<<dp[n]<<endl;
      |                      ^~~~
      |                      std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF = 1LL << 60;

int main(){

  int n,k;
    cin >> n >> k;
    int h[10000000];
    FOR(i,n){
      cin >> h[i];
    }
    int dp[10000000]={INF},a;
    dp[0]=0;
    for(int i=1;i<n;i++){
      a=min(i,k);
      FOR(j,a){
        chmin(dp[i],dp[i-a-1]+abs(h[i]-h[i-a-1]));
      }
    }
    cout << dp[n-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:23: error: narrowing conversion of '1152921504606846976' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   20 |     int dp[10000000]={INF},a;
      |                       ^~~
Language: C

#include <stdio.h>
long abs(long);
int main(){
  int n,k,h[100000];
  long dp[100000],min;
  scanf("%d%d",&n,&k);
  for (int i=0;i<n;i++) scanf("%d",&h[i]);
  dp[0]=0;
  for (int i=1;i<n;i++){
    min=1000000000;
    if (i<k){
      for (int j=1;j<=i;j++){
        else if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
      }
    }
    else {
      for (int j=1;j<=k;j++){
        else if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
      }
    }
    dp[i]=min;
  }
  printf("%ld\n",(long)dp[n-1]);
  return 0;
}
long abs(long num){
  if (num<0) num=-num;
  return num;
}


Compiler output:
main.c:2:6: warning: conflicting types for built-in function 'abs'; expected 'int(int)' [-Wbuiltin-declaration-mismatch]
    2 | long abs(long);
      |      ^~~
main.c:2:1: note: 'abs' is declared in header '<stdlib.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | long abs(long);
main.c: In function 'main':
main.c:13:9: error: 'else' without a previous 'if'
   13 |         else if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
      |         ^~~~
main.c:18:9: error: 'else' without a previous 'if'
   18 |         else if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
      |         ^~~~
Language: C

#include <stdio.h>
long abs(long);
int main(){
  int n,k,h[100000],dp[100000],min;
  scanf("%d%d",&n,&k);
  for (int i=0;i<n;i++) scanf("%d",&h[i]);
  dp[0]=0;
  for (int i=1;i<n;i++){
    min=10000;
    if (i<k){
      for (int j=1;j<=i;j++){
        if (j=1) min=dp[i-1]+abs(h[i]-h[i-1]);
        else if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
    }
    else {
      for (int j=1;j<=k;j++){
        if (j=1) min=dp[i-1]+abs(h[i]-h[i-1]);
        else if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
    }
    dp[i]=min;
  }
  printf("%ld\n",(long)dp[n-1]);
  return 0;
}
long abs(long num){
  if (num<0) num=-num;
  return num;
}


Compiler output:
main.c:2:6: warning: conflicting types for built-in function 'abs'; expected 'int(int)' [-Wbuiltin-declaration-mismatch]
    2 | long abs(long);
      |      ^~~
main.c:2:1: note: 'abs' is declared in header '<stdlib.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | long abs(long);
main.c: In function 'main':
main.c:15:5: error: expected '}' before 'else'
   15 |     else {
      |     ^~~~
main.c:28:1: error: expected declaration or statement at end of input
   28 | }
      | ^
Language: C

#include <stdio.h>
long abs(long);
int main(){
  int n,h[100000],dp[100000],min;
  scanf("%d",&n);
  for (int i=0;i<n;i++) scanf("%d",&h[i]);
  dp[0]=0;
  for (int i=1;i<n;i++){
    min=10000;
    if (i<k){
      for (int j=1;j<=i;j++){
        if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
      }
    }
    else {
      for (int j=1;j<=k;j++){
        if (min>dp[i-j]+abs(h[i]-h[i-j])) min=dp[i-j]+abs(h[i]-h[i-j]);
      }
    }
    dp[i]=min;
  }
  printf("%ld\n",(long)dp[n-1]);
  return 0;
}
long abs(long num){
  if (num<0) num=-num;
  return num;
}

Compiler output:
main.c:2:6: warning: conflicting types for built-in function 'abs'; expected 'int(int)' [-Wbuiltin-declaration-mismatch]
    2 | long abs(long);
      |      ^~~
main.c:2:1: note: 'abs' is declared in header '<stdlib.h>'
    1 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    2 | long abs(long);
main.c: In function 'main':
main.c:10:11: error: 'k' undeclared (first use in this function)
   10 |     if (i<k){
      |           ^
main.c:10:11: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

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

using namespace std;

int minCostToReachN(vector<int>& stones, int k) {
	int stonesCount = stones.size();
	vector<int> dp(stonesCount);

	dp[stonesCount - 1] = 0;
	for (int i = stonesCount - 2; i >= 0; --i) {
		dp[i] = INT_MAX;
		for(int j = i + 1; j < stonesCount && j <= i + k; ++j)
			dp[i] = min(dp[i], dp[j] + abs(stones[i] - stones[j]));
	}

	return dp[0];
}

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

	vector<int> stones(n);
	for (auto& stone : stones)
		cin >> stone;

	cout << minCostToReachN(stones, k) << endl;

	return 0;
}



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

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

int main()
{
int n,k;
cin>>n;
cin>>k;
vector <int> v(n);
int i,j;
for (i=0;i<n;i++)
{
    cin>>v[i];
}
vector <int> ans(n,INF);
int maxmin=10001;
ans[0]=0;

for (i=1;i<n;i++)
{
    for (j=max(i-k,0);j<i;j++)
    {
        
        ans[i]=min(ans[i],ans[j]+abs(v[i]-v[j]));
    }
        
}
cout<<ans[n-1];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: 'INF' was not declared in this scope
   15 | vector <int> ans(n,INF);
      |                    ^~~
Language: C++

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

int main()
{
int n,k;
cin>>n;
cin>>k;
vector <int> v(n);
int i,j,k;
for (i=0;i<n;i++)
{
    cin>>v[i];
}
vector <int> ans(n,0);
maxmin=10001;
ans[0]=0

for (i=1;i<n;i++)
{
    for (j=max(i-k,0);j<i;j++)
    {
        
        ans[i]=min(ans[i],ans[j]+abs(v[i]-v[j]));
    }
        
}
cout<<ans[n-1];
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: redeclaration of 'int k'
   10 | int i,j,k;
      |         ^
a.cc:6:7: note: 'int k' previously declared here
    6 | int n,k;
      |       ^
a.cc:16:1: error: 'maxmin' was not declared in this scope; did you mean 'main'?
   16 | maxmin=10001;
      | ^~~~~~
      | main
a.cc:17:9: error: expected ';' before 'for'
   17 | ans[0]=0
      |         ^
      |         ;
   18 | 
   19 | for (i=1;i<n;i++)
      | ~~~      
a.cc:19:17: error: expected ';' before ')' token
   19 | for (i=1;i<n;i++)
      |                 ^
      |                 ;
Language: C++

/*input
5 3
10 30 40 50 20
*/

#include<bits/stdc++.h>
using namespace std;
int main()
{

	int n,k;
	cin>>n>>k;
	vector<int>a(n);
	vector<int>dp(n);
    int dp[0]=0;
	for(int i=0;i<=n;i++)
	{
		a.push_back(i);
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: conflicting declaration 'int dp [0]'
   15 |     int dp[0]=0;
      |         ^~
a.cc:14:20: note: previous declaration as 'std::vector<int> dp'
   14 |         vector<int>dp(n);
      |                    ^~
Language: C++

/*input
5 3
10 30 40 50 20
*/

#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<int>a(n);
	vector<int>dp(n);
	dp[0]=0;
	int n,k;
	cin>>n>>k;
	for(int i=0;i<=n;i++)
	{
		a.push_back(i);
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:22: error: 'n' was not declared in this scope
   10 |         vector<int>a(n);
      |                      ^
Language: C++

/*input
5 3
10 30 40 50 20
*/

#include<bits/stdc++.h>
#define long long ll
using namespace std;
int main()
{
	vector<ll>a(n);
	vector<ll>dp(n);
	dp[0]=0;
	int n,k;
	cin>>n>>k;
	for(int i=0;i<=n;i++)
	{
		a.push_back(i);
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:11:16: error: 'll' was not declared in this scope
   11 |         vector<ll>a(n);
      |                ^~
a.cc:11:18: error: template argument 1 is invalid
   11 |         vector<ll>a(n);
      |                  ^
a.cc:11:18: error: template argument 2 is invalid
a.cc:11:21: error: 'n' was not declared in this scope
   11 |         vector<ll>a(n);
      |                     ^
a.cc:12:18: error: template argument 2 is invalid
   12 |         vector<ll>dp(n);
      |                  ^
a.cc:13:11: error: invalid types 'int[int]' for array subscript
   13 |         dp[0]=0;
      |           ^
a.cc:18:19: error: request for member 'push_back' in 'a', which is of non-class type 'int'
   18 |                 a.push_back(i);
      |                   ^~~~~~~~~
a.cc:23:19: error: invalid types 'int[int]' for array subscript
   23 |                 dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      |                   ^
a.cc:23:25: error: invalid types 'int[int]' for array subscript
   23 |                 dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      |                         ^
a.cc:23:36: error: invalid types 'int[int]' for array subscript
   23 |                 dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      |                                    ^
a.cc:23:41: error: invalid types 'int[int]' for array subscript
   23 |                 dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
      |                                         ^
a.cc:28:35: error: invalid types 'int[int]' for array subscript
   28 |                                 dp[i]=min(dp[i],dp[i-j]+abs(dp[i]-dp[i-j]));
      |                                   ^
a.cc:28:45: error: invalid types 'int[int]' for array subscript
   28 |                                 dp[i]=min(dp[i],dp[i-j]+abs(dp[i]-dp[i-j]));
      |                                             ^
a.cc:28:51: error: invalid types 'int[int]' for array subscript
   28 |                                 dp[i]=min(dp[i],dp[i-j]+abs(dp[i]-dp[i-j]));
      |                                                   ^
a.cc:28:63: error: invalid types 'int[int]' for array subscript
   28 |                                 dp[i]=min(dp[i],dp[i-j]+abs(dp[i]-dp[i-j]));
      |                                                               ^
a.cc:28:69: error: invalid types 'int[int]' for array subscript
   28 |                                 dp[i]=min(dp[i],dp[i-j]+abs(dp[i]-dp[i-j]));
      |                                                                     ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
void dp(int a[],int n,int k){
	int cost[n];cost[0]=0;cost[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		cost[i]=INT_MAX;
		for(int j=i-min(i,k);j<i;j++){
			cost[i]=min(cost[i],abs(a[i]-a[j])+cost[j]);
		}
	}
	cout<<cost[n-1]<<endl;
}
int main(){
	int n,k;cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	dp(a,n,k);
}

Compiler output:
a.cc: In function 'void dp(int*, int, int)':
a.cc:7:25: error: 'INT_MAX' was not declared in this scope
    7 |                 cost[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<algorithm>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
const long long int INF=100100100100;
int main(){
  int n,k;
  cin>>n>>k;
  long long int dp[100010];
  long long int h[100010];
  for(int i=0;i<n+10;i++){
    dp[i]=INF;
  }
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  for(int i=0;i<n;i++){
    foi(int j=1;j<k+1;j++){
    mins(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:23:9: error: expected primary-expression before 'int'
   23 |     foi(int j=1;j<k+1;j++){
      |         ^~~
a.cc:23:17: error: 'j' was not declared in this scope
   23 |     foi(int j=1;j<k+1;j++){
      |                 ^
Language: C++

#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;
const long long int inf=100100100100;
int main(){
  int n,k;
  cin>>n>>k;
  long long int dp[100010];
  long long int h[100010];
  for(int i=0;i<n+10;i++){
    dp[i]=INF;
  }
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  for(int i=0;i<n;i++){
    mins(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
    mins(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    mins(dp[i+k],dp[i]+abs(h[i]-h[i+k]));
  }
  cout<<dp[n-1]<<endl;
}

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'mn' was not declared in this scope; did you mean 'yn'?
   10 |     mn=INT_MAX;
      |     ^~
      |     yn
Language: C++

/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

const int mxn = 100005;
const int inf = 1e7;
int n, k, h[mxn];
int ff[mxn];

void solution()
{
  ff[n] = 0;
  for(int i = n - 1; i > 0; i--)
  {
    ff[i] = inf;
    for(int j = 1; j <= k and i + j <= n; j++)
    {
      ff[i] = min(ff[i], abs(h[i] - h[i + j]) + dfs( i + j ));
    }
  }
}

int main()
{
  scanf("%d %d", &n, &k);
  for(int i = 1; i <= n; i++) 
  { 
    scanf("%d", h + i);
  }
  solution();
  printf("%d\n", ff[1]);
  return 0;
}

Compiler output:
a.cc: In function 'void solution()':
a.cc:18:49: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   18 |       ff[i] = min(ff[i], abs(h[i] - h[i + j]) + dfs( i + j ));
      |                                                 ^~~
      |                                                 ffs
Language: Java

//package AtCoder;
//package ;
import java.io.*;
import java.util.*;

public class Frog_1 {
	static long dp(int i)
	{
		if(i==n-1)
			return 0;
		if(dp[i]!=-1)return dp[i];
		long ans=(long)1e9;
		for(int j=i+1;j<n && j-i<=k;j++)
			ans=Math.min(ans, (long)Math.abs(a[i]-a[j])+dp(j));
		return dp[i]=ans;
	}
	static int n,k;
	static long dp[],a[];
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		n=sc.nextInt();k=sc.nextInt();
		a=new long[n];
		for(int i=0;i<n;i++)a[i]=sc.nextLong();
		dp=new long[n];
		Arrays.fill(dp, -1);
		System.out.println(dp(0));
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		boolean hasnext() throws IOException {
			return br.ready();
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] a = new Integer[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		char[] nextCharArray() throws IOException {
			return br.readLine().toCharArray();
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] ans = new double[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextDouble();
			return ans;
		}

	}
}


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

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="B - Frog 2" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/B - Frog 2" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/B - Frog 2" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
			<Add option="-fexceptions" />
		</Compiler>
		<Unit filename="main.cpp" />
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
			<lib_finder disable_auto="1" />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


Compiler output:
a.cc:1:1: error: expected unqualified-id before '<' token
    1 | <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n, k, h[100004], f[100004];
	cin >> n >> k;
	for (long long i = 1; i <= n; i++)
		cin >> h[i];
	f[1] = 0;
	for (long long i = 2; i <= n; i++) {
		long long minn = 0x7f7f7f7f
		for (long long j = (i - k >= 0)? i - k : 1; j < i; j++) {
			long long tmp = f[j] + abs(h[i] - h[j]);
			if (tmp < minn)
				minn = tmp;
		}
		f[i] = minn;
	}
	cout << f[n] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:17: error: expected ',' or ';' before 'for'
   12 |                 for (long long j = (i - k >= 0)? i - k : 1; j < i; j++) {
      |                 ^~~
a.cc:12:61: error: 'j' was not declared in this scope
   12 |                 for (long long j = (i - k >= 0)? i - k : 1; j < i; j++) {
      |                                                             ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long n, k, h[100004], f[100004];
	cin >> n >> k;
	for (long long i = 1; i <= n; i++)
		cin >> h[i];
	f[1] = 0;
	for (long long i = 2; i <= n; i++) {
		fong long minn = 0x7f7f7f7f
		for (long long j = (i - k >= 0)? i - k : 1; j < i; j++) {
			long long tmp = f[j] + abs(h[i] - h[j]);
			if (tmp < minn)
				minn = tmp;
		}
		f[i] = minn;
	}
	cout << f[n] << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:17: error: 'fong' was not declared in this scope; did you mean 'long'?
   11 |                 fong long minn = 0x7f7f7f7f
      |                 ^~~~
      |                 long
a.cc:12:61: error: 'j' was not declared in this scope
   12 |                 for (long long j = (i - k >= 0)? i - k : 1; j < i; j++) {
      |                                                             ^
a.cc:17:24: error: 'minn' was not declared in this scope
   17 |                 f[i] = minn;
      |                        ^~~~