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

#include <iostream>
#include <limits>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility> 
#include <iomanip>      // std::setprecision
using namespace std;
typedef long long int l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// #define __gcd(a,b) __algo_gcd(a,b)
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<endl;
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
const int MOD = 1e9+7;

int main()
{
    FIO;
    int t;
    t = 1;
    // cin>>t; 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    for(int tc=0;tc<t;tc++)
    {   
        int n,k;
        cin>>n>>k;
        vector<int> arr(n+1);
        for(int i1=1;i1<=n;i1++) cin>>arr[i1];
        vector<int> dp(n+1,INT_MAX);
        dp[0]=0;
        dp[1] = 0;
        dp[2] = abs(arr[2]-arr[1]);
        for(int i=3;i<=n;i++)
        {
            for(int j=i-1;j>=max(1,i-k);j--)
            {
                dp[i] = min(dp[j]+abs(arr[i]-arr[j]),dp[i]);
            }
        }
        // PrintArray(dp);
        cout<<dp[n]<<"\n";
    }
    return 0;
}

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

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

const int INF = 9999999;

int N,K;
vector<int> h;
vector<int> dp;

int main(){
    cin >> N >> K;
    h.resize(N);
    dp.resize(N,INF);
    for(int i = 0;i < N;++i)cin >> h[i];

    dp[N-1] = 0;
    dp[N-2] = abs(h[N-2]-h[N-1]);

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


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

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


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:21:16: error: 'min' cannot be used as a function
   21 |       dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:16: error: 'min' cannot be used as a function
   25 |       dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));
      |             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

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

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int dist(int& x, int& y) {
	return abs(x - y);
}
int minCost(int n, int k, vector <int>& h) {
	vector <int> dp(n + 1, 0);
	dp[2] = dist(h[0], h[1]);
	for (int i = 3; i <= n; ++i) {
      dp[i] = INT_MAX;
      for (int j = k; j >= 1 && ; --j) {
        if (i - k > 0)
			dp[i] = min(dp[i], dp[i - k] + dist(h[i - 1], h[i - k - 1]));
      }
}
	return dp[n];
}


int main() {
	int n, x, k;
  	cin >> n >> k;
  	vector <int> v;
  	for(int i = 0; i < n; ++i) 
      cin >> x, v.push_back(x);
  	cout << minCost(n, k, v) << endl;
}



Compiler output:
a.cc: In function 'int minCost(int, int, std::vector<int>&)':
a.cc:14:15: error: 'INT_MAX' was not declared in this scope
   14 |       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 <cmath>
  +++ |+#include <climits>
    4 | 
a.cc:15:33: error: expected primary-expression before ';' token
   15 |       for (int j = k; j >= 1 && ; --j) {
      |                                 ^
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:11: error: 'MAX' was not declared in this scope
   13 |     dp[i]=MAX;
      |           ^~~
a.cc:14:28: error: 'k' was not declared in this scope
   14 |         for(int j=i-1;j>=i-k && j>=0;j--) {
      |                            ^
Language: C++

n,k = map(int,input().split())
h = list(map(int,input().split()))
start = h[0]
for i in range(n):
    h[i] -= start
dp = [10**4]*n
dp[0] = h[0]
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n,k = map(int,input().split())
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <functional>
#include <map>
#include <set>
#include <cmath>
using namespace std;
 
 
 

// DP !!
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);

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

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

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

    return 0;
}

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

#include<iostream>
#include<vector>

using namespace std;

int main(){
	int n, k;
	cin>>n>>k;
	vector<int> dp(k,-1);
	dp[0]=0;
	vector<int> heights(n, 0);
	for(int i=0; i<n; i++)
		cin>>heights[i];
	for(int i=1; i<n; i++){
		int temp=INT_MAX;
		int kn=i-k;
		//cout<<"\ni:"<<i<<"- kn:"<<kn<<"----------";
		//cout<<"\n-------";
		for(int j=0; j<k; j++){
			if(kn+j>=0){
				//	cout<<(kn+j)%k<<","<<kn+j<<"-"<<dp[(kn+j)%k]<<"  ---  ";
				temp=min(temp, abs(heights[i]-heights[kn+j])+dp[(kn+j)%k]);
			}
		}
		//cout<<"\n";
		//cout<<i%k<<" -- "<<temp<<"\n";
		dp[i%k]=temp;
	}
	cout<<dp[(n-1)%k]<<"\n";
}


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

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

