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

#include <bits/stdc++.h>

using namespace std;

int main(){
	int N;
	in >> N;

	vector<int> h(N);
	for(int index = 0; index < N; index++)
		in >> h[index];

	vector<long long int> DP(N, LLONG_MAX);
	DP[0] = 0;
	for(int index = 0; index < N; index++){
		if((index + 1) < N)
			DP[index + 1] = min(DP[index + 1], DP[index] + abs(h[index + 1] - h[index]));
		if((index + 2) < N)
			DP[index + 2] = min(DP[index + 2], DP[index] + abs(h[index + 2] - h[index]));
	}
	out << DP[N - 1];
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'in' was not declared in this scope; did you mean 'yn'?
    7 |         in >> N;
      |         ^~
      |         yn
a.cc:21:9: error: 'out' was not declared in this scope
   21 |         out << DP[N - 1];
      |         ^~~
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
  vector<long long int> DP
long long int DP_function(int i, vector<int> h){
	if(DP[i] == -1)
		DP[i] = min(abs(h[i + 2] - h[i]) + DP_function(i + 2, h), abs(h[i + 1] - h[i]) + DP_function(i + 1, h)); 
	
	return DP[i];
}
 
int main(){
	int N;
	cin >> N;
 
	vector<int> h(N);
	for(int index = 0; index < N; index++)
		cin >> h[index];
 
	 DP.resize(N, -1);
	DP[N - 1] = 0;
	DP[N - 2] = abs(h[N - 1] - h[N - 2]);
	cout << DP_function(0, h);
 
	return 0;
}

Compiler output:
a.cc:5:1: error: expected initializer before 'long'
    5 | long long int DP_function(int i, vector<int> h){
      | ^~~~
a.cc: In function 'int main()':
a.cc:20:10: error: 'DP' was not declared in this scope
   20 |          DP.resize(N, -1);
      |          ^~
a.cc:23:17: error: 'DP_function' was not declared in this scope
   23 |         cout << DP_function(0, h);
      |                 ^~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int dp[100005];
int rec(int i,int n){
	if(i==n)return 0;
	if(dp[i]!=-1)return dp[i];

	         int  	x=i+1<=n?abs(h[i]-h[i+1])+rec(i+1,n):INF;
	          int  y=i+2<=n?abs(h[i]-h[i+2])+rec(i+2,n):INF; 
	            return dp[i]=min(x,y);
	          
}
int main() {
     int n,i;
     cin>>n;
     for(i=1;i<=n;i++){
     	cin>>h[i];
     }
     for(i=1;i<=n;i++){
     	dp[i]=-1;
     }
   int  ans=rec(1,n);
   cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int rec(int, int)':
a.cc:8:38: error: 'h' was not declared in this scope
    8 |                  int    x=i+1<=n?abs(h[i]-h[i+1])+rec(i+1,n):INF;
      |                                      ^
a.cc:8:62: error: 'INF' was not declared in this scope
    8 |                  int    x=i+1<=n?abs(h[i]-h[i+1])+rec(i+1,n):INF;
      |                                                              ^~~
a.cc: In function 'int main()':
a.cc:17:14: error: 'h' was not declared in this scope
   17 |         cin>>h[i];
      |              ^
Language: C++

//
// Created by Naman Bhalla on 2019-05-26.
//

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

int dp[100005];
int h[100005];
int main(){
    memset(dp, 0, sizeof dp);

    int n;
    cin >> n;

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

    h[0] = INT_MAX;
    for(int i = 2; i <= n; ++i){
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:24:12: error: 'INT_MAX' was not declared in this scope
   24 |     h[0] = INT_MAX;
      |            ^~~~~~~
a.cc:9:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include <cstring>
  +++ |+#include <climits>
    9 |
Language: C++

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAXN = 1e5  + 10;
long long dp[MAXN];
long long h[MAXN];
int main() {
  int n;
	cin >> n;
  	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 = 1; j <= 2 && i + j <= n; j++) {
    	dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]);
    }
  }
                        
  cout << dp[n];
  return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAXN = 1e5  + 10;
long long dp[MAXN];
int main() {
  int n;
	cin >> n;
  	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 = 1; j <= 2 && i + j <= n; j++) {
    	dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]);
    }
  }
                        
  cout << dp[n];
  return 0;
}

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

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

