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

#include<stdio.h> 
#include<iostream>
  
// A utility function that returns maximum of two integers 
int max(int a, int b) { return (a > b)? a : b; } 
  
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
   int i, w; 
   int K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   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 wt[n],val[n];
 for(int i=0;i<n;i++)
   cin>>wt[i]>>val[i];
  
    printf("%d", knapSack(w, wt, val, n)); 
    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:2: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   32 |  cin>>n>>w;
      |  ^~~
      |  std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
Language: Java

import java.util.Scanner;

public class DP1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i=0;i<n;i++){
            arr[i] = in.nextInt();
        }

        int[] dp = new int[n+1];
        dp[0] = 0;
        dp[1]= Math.abs(arr[1]-arr[0]);

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

            int x = Math.abs(arr[i]-arr[i-2]);
            int y = Math.abs(arr[i]-arr[i-1]);

            dp[i] = Math.min((dp[i-2]+x),(dp[i-1]+y));


        }


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


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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:22:25: error: expected '}' at end of input
   22 |   cout<<recur(0,n,a,dp);
      |                         ^
a.cc:13:1: note: to match this '{'
   13 | {
      | ^
Language: C++

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

    int h1, h2, h3;
    int c1, c2, c3;

    cin >> h1 >> h2;
    c1 = h1; c2 = h2;

    for (int i = 2; i < n; i++) {
        cin >> h3;
        // cost[i] = min(cost[i-1] + abs(height[i] - height[i-1]), cost[i-2] + abs(height[i] - height[i-2]));
        c3 = min (c2 + abs(h3 - h2), c1 + abs(h3 - h1));
        c1 = c2; c2 = c3;
        h1 = h2; h2 = h3;
    }
    
    cout << c3 << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
    3 |     cin >> n;
      |     ^~~
a.cc:14:24: error: 'abs' was not declared in this scope
   14 |         c3 = min (c2 + abs(h3 - h2), c1 + abs(h3 - h1));
      |                        ^~~
a.cc:14:14: error: 'min' was not declared in this scope; did you mean 'main'?
   14 |         c3 = min (c2 + abs(h3 - h2), c1 + abs(h3 - h1));
      |              ^~~
      |              main
a.cc:19:5: error: 'cout' was not declared in this scope
   19 |     cout << c3 << endl;
      |     ^~~~
a.cc:19:19: error: 'endl' was not declared in this scope
   19 |     cout << c3 << endl;
      |                   ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int  INF= 1e9+5;
int main(){
	fastio();

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





    return 0;

}
	

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

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 const int  INF= 1e9+5;
int main(){
	fastio();

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





    return 0;

}
	

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

#include <stdio.h>

int main(void) {
	long long int cost=0;
	long long int cost_cur_step;
	long long int N;
	
	scanf("%N", &lli);
	for(i=0;i<N;i++){
	    scanf("%lli", &cost_cur_step)
	    cost+=cost_cur_step;
	}
	
	return 0;
}

long long int find_cost(long long int n){
    find_cost(n-1);
}

Compiler output:
main.c: In function 'main':
main.c:8:22: error: 'lli' undeclared (first use in this function)
    8 |         scanf("%N", &lli);
      |                      ^~~
main.c:8:22: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:13: error: 'i' undeclared (first use in this function)
    9 |         for(i=0;i<N;i++){
      |             ^
main.c:10:42: error: expected ';' before 'cost'
   10 |             scanf("%lli", &cost_cur_step)
      |                                          ^
      |                                          ;
   11 |             cost+=cost_cur_step;
      |             ~~~~
Language: C++

#include <stdio.h>

int main(void) {
	long long int cost=0;
	long long int cost_cur_step;
	long long int N;
	
	scanf("%N", &lli);
	for(i=0;i<N;i++){
	    scanf("%lli", &cost_cur_step)
	    cost+=cost_cur_step;
	}
	
	return 0;
}

long long int find_cost(long long int n){
    find_cost(n-1);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:22: error: 'lli' was not declared in this scope
    8 |         scanf("%N", &lli);
      |                      ^~~
a.cc:9:13: error: 'i' was not declared in this scope
    9 |         for(i=0;i<N;i++){
      |             ^
a.cc:10:42: error: expected ';' before 'cost'
   10 |             scanf("%lli", &cost_cur_step)
      |                                          ^
      |                                          ;
   11 |             cost+=cost_cur_step;
      |             ~~~~                          
a.cc: In function 'long long int find_cost(long long int)':
a.cc:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Solution {
    private int N = (int) (1e5 + 1);
    //private int[] stones = new int[N];
    private static List<Integer> stones = new ArrayList<>();
    private static int n;
    private static Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        n = input.nextInt();
        for (int i = 0; i < n; i++) {
            stones.add(input.nextInt());
        }
        System.out.println(solution(stones, n - 1));
    }

    public static int solution(List<Integer> stones, int n) {
        if (n == 0) {
            return 0;
        }
        int poss1 = solution(stones, n - 1) + Math.abs(stones.get(n) - stones.get(n - 1));
        int poss2;
        if (n-2 < 0) {
            poss2 = (int)(1e9 + 7);
        } else {
            poss2 = solution(stones, n - 2) + Math.abs(stones.get(n) - stones.get(n - 2));
        }
        return Math.min(poss1, poss2);
    }
}


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

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class DPA {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = scanner.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = scanner.nextInt();
        }

        int[] minA = new int[n];
        minA[0] = 0;
        minA[1] = Math.abs(arr[1] - arr[0]);
        for(int i = 2; i < n; i++){
            minA[i] = Math.min(Math.abs(arr[i] - arr[i - 1]) + minA[i - 1], Math.abs(arr[i] - arr[i - 2]) + minA[i - 2]);
        }

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

    }
}


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

#include <algorithm>

void Frog(int &size, int stones[])
{
  int cost[size];
  cost[0] = 0;
  cost[1] = abs(stones[1] - stones[0]);
  
  for (int i = 2; i < size; i++)
  {
    cost[i] = std::min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
  }
  
  printf("%d\n", cost[size-1]);
}
 
int main()
{
  int size;
  
  scanf("%d", &size);
  
  int stones[size];
  
  for (int i = 0; i < size; i++) scanf("%d", &stones[i]);
  
  Frog(size, stones);
  
  return 0;
}

Compiler output:
a.cc: In function 'void Frog(int&, int*)':
a.cc:14:3: error: 'printf' was not declared in this scope
   14 |   printf("%d\n", cost[size-1]);
      |   ^~~~~~
a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    1 | #include <algorithm>
  +++ |+#include <cstdio>
    2 | 
a.cc: In function 'int main()':
a.cc:21:3: error: 'scanf' was not declared in this scope
   21 |   scanf("%d", &size);
      |   ^~~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
 
void Frog(int &size, int stones[])
{
  int cost[size];
  cost[0] = 0;
  cost[1] = abs(stones[1] - stones[0]);
  
  for (int i = 2; i < size; i++)
  {
    cost[i] = min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
  }
  
  printf("%d", cost[size-1]);
}
 
int main()
{
  int size;
  
  scanf("%d", &size);
  
  int stones[size];
  
  for (int i = 0; i < size; i++) scanf("%d", &stones[i]);
  
  Frog(size, stones);
  
  return 0;
}

Compiler output:
a.cc: In function 'void Frog(int&, int*)':
a.cc:13:15: error: 'min' was not declared in this scope; did you mean 'std::min'?
   13 |     cost[i] = min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
      |               ^~~
      |               std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <algorithm.h>
 
void Frog(int &size, int stones[])
{
  int cost[size];
  cost[0] = 0;
  cost[1] = abs(stones[1] - stones[0]);
  
  for (int i = 2; i < size; i++)
  {
    cost[i] = min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
  }
  
  printf("%d", cost[size-1]);
}
 
int main()
{
  int size;
  
  scanf("%d", &size);
  
  int stones[size];
  
  for (int i = 0; i < size; i++) scanf("%d", &stones[i]);
  
  Frog(size, stones);
  
  return 0;
}

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

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

void Frog(int &size, int stones[])
{
  int cost[size];
  cost[0] = 0;
  cost[1] = abs(stones[1] - stones[0]);
  
  for (int i = 2; i < size; i++)
  {
    cost[i] = min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
  }
  
  printf("%d", cost[size-1]);
}

int main()
{
  int size;
  
  scanf("%d", &size);
  
  int stones[size];
  
  for (int i = 0; i < size; i++) scanf("%d", &stones[i]);
  
  Frog(size, stones);
  
  return 0;
}

Compiler output:
a.cc: In function 'void Frog(int&, int*)':
a.cc:12:15: error: 'min' was not declared in this scope
   12 |     cost[i] = min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
      |               ^~~
Language: C++

#include <stdio.h>

void Frog(int &size, int stones[])
{
  int cost[size];
  cost[0] = 0;
  cost[1] = abs(stones[1] - stones[0]);
  
  for (int i = 2; i < size; i++)
  {
    cost[i] = min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
  }
  
  printf("%d", cost[size-1]);
}

int main()
{
  int size;
  
  scanf("%d", &size);
  
  int stones[size];
  
  for (int i = 0; i < size; i++) scanf("%d", &stones[i]);
  
  Frog(size, stones);
  
  return 0;
}

Compiler output:
a.cc: In function 'void Frog(int&, int*)':
a.cc:7:13: error: 'abs' was not declared in this scope
    7 |   cost[1] = abs(stones[1] - stones[0]);
      |             ^~~
a.cc:11:15: error: 'min' was not declared in this scope
   11 |     cost[i] = min(abs(stones[i-2] - stones[i]) + cost[i-2], abs(stones[i-1] - stones[i]) + cost[i-1]);
      |               ^~~
Language: C++

#include <iostream>
#include <algorithm>
#define INF 1000000001
using namespace std;
int arr[100001];
int state[100001];
int dp(int ind) {
	if (ind == n - 1)
		return 0;
	else if (ind == n)
		return INF;
  	if (state[ind] == -1) {
    	state[ind] = min(dp(ind + 1) + abs(arr[ind + 1] - arr[ind]), dp(ind + 2) + abs(arr[ind + 2] - arr[ind]));
  	}

	return state[ind];
}

int main() {
	int n;
	cin >> n;
  	for (int i = 0; i < n; i++) {
        state[i] = -1;
      	cin >> arr[i];
    }
  	cout << dp(0) << '\n';
}

Compiler output:
a.cc: In function 'int dp(int)':
a.cc:8:20: error: 'n' was not declared in this scope
    8 |         if (ind == n - 1)
      |                    ^
Language: C++

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

const int INF =1e9 + 5;

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

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

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

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: array must be initialized with a brace-enclosed initializer
   14 |         int dp[n] = INF;
      |                     ^~~
Language: C++

#include <iostream>
#include <vector>

using namespace std;

int n;
cin>>n;
int h[n];
for (int i = 0; i < n; i++) cin>>h[i];
vector<int> d(n, 0);
for (int i = 1; i < n; i++) {
  int mi = INT_MAX;
  for (int j = i-1; j >= i-2 && j >= 0; j--) {
    mi = min(mi, d[j] + abs(h[i]-h[j]));
  }
  d[i] = mi;
}
cout<<d[n-1]<<endl;

Compiler output:
a.cc:7:1: error: 'cin' does not name a type
    7 | cin>>n;
      | ^~~
a.cc:8:7: error: size of array 'h' is not an integral constant-expression
    8 | int h[n];
      |       ^
a.cc:9:1: error: expected unqualified-id before 'for'
    9 | for (int i = 0; i < n; i++) cin>>h[i];
      | ^~~
a.cc:9:17: error: 'i' does not name a type
    9 | for (int i = 0; i < n; i++) cin>>h[i];
      |                 ^
a.cc:9:24: error: 'i' does not name a type
    9 | for (int i = 0; i < n; i++) cin>>h[i];
      |                        ^
a.cc:11:1: error: expected unqualified-id before 'for'
   11 | for (int i = 1; i < n; i++) {
      | ^~~
a.cc:11:17: error: 'i' does not name a type
   11 | for (int i = 1; i < n; i++) {
      |                 ^
a.cc:11:24: error: 'i' does not name a type
   11 | for (int i = 1; i < n; i++) {
      |                        ^
a.cc:18:1: error: 'cout' does not name a type
   18 | cout<<d[n-1]<<endl;
      | ^~~~
Language: C++

#include <vector>

int n;
cin>>n;
int h[n];
for (int i = 0; i < n; i++) cin>>h[i];
vector<int> d(n, 0);
for (int i = 1; i < n; i++) {
  int mi = INT_MAX;
  for (int j = i-1; j >= i-2 && j >= 0; j--) {
    mi = min(mi, d[j] + abs(h[i]-h[j]));
  }
  d[i] = mi;
}
cout<<d[n-1]<<endl;

Compiler output:
a.cc:4:1: error: 'cin' does not name a type
    4 | cin>>n;
      | ^~~
a.cc:5:7: error: size of array 'h' is not an integral constant-expression
    5 | int h[n];
      |       ^
a.cc:6:1: error: expected unqualified-id before 'for'
    6 | for (int i = 0; i < n; i++) cin>>h[i];
      | ^~~
a.cc:6:17: error: 'i' does not name a type
    6 | for (int i = 0; i < n; i++) cin>>h[i];
      |                 ^
a.cc:6:24: error: 'i' does not name a type
    6 | for (int i = 0; i < n; i++) cin>>h[i];
      |                        ^
a.cc:7:1: error: 'vector' does not name a type
    7 | vector<int> d(n, 0);
      | ^~~~~~
a.cc:8:1: error: expected unqualified-id before 'for'
    8 | for (int i = 1; i < n; i++) {
      | ^~~
a.cc:8:17: error: 'i' does not name a type
    8 | for (int i = 1; i < n; i++) {
      |                 ^
a.cc:8:24: error: 'i' does not name a type
    8 | for (int i = 1; i < n; i++) {
      |                        ^
a.cc:15:1: error: 'cout' does not name a type
   15 | cout<<d[n-1]<<endl;
      | ^~~~
Language: C++

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

vector<int> hi(100000);
vector<int> cost(100000);

int cost_fn(int n)
{
	// if(n == 0) return 0;
	// if(n == 1) return abs(hi[1]-hi[0]);

	// int onestep = abs(hi[n]-hi[n-1]) + cost_fn(n-1);
	// int twostep = abs(hi[n]-hi[n-2]) + cost_fn(n-2);

	// return min(onestep, twostep);

	cost[1] = abs(hi[1]-hi[0]);

	for(int i = 2; i <= n; i++)
	{
		int onestep = abs(hi[i]-hi[o-1]) + cost[i-1];
		int twostep = abs(hi[i]-hi[i-2]) + cost[i-2];
		cost[i] = min(onestep, twostep);
	}

	cout << cost[n] << endl;
}

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

	for(int i = 0; i < n; i++)
		cin >> hi[i];
	cout << cost_fn(n-1) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int cost_fn(int)':
a.cc:21:44: error: 'o' was not declared in this scope
   21 |                 int onestep = abs(hi[i]-hi[o-1]) + cost[i-1];
      |                                            ^
a.cc:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
   27 | }
      | ^
Language: C++

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

vector<int> hi(100000);
vector<int> cost(100000);

int cost_fn(int n)
{
	if(n == 0) return 0;
	if(n == 1) return abs(hi[1]-hi[0]);

	int onestep = abs(hi[n]-hi[n-1]) + cost(n-1);
	int twostep = abs(hi[n]-hi[n-1]) + cost(n-2);

	return min(onestep, twostep);

	// cost[1] = abs(hi[1]-hi[0]);

	// for(int i = 2; i < n; i++)
	// {
	// 	int onestep = abs(hi[n]-hi[n-1]) + cost[i-1];
	// 	int twostep = abs(hi[n]-hi[n-2]) + cost[i-2];
	// 	cost[i] = min(onestep, twostep);
	// }

	// cout << cost[n-1] << endl;
}

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

	for(int i = 0; i < n; i++)
		cin >> hi[i];
	cout << cost_fn(n) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int cost_fn(int)':
a.cc:12:48: error: no match for call to '(std::vector<int>) (int)'
   12 |         int onestep = abs(hi[n]-hi[n-1]) + cost(n-1);
      |                                            ~~~~^~~~~
a.cc:13:48: error: no match for call to '(std::vector<int>) (int)'
   13 |         int twostep = abs(hi[n]-hi[n-1]) + cost(n-2);
      |                                            ~~~~^~~~~
Language: C++


int cost_fn(int n)
{
	if(n == 0) return 0;
	if(n == 1) return abs(hi[1]-hi[0]);

	int onestep = abs(hi[n]-hi[n-1]) + cost(n-1);
	int twostep = abs(hi[n]-hi[n-1]) + cost(n-2);

	return min(onestep, twostep);

	// cost[1] = abs(hi[1]-hi[0]);

	// for(int i = 2; i < n; i++)
	// {
	// 	int onestep = abs(hi[n]-hi[n-1]) + cost[i-1];
	// 	int twostep = abs(hi[n]-hi[n-2]) + cost[i-2];
	// 	cost[i] = min(onestep, twostep);
	// }

	// cout << cost[n-1] << endl;
}

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

	for(int i = 0; i < n; i++)
		cin >> hi[i];
	cout << cost_fn(n) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int cost_fn(int)':
a.cc:5:31: error: 'hi' was not declared in this scope
    5 |         if(n == 1) return abs(hi[1]-hi[0]);
      |                               ^~
a.cc:5:27: error: 'abs' was not declared in this scope
    5 |         if(n == 1) return abs(hi[1]-hi[0]);
      |                           ^~~
a.cc:7:27: error: 'hi' was not declared in this scope
    7 |         int onestep = abs(hi[n]-hi[n-1]) + cost(n-1);
      |                           ^~
a.cc:7:23: error: 'abs' was not declared in this scope
    7 |         int onestep = abs(hi[n]-hi[n-1]) + cost(n-1);
      |                       ^~~
a.cc:7:44: error: 'cost' was not declared in this scope; did you mean 'const'?
    7 |         int onestep = abs(hi[n]-hi[n-1]) + cost(n-1);
      |                                            ^~~~
      |                                            const
a.cc:10:16: error: 'min' was not declared in this scope
   10 |         return min(onestep, twostep);
      |                ^~~
a.cc: In function 'int main()':
a.cc:27:9: error: 'cin' was not declared in this scope
   27 |         cin >> n;
      |         ^~~
a.cc:30:24: error: 'hi' was not declared in this scope; did you mean 'i'?
   30 |                 cin >> hi[i];
      |                        ^~
      |                        i
a.cc:31:9: error: 'cout' was not declared in this scope
   31 |         cout << cost_fn(n) << endl;
      |         ^~~~
a.cc:31:31: error: 'endl' was not declared in this scope
   31 |         cout << cost_fn(n) << endl;
      |                               ^~~~
Language: C

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int N;
int  h[100001];
int  dp[100001];
int  INF = 100000;

int 
chmin(int  *a, int b) 
{
	 if (*a > b){
		 *a = b; //	printf("%ld\n",*a);
		 return 1; 
	 }
	 return 0;
}


int 
main(){
	int int i;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
		dp[i]=INF;
	}
	
	dp[0]=0;
	
	#if 0
	for(i=0;i<N;++i){
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    #endif
    for (i = 1; i < N; i++) {
        dp[i]=fmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) dp[i]=fmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
	
	//for(i=0;i<N;i++){
		printf("%d\n",dp[N-1]);
	
	//}
	
 return 0;
}

Compiler output:
main.c: In function 'main':
main.c:22:13: error: two or more data types in declaration specifiers
   22 |         int int i;
      |             ^~~
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 ar[]=new int[n];
		int du[]=new int[n];
		for(int i=0;i<n;i++)
		{
			ar[i]=sc.nextInt();
		}
		du[0]=0;
		du[1]=Math.abs(ar[1]-ar[0]);
		if(n>=3)
		{
			du[2]=Math.min(Math.abs(ar[2]-ar[0]),Math.abs(ar[2]-ar[1]));
		
		for(int i=3;i<n;i++)
		{
			du[i]=Math.min(Math.abs(ar[i]-ar[i-1])+du[i-1], Math.abs(ar[i]-ar[i-2])+du[i-2]);
		}
		}
     System.out.println(du[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<math.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>

using namespace std;

int dp[100001] = {};
int a[100001] = {};

int saisyo(int i) {
	if (i == 0) {
		dp[0] = 0;
		return 0;
	}
	if (i == 1) {
		dp[1] = abs(a[1] - a[0]);
		return dp[1];
	}
	dp[i] = min(dp[i-2] + abs(a[i] - a[i - 2]), dp[i -1 ] + abs(a[i] - a[i - 1]));
	return dp[i];
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long int cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += saisyo(i);
	}
	cout << dp[n - 1]; << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:28: error: expected primary-expression before '<<' token
   41 |         cout << dp[n - 1]; << endl;
      |                            ^~
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:7:29: error: no match for call to '(std::vector<int>) (int&)'
    7 |   for(int i=0;i<n;i++)cin>>h(i);
      |                            ~^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
int dp[1000000000];
vector <int> v;
main(){
	int n,w,c,i,j,a,b,mx=-1;
	cin>>n>>w;
	dp[0]=1;
	v.pb(0);
	for (i=0;i<n;++i){
		cin>>a>>b;
		c=v.size();
		for (j=0;j<c;j++){
			if (v[j]+a>w ||v[j]+a>1000000000 )continue;
			dp[v[j]+a]=max(dp[v[j]+a],dp[v[j]]+b);
			v.pb(v[j]+a);
		}
	}
	for (i=0;i<=w;++i){
		mx=max(dp[i],mx);
	}
	cout <<mx-1;
}

Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
/tmp/ccThyYfX.o: in function `main':
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0x126): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0x15d): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0x1d4): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0x1f8): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
/tmp/ccThyYfX.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x29e): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccThyYfX.o
a.cc:(.text+0x2b7): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int N = 100005;
int n, dp[N], h[N];
int cal(int x) {
  if (x > n) return 2e9;
  if (x == n) {
    return 0;
  }
  int &ret = dp[x];
  if (ret < 2e9) {
    return ret;
  }
  ret = cal(x+1) + abs(h[x] - h[x+1]);
  ret = min(ret, cal(x+2) + abs(h[x] - h[x+2]));
  return ret;
}

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

Compiler output:
a.cc:26:9: error: expected constructor, destructor, or type conversion before '(' token
   26 |   printf("%d", cal(1));
      |         ^
a.cc:27:3: error: expected unqualified-id before 'return'
   27 |   return 0;
      |   ^~~~~~
a.cc:28:1: error: expected declaration before '}' token
   28 | }
      | ^
Language: C++

using namespace std;

int dp[21][(1 << 21)];
int can[21][21];

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

	for (auto i = 0; i < n; i++)
		for (auto j = 0; j < n; j++)
			cin >> can[i][j];

	for (auto i = 0; i < n; i++)
		dp[0][1 << i] = can[0][i];

	for (auto i = 1; i < n; i++)
		for (auto mask = 1; mask < (1 << n); mask++)
			for (auto j = 0; j < n; j++)
				if (can[i][j] && (mask & (1 << j))) {
					dp[i][mask] += dp[i - 1][mask ^ (1 << j)];
					dp[i][mask] %= (int)(1e9 + 7);
				}

	cout << dp[n - 1][(1 << n) - 1] << endl;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:16: error: 'cin' was not declared in this scope
    8 |         int n; cin >> n;
      |                ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:25:9: error: 'cout' was not declared in this scope
   25 |         cout << dp[n - 1][(1 << n) - 1] << endl;
      |         ^~~~
a.cc:25:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:25:44: error: 'endl' was not declared in this scope
   25 |         cout << dp[n - 1][(1 << n) - 1] << endl;
      |                                            ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
Language: C++

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;

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

int main(void) {
	ll i, j, k,tmp;
	vector<ll>dp;
	vector<ll>h;
	ll N;
	scanf("%lld", &N);
	for (i = 0; i < N; i++) {
		scanf("%lld", &tmp);
		h.push_back(tmp);
		dp.push_back(LLONG_MAX);
	}
	dp.at(0) = h.at(0);
	dp.at(1) = abs(h.at(1) - dp.at(0));
	for (i = 2; i < N; i++) {
		chmin(dp.at(i), dp.at(i - 1) + abs( h.at(i) - h.at(i - 1)));
		chmin(dp.at(i), dp.at(i - 2) + abs( h.at(i) - h.at(i - 2)));
	}
	printf("%lld\n", dp.at(N - 1));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:30: error: 'LLONG_MAX' was not declared in this scope
   28 |                 dp.push_back(LLONG_MAX);
      |                              ^~~~~~~~~
a.cc:7:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    6 | #include <math.h>
  +++ |+#include <climits>
    7 | #define rep(i,n) for(int i = 0; i <(n); i++)
Language: C++

#include <iostream>
using namespace std;

void main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int res[n];
  res[0]=0;
  for(int i=1;i<n;i++){
    int mini = res[i-1]+abs(a[i]-a[i-1]);
    if(i-2>=0){
       mini = min(mini,res[i-2]+abs(a[i]-a[i-2]));
    }
    res[i]=mini;
  }
  cout<<res[n-1]<<"\n";
}
      
  

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | void main(){
      | ^~~~
Language: C++


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import java.text.*;
public class Rough{
   
    static PrintWriter w=new PrintWriter(System.out);
    public static void main(String [] args){
        DecimalFormat dm=new DecimalFormat("0.000000");
        Scanner sc=new Scanner(System.in);
//        int t=sc.nextInt();
//    	 while(t-->0){
//    	     int n=sc.nextInt();
//    	     int arr[]=new int[n];
//    	     for(int i=0;i<n;i++){
//    	         arr[i]=sc.nextInt();
//    	     }
//    	     int or[][]=new int[n+1][2];
//    	     for(int i=0;i<n-1;i++){
//    	         or[i][0]=arr[i];
//    	         or[i][1]=arr[i+1];
//    	     }
//    	     long sum=0;
//    	     for(int j=n-1;j>=2;j--){
//    	         long min=Long.MAX_VALUE;
//    	         int index=0;
//    	         for(int i=0;i<j-1;i++){
//    	             if(or[i][0]*or[i+1][1]<min){
//    	                 min=or[i][0]*or[i+1][1];
//    	                 index=i;
//    	             }
//    	         }
//    	         sum+=((long)or[index][0]*or[index][1]*or[index+1][1]);
//    	         or[index][1]=or[index+1][1];
//    	         for(int i=index+1;i<n-1;i++){
//    	             or[i][0]=or[i+1][0];
//    	             or[i][1]=or[i+1][1];
//    	         }
//    	     }
//    	     System.out.println(sum);
int n=sc.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    int dp[]=new int[n];
    Arrays.fill(dp,Integer.MAX_VALUE);
    dp[0]=0;
    for(int i=0;i<n-1;i++){
     	dp[i+1]=Math.min(dp[i]+Math.abs(arr[i+1]-arr[i]),dp[i+1]);
      	if(i>=n-2)
          continue;
      	dp[i+2]=Math.min(dp[i]+Math.abs(arr[i+2]-arr[i]),dp[i+2]);
    }
    System.out.println(dp[n-1]);
    	 
        w.close();
    }
}

Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.lang.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.math.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.io.*;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import java.text.*;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
    7 | public class Rough{
      | ^~~~~~
Language: Java

package rough;


import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import java.text.*;
public class Rough{
   
    static PrintWriter w=new PrintWriter(System.out);
    public static void main(String [] args){
        DecimalFormat dm=new DecimalFormat("0.000000");
        Scanner sc=new Scanner(System.in);
//        int t=sc.nextInt();
//    	 while(t-->0){
//    	     int n=sc.nextInt();
//    	     int arr[]=new int[n];
//    	     for(int i=0;i<n;i++){
//    	         arr[i]=sc.nextInt();
//    	     }
//    	     int or[][]=new int[n+1][2];
//    	     for(int i=0;i<n-1;i++){
//    	         or[i][0]=arr[i];
//    	         or[i][1]=arr[i+1];
//    	     }
//    	     long sum=0;
//    	     for(int j=n-1;j>=2;j--){
//    	         long min=Long.MAX_VALUE;
//    	         int index=0;
//    	         for(int i=0;i<j-1;i++){
//    	             if(or[i][0]*or[i+1][1]<min){
//    	                 min=or[i][0]*or[i+1][1];
//    	                 index=i;
//    	             }
//    	         }
//    	         sum+=((long)or[index][0]*or[index][1]*or[index+1][1]);
//    	         or[index][1]=or[index+1][1];
//    	         for(int i=index+1;i<n-1;i++){
//    	             or[i][0]=or[i+1][0];
//    	             or[i][1]=or[i+1][1];
//    	         }
//    	     }
//    	     System.out.println(sum);
int n=sc.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    int dp[]=new int[n];
    Arrays.fill(dp,Integer.MAX_VALUE);
    dp[0]=0;
    for(int i=0;i<n-1;i++){
     	dp[i+1]=Math.min(dp[i]+Math.abs(arr[i+1]-arr[i]),dp[i+1]);
      	if(i>=n-2)
          continue;
      	dp[i+2]=Math.min(dp[i]+Math.abs(arr[i+2]-arr[i]),dp[i+2]);
    }
    System.out.println(dp[n-1]);
    	 
        w.close();
    }
}

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

import java.util.*;
import java.math.*;
public class A{
  public static void main(String agrgs[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int arr[]=new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    int dp[]=new int[n];
    Arrays.fill(dp,Integer.MAX_VALUE);
    dp[0]=0;
    for(int i=0;i<n-1;i++){
     	dp[i+1]=Math.min(dp[i]+Math.abs(arr[i+1]-arr[i]),dp[i+1]);
      	if(i>=n-2)
          continue;
      	dp[i+2]=Math.min(dp[i]+Math.abs(arr[i+2]-arr[i]),dp[i+2]);
    }
    System.out.println(dp[n-1]);
  }
}


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

import java.io.*;

public class dp_a {
	static long[] dp;
	  
	public static long minCost(long[] arr, int pos){
	  	if(pos<0) return 0;
	    if(dp[pos]!=-1) return dp[pos];
	    return dp[pos] = 
	      Math.min(minCost(arr, pos-1)+Math.abs(arr[Math.max(pos, 0)]-arr[Math.max(pos-1, 0)]),
	               minCost(arr, pos-2)+Math.abs(arr[Math.max(pos, 0)]-arr[Math.max(pos-2, 0)]));
	}
	  
	public static void main(String[] args) throws Exception{
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    int n = Integer.parseInt(br.readLine());
	    long[] arr = new long[n];
	    dp = new long[n];
	    String[] str = br.readLine().split(" ");
	    for(int i=0; i<n; i++) {
	    	arr[i] = Long.parseLong(str[i]);
	    	dp[i] = -1;
	    }
		System.out.println(minCost(arr, n-1));
		//for(int i=0; i<n; i++) System.out.print(dp[i]+" ");
	}
}


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

#include<bits/stdc++.h>
#define ll long long int
#define lp(i,n) for(ll i=0;i<n;i++)
using namespace std;
ll min(ll a,ll b){
 return a<b?a:b;
}
int main(){
  ll n;
  cin>>n;
  ll h[n];
  lp(i,n)
    cin>>h[i];
  ll dp[n+1];
  dp[0]=0;
  lp(i,n+1){
    if(i-1>0)
      dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    if(i-2>0)
      dp[i]=min(dp[i],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:20:48: error: expected ';' before '}' token
   20 |       dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
      |                                                ^
      |                                                ;
   21 |   }
      |   ~
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define lp(i,n) for(ll i=0;i<n;i++)
using namespace std;
ll min(ll a,ll b){
 return a<b?a:b;
}
int main(){
  ll n;
  cin>>n;
  ll c[n];
  lp(i,n)
    cin>>c[i];
  ll dp[n+1];
  dp[0]=0;
  lp(i,n+1){
    if(i-1>0)
      dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    if(i-2>0)
      dp[i]=min(dp[i],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:18:25: error: 'h' was not declared in this scope
   18 |       dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
      |                         ^
a.cc:20:35: error: 'h' was not declared in this scope
   20 |       dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]))
      |                                   ^
Language: Java

public class Main {
	static int lowestNum;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();
		
		int[] frog = new int[n];
		Arrays.fill(frog,  Integer.MAX_VALUE);
		
		frog[0] = 0;
		for (int i = 0; i < n; i++) {
			if (frog[i] == Integer.MAX_VALUE)
				continue;
			if (i+1 < n) {
				frog[i+1] = Math.min(frog[i+1], frog[i] + Math.abs(arr[i+1]-arr[i]));
			}
			if (i+2 < n) {
				frog[i+2] = Math.min(frog[i+2], frog[i] + Math.abs(arr[i+2] - arr[i]));
			}
		}
		System.out.println(frog[n-1]);
		/*
		lowestNum = Integer.MAX_VALUE;
		int[] memo = new int[n];
		for (int i = 0; i < n; i++)
			memo[i] = -1;
		
		System.out.println(frog(arr, arr.length - 1, 0, memo));
		*/
	}
	
	
	
	public static int frog(int[] arr, int pos, int totalCost, int[] memo) { // pos 0 - indexed
		if (pos == 0)
			return totalCost;
		if (pos == 1)
			return totalCost + Math.abs(arr[1] - arr[0]);
		if (memo[pos] != -1)
			return memo[pos];
		
		int cost1 = frog(arr, pos - 1, totalCost + Math.abs(arr[pos] - arr[pos-1]), memo);
		int cost2 = frog(arr, pos - 2, totalCost + Math.abs(arr[pos] - arr[pos-2]), memo);
		
		memo[pos] = Math.min(cost1, cost2);
		return Math.min(cost1, cost2);
	}
}


Compiler output:
Main.java:4: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
Main.java:12: error: cannot find symbol
		Arrays.fill(frog,  Integer.MAX_VALUE);
		^
  symbol:   variable Arrays
  location: class Main
3 errors
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
int func(int n,int m, vector<vector<int>>v)
{
    int a[n][m];
    for(int j=0;j<m;j++)
    a[0][j]=v[0][j];
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            int min=INT_MAX;
           for(int k=0;k<m;k++)
            if(min>v[i][k]&&k!=j)
            min=v[i][k];
            a[i][j]=a[i-1][j]+min;
        }
    }
    int min=10000;
    for(int i=0;i<m;i++)
    if(min>a[n-1][i])
    min=a[n-1][i];
    return min;
}

int main() {
    int m,n,d;
    cin>>n;
  m=3;
    vector< vector<int> >v(n,vector<int>(m)) ;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>d;
            v[i][j]=(d);
    
        }
    }
    cout<<func(n,m,v);
  return 0;
}

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

import java.util.Scanner;

public class frog1 {
	static int lowestNum;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();
		
		lowestNum = Integer.MAX_VALUE;
		int[] memo = new int[n];
		for (int i = 0; i < n; i++)
			memo[i] = -1;
		
		System.out.println(frog(arr, arr.length - 1, 0, memo));
	}
	
	public static int frog(int[] arr, int pos, int totalCost, int[] memo) { // pos 0 - indexed
		if (pos == 0)
			return totalCost;
		if (pos == 1)
			return totalCost + Math.abs(arr[1] - arr[0]);
		if (memo[pos] != -1)
			return memo[pos];
		
		int cost1 = frog(arr, pos - 1, totalCost + Math.abs(arr[pos] - arr[pos-1]), memo);
		int cost2 = frog(arr, pos - 2, totalCost + Math.abs(arr[pos] - arr[pos-2]), memo);
		
		memo[pos] = Math.min(cost1, cost2);
		return Math.min(cost1, cost2);
	}
}

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: Java

import java.util.Scanner;

public class frog1 {
	static int lowestNum;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();
		
		lowestNum = Integer.MAX_VALUE;
		int[] memo = new int[n];
		for (int i = 0; i < n; i++)
			memo[i] = -1;
		
		System.out.println(frog(arr, arr.length - 1, 0, memo));
	}
	
	public static int frog(int[] arr, int pos, int totalCost, int[] memo) { // pos 0 - indexed
		if (pos == 0)
			return totalCost;
		if (pos == 1)
			return totalCost + Math.abs(arr[1] - arr[0]);
		if (memo[pos] != -1)
			return memo[pos];
		
		int cost1 = frog(arr, pos - 1, totalCost + Math.abs(arr[pos] - arr[pos-1]), memo);
		int cost2 = frog(arr, pos - 2, totalCost + Math.abs(arr[pos] - arr[pos-2]), memo);
		
		memo[pos] = Math.min(cost1, cost2);
		return Math.min(cost1, cost2);
	}
}


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++

import java.util.Scanner;

public class frog1 {
	static int lowestNum;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		
		for (int i = 0; i < n; i++)
			arr[i] = sc.nextInt();
		
		lowestNum = Integer.MAX_VALUE;
		int[] memo = new int[n];
		for (int i = 0; i < n; i++)
			memo[i] = -1;
		
		System.out.println(frog(arr, arr.length - 1, 0, memo));
	}
	
	public static int frog(int[] arr, int pos, int totalCost, int[] memo) { // pos 0 - indexed
		if (pos == 0)
			return totalCost;
		if (pos == 1)
			return totalCost + Math.abs(arr[1] - arr[0]);
		if (memo[pos] != -1)
			return memo[pos];
		
		int cost1 = frog(arr, pos - 1, totalCost + Math.abs(arr[pos] - arr[pos-1]), memo);
		int cost2 = frog(arr, pos - 2, totalCost + Math.abs(arr[pos] - arr[pos-2]), memo);
		
		memo[pos] = Math.min(cost1, cost2);
		return Math.min(cost1, cost2);
	}
}


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

#include <bits/stdc++.h>

using namespace std;
#define ll  long long
#define ld long double
ll a[100005]={0};
ll n,k;
ll hod[105]={0};
ll rec(ll k) {
    if(a[k]!=-1) return a[k];
  bool b = new bool[105];
  for(ll i =0;i<=105;i++) {
    b[i] = 0;
  }
    for(ll i =1;i<=n;i++) {
            if(hod[i]<=k)
        b[rec(k-hod[i])] = 1; else break;
    }
    for(ll i =0;i<=105;i++) {
        if(!b[i]) {a[k] = i; delete b; return i;}
    }

}
int main()
{
 // freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);

    cin>>n>>k;
    for(ll i =1;i<=k;i++) {
        a[i] = -1;
    }
    for(ll i =1;i<=n;i++) {
        cin>>hod[i];
    }
    stable_sort(hod+1,hod+1+n);
a[0] = 0;
if(rec(k)==0) cout<<"Second"; else cout<<"First";

}



Compiler output:
a.cc: In function 'long long int rec(long long int)':
a.cc:13:6: error: invalid types 'bool[long long int]' for array subscript
   13 |     b[i] = 0;
      |      ^
a.cc:17:10: error: invalid types 'bool[long long int]' for array subscript
   17 |         b[rec(k-hod[i])] = 1; else break;
      |          ^
a.cc:20:14: error: invalid types 'bool[long long int]' for array subscript
   20 |         if(!b[i]) {a[k] = i; delete b; return i;}
      |              ^
a.cc:20:37: error: type 'bool' argument given to 'delete', expected pointer
   20 |         if(!b[i]) {a[k] = i; delete b; return i;}
      |                                     ^
a.cc:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^
Language: Java

/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
**************************
Time to solve: 
*/
import java.util.*;
import java.io.*;

   public class A
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long[] dp = new long[N];
         Arrays.fill(dp, Integer.MAX_VALUE);
         dp[0] = 0;
         for(int i=0; i < N; i++)
         {
            if(dp[i] == Integer.MAX_VALUE)
               continue;
            if(i+1 < N)
               dp[i+1] = Math.min(dp[i+1], dp[i]+Math.abs(arr[i]-arr[i+1]));
            if(i+2 < N)
               dp[i+2] = Math.min(dp[i+2], dp[i]+Math.abs(arr[i]-arr[i+2]));
         }
         System.out.println(dp[N-1]);
      }
   }

Compiler output:
Main.java:12: error: class A is public, should be declared in a file named A.java
   public class A
          ^
1 error