int main() {
  int N;
  int INF=1000000000;
  cin >> N;
  vector<int> h(N);
  vector<int> d(N);
  
  for (int i=0; i<N; i++) {
    cin >> h.at(i);
  }
  
  for (int i=0; i<N; i++) {
    d.at(i)=INF;
  }
  
  d.at(0)=0;
  
  for (int i=1; i<N; i++) {
    for (int j=1;j=<i; j++) {
      d.at(i)=min(d.at(i), d.at(j-1)+abs(h.at(i)-h.at(j-1)));
    }
  }
  
  cout << d.at(N-1) << endl;
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:20: error: expected primary-expression before '<' token
   23 |     for (int j=1;j=<i; j++) {
      |                    ^
Language: C++

#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include<stack>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) for(auto r:v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define pc() pop_back()
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
#define ll long long
#define endl '\n'
#define st stack<int>
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define mod 1000000007
#define ss second
#define ff first> 
#define vpii vector<pii>
#define vvi vector<vi>
#define vs vector<string>
#define mii map<int,int>

int power(int a, int b) {
    int res = 1;
    while (b != 0) {
        if (b & 1) {
            res *= a;
        }
        a = (a * a);
        b = (b / 2);
    }
    return res;
}
template<typename T, typename U> inline void amin(T& x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T& x, U y) {
    if (x < y) x = y;
}
bool comp(int n) {
    vi v(4);
    int i = 0;
    while (n) {
        v[i] = n % 10;
        n /= 10;
        i++;


    }
    set<int> s(all(v));
    if (s.size() != 4) return false;
    else return true;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, k;
    cin >> n >> k;
    vi v(n);
    rep(i, n) cin >> v[i];
    vi dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(v[0] - v[1]);
    int t;
    for (int j = 2; j < n; j++) {
        t = 1;
        while (t<=k&&j-t>=0) {
            dp[j] = min(dp[j], dp[j-t]+abs(v[j - t] - v[j]));
            t++;
        }
    }
    cout << dp[n - 1];



}

Compiler output:
a.cc: In function 'int main()':
a.cc:87:14: error: 'INT_MAX' was not declared in this scope
   87 |     vi dp(n, INT_MAX);
      |              ^~~~~~~
a.cc:19:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   18 | #include <functional>
  +++ |+#include <climits>
   19 | #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
Language: C

#include<stdio.h>
#define inf 100100100
int min(int a,int b){return a<b?a:b;}
int abs(int a){if(a > 0) return a; return -a;}
int main(){
  int n, k;
  scand("%d%d",&n,&k);
  int h[n];
  for(int i = 0; i < n; i++)
    scanf("%d",&h[i]);
  int dp[n];
  dp[0] = 0;
  for(int i = 1; i < n; i++)
    dp[i] = inf;
  for(int i = 0; i < n; i++)
    for(int j = 1; j < k; j++)
      dp[i + j] = min(dp[i + j],dp[i] + abs(h[i] - h[j]));
  printf("%d\n",dp[n - 1]);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:7:3: error: implicit declaration of function 'scand'; did you mean 'scanf'? [-Wimplicit-function-declaration]
    7 |   scand("%d%d",&n,&k);
      |   ^~~~~
      |   scanf
Language: C

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

int n, k;

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


Compiler output:
main.c:3:10: fatal error: iostream: No such file or directory
    3 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

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

using namespace std;

int mainb() {
	int n, k;
	cin >> n >> k;
	vector<int> dp(n + 1);
	vector<int> heights(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> heights[i];
	dp[1] = 0;
	dp[2] = abs(heights[1] - heights[2]);
	for (int i = 3; i <= n; i++) {		// For Each Stone
		int min_cost = INT_MAX;
		for (int j = i - 1; j > 0 && ((i - j) <= k); j--) {
			int cost = dp[j] + abs(heights[j] - heights[i]);
			min_cost = min(min_cost, cost);
		}
		dp[i] = min_cost;
	}

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

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

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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> dp(n + 1);
	vector<int> heights(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> heights[i];
	dp[1] = 0;
	dp[2] = abs(heights[1] - heights[2]);
	for (int i = 3; i <= n; i++) {		// For Each Stone
		int min_cost = INT_MAX;
		for (int j = i - 1; j > 0 && ((i - j) <= k); j--) {
			int cost = dp[j] + abs(heights[j] - heights[i]);
			min_cost = min(min_cost, cost);
		}
		dp[i] = min_cost;
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:17:32: error: 'INT_MAX' was not declared in this scope
   17 |                 int min_cost = 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;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
ll int dp[1000005];
ll int N,K;
vector<ll int> v;
int fun(int i)
{
  int x;
  if(i==N-1)
    return 0;
  if(i>=N)
    return 0;
  if(dp[i+1]==-1)
    dp[i+1]=fun(i+1);
  int mini=abs(v[i+1]-v[i])+dp[i+1];
  for(x=2;x<=K&&(i+x)<N;x++)
  {
    if(dp[i+x]==-1)
      dp[i+x]=fun(i+x);
   	mini=mini<=(abs(v[i+x]-v[i])+dp[i+x])?mini:(abs(v[i+x]-v[i])+dp[i+x]));
  }
  dp[i]=mini;
  return dp[i]; 
}
int main()
{
  int i,x;
  for(i=0;i<1000005;i++)
    dp[i]=-1;
  cin>>N>>K;
  for(i=0;i<N;i++)
  {
    cin>>x;
    v.pb(x);
  }
  dp[0]=fun(0);
  cout<<dp[0]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int fun(int)':
a.cc:25:78: error: expected ';' before ')' token
   25 |         mini=mini<=(abs(v[i+x]-v[i])+dp[i+x])?mini:(abs(v[i+x]-v[i])+dp[i+x]));
      |                                                                              ^
      |                                                                              ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
ll int dp[1000005];
ll int N,K;
vector<ll int> v;
int fun(int i)
{
  int x;
  if(i==N-1)
    return 0;
  if(i>=N)
    return 0;
  if(dp[i+1]==-1)
    dp[i+1]=fun(i+1);
  int mini=abs(v[i+1]-v[i])+dp[i+1];
  for(x=2;x<=K&&(i+x)<N;x++)
  {
    if(dp[i+x]==-1)
      dp[i+x]=fun(i+x);
   	mini=mini<=(abs(v[i+x]-v[i])+dp[i+x]))?mini:(abs(v[i+x]-v[i])+dp[i+x]));
  }
  dp[i]=mini;
  return dp[i]; 
}
int main()
{
  int i,x;
  for(i=0;i<1000005;i++)
    dp[i]=-1;
  cin>>N>>K;
  for(i=0;i<N;i++)
  {
    cin>>x;
    v.pb(x);
  }
  dp[0]=fun(0);
  cout<<dp[0]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int fun(int)':
a.cc:25:46: error: expected ';' before ')' token
   25 |         mini=mini<=(abs(v[i+x]-v[i])+dp[i+x]))?mini:(abs(v[i+x]-v[i])+dp[i+x]));
      |                                              ^
      |                                              ;
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
ll int dp[1000005];
ll int N,K;
vector<ll int> v;
int fun(int i)
{
  int x;
  if(i==N-1)
    return 0;
  if(i>=N)
    return 0;
  if(dp[i+1]==-1)
    dp[i+1]=fun(i+1);
  int mini=abs(v[i+1]-v[i])+dp[i+1];
  for(x=2;x<=K&&(i+x)<N;x++)
  {
    if(dp[i+x]==-1)
      dp[i+x]=fun(i+x);
   	mini=min(mini,(abs(v[i+x]-v[i])+dp[i+x]));
  }
  dp[i]=mini;
  return dp[i]; 
}
int main()
{
  int i,x;
  for(i=0;i<1000005;i++)
    dp[i]=-1;
  cin>>N>>K;
  for(i=0;i<N;i++)
  {
    cin>>x;
    v.pb(x);
  }
  dp[0]=fun(0);
  cout<<dp[0]<<endl;
  return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
ll int dp[1000005];
ll int N,K;
vector<ll int> v;
int fun(int i)
{
  int x;
  if(i==N-1)
    return 0;
  if(i>=N)
    return 0;
  if(dp[i+1]==-1)
    dp[i+1]=fun(i+1);
  int mini=abs(v[i+1]-v[i])+dp[i+1];
  for(x=2;x<=K&&(i+x)<N;x++)
  {
    if(dp[i+x]==-1)
      dp[i+x]=fun(i+x);
   	mini=min(mini,(abs(v[i+x]-v[i])+d[i+x]));
  }
  dp[i]=mini;
  return dp[i]; 
}
int main()
{
  int i,x;
  for(i=0;i<1000005;i++)
    dp[i]=-1;
  cin>>N>>K;
  for(i=0;i<N;i++)
  {
    cin>>x;
    v.pb(x);
  }
  dp[0]=fun(0);
  cout<<dp[0]<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int fun(int)':
a.cc:25:41: error: 'd' was not declared in this scope
   25 |         mini=min(mini,(abs(v[i+x]-v[i])+d[i+x]));
      |                                         ^
Language: Java

import java.util.*;
import java.lang.*;
import java.io.*;
 
public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
      for(int i =0; i< n; i++)
        arr[i]= in.nextInt();
        
        int[] dp = new int[n];
        dp[0] =0;
         dp[1]= Math.abs(arr[1]-arr[0]);
       Arrays.fill(dp, Integer.MAX_VALUE);
      for(int i =2; i< n ; i++) {
         for(int j =1; j<=k;j++){
            if(i-j>=0){
             dp[i] = Math.min(Math.abs(arr[i]-arr[i-j])+ dp[i-j], dp[i]);
            }
         }
      }
      System.out.println(dp[n-1]);
    }
}


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

import java.util.*;
import java.lang.*;
import java.io.*;
 
public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
      for(int i =0; i< n; i++)
        arr[i]= in.nextInt();
        
        int[] dp = new int[n];
        dp[0] =0;
         dp[1]= Math.abs(arr[1]-arr[0]);
       Arrays.fill(dp, Integer.MAX_VALUE);
      for(int i =2; i< n ; i++) {
         for(int j =1; j<=k: j++){
            if(i-j>=0){
             dp[i] = Math.min(Math.abs(arr[i]-arr[i-j])+ dp[i-j], dp[i]);
            }
         }
      }
      System.out.println(dp[n-1]);
    }
}

Compiler output:
Main.java:19: error: ';' expected
         for(int j =1; j<=k: j++){
                           ^
Main.java:19: error: ';' expected
         for(int j =1; j<=k: j++){
                                ^
2 errors
Language: C++

import sys
def main(lines):
    n,k=map(int,lines[0].split())
    h=list(map(int,lines[1].split()))
    dp=[1000000]*(100100)
    h.extend([0]*101)
    for i in range(n):
        for j in range(k+1):
            temp=dp[i]+abs(h[i]-h[i+j])
            if dp[i+j]>temp:
                dp[i+j]=temp
        
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)

Compiler output:
a.cc:13:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   13 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:16:31: warning: multi-character character constant [-Wmultichar]
   16 |         lines.append(l.rstrip('\r\n'))
      |                               ^~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

import sys
def main(lines):
    n,k=map(int,lines[0].split())
    h=list(map(int,lines[1].split()))
    h.extend([0]*101)
    dp=[1000000]*(100100)
    dp[0]=0
    for i in range(n):
        for j in range(k+1):
            temp=dp[i]+abs(h[i]-h[i+j])
            if dp[i+j]>temp:
                dp[i+j]=temp
    print(dp[n-1])
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)

Compiler output:
a.cc:14:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   14 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:17:31: warning: multi-character character constant [-Wmultichar]
   17 |         lines.append(l.rstrip('\r\n'))
      |                               ^~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: overloaded function with no contextual type information
   14 |     min=INT_MAX;
      |         ^~~~~~~
a.cc:16:13: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator>'
   16 |       if(min>result[j]+mod(h[i]-h[j]))min=result[j]+mod(h[i]-h[j]);
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:16:66: error: overloaded function with no contextual type information
   16 |       if(min>result[j]+mod(h[i]-h[j]))min=result[j]+mod(h[i]-h[j]);
      |                                                                  ^
a.cc:17:15: error: cannot resolve overloaded function 'min' based on conversion to type 'int'
   17 |     result[i]=min;
      |               ^~~
Language: C++

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

const int inf = 1e9 + 7;

void Frog_2(vector<int> &h, int k)
{
	int n = h.size();

	vector<int> dp(n, inf);

	/* dp[i] represents the minimum cost to reach the end when you start at i */
	
	// No out of bound acces due to input constraints
	dp[n-1] = 0;

	for(int i = n-3; i >= 0; i--)
	{
		for(int j = i + 1; j <= i + k; j++)
		{
			if(j >= n)
				continue;

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

	cout << dp.front() << endl;
}

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

	vector<int> h(n);
	for(auto &ele : h)
		cin >> ele;

	Frog_2(h, k);
	return 0;
}


Compiler output:
a.cc: In function 'void Frog_2(std::vector<int>&, int)':
a.cc:30:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   30 | int main()
      |         ^~
a.cc:30:9: note: remove parentheses to default-initialize a variable
   30 | int main()
      |         ^~
      |         --
a.cc:30:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:31:1: error: a function-definition is not allowed here before '{' token
   31 | {
      | ^
a.cc:41:2: error: expected '}' at end of input
   41 | }
      |  ^
a.cc:7:1: note: to match this '{'
    7 | {
      | ^
Language: C++

using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>

#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

vi dp;
int mincost(vi& ht, int n, int idx, int k)
{
	if (idx == n - 1)
		return 0;
	if (dp[idx] != -1)
		return dp[idx];

	int minc = INT_MAX;
	for (int i = 1; i <= k; ++i)
	{
		if (idx + i < n)
		{
			int mincst = abs(ht[idx + i] - ht[idx]) + mincost(ht, n, idx + i, k);
			minc = min(mincst, minc);
			dp[idx] = minc;
		}
	}

	return dp[idx];
}

int main()
{
	int n, k;
	cin >> n >> k;
	vi ht(n);
	rep(n)
		cin >> ht[i];

	dp.resize(n, -1);
	auto ans = mincost(ht, n, 0, k);
	cout << ans;
	ret(0);
}


Compiler output:
a.cc: In function 'int mincost(vi&, int, int, int)':
a.cc:44:20: error: 'INT_MAX' was not declared in this scope
   44 |         int minc = INT_MAX;
      |                    ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <unordered_map>
  +++ |+#include <climits>
    9 |
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Frog2 {
    static int[] dp;
    static int[] input;

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));


        String[] line = reader.readLine().split(" ");

        int n = Integer.parseInt(line[0]);
        int k = Integer.parseInt(line[1]);


        input = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        dp = new int[input.length];
        List<Integer> backwards;
        dp[0] = 0;

        for (int i = 1; i < n; i++) {

            backwards = new ArrayList<>();
            for (int j = i - 1, c = 0; j >= 0 && c < k; j--, c++) {
                backwards.add(Math.abs(input[i] - input[j]) + dp[j]);
            }

            dp[i] = backwards.stream().min(Integer::compare).get();

        }

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




}


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

n, k = map(int, input().split())
h = [int(x) for x in input().split()]
dp = [None] * n
 
INF = float('inf')
 
dp[0] = 0
for x in range(1, n):
  dp[x] = min(dp.get(x - i, INF) + abs(h[x] - h[x - i]) for i in range(1, min(k,x) + 1))
 
print(dp[n-1])

Compiler output:
a.cc:5:13: warning: multi-character character constant [-Wmultichar]
    5 | INF = float('inf')
      |             ^~~~~
a.cc:1:1: error: 'n' does not name a type
    1 | n, k = map(int, input().split())
      | ^
Language: C++

#define _CRT_SECURE_NO_WARINGS
#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<fstream>
#include<map>
#include<unordered_map>
using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;
#define andrew  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define sz(v)(int)(v.size())
#define all(v) v.begin(),v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i*PI/180.0);
#define OO 1e18;
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int dy8[] = { 0,0,1,-1,1,-1,-1,1 };
int dx8[] = { 1,-1,0,0,1,-1,1,-1 };
int id8[] = { 0, 1,2,3,4, 5,6, 7 };
// you can be specialist 
// soon will be (Cyain)
ll n, k;
vector<ll>v;
ll m[101] = -1;
ll solve(int i)
{
    if (i >= n)
        return 1e18;
    if (i == n-1)
        return 0;
    if (m[i] != -1)
        return m[i];
    ll ch = LLONG_MAX;
    for (int l = 1; l <= k; l++)
    {
      m[i] = ch = min(ch, solve(i + l) + abs(v[i] - v[i + l]));
    }
    return m[i] = ch;

}
int main()
{
    andrew;
    cin >> n >> k;
    v.resize(n+n+k);
    for (int i = 0; i < n; i++)cin >> v[i];
    cout << solve(0) << endl;
   
}

Compiler output:
a.cc:39:13: error: array must be initialized with a brace-enclosed initializer
   39 | ll m[101] = -1;
      |             ^~
a.cc: In function 'll solve(int)':
a.cc:48:13: error: 'LLONG_MAX' was not declared in this scope
   48 |     ll ch = LLONG_MAX;
      |             ^~~~~~~~~
a.cc:18:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include<unordered_map>
  +++ |+#include <climits>
   18 | using namespace std;
Language: C++

#define _CRT_SECURE_NO_WARINGS
#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<fstream>
#include<map>
#include<unordered_map>
using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;
#define andrew  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define sz(v)(int)(v.size())
#define all(v) v.begin(),v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i*PI/180.0);
#define OO 1e18;
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }
void the_end() {
#ifndef ONLINE_JUDGE;
    system("pause");
#endif
}
int dy8[] = { 0,0,1,-1,1,-1,-1,1 };
int dx8[] = { 1,-1,0,0,1,-1,1,-1 };
int id8[] = { 0, 1,2,3,4, 5,6, 7 };
// you can be specialist 
// soon will be (Cyain)
ll n, k;
vector<ll>v;
map<int, ll>m;
ll solve(int i)
{
    if (i >= n)
        return 1e18;
    if (i == n-1)
        return 0;
    if (m.find(i) != m.end())
        return m[i];
    ll ch = LLONG_MAX;
    for (int l = 1; l <= k; l++)
    {
        ch = min(ch, solve(i + l) + abs(v[i] - v[i + l]));
    }
    return m[i] = ch;

}
int main()
{
    andrew;
    cin >> n >> k;
    v.resize(n+n+k);
    for (int i = 0; i < n; i++)cin >> v[i];
    cout << solve(0) << endl;
    the_end();
}