int max(int a,int b){
	if(a>b) return a;
	else return b;
}

int min(int a,int b){
	if(a>b) return b;
	else return a;
}

int min_array(int *array){
	int min=array[0];
	for(int i=1;i<sizeof(array)/sizeof(int);i++){
		if(min>array[i]) min=array[i];
	}
	return min
}

int main(void){
	int n,h[100000],dp[100000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

Compiler output:
main.c: In function 'min_array':
main.c:19:19: error: expected ';' before '}' token
   19 |         return min
      |                   ^
      |                   ;
   20 | }
      | ~
Language: C

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

int max(int a,int b){
	if(a>b) return a;
	else return b;
}

int min(int a,int b){
	if(a>b) return b;
	else return a;
}

int min_array(int *array){
	min=array[0];
	for(int i=1;i<sizeof(array)/sizeof(int);i++){
		if(min>array[i]) min=array[i];
	}
	return min;
}

int main(void){
	int n,h[100000],dp[100000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

Compiler output:
main.c: In function 'min_array':
main.c:15:12: error: lvalue required as left operand of assignment
   15 |         min=array[0];
      |            ^
main.c:17:23: warning: comparison between pointer and integer
   17 |                 if(min>array[i]) min=array[i];
      |                       ^
main.c:17:37: error: lvalue required as left operand of assignment
   17 |                 if(min>array[i]) min=array[i];
      |                                     ^
main.c:19:16: error: returning 'int (*)(int,  int)' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
   19 |         return min;
      |                ^~~
Language: C

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

int max(int a,int b){
	if(a>b) return a;
	else return b;
}

int min(int a,int b){
	if(a>b) return b;
	else return a;
}

int min_array(int *array){
	min=array[0];
	for(int i=1;i<sizeof(array)/sizeof(int);i++){
		if(min>array[i]) min=array[i];
	}
	return min
}

int main(void){
	int n,h[100000],dp[100000];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
	}
	printf("%d\n",dp[n-1]);
	return 0;
}

Compiler output:
main.c: In function 'min_array':
main.c:15:12: error: lvalue required as left operand of assignment
   15 |         min=array[0];
      |            ^
main.c:17:23: warning: comparison between pointer and integer
   17 |                 if(min>array[i]) min=array[i];
      |                       ^
main.c:17:37: error: lvalue required as left operand of assignment
   17 |                 if(min>array[i]) min=array[i];
      |                                     ^
main.c:19:16: error: returning 'int (*)(int,  int)' from a function with return type 'int' makes integer from pointer without a cast [-Wint-conversion]
   19 |         return min
      |                ^~~
main.c:19:19: error: expected ';' before '}' token
   19 |         return min
      |                   ^
      |                   ;
   20 | }
      | ~
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:22:13: error: too few arguments to function 'int mn(int, long long int)'
   22 |     cout<<mn(1)<<endl;
      |           ~~^~~
a.cc:7:5: note: declared here
    7 | int mn(int i,long long sum)
      |     ^~
Language: C++


    if (m >= n )sum = 2e9;
    if (m >= n - 1)return sum;
    if (dp1[m])return dp1[m];

    return dp1[m] = min(dp(m + 1,sum + abs(least[m] - least[m + 1])), dp(m + 2 , sum + abs(least[m] - least[m + 2])));


}


int main()
{

    cin >> n;
    for (int i = 0 ; i < n ; i++)cin >> least[i];

    cout<<dp(0,0)<<endl;


    return 0;
}


Compiler output:
a.cc:2:5: error: expected unqualified-id before 'if'
    2 |     if (m >= n )sum = 2e9;
      |     ^~
a.cc:3:5: error: expected unqualified-id before 'if'
    3 |     if (m >= n - 1)return sum;
      |     ^~
