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

#include<bits/stdc++.h>
using namespace std;
int dp[100010],n,a[100010];
int solve()
{
  if(i==n)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  int m=0;
  if(i+1<n)
    m=abs(a[i]-a[i+1]);
  if(i+2<n)
  m=min(abs(a[i]-a[i+1])+solve(i+1),abs(a[i]-a[i+2])+solve(i+2));
  return dp[i]=m;
}
int main()
{
  memset(dp,-1,sizeof(dp));
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>a[i];
  cout<<solve()<<"\n";
  return 0;
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:6:6: error: 'i' was not declared in this scope
    6 |   if(i==n)
      |      ^
a.cc:8:9: error: 'i' was not declared in this scope
    8 |   if(dp[i]!=-1)
      |         ^
a.cc:11:6: error: 'i' was not declared in this scope
   11 |   if(i+1<n)
      |      ^
a.cc:13:6: error: 'i' was not declared in this scope
   13 |   if(i+2<n)
      |      ^
a.cc:15:13: error: 'i' was not declared in this scope
   15 |   return dp[i]=m;
      |             ^
Language: C++

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

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

    int A[n];
    for (int i = 0; i < n; ++i)
        cin >> A[i];
    int n_2 = 0;
    int n_1 = abs(A[0] - A[1]);
    if (n == 2)
      sum = n_1;

    int sum = 0;
    for (int i = 2; i < n; ++i) {
        sum = min(n_1 + abs(A[i] - A[i - 1]),
                  n_2 + abs(A[i] - A[i - 2]));
        n_2 = n_1;
        n_1 = sum;
    }

    cout << sum << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:7: error: 'sum' was not declared in this scope
   14 |       sum = n_1;
      |       ^~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  	//5 3
	//10 30 40 50 20
  	//0  20 30 40 30
  	int n,k;
  	cin >> n >> k;
  	int jump[n], dp[n]={INF};
  	for(int i=0;i<n;i++)
      cin >> jump[i];
    dp[0]=0;
  	for(int i=0;i<n;i++)
      for(int j=i+1;j<=i+k;j++)
        if(j<n)
        	dp[j]=min(dp[j], dp[i]+abs(jump[j]-jump[i]));
  	cout << dp[n-1];
}


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

#include<iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int input[n];
  for(int i=1;i<=n;i++)
  {
    cin >> input[i];
  }
  // 10, 30, 40, 20
  // 0,  20, 30  30
  int dp [n];
  dp[1]=0;
  dp[2]=abs(input[2]-input[1]);
  if(n<3)
    return dp[n];
  for(int i=3;i<=n;i++)
  {
    dp[i]=min(dp[i-1]+abs(input[i]-input[i-1]),dp[i-2]+abs(input[i]-input[i-2]))
  } 
  return dp[n];
}


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

#include<bits/stdc++.h>