Compiler output:
a.cc:32:21: warning: extra tokens at end of #ifndef directive
   32 | #ifndef ONLINE_JUDGE;
      |                     ^
a.cc: In function 'll solve(int)':
a.cc:52:13: error: 'LLONG_MAX' was not declared in this scope
   52 |     ll ch = LLONG_MAX;
      |             ^~~~~~~~~
a.cc:18:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include<unordered_map>
  +++ |+#include <climits>
   18 | using namespace std;
Language: C++

#define _CRT_SECURE_NO_WARINGS
#include<iostream>
#include<stdio.h>
#include<iomanip>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<fstream>
#include<map>
#include<unordered_map>
using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;
#define andrew  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define sz(v)(int)(v.size())
#define all(v) v.begin(),v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i*PI/180.0);
#define OO 1e18;
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }
void the_end() {
#ifndef ONLINE_JUDGE;
    system("pause");
#endif
}
int dy8[] = { 0,0,1,-1,1,-1,-1,1 };
int dx8[] = { 1,-1,0,0,1,-1,1,-1 };
int id8[] = { 0, 1,2,3,4, 5,6, 7 };
// you can be specialist 
// soon will be (Cyain)
ll n, k;
vector<ll>v;
map<int, ll>m;
ll solve(int i)
{
    if (i > n)
        return 1e18;
    if (i== n-1)
        return 0;
    if (m.find(i) != m.end())
        return m[i];
    ll ch = LLONG_MAX;
    for (int l = 1; l <= k; l++)
    {
        ch = min(ch,solve(i + l) + abs(v[i] - v[i + l]));
    }
return m[i]=ch;
}
int main()
{
    andrew;
    cin >> n >> k;
    v.resize(n + k);
    for (int i = 0; i < n; i++)cin >> v[i];
    cout << solve(0) << endl;
    the_end();
}