a.cc:4:5: error: expected unqualified-id before 'if'
    4 |     if (dp1[m])return dp1[m];
      |     ^~
a.cc:6:5: error: expected unqualified-id before 'return'
    6 |     return dp1[m] = min(dp(m + 1,sum + abs(least[m] - least[m + 1])), dp(m + 2 , sum + abs(least[m] - least[m + 2])));
      |     ^~~~~~
a.cc:9:1: error: expected declaration before '}' token
    9 | }
      | ^
a.cc: In function 'int main()':
a.cc:15:5: error: 'cin' was not declared in this scope
   15 |     cin >> n;
      |     ^~~
a.cc:15:12: error: 'n' was not declared in this scope
   15 |     cin >> n;
      |            ^
a.cc:16:41: error: 'least' was not declared in this scope
   16 |     for (int i = 0 ; i < n ; i++)cin >> least[i];
      |                                         ^~~~~
a.cc:18:5: error: 'cout' was not declared in this scope
   18 |     cout<<dp(0,0)<<endl;
      |     ^~~~
a.cc:18:11: error: 'dp' was not declared in this scope
   18 |     cout<<dp(0,0)<<endl;
      |           ^~
a.cc:18:20: error: 'endl' was not declared in this scope
   18 |     cout<<dp(0,0)<<endl;
      |                    ^~~~
Language: C++

#include <bits/stdc++.h>

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

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

using namespace std;

const long long INF = 1LL << 60;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

// 入力
//    int N;
    long long h[100010];

// DP テーブル
    long long dp[100010];
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;


    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

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


}

Compiler output:
a.cc:13:13: error: expected unqualified-id before numeric constant
   13 | #define INF 1e9
      |             ^~~
a.cc:20:17: note: in expansion of macro 'INF'
   20 | const long long INF = 1LL << 60;
      |                 ^~~
a.cc: In function 'int main()':
a.cc:73:9: error: 'chmin' was not declared in this scope
   73 |         chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
      |         ^~~~~
Language: C++

#include < iostream >


#define maxn 1000001
#define ll long long 
using namespace std;

ll DP[maxn];
int N;
int height[maxn];

ll min(ll a, ll b) {
	if (a <= b) return a;
	return b;
}

ll cal(int pos) {
	if (pos == N - 1) return 0LL;


	ll& res = DP[pos];

	if (res != -1) return res;

	res = abs(height[pos] - height[pos + 1]) + cal(pos + 1);
	if (pos + 2 < N)
		res = min(res, abs(height[pos] - height[pos + 2]) + cal(pos + 2));
	return res;
}


int main() {

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

	for (int i = 0; i < maxn; i++) {
		DP[i] = -1;
	}

	cout << cal(0) << endl;



	return 0;
}

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

#include<bits/stdc++.h>
using namespace std ;
#define rep(i,n) for(int i=0;i<n;i++)
#define maxn 200005
#define int long long
int dp[maxn];
void solve(){
    int n ;
    cin >> n ;
    int arr[n];
    rep(i,n){
        cin >> arr[i] ;
    }
    dp[0] = 0 ;
    dp[1] = arr[1]-arr[0] ;
    for(int i=2;i<n;i++){
        dp[i] = min(abs(arr[i]-arr[i-1])+dp[i-1],
                    abs(arr[i]-arr[i-2])+dp[i-2]);
    }
    cout << dp[n-1] ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1 ;
    while(t--){solve();}
    return 0 ;
}


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

import math
n_test = 1

def solve():
    n = int(input())
    h = list(map(int, input().split()))

    res = [0 for _ in range(n)]
    res[0] = 0
    res[1] = abs(h[1] - h[0])

    for i in range(2, n):
        res[i] = min(res[i - 2] + abs(h[i] - h[i - 2]), 
                     res[i - 1] + abs(h[i] - h[i - 1]))

    return res[n - 1]



for _ in range(n_test):
    print(solve())

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

/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = ''; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
} 
  