using namespace std;
int minHeight(int arr[], vector<int> dp, int index)
{
  int len = dp.size();
  if(index >= len)
  {
    return 0;
  }
  if(dp[index]!=-1)
  {
   	int t1,t2;
    dp[index] = min( abs( arr[index] - arr[index - 1] ) + minHeight(arr, dp, index - 1), abs( arr[index] - arr[index - 2] ) + minHeight(arr, dp, index - 2);
  }
  return dp[index];                 
}

int main()
{
  int n;
  cin >> n;
  int arr[n];
  for(int i = 0; i < n; i++)
  {
   	cin >> arr[i];
  }
  vector<int> ans(n,-1);
  ans[0] = 0;
  ans[1] = abs( arr[1] - arr[0] );
  minHeight(arr, ans, 2);
  cout<< ans[n-1] <<endl;
}


Compiler output:
a.cc: In function 'int minHeight(int*, std::vector<int>, int)':
a.cc:14:156: error: expected ')' before ';' token
   14 |     dp[index] = min( abs( arr[index] - arr[index - 1] ) + minHeight(arr, dp, index - 1), abs( arr[index] - arr[index - 2] ) + minHeight(arr, dp, index - 2);
      |                    ~                                                                                                                                       ^
      |                                                                                                                                                            )
Language: C++

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

int main(){
    ll n;
    cin >> n;
    vector<ll> dp(n,1e18);
    ll i,j;
    dp[0]=0;
    ll h[n];
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    for(i=0;i<n;i++){
        if((i+1) < n){
            dp[i+1] = min(dp[i+1] , abs(h[i]-h[i+1]) + dp[i] );
        }
        if((i+2) < n){
            dp[i+2] = min(dp[i+2] , abs(h[i]-h[i+2]) + dp[i] );
        }
    }
    cout << dp[n-1] << endl;
}

Compiler output:
a.cc:3:2: error: invalid preprocessing directive #deifne; did you mean #define?
    3 | #deifne ll long long
      |  ^~~~~~
      |  define
a.cc: In function 'int main()':
a.cc:6:5: error: 'll' was not declared in this scope
    6 |     ll n;
      |     ^~
a.cc:7:12: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |     cin >> n;
      |            ^
      |            yn
a.cc:8:14: error: template argument 2 is invalid
    8 |     vector<ll> dp(n,1e18);
      |              ^
a.cc:8:25: error: expression list treated as compound expression in initializer [-fpermissive]
    8 |     vector<ll> dp(n,1e18);
      |                         ^
a.cc:9:7: error: expected ';' before 'i'
    9 |     ll i,j;
      |       ^~
      |       ;
a.cc:10:7: error: invalid types 'int[int]' for array subscript
   10 |     dp[0]=0;
      |       ^
a.cc:11:7: error: expected ';' before 'h'
   11 |     ll h[n];
      |       ^~
      |       ;
a.cc:12:9: error: 'i' was not declared in this scope
   12 |     for(i=0;i<n;i++){
      |         ^
a.cc:13:16: error: 'h' was not declared in this scope
   13 |         cin >> h[i];
      |                ^
a.cc:15:9: error: 'i' was not declared in this scope
   15 |     for(i=0;i<n;i++){
      |         ^
a.cc:17:41: error: 'h' was not declared in this scope
   17 |             dp[i+1] = min(dp[i+1] , abs(h[i]-h[i+1]) + dp[i] );
      |                                         ^
a.cc:20:41: error: 'h' was not declared in this scope
   20 |             dp[i+2] = min(dp[i+2] , abs(h[i]-h[i+2]) + dp[i] );
      |                                         ^
Language: Java

import java.util.*;
public class Frog1_atcoder {
    static int calculate_cost(int h[],int N)
    {
        int dp[]=new int[N];
        dp[0]=0;
        dp[1]=Math.abs(h[0]-h[1]);
        int i;
        for(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[N-1];
    }
    public static void main(String[]args)
    {
        Scanner sc=new Scanner(System.in);
        int i;
        int N=sc.nextInt();
        sc.nextLine();
        int h[]=new int[N];
        StringTokenizer tk=new StringTokenizer(sc.nextLine());
        for(i=0;i<N;i++)
            h[i]=Integer.parseInt(tk.nextToken());
        int totalcost=calculate_cost(h,N);
        System.out.println(totalcost);
    }

}


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

import java.util.*;
public class Frog1_atcoder {
    static int calculate_cost(int h[],int N)
    {
        int dp[]=new int[N];
        dp[0]=0;
        dp[1]=Math.abs(h[0]-h[1]);
        int i;
        for(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[n-1];
    }
    public static void main(String[]args)
    {
        Scanner sc=new Scanner(System.in);
        int i;
        int N=sc.nextInt();
        sc.nextLine();
        int h[]=new int[N];
        StringTokenizer tk=new StringTokenizer(sc.nextLine());
        for(i=0;i<N;i++)
            h[i]=Integer.parseInt(tk.nextToken());
        int totalcost=calculate_cost(h,N);
        System.out.println(totalcost);
    }

}


Compiler output:
Main.java:2: error: class Frog1_atcoder is public, should be declared in a file named Frog1_atcoder.java
public class Frog1_atcoder {
       ^
Main.java:14: error: cannot find symbol
        return dp[n-1];
                  ^
  symbol:   variable n
  location: class Frog1_atcoder
2 errors
Language: Java

import java.util.*;
public class Frog1_atcoder {
    static int calculate_cost(int cost[],int n)
    {
        int dp[]=new int[n];
        dp[0]=0;
        dp[1]=Math.abs(cost[0]-cost[1]);
        int i;
        for(i=2;i<n;i++)
        {
            dp[i]=Math.min((Math.abs(cost[i]-cost[i-1])+dp[i-1]),(Math.abs(cost[i]-cost[i-2])+dp[i-2]));

        }
        return dp[n-1];
    }
    public static void main(String[]args)
    {
        Scanner sc=new Scanner(System.in);
        int i;
        int n=sc.nextInt();
        sc.nextLine();
        int cost[]=new int[n];
        StringTokenizer tk=new StringTokenizer(sc.nextLine());
        for(i=0;i<n;i++)
            cost[i]=Integer.parseInt(tk.nextToken());
        int totalcost=calculate_cost(cost,n);
        System.out.println(totalcost);
    }

}


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

    #include<bits/stdc++.h>
        
    using namespace std;
        
    #define H_MAX 100000
     
    int n;
    int height[H_MAX];
    int dp[H_MAX] = {0};
        
        
    //top down approach
    int minimumCost(int stone){
        // memory lookup
        if(dp[stone]!=0){
            return dp[stone];
        }
        
        // recursion logic
        
        int twoStep = INT_MAX;
        
        if(stone+2<n) twoStep = minimumCost(stone+2) + abs(height[stone]-height[stone+2]);
        int oneStep = 0;
        if(stone+1<n) oneStep = minimumCost(stone+1) + abs(height[stone]-height[stone+1]);
        
        return dp[stone] = min(oneStep, twoStep);
    }
        
    int main(){
        cin >> n;
        
        for(int i=0; i<n; i++){
            int x;
            cin >> x;
            height.push_back(x);
        }
        if (n == 1) cout << 0 << endl;
        else cout << minimumCost(0);
        
        return 0;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:36:20: error: request for member 'push_back' in 'height', which is of non-class type 'int [100000]'
   36 |             height.push_back(x);
      |                    ^~~~~~~~~
Language: C++

    #include<bits/stdc++.h>
            
        using namespace std;
            
        #define H_MAX 100000
            
vector<int> height;
int dp[H_MAX] = {0};

        //top down approach
        int minimumCost(int stone, int n){
            //base case
            if(stone==n-1){
                return 0;
            }
         
            // memory lookup
            if(dp[stone]!=0){
                return dp[stone];
            }
            
            // recursion logic
    		int twoStep = INT_MAX;
            
            if(stone+2<n) twoStep = minimumCost(stone+2, n) + abs(height[stone]-height[stone+2]);
                  
            int oneStep = 0;
            if(stone+1<n) = minimumCost(stone+1, n) + abs(height[stone]-height[stone+1]);
            
            
            return dp[stone] = min(oneStep, twoStep);
        }
            
        int main(){
            int n;
            cin >> n;
          
          height.resize(n);
            
          
            for(int i=0; i<n; i++){
                cin >> height[i];
            }
            
           
            
            cout << minimumCost(0, n);
            
            return 0;
        }

Compiler output:
a.cc: In function 'int minimumCost(int, int)':
a.cc:28:27: error: expected primary-expression before '=' token
   28 |             if(stone+1<n) = minimumCost(stone+1, n) + abs(height[stone]-height[stone+1]);
      |                           ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'j' was not declared in this scope
   16 |     for(j=1;j<=2 && (i+j)<=n;j++)
      |         ^
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Frog1
{
  static class FastScanner
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    String next() {
      while(!st.hasMoreTokens()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {}
      }
      return st.nextToken();
    }
    
    int nextInt() {
      return Integer.parseInt(next());
    }
    
    long nextLong() {
      return Long.parseLong(next());
    }
    
  }
  
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    int n = fs.nextInt();
    int[] arr = new int[n];
    for(int i = 0; i < n; ++i) {
      arr[i] = fs.nextInt();
    }
    int[] dp = new int[n];
    dp[1] = (int)Math.abs(arr[1]-arr[0]);
    for(int i = 2; i < n; ++i) {
      dp[i] = Math.min(dp[i-1] + (int)Math.abs(arr[i-1]-arr[i]), 
          dp[i-2] + (int)Math.abs(arr[i-2]-arr[i]));
    }
    PrintWriter out = new PrintWriter(System.out);
    out.println(dp[n-1]);
    out.close();
  }

}


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


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class frog1
{
  static class FastScanner
  {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    String next() {
      while(!st.hasMoreTokens()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {}
      }
      return st.nextToken();
    }
    
    int nextInt() {
      return Integer.parseInt(next());
    }
    
    long nextLong() {
      return Long.parseLong(next());
    }
    
  }
  
  public static void main(String[] args) {
    FastScanner fs = new FastScanner();
    int n = fs.nextInt();
    int[] arr = new int[n];
    for(int i = 0; i < n; ++i) {
      arr[i] = fs.nextInt();
    }
    int[] dp = new int[n];
    dp[1] = (int)Math.abs(arr[1]-arr[0]);
    for(int i = 2; i < n; ++i) {
      dp[i] = Math.min(dp[i-1] + (int)Math.abs(arr[i-1]-arr[i]), 
          dp[i-2] + (int)Math.abs(arr[i-2]-arr[i]));
    }
    PrintWriter out = new PrintWriter(System.out);
    out.println(dp[n-1]);
    out.close();
  }

}


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

#include<bits/stdc++.h>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int  arr[n];
    dp[n];
    for(int  i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1]- arr[0]);
    for(int i=2; i<n; i++)
    {
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] +abs(arr[i] - arr[i-2]) );
    }
    cout<< dp[n-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |     dp[n];
      |     ^~
      |     dup
Language: C++

#include<bits/stdc++.h>

using namespace std;
int main()
{
    int n;
    cin >> n;
    int  arr[n];
    dp[n];
    for(int  i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    dp[0] = 0;
    dp[1] = abs(arr[1]- arr[0]);
    for(ll i=2; i<n; i++)
    {
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] +abs(arr[i] - arr[i-2]) );
    }
    cout<< dp[n-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |     dp[n];
      |     ^~
      |     dup
a.cc:16:9: error: 'll' was not declared in this scope
   16 |     for(ll i=2; i<n; i++)
      |         ^~
a.cc:16:17: error: 'i' was not declared in this scope
   16 |     for(ll i=2; i<n; i++)
      |                 ^
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |     dp[n];
      |     ^~
      |     dup
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |     dp[n];
      |     ^~
      |     dup
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |     dp[n];
      |     ^~
      |     dup
Language: C++

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

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
    9 |     dp[100001];
      |     ^~
      |     dup
Language: C++

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
#define endl "\n"
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    PBDS;
typedef long long int ll;
const int N=1e5;
void solve(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
		}
		cout<<dp[n-1]<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output (2).txt","w",stdout);
#endif
	int t;
	t=1;
	while(t--){
	solve();
	}
	return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:17:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |         dp[0]=0;
      |         ^~
      |         dup
Language: C++

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

int main(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i=0; i<n; i++) cin>>arr[i];
  
  vector<int> dp(n,INT_MAX);
  dp[0]=0;
  dp[1]=abs(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]<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:39: error: expected ']' before ')' token
   15 |         dp[i] = min(abs(arr[i]-arr[i-1)+dp[i-1], abs(arr[i]-arr[i-2])+dp[i-2]);
      |                                       ^
      |                                       ]
Language: C++

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

vector<int> h;
vector<int> memo;

int f(int i){
    if(memo[i]!=-1) return memo[i];
    
    if(i==1) return memo[i]=0;
    
    int ret;
    if(i==2)
        ret = f(i-1) + abs(h[i]-h[i-1]);
    else
        ret = min(f(i-1) + abs(h[i]-h[i-1]),
                  f(i-2) + abs(h[i]-h[i-2]));
    
    return memo[i]=ret;
}

void solve(){
    int N;
    cin >> N;
    h.resize(N);
    rep(i,N) cin >> h[i];
    
    memo.assign(N+1, -1);
    
    cout << f(N) << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:27:9: error: 'i' was not declared in this scope
   27 |     rep(i,N) cin >> h[i];
      |         ^
a.cc:27:5: error: 'rep' was not declared in this scope
   27 |     rep(i,N) cin >> h[i];
      |     ^~~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
vector<int>a;
vector<int>memo;

int dp(int curr)
{
    if(curr >= (int)a.size()-1)
    {
        return 0;
    }
    if(memo[curr]!=-1)
    {
        return memo[curr];
    }
    int ans = INT_MAX;
    ans = min(ans,abs(a[curr]-a[curr+1])+dp(curr+1));
    if(curr+2<(int)a.size())
    {
         ans = min(ans,abs(a[curr]-a[curr+2])+dp(curr+2));
    }
    if(ans ==INT_MAX)
    {
        ans = 0;
    }
    return memo[curr] = ans;
}


int main()
{

    int n;
    cin>>n;

    a.resize(n);
    memo.resize(n+1,-1);
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
    }


    cout<<dp(0);

}


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

#include<iostream>
#include<vector>
using namespace std;
vector<int>a;
vector<int>memo;

int dp(int curr)
{
    if(curr >= a.size()-1)
    {
        return 0;
    }
    if(memo[curr]!=-1)
    {
        return memo[curr];
    }
    int ans = INT_MAX;
    ans = min(ans,abs(a[curr]-a[curr+1])+dp(curr+1));
    if(curr+2<a.size())
    {
         ans = min(ans,abs(a[curr]-a[curr+2])+dp(curr+2));
    }
    if(ans ==INT_MAX)
    {
        ans = 0;
    }
    return memo[curr] = ans;
}


int main()
{

    int n;
    cin>>n;
    a.resize(n);
    memo.resize(n+1,-1);
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
    }


    cout<<dp(0);

}


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

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

int main()
{
  // INPUT
  int n; cin >> n;
  int arr[n];
  for(int i=0;  i<n; i++) cin >> arr[i];

  // INIT
  int dp[n]={};

  // Base case already done: dp[n-1]=0;


  for(int i=n-2;i>=0;i--;)
  {
    int a = dp[i+1] + abs(arr[i]-arr[i+1]);
    int b = 0;
    if(i+2<n) b = dp[i+2] + abs(arr[i]-arr[i+2]);
    dp[i]= min(a,b);
  }

  // OUTPUT
  cout << dp[0] << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:25: error: expected ')' before ';' token
   17 |   for(int i=n-2;i>=0;i--;)
      |      ~                  ^
      |                         )
a.cc:17:26: error: expected primary-expression before ')' token
   17 |   for(int i=n-2;i>=0;i--;)
      |                          ^
Language: C++

// Program.cpp
 
#include <bits/stdc++.h>
using namespace std;
 
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
 
#define fr(i, n)            for(int i=0; i<(n); ++i)
#define frC(i, n)           for(int i=0; (i<(n)) && (c); ++i)
#define frA(i, a, n)        for(int i=a; i<=(n); ++i)
#define frD(i, a, n)        for(int i=a; i>=(n); --i)
#define fill(a)             memset(a, 0, sizeof(a))
#define revsort(a, b)       sort(a, b, greater<int>())
#define dout                if(DEBUGGING) cout
#define dbg                 if(DEBUGGING) 
#define endl                "\n"
 
int DEBUGGING    =          0;
const int INF    =          1000000010;
const int MOD    =          1000000007;
const double PI  =          3.1415926535897932;
const double EPS =          1e-7;

int arr[100005];
int m[100005];

int cost(int n, int i){
    if(m[n-i]!=INF){
        dout << i << "-> " << m[n-i] << endl;
        return m[i];
    }
    dout << "caclulating for pos "<<(n-i)<<endl;
    if(i == 1){
        m[n-1] = 0;
        return 0;
    }
    if(i == 2){
        m[n-2] = abs(arr[n-2] - arr[n-1]); 
        dout << i << "--> " << m[n-2] << endl;
        return m[n-2];
    }
    int a1 = cost(n,i-2,arr,m) + abs(arr[i-1]-arr[i-3]);
    int a2 = cost(n,i-1,arr,m) + abs(arr[i-1]-arr[i-2]);
    m[n-i] = min(a1,a2);
    dout << i << "--> " << m[n-i] << endl;
    return m[n-i];
 
}
 
void solve(int TEST_CASE){
    int n;
    cin >> n;
    fr(i,n){
        cin >> arr[i];
        m[i] = INF;
    }
    cout << cost(n,n,arr,m) << endl;
}
 
int main(int argc, char* argv[]){
    if(argc==2 && argv[1][1]=='v') DEBUGGING = 1;
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    int nTestCases=1;
    //cin >> nTestCases;
    frA(i,1,nTestCases) solve(i);
    return 0;
}

Compiler output:
a.cc: In function 'int cost(int, int)':
a.cc:44:18: error: too many arguments to function 'int cost(int, int)'
   44 |     int a1 = cost(n,i-2,arr,m) + abs(arr[i-1]-arr[i-3]);
      |              ~~~~^~~~~~~~~~~~~
a.cc:29:5: note: declared here
   29 | int cost(int n, int i){
      |     ^~~~
a.cc:45:18: error: too many arguments to function 'int cost(int, int)'
   45 |     int a2 = cost(n,i-1,arr,m) + abs(arr[i-1]-arr[i-2]);
      |              ~~~~^~~~~~~~~~~~~
a.cc:29:5: note: declared here
   29 | int cost(int n, int i){
      |     ^~~~
a.cc: In function 'void solve(int)':
a.cc:59:17: error: too many arguments to function 'int cost(int, int)'
   59 |     cout << cost(n,n,arr,m) << endl;
      |             ~~~~^~~~~~~~~~~
a.cc:29:5: note: declared here
   29 | int cost(int n, int i){
      |     ^~~~
Language: Java



		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] height = new int[n];
		for(int i=0; i<n; i++) {
			height[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		int[] temp = new int[n];
		for(int i=1; i<n; i++) {
			cost[i] = cost[i-1] + Math.abs(height[i]-height[i-1]);
			if(i-2>=0) {
				for(int j=2; j<k+1; j++) {
					if(i-j < 0) {
						break;
					}
					temp[i] = cost[i-j] + Math.abs(height[i]-height[i-j]);
					if(temp[i] < cost[i]) {
						cost[i] = temp[i];
					}
				}
				
			}
		}
		System.out.println(cost[n-1]);


Compiler output:
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
		Scanner sc = new Scanner(System.in);
		^
  (use --enable-preview to enable unnamed classes)
Main.java:7: error: class, interface, enum, or record expected
		for(int i=0; i<n; i++) {
		^
Main.java:7: error: class, interface, enum, or record expected
		for(int i=0; i<n; i++) {
		             ^
Main.java:7: error: class, interface, enum, or record expected
		for(int i=0; i<n; i++) {
		                  ^
Main.java:9: error: class, interface, enum, or record expected
		}
		^
Main.java:11: error: class, interface, enum, or record expected
		cost[0] = 0;
		^
Main.java:13: error: class, interface, enum, or record expected
		for(int i=1; i<n; i++) {
		^
Main.java:13: error: class, interface, enum, or record expected
		for(int i=1; i<n; i++) {
		             ^
Main.java:13: error: class, interface, enum, or record expected
		for(int i=1; i<n; i++) {
		                  ^
Main.java:15: error: class, interface, enum, or record expected
			if(i-2>=0) {
			^
Main.java:16: error: class, interface, enum, or record expected
				for(int j=2; j<k+1; j++) {
				             ^
Main.java:16: error: class, interface, enum, or record expected
				for(int j=2; j<k+1; j++) {
				                    ^
Main.java:19: error: class, interface, enum, or record expected
					}
					^
Main.java:21: error: class, interface, enum, or record expected
					if(temp[i] < cost[i]) {
					^
Main.java:23: error: class, interface, enum, or record expected
					}
					^
15 errors
Language: Java

import java.util.Scanner;

public class frog1 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] height = new int[n];
		for(int i=0; i<n; i++) {
			height[i] = sc.nextInt();
		}
		int[] cost = new int[n];
		cost[0] = 0;
		for(int i=1; i<n; i++) {
			cost[i] = cost[i-1]+Math.abs(height[i]-height[i-1]);
			if(i-2>=0) {
				cost[i] = Math.min(cost[i-2]+Math.abs(height[i]-height[i-2]), cost[i]);
			}
		}
		System.out.println(cost[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>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int m = s.size();
  int n = t.size();
  int ans[3000][3000];
  for(int i=0; i<m; i++)
    for(int j=0; j<n; j++)
    {
      if(i==0 || j==0)
       ans[i][j] = 0;
      else if(s[i-1]==t[j-1])
        ans[i][j] = ans[i-1][j-1]+1;
      else
        ans[i][j] = max(ans[i-1][j-1], max(ans[i][j-1], ans[i-1][j]);
                        }
     cout << ans[m-1][n-1] << endl;
                        }


Compiler output:
a.cc: In function 'int main()':
a.cc:18:69: error: expected ')' before ';' token
   18 |         ans[i][j] = max(ans[i-1][j-1], max(ans[i][j-1], ans[i-1][j]);
      |                        ~                                            ^
      |                                                                     )
Language: C++

#include <iostream>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int m = s.size();
  int n = t.size();
  ans[3000][3000];
  for(int i=0; i<m; i++)
    for(int j=0; j<n; j++)
    {
      if(i==0 || j==0)
      int ans[i][j] = 0;
      else if(s[i-1]==t[j-1])
        ans[i][j] = ans[i-1][j-1]+1;
      else
        ans[i][j] = max(ans[i-1][j-1], max(ans[i][j-1], ans[i-1][j]);
                        }
     cout << ans[m-1][n-1] << endl;
                        }


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
    9 |   ans[3000][3000];
      |   ^~~
      |   abs
a.cc:14:23: error: array must be initialized with a brace-enclosed initializer
   14 |       int ans[i][j] = 0;
      |                       ^
Language: C++

#include <iostream>
using namespace std;
int main()
{
  string s, t;
  cin >> s >> t;
  int m = s.size();
  int n = t.size();
  ans[3000][3000];
  for(int i=0; i<m; i++)
    for(int j=0; j<n; j++)
    {
      if(i==0 || j==0)
        ans[i][j] = 0;
      else if(s[i-1]==t[j-1])
        ans[i][j] = ans[i-1][j-1]+1;
      else
        ans[i][j] = max(ans[i-1][j-1], max(ans[i][j-1], ans[i-1][j]);
                        }
     cout << ans[m-1][n-1] << endl;
                        }


Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
    9 |   ans[3000][3000];
      |   ^~~
      |   abs
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define sz(a) int((a).size())
#define fr(i,n) for(int i=0;i<n;i++) 
#define rf(i,n) for(int i=1;i<=n;i++) 
#define pb push_back 
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define MAX INT_MAX 
#define f first
#define s second
using namespace std;
#define M 1000000007
int main()
{
    int n;
    cin>>n;
    std::vector<int> v(n);
    fr(i,n)
    cin>>v[i];
    int dp[n];
    memset(dp,INT_MAX,sizeof(dp));
    dp[0]=0;
    //dp[1]=min(v[1],abs(v[1]-v[0]));
    for(int i=1;i<n;i++)
        {
            dp[i+1] = min(abs(v[i]-v[i-1])+dp[i-1],dp[i])
            dp[i+2] = min(abs(v[i]-v[i-2])+dp[i-2],dp[i]);
        }
    cout<<dp[n-1]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:58: error: expected ';' before 'dp'
   29 |             dp[i+1] = min(abs(v[i]-v[i-1])+dp[i-1],dp[i])
      |                                                          ^
      |                                                          ;
   30 |             dp[i+2] = min(abs(v[i]-v[i-2])+dp[i-2],dp[i]);
      |             ~~
Language: C++

#include <iostream>
using namespace std;
long n,m;
vector <long> F[100005];
bool Free[100005];
long G[100005];
long DFS(long u)
    {
        long i,v;
        if (G[u]!=0) return G[u];
        for (i=0;i<F[u].size();++i)
        {
            v=F[u][i];
            if (Free[v]==true)
            {
                Free[v]=false;
                G[u]=max(G[u],DFS(v)+1);
            }
            Free[v]=true;
        }
        return G[u];
    }
int main()
    {
        long i,t1,t2;
        cin>>n>>m;
        for (i=1;i<=m;++i)
        {
            cin>>t1>>t2;
            F[t1].push_back(t2);
        }
        for (i=1;i<=n;++i) F[0].push_back(i);
        fill(Free+1,Free+1+n,true);
        cout<<DFS(0)-1;
        return 0;
    }


Compiler output:
a.cc:4:1: error: 'vector' does not name a type
    4 | vector <long> F[100005];
      | ^~~~~~
a.cc: In function 'long int DFS(long int)':
a.cc:11:20: error: 'F' was not declared in this scope
   11 |         for (i=0;i<F[u].size();++i)
      |                    ^
a.cc: In function 'int main()':
a.cc:30:13: error: 'F' was not declared in this scope
   30 |             F[t1].push_back(t2);
      |             ^
a.cc:32:28: error: 'F' was not declared in this scope
   32 |         for (i=1;i<=n;++i) F[0].push_back(i);
      |                            ^
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class A_Frog1 {
	public static void main(String[] args)
	{
		FastScanner in =new FastScanner();
		int n=in.nextInt();
		int[] h=in.readArray(n);
		int[] dp=new int[n+1];
		for(int i=0;i<n+1;i++)
			dp[i]=Integer.MAX_VALUE;
		dp[0]=0;
		dp[1]=Math.abs(h[1]-h[0]);
		for(int i=2;i<n;i++)
		{
			int diff1=Math.abs(h[i]-h[i-1]);
			int diff2=Math.abs(h[i]-h[i-2]);
			dp[i]=Math.min(dp[i-1]+diff1,dp[i-2]+diff2);
		}
		System.out.println(dp[n-1]);
	}
	
static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;
 
public class AtCoderDp_A_Frog1 {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[n+1];
		Arrays.fill(dp, N);
		dp[0] = 0;
		for(int i = 0 ; i < n ; ++i ) {
			for(int j : new int[]{i+1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
}


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

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Collections;
import java.util.StringTokenizer;
 
public class AtCoderDp_A_Frog1 {
	
	static int N = (int)1e9 + 7;
	static int dp[];
 
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();

		int n = sc.nextInt();
		int a[] = sc.readArray(n);
		dp = new int[N];
		for(int i = 0 ; i < n ; i++ ) {
			for(int j : new int[]{i +1  , i+2}) {
				if(j < n) {
					dp[j] = Math.min(dp[j], dp[i] + Math.abs(a[j] - a[i]));
				}
			}
		}
		System.out.println(dp[n-1]);
		
	}
	
	public void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
 
}


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


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

public class AFrog1 {
    public static int cost(int i, int j, int[] heights){
        return Math.abs(heights[i] - heights[j]);
    }

    public static int MinCost(int n, int[] heights, int[] dp){
        if(n <= 0){
            return 0;
        }
        if(n == 1){
            return cost(1, 0, heights);
        }
        if(dp[n] != -1){
            return dp[n];
        }
        dp[n] = Math.min(MinCost(n-1, heights, dp) + cost(n, n-1, heights), MinCost(n-2, heights, dp) + cost(n, n-2, heights));
        return dp[n];
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        int[] heights = Arrays.stream(reader.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int[] dp = new int[n];
        Arrays.fill(dp, -1);
        int ans = MinCost(n-1, heights, dp);
        System.out.println(ans);
    }
}

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

#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(type,arr,n)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//=======================
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 300005, M = N;
//=======================
vi g[N],adj[N];
int n, m, s, w, W, S, k, i, l, j, p, q, pr, fi, md;


void abhinay()
{
   
    #ifndef ONLINE_JUDGE   
        freopen("input.txt", "r", stdin);   
        freopen("output.txt", "w", stdout);   
    #endif   
    
}

int main(){
    abhinay();
    cin>>n;
    vi dp(n+1,MOD),v(n+1); 
    dp[0]=0;
    fo(i,n) cin>>v[i];
    dp[1] = abs(jumps[1] - jumps[0]); 
    for (int i = 2; i < n; i++)
        dp[i] = min(abs(v[i] - v[i - 1]) + dp[i - 1], abs(v[i] - v[i - 2]) + dp[i - 2]);
    cout << dp[n - 1];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:17: error: 'jumps' was not declared in this scope
   51 |     dp[1] = abs(jumps[1] - jumps[0]);
      |                 ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(type,arr,n)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//=======================
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 300005, M = N;
//=======================
vi g[N],adj[N];
int n, m, s, w, W, S, k, i, l, j, p, q, pr, fi, md;


void abhinay()
{
   
    #ifndef ONLINE_JUDGE   
        freopen("input.txt", "r", stdin);   
        freopen("output.txt", "w", stdout);   
    #endif   
    
}

int main(){
    abhinay();
    cin>>n;
    vi dp(n+1,MOD),v(n+1); 
    dp[0]=0;
    fo1(i,n) cin>>v[i];
    fo1(i,n)
    {
        if (i+1<a)
        {
            dp[i+1] = min(dp[i+1],dp[i-1]+abs(v[i]-v[i-1]));
        }
        if (i+2<a)
        {
            dp[i+2] = min(dp[i+2],dp[i-2]+abs(v[i]-v[i-2]));
                
        }

    }
    cout<<dp[n-1];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:17: error: 'a' was not declared in this scope
   53 |         if (i+1<a)
      |                 ^
a.cc:57:17: error: 'a' was not declared in this scope
   57 |         if (i+2<a)
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define pb push_back
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(type,arr,n)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//=======================
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
//=======================
const int MOD = 1000000007;
const int N = 300005, M = N;
//=======================
vi g[N],adj[N];
int n, m, s, w, W, S, k, i, l, j, p, q, pr, fi, md;


void abhinay()
{
   
    #ifndef ONLINE_JUDGE   
        freopen("input.txt", "r", stdin);   
        freopen("output.txt", "w", stdout);   
    #endif   
    
}

int main(){
    abhinay();
    cin>>n;
    vi dp(n+1),v(n+1); 
    dp[0]=0;
    fo1(i,n)
    {
        if (i-2>=0)
        {
            dp[i] = abs(v[i]-min(dp[i-1],dp[i-2]));
        }
        else if (i-1=0)
        {
            dp[i] = abs(v[i]-dp[i-1]);
        }
        
    }
    cout<<dp[n];
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:19: error: lvalue required as left operand of assignment
   56 |         else if (i-1=0)
      |                  ~^~
Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 305;
ld dp[N][N][N];
boo; mark[N][N][N];
int n;

ld solve(int t1, int t2, int t3) {
	int t0 = n - (t1 + t2 + t3);
	if (t0 == n)
		return 0;
	ld &ans = dp[t1][t2][t3];
	if (mark[t1][t2][t3])
		return ans;
	mark[t1][t2][t3] = 1;
	ans = 1;
	if (t1)
		ans += solve(t1 - 1, t2, t3) * ((ld) t1 / n);
	if (t2)
		ans += solve(t1 + 1, t2 - 1, t3) * ((ld) t2 / n);
	if (t3)
		ans += solve(t1, t2 + 1, t3 - 1) * ((ld) t3 / n);
	ans /= (1 - ((ld)t0 / n));
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t[4] = {};
	cin >> n;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		t[a]++;
	}
	cout << fixed << setprecision(12) << solve(t[1], t[2], t[3]);
	return 0;
}


Compiler output:
a.cc:10:1: error: 'boo' does not name a type; did you mean 'bool'?
   10 | boo; mark[N][N][N];
      | ^~~
      | bool
a.cc:10:6: error: 'mark' does not name a type
   10 | boo; mark[N][N][N];
      |      ^~~~
a.cc: In function 'ld solve(int, int, int)':
a.cc:18:13: error: 'mark' was not declared in this scope
   18 |         if (mark[t1][t2][t3])
      |             ^~~~
a.cc:20:9: error: 'mark' was not declared in this scope
   20 |         mark[t1][t2][t3] = 1;
      |         ^~~~
Language: Java

import java.util.*;

public class main{
	public static void main(String args[])throws IOException{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] h = new int[n];
	//	Scanner scan = new Scanner(System.in);
		for(int i = 0; i < n; i++)
			h[i] = scan.nextInt();
		int[] dp = new int[n];
	Arrays.fill(dp, Integer.MAX_VALUE);
	dp[0] = 0;
		for(int i = 1; i < n; i++){
			//int min = Integer.MAX_VALUE;
			for(int j = i - 1; j >= Math.max(0, i - k); --j){
					dp[i] = Math.min(dp[i], dp[j] + Math.abs(h[i] - h[j]));
				}
		}
		System.out.println(dp[n - 1]);
}
}


Compiler output:
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main{
       ^
Main.java:4: error: cannot find symbol
	public static void main(String args[])throws IOException{
	                                             ^
  symbol:   class IOException
  location: class main
2 errors