Compiler output:
a.cc:32:21: warning: extra tokens at end of #ifndef directive
   32 | #ifndef ONLINE_JUDGE;
      |                     ^
a.cc: In function 'll solve(int)':
a.cc:52:13: error: 'LLONG_MAX' was not declared in this scope
   52 |     ll ch = LLONG_MAX;
      |             ^~~~~~~~~
a.cc:18:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   17 | #include<unordered_map>
  +++ |+#include <climits>
   18 | using namespace std;
Language: C++

using namespace std;
int dp[100001];
int a[100001];
int n;
int k;
long long int mod=1000000007;
int max_q(int i){
    //cout<<"Function enters"<<endl;
    if(i>=n){
        return 0;
    }
    int m=INT_MAX;
    if(dp[i]!=-1){
        return dp[i];
    }
     
    for(int j=1;j<=min(k,n-1);j++){
        m=min(m,abs(a[i]-a[i+j])+max_q(i+j));
    }
    dp[i]=m;
        //dp[i]=min(abs(a[i]-a[i+1])+max_q(i+1),abs(a[i]-a[i+2])+max_q(i+2));
        //dp[i][j][k]=max(dp[i][j][k],longest_sub(i,j,k+1));
        
    return dp[i];
    
}
int main() 
{ 
    for(int i=0;i<=100000;i++){
        dp[i]=-1;
    }
    cin>>n>>k;
    for(int i =0;i<n;i++){
        cin>>a[i];
    }
    cout<<max_q(0);
	return 0; 
} 