/* Driver program to test above function */
int main() 
{ 
  char X[3030] = {}; 
  char Y[3030] = {};
  scanf("%s%s", X, Y);
  int m = strlen(X); 
  int n = strlen(Y); 
  lcs(X, Y, m, n); 
  return 0; 
} 

Compiler output:
a.cc:32:17: error: empty character constant
   32 |    lcs[index] = ''; // Set the terminating character
      |                 ^~
Language: Java

import java.util.Scanner;
import java.lang.Math;

public class apples {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n; n =in.nextInt();
		int[] h = new int[n];
		for(int i=0;i<n;i++) h[i]=in.nextInt();
		int[] dp = new int[n];
		for(int i=0;i<n;i++) dp[i]=1000000000;
		dp[0]=0;
		for(int i=1;i<n;i++)
		{
			if(i>=2) dp[i]=Math.min(dp[i-1]+Math.abs(h[i]-h[i-1]), dp[i-2]+Math.abs(h[i]-h[i-2]));
			else dp[i]=dp[i-1]+Math.abs(h[1]-h[0]);
		}
		//for(int i=0;i<n;++i) System.out.println(dp[i]);
		System.out.print(dp[n-1]);
	}
}


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

//package com.karancp;

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.InputStream;


public class karan {
    public static void main(String args[])
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader z = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        task solver =new task();
        solver.solve(z,out);
        out.close();
    }

    static class task
    {

        static long gcd(long a,long b)
        {
            if(b==0)return a;
            else return gcd(b,a%b);
        }
        static long lcm(long a,long b)
        {
            long pp=a*b;
            long bb=gcd(a,b);
            long res =pp/bb;
            return res;
        }
        static int max(int a,int b)
        {
            return Math.max(a,b);
        }
        static int min(int a,int b)
        {
            return Math.min(a,b);
        }





        public static void solve(InputReader z, PrintWriter out) {
            int n=z.nextInt();
            int ar[]=new int[n];
            int dp[]=new int[n+1];
            int i;
            for(i=0;i<n;i++)ar[i]=z.nextInt();

            dp[1]=0;
            dp[2]=Math.abs(ar[0]-ar[1]);
            for(i=3;i<=n;i++)
            {
                int a=Math.abs(ar[i-2]-ar[i-1]);
                int b=Math.abs(ar[i-3]-ar[i-1]);
                dp[i]=Math.min(dp[i-1]+a,dp[i-2]+b);
            }
            out.print(dp[n]);


        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }

    }



}

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


import java.util.*;
public class Frog1 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int nums[] = new int[n];
		int dp[] = new int[n];		
		Arrays.fill(dp, 999999);
		dp[0] = 0;
		for(int i = 0 ; i < n; i++) {
			nums[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++) {
			if(i + 1 < n)dp[i+1] = Math.min(dp[i+1],  Math.abs(nums[i] - nums[i+1]) + dp[i]);
			if(i + 2 < n)dp[i+2] = Math.min(dp[i+2],  Math.abs(nums[i] - nums[i+2]) + dp[i]);
		}
		System.out.println(dp[n-1]);
	}
}


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

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<limits>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