Compiler output:
a.cc: In function 'int max_q(int)':
a.cc:12:11: error: 'INT_MAX' was not declared in this scope
   12 |     int m=INT_MAX;
      |           ^~~~~~~
a.cc:1:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
  +++ |+#include <climits>
    1 | using namespace std;
a.cc:17:20: error: 'min' was not declared in this scope
   17 |     for(int j=1;j<=min(k,n-1);j++){
      |                    ^~~
a.cc:18:17: error: 'abs' was not declared in this scope
   18 |         m=min(m,abs(a[i]-a[i+j])+max_q(i+j));
      |                 ^~~
a.cc: In function 'int main()':
a.cc:32:5: error: 'cin' was not declared in this scope
   32 |     cin>>n>>k;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:36:5: error: 'cout' was not declared in this scope
   36 |     cout<<max_q(0);
      |     ^~~~
a.cc:36:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;++i) cin>>a[i];
  int ans[n]={};
  for(int i=1;i<n;++i)
  {
    ans[i]=INT_MAX;
    for(int j=1;j<=k and (i-j)>=0;++j)
      ans[i]=min(ans[i],abs(a[i]-a[i-j])+ans[i-j]);
  }
  cout<<ans[n];
}

Compiler output:
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:14:20: error: 'k' was not declared in this scope
   14 |     for(int j=1;j<=k and (i-j)>=0;++j)
      |                    ^
Language: C++

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

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

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


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

#include <iostream>
#include <cstdlib>
#include <algorithm>
#define oo 999999999
using namespace std;
 
int a[100000];
int W(int m,int b)
{
        return abs(a[m]-a[b]);
 
}
 
int F(int num, int k)
{
    int dp[num+1];
    dp[0]=0;
    dp[1]=W(0,1);
 
   for(int i=2;i<=num;i++)
   {
    int mi=oo;
    for(int j=i-1;j>=i-k;j--)
    {
        if(j>=0)
      {
          mi=min(mi,(dp[j]+W(i,j)));
          //cout<<"value of mi for "<<i<<" is :"<<mi<<"\n";
      }
 
    }
    dp[i]=mi;
    //cout<<"value at "<<i<<" is :"<<dp[i]<<"\n";
 
   }
 
    return dp[num];
}
 
 
int main() {
    int n;
    int k;
    cin>>n;
    cin>>k;
for(int i=0;i<n;i++)
   cin>>a[i];
 
int ans=F(n-1,k);
cout<<"\n"<<ans;
return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:51:10: error: expected '}' at end of input
   51 | return 0;
      |          ^
a.cc:41:12: note: to match this '{'
   41 | int main() {
      |            ^
Language: C++

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

int a[100000];
int W(int m,int b)
{
        return abs(a[m]-a[b]);

}

int F(int num, int k)
{
    int dp[num+1];
    dp[0]=0;
    dp[1]=W(0,1);

   for(int i=2;i<=num;i++)
   {
    int mi=INT_MAX;
    for(int j=i-1;j>=i-k;j--)
    {
        if(j>=0)
      {
          mi=min(mi,(dp[j]+W(i,j)));
          //cout<<"value of mi for "<<i<<" is :"<<mi<<"\n";
      }

    }
    dp[i]=mi;
    //cout<<"value at "<<i<<" is :"<<dp[i]<<"\n";

   }

    return dp[num];
}


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

int ans=F(n-1,k);
cout<<"\n"<<ans;
return 0;
}


Compiler output:
a.cc: In function 'int F(int, int)':
a.cc:21:12: error: 'INT_MAX' was not declared in this scope
   21 |     int mi=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 | using namespace std;
Language: C++

ll solve(vector <int> &v, int n, int k)
{
	ll MAXN = 10000000000000000;
	vector <ll> dp(n,MAXN);
	dp[0]=0;
	forr(i,1,n)
	{
		for(int j=1; j<=k; j++)
		{
			if(i-j < 0) break;
			dp[i]=min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
		}
	}
	return dp[n-1];
}
 
int main()
{ 
	FIN;
	
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif
	
	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	forn(i,n) cin >> v[i];
	cout << solve(v,n,k) << endl;
	return 0;
}

Compiler output:
a.cc:1:1: error: 'll' does not name a type
    1 | ll solve(vector <int> &v, int n, int k)
      | ^~
a.cc: In function 'int main()':
a.cc:19:9: error: 'FIN' was not declared in this scope
   19 |         FIN;
      |         ^~~
a.cc:26:9: error: 'cin' was not declared in this scope
   26 |         cin >> n >> k;
      |         ^~~
a.cc:27:9: error: 'vector' was not declared in this scope
   27 |         vector <int> v(n);
      |         ^~~~~~
a.cc:27:17: error: expected primary-expression before 'int'
   27 |         vector <int> v(n);
      |                 ^~~
a.cc:28:14: error: 'i' was not declared in this scope
   28 |         forn(i,n) cin >> v[i];
      |              ^
a.cc:28:9: error: 'forn' was not declared in this scope
   28 |         forn(i,n) cin >> v[i];
      |         ^~~~
a.cc:29:9: error: 'cout' was not declared in this scope
   29 |         cout << solve(v,n,k) << endl;
      |         ^~~~
a.cc:29:23: error: 'v' was not declared in this scope
   29 |         cout << solve(v,n,k) << endl;
      |                       ^
a.cc:29:17: error: 'solve' was not declared in this scope
   29 |         cout << solve(v,n,k) << endl;
      |                 ^~~~~
a.cc:29:33: error: 'endl' was not declared in this scope
   29 |         cout << solve(v,n,k) << endl;
      |                                 ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const long long INF = 9e9;

template<class T> inline bool chmin(T &a,T b){
  if(a > b){
    a = b;
    return true;
  }
  else
    return false;
}

using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  rep0(i,N){
    cin >> h[i];
  }
  long long dp[N];
  rep0(i,N){
    dp[i] = INF;
  }
  dp[0]=0;
  rep1(i,N){
    rep1(j,min(i,K);j++){
      dp[i] = chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout << dp[N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:20: error: expected ')' before ';' token
   29 |     rep1(j,min(i,K);j++){
      |                    ^
a.cc:3:40: note: in definition of macro 'rep1'
    3 | #define rep1(i,n) for(int i=1;i<=(int)(n);i++)
      |                                        ^
a.cc:3:39: note: to match this '('
    3 | #define rep1(i,n) for(int i=1;i<=(int)(n);i++)
      |                                       ^
a.cc:29:5: note: in expansion of macro 'rep1'
   29 |     rep1(j,min(i,K);j++){
      |     ^~~~
a.cc:29:10: error: 'j' was not declared in this scope
   29 |     rep1(j,min(i,K);j++){
      |          ^
a.cc:3:43: note: in definition of macro 'rep1'
    3 | #define rep1(i,n) for(int i=1;i<=(int)(n);i++)
      |                                           ^
Language: C++

#include <bits/stdc++.h>
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const long long INF = 9e9;

template<class T> inline bool chmin(T &a,T b){
  if(a > b){
    a = b;
    return true;
  }
  else
    return false;
}

using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int h[N];
  rep0(i,N){
    cin >> h[i];
  }
  int dp[N];
  rep0(i,N){
    dp[i] = INF;
  }
  dp[0]=0;
  rep1(i,N){
    rep1(j,min(i,K);j++){
      dp[i] = chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout << dp[N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: warning: overflow in conversion from 'long long int' to 'int' changes value from '9000000000' to '410065408' [-Woverflow]
   25 |     dp[i] = INF;
      |             ^~~
a.cc:29:20: error: expected ')' before ';' token
   29 |     rep1(j,min(i,K);j++){
      |                    ^
a.cc:3:40: note: in definition of macro 'rep1'
    3 | #define rep1(i,n) for(int i=1;i<=(int)(n);i++)
      |                                        ^
a.cc:3:39: note: to match this '('
    3 | #define rep1(i,n) for(int i=1;i<=(int)(n);i++)
      |                                       ^
a.cc:29:5: note: in expansion of macro 'rep1'
   29 |     rep1(j,min(i,K);j++){
      |     ^~~~
a.cc:29:10: error: 'j' was not declared in this scope
   29 |     rep1(j,min(i,K);j++){
      |          ^
a.cc:3:43: note: in definition of macro 'rep1'
    3 | #define rep1(i,n) for(int i=1;i<=(int)(n);i++)
      |                                           ^