int main(void) {
	int N;
	cin >> N;

	vector<long long> h(N);
	rep(i, N) cin >> h[i];

	vector<long long> dp(N, LLONG_MAX);
	dp[0] = 0;
	REP(i, 1, N)
	{
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) 
		{
			chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}
	cout << dp[N - 1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:33: error: 'LLONG_MAX' was not declared in this scope
   20 |         vector<long long> dp(N, LLONG_MAX);
      |                                 ^~~~~~~~~
a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include<limits>
  +++ |+#include <climits>
    7 | #define REP(i,m,n) for(int i = m; i < n; i++)
Language: C++

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

#define mod 1e9+7

int main()
{
  int m, n;
  cin >> m >> n;
  char a[m][n];
  for(int i = 0; i < m; i++)
    for(int j = 0; j < n; j++)
      cin >> a[i][j];
  
  int DP[m + 1][n + 1];
    
    for (int i = 0; i <= m; ++i)
        for (int j = 0; j <= n; ++j)
        {
            if (i == 0 || j == 0)
                DP[i][j] = 0;
            else if (a[i - 1][j - 1] == '#')
                DP[i][j] = 0;
            else if (i == 1 && j == 1)
                DP[i][j] = 1;
            else
                DP[i][j] = (DP[i][j - 1] % mod + DP[i - 1][j]%mod)%mod;
        }
    
    cout << DP[m][n] << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:42: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   27 |                 DP[i][j] = (DP[i][j - 1] % mod + DP[i - 1][j]%mod)%mod;
      |                             ~~~~~~~~~~~~ ^
      |                                        |
      |                                        int
a.cc:27:62: error: invalid operands of types 'int' and 'double' to binary 'operator%'
   27 |                 DP[i][j] = (DP[i][j - 1] % mod + DP[i - 1][j]%mod)%mod;
      |                                                  ~~~~~~~~~~~~^
      |                                                             |
      |                                                             int
Language: C++

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

void knapsack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   long long K[n+1][W+1]; 
  
   for (i = 0; i <= n; i++)
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
}

int main()
{
  int n, w;
  cin >> n >> w;
  
  int val[n], wt[n];
  for(int i = 0; i < n; i++)
    cin >> wt[i] >> val[i];
  
  knapsack(w, wt, val, n);
}


Compiler output:
a.cc: In function 'void knapsack(int, int*, int*, int)':
a.cc:22:17: error: return-statement with a value, in function returning 'void' [-fpermissive]
   22 |    return K[n][W];
      |           ~~~~~~^
Language: C++

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

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   }  
   int index = L[m][n]; 
   //char lcs[index+1]; 
   string lcs = ""; 

   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs += X[i-1];
          i--; j--; index--;
      } 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   }
  reverse(lcs.begin(), lcs.end(());
  cout << lcs << endl;
}

int main()
{
  string s1, s2;
  cin >> s1 >> s2;
  lcs(s1, s2, s1.length(), s2.length());
  return 0;
}


Compiler output:
a.cc: In function 'void lcs(std::string, std::string, int, int)':
a.cc:36:33: error: expected primary-expression before ')' token
   36 |   reverse(lcs.begin(), lcs.end(());
      |                                 ^
Language: C

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

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   }  
   int index = L[m][n]; 
   //char lcs[index+1]; 
   string lcs = ""; 

   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs += X[i-1];
          i--; j--; index--;
      } 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   }
  reverse(lcs.begin(), lcs.end(());
  cout << lcs << endl;
}

int main()
{
  string s1, s2;
  cin >> s1 >> s2;
  lcs(s1, s2, s1.length(), s2.length());
  return 0;
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
int min(int a, int b)
{
	return a < b ? a : b;
}
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{
	int N;
	int h[100010];
	int dp[100010] = {0};
	scanf("%d", &N);
	
	for (int i = 1;i <= N;i++)scanf("%d", &h[i]);
	h[0] = h[1];
	for (int i = 2;i <= N;i++)
	{
		/*dp[i-1]から1つジャンプ*/
		int step1 = dp[i - 1] + abs(h[i-1]-h[i]);
		/*dp[i-2]から2つジャンプ*/
		int step2 = dp[i - 2] + abs(h[i - 2] - h[i]);
		dp[i] = min(step1, step2);
	}

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

#include<bits/stdc++.h>
using namespace std;
#define high 100000000
int n;

void func(int x,int *a,int *b)
{
	if(x==n-1) return;
	if(b[x+1]>b[x]+abs(a[x+1]-a[x])) b[x+1]=b[x]+abs(a[x+1]-a[x]);
	if(x!=n-2)if(b[x+2]>b[x]+abs(a[x+2]-a[x])) b[x+2]=b[x]+abs(a[x+2]-a[x]);
	return func(x+1,a,b);
}

int main()
{
	
	cin>>n;
	long long int a[n],i,b[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=high;
	}
	b[0]=0;
	func(0,a,b);
	cout<<b[n-1]<<endl;
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:16: error: cannot convert 'long long int*' to 'int*'
   25 |         func(0,a,b);
      |                ^
      |                |
      |                long long int*
a.cc:6:22: note:   initializing argument 2 of 'void func(int, int*, int*)'
    6 | void func(int x,int *a,int *b)
      |                 ~~~~~^
Language: C++

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

int main(){
  int n;cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h.at(i);
  }
  vector<int> dp(N);
  
  dp.at(0)=0;dp.at(1)=abs(h.at(1)-h.at(0));
  
  for(int i=2;i<N;i++){
    dp.at(i)=min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)),dp.at(i-2)+abs(h.at(i)-h.at(i-2));
  }
  cout<<dp.at(N-1);    
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:18: error: 'N' was not declared in this scope
   10 |   vector<int> dp(N);
      |                  ^
a.cc:15:85: error: expected ')' before ';' token
   15 |     dp.at(i)=min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)),dp.at(i-2)+abs(h.at(i)-h.at(i-2));
      |                 ~                                                                   ^
      |                                                                                     )
Language: C++

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

const int N = 100000;
const int K = 100;
int n,k;
int arr[N];
int matrix[N][K];


int checkmin(int i){
  int res = matrix[i][0];
  for(int j = 0; j < k; j++){
    if(matrix[i][j] >= 0){
      res = min(res,matrix[i][j]);
    }
  }
  return res;
}


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

  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  
  for(int r = 0; r < k; r++){
    for(int f = 0; f < n; f++){
      if(r > n-f-1) matrix[f][r] = -1;
    }
    matrix[n-1][b] = 0;
    matrix[n-b-2][b] = abs(arr[n-b-2]-arr[n-1]);
  }


  for(int j = n-2; j >= 0; j--){
    for(int h = 0; h < k; h++){
      if(h < n-j-1){
        matrix[j][h] = abs(arr[j] - arr[j+h+1]) + checkmin(j+h+1);
      }
    }
  }
  // for(int j = 0; j < n; j++){
  //   for(int h = 0; h < k; h++){
  //     printf("%d ",matrix[j][h] );
  //   }
  //   printf("\n");
  // }
  int res = matrix[0][0];
  for(int a = 0; a < k; a++){
    res = min(res,matrix[0][a]);
  }
  cout << res;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: 'b' was not declared in this scope
   34 |     matrix[n-1][b] = 0;
      |                 ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Frog {

    static int[] height;
    static int[] minHeight;

    static void min(int i){
        if(i==0){
            minHeight[0] = 0;

        }
        else if(i==1){
            int a = height[0];
            int b = height[1];
            int c = a-b;
            if(c<0){
                c = -c;
            }
            minHeight[1] = c;
        }
        else {
            int d = height[i];
            int a = height[i - 1];
            int b = height[i - 2];

            a = a - d;
            b = b - d;

            if (a < 0) {
                a = -a;
            }
            if (b < 0) {
                b = -b;
            }

            a = minHeight[i-1] + a;
            b = minHeight[i-2] + b;

            int c = a;
            if (a > b) {
                c = b;
            }
            minHeight[i] = c;
        }
    }
    public static void main(String[] args) throws IOException {

        BufferedReader inp = new BufferedReader(new InputStreamReader(System.in));
        String sz = inp.readLine();
        int size = Integer.parseInt(sz);

        String[] given = inp.readLine().split(" ");
        height = new int[size];
        minHeight = new int[size];

        for(int i=0;i<size;i++){
            height[i] = Integer.parseInt(given[i]);
        }

        int ans = 0;

        for (int i=0;i<size;i++){
             min(i);
        }

        System.out.println(minHeight[size-1]);


    }
}


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:67: error: expected ';' before '}' token
   14 |     dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]))
      |                                                                   ^
      |                                                                   ;
   15 |   }
      |   ~
Language: Java

import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Atcoder_dp_A {
    static class Node implements Comparable<Node>{
        int index;
        int cost;
        Node(int index,int cost){
            this.index = index;
            this.cost = cost;
        }
        public int compareTo(Node other){
            if(this.cost == other.cost)
                return 0;
            else if(this.cost > other.cost)
                return 1;
            else
                return -1;
        }
    }
    public static void bfs(int[] arr){
        LinkedList<Node> queue = new LinkedList<Node>();
        LinkedList<Node> res = new LinkedList<Node>();
        queue.add(new Node(0,0));
        while (!queue.isEmpty()){
            Node current = queue.poll();
            if(current.index == arr.length-1){
                res.add(current);
            }
            if(current.index + 1 < arr.length){
                queue.add(new Node(current.index+1,current.cost + Math.abs(arr[current.index+1] - arr[current.index])));
            }
            if(current.index+2 < arr.length){
                queue.add(new Node(current.index+2,current.cost + Math.abs(arr[current.index+2] - arr[current.index])));
            }
        }
        Collections.sort(res);
        System.out.println(res.get(0).cost);
    }
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] arr = new int[n];
        for(int i = 0;i < n;i++){
            arr[i] = input.nextInt();
        }
        bfs(arr);
    }
}


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

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

public class Main
{
  	char[] n;
  	int d, l;
  	long mod = (long)1e9+7;
  	long[][][] dp;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.next().toCharArray();
      d = in.nextInt();
      dp = new long[2][d][l = n.length];
      for (int i = 0; i < 2; i++)
        for (int j = 0; j < d; j++)
          Arrays.fill(dp[i][j], -1L);
      out.println(dp(1, 0, 0)-1);
    }
  
  	long dp(int b, int s, int at)
    {
      if (s >= d) s %= d;
      if (at == l) return s == 0 ? 1L : 0L;
      if (dp[b][s][at] != -1L) return dp[b][s][at];
      
      long ans = 0L;
      int lo = (b == 0 && n == l-1) ? 1 : 0;
      int up = b == 1 ? n[at]-'1' : 9;
      if (b == 1)
        ans += dp(1, s+n[at]-'0', at+1);
      for (int i = lo; i <= up; i++)
        ans += dp(0, s+i, at+1);
      return dp[b][s][at] = ans % mod;
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}


Compiler output:
Main.java:29: error: bad operand types for binary operator '=='
      int lo = (b == 0 && n == l-1) ? 1 : 0;
                            ^
  first type:  char[]
  second type: int
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;
int nRocher;
int tab[100005];
int memo[100005];
int DP(int iRocher)
{
    if(iRocher==nRocher-1)
    {
        return 0;
    }
    else if(iRocher==nRocher)
    {
        return 1000000000;
    }
    else if(memo[iRocher][1]==0)
    {
        memo[iRocher][0]=min(DP(iRocher+1)+abs(tab[iRocher]-tab[iRocher+1]),DP(iRocher+2)+abs(tab[iRocher]-tab[iRocher+2]));
        memo[iRocher][1]=1;
    }
    return memo[iRocher][0];
}
int main()
{
    scanf("%d", &nRocher);
    for(int i=0;i<nRocher;i++)
    {
        scanf("%d", &tab[i]);
    }
    printf("%d", DP(0));
}

Compiler output:
a.cc: In function 'int DP(int)':
a.cc:16:26: error: invalid types 'int[int]' for array subscript
   16 |     else if(memo[iRocher][1]==0)
      |                          ^
a.cc:18:22: error: invalid types 'int[int]' for array subscript
   18 |         memo[iRocher][0]=min(DP(iRocher+1)+abs(tab[iRocher]-tab[iRocher+1]),DP(iRocher+2)+abs(tab[iRocher]-tab[iRocher+2]));
      |                      ^
a.cc:19:22: error: invalid types 'int[int]' for array subscript
   19 |         memo[iRocher][1]=1;
      |                      ^
a.cc:21:25: error: invalid types 'int[int]' for array subscript
   21 |     return memo[iRocher][0];
      |                         ^
Language: C++

using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(dp(n,h)[n-1]);
    }
    static int[] dp(int n, int[] h) {
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.Abs(h[1]-h[0]);
        for(int i = 2; i < n; i ++) {
            dp[i] = Math.Min(Math.Abs(h[i]-h[i-1])+dp[i-1], Math.Abs(h[i]-h[i-2])+dp[i-2]);
        }
        return dp;
    }
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Linq;
      |       ^~~~~~
a.cc:6:22: error: 'string' has not been declared
    6 |     static void Main(string[] args) {
      |                      ^~~~~~
a.cc:6:31: error: expected ',' or '...' before 'args'
    6 |     static void Main(string[] args) {
      |                               ^~~~
a.cc:11:15: error: expected unqualified-id before '[' token
   11 |     static int[] dp(int n, int[] h) {
      |               ^
a.cc:20:2: error: expected ';' after class definition
   20 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Program::Main(int*)':
a.cc:7:17: error: expected primary-expression before 'int'
    7 |         int n = int.Parse(Console.ReadLine());
      |                 ^~~
a.cc:8:12: error: structured binding declaration cannot have type 'int'
    8 |         int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
      |            ^~
a.cc:8:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:8:12: error: empty structured binding declaration
a.cc:8:15: error: expected initializer before 'h'
    8 |         int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
      |               ^
a.cc:9:9: error: 'Console' was not declared in this scope
    9 |         Console.WriteLine(dp(n,h)[n-1]);
      |         ^~~~~~~
a.cc:9:32: error: 'h' was not declared in this scope
    9 |         Console.WriteLine(dp(n,h)[n-1]);
      |                                ^
a.cc:9:27: error: 'dp' was not declared in this scope
    9 |         Console.WriteLine(dp(n,h)[n-1]);
      |                           ^~
Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}

void solve(void){
    int n;
    cin >> n;
    int h[n];
    rep(i,0,n) cin >> h[i];
    int dp[n];
    dp[0] = 0;
    rep(i,1,n){
        dp[i] = INF;
    }
    
    rep(i,2,n){
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i > 1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << endl;

}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}g++ 

Compiler output:
a.cc:115:2: error: 'g' does not name a type
  115 | }g++
      |  ^
Language: C++

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

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

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

const long long INF = 1LL << 60;

int main(){
  int N;
  cin >> N;
  int h[N];

  long long dp[100010];
  for(int i=0;i<100010;i++) dp[i] = INF;
  
  for(int i=0;i<N;++i)cin >> h[i];
  
  dp[0] = 0;
  dp[1] = h[1] - h[0];

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

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

#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[300005];
int f[300005];

main()
{
    int n;

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        f[i]=LONG_MAX;
    }
    f[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i;j>=max(i-2,0);j--)
            f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
    }
    cout<<f[n-1];
}


Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:20:27: error: no matching function for call to 'max(long long int, int)'
   20 |         for(int j=i;j>=max(i-2,0);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:20:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |         for(int j=i;j>=max(i-2,0);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:20:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |         for(int j=i;j>=max(i-2,0);j--)
      |                        ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[300005];
int f[300005];

int main()
{
    int n;

    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        f[i]=LONG_MAX;
    }
    f[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i;j>=max(i-2,0);j--)
            f[i]=min(f[i],f[j]+abs(a[i]-a[j]));
    }
    cout<<f[n-1];
}


Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:20:27: error: no matching function for call to 'max(long long int, int)'
   20 |         for(int j=i;j>=max(i-2,0);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:20:27: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |         for(int j=i;j>=max(i-2,0);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:20:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |         for(int j=i;j>=max(i-2,0);j--)
      |                        ~~~^~~~~~~
Language: C++

#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define int long long
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define INF 100000000

void chmin(int &a, int b) {
    if(a > b) {
        a = b;
    }
};

int main() {
    int n;
    cin >> n;
    int dp[100100];
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    rep(i, n) dp[i] = INF;
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    REP(i, 1, n) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
}


Compiler output:
cc1plus: error: '::main' must return 'int'