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

#include<bits/stdc++.h>
using namespace std;
void solve();
int main()
{
//	freopen("SNOOKER.inp","r",stdin);
//	freopen("SNOOKER.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}
/*----------------------------------------------------------------------
 
-----------------------------------------------------------------------*/
using ll =  long long;
#define endl "\n"
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define what_is(x)  cerr << #x << " is :" << (x) << endl
const int MOD =  1e9+7;
const ll inf = LLONG_MAX;
const int MAX_N = 1e5 + 7;

int n;

ll a[MAX_N], dp[MAX_N];
void solve()
{
	cin >> n;
	for(int i = 1; i <= n ; i++)
	{
		cin >> a[i];
	}
	a[0] = 0
	dp[0] = dp[1] = 0;
  	dp[2] = abs(a[2]-a[1]);
	for(int i = 3; i <= n; i ++)
	{
		dp[i] = min(	abs(a[i]-a[i-1] )+ dp[i-1], 
						abs(a[i]-a[i-2] )+ dp[i-2]
				);
	}
	//for(int i = 1; i <= cur_lenght; i++) cout << tail[i] << endl;
	cout << dp[n] ;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:34:17: error: expected ';' before 'dp'
   34 |         a[0] = 0
      |                 ^
      |                 ;
   35 |         dp[0] = dp[1] = 0;
      |         ~~
Language: C++

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

#define N 305
#define f1 first
#define s2 second
#define pb push_back
#define ll long long
#define ull unsigned long long;
#define all(a) a.begin(),a.end()
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);

int dp[N],dizi[N],n

int main(){
	fri("in.txt");
	fro("out.txt");
	
	cin>>n;
	for(int i=1;i<=n;i++{
		dp[i]=INT_MAX;
		cin>>dizi[i];
	}
	for(int i=1;i<=n;i++){
		dp[i]=i>2min()
	}


	return 0;
}

Compiler output:
a.cc:16:1: error: expected initializer before 'int'
   16 | int main(){
      | ^~~
Language: C++

#include <iostream>
#include <algorithm>

#define Max 10001

using namespace std;

int main()
{
	int N;
	int h[Max+1];
	int dp[10*Max+1];

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




Compiler output:
a.cc: In function 'int main()':
a.cc:15:9: error: 'memset' was not declared in this scope
   15 |         memset(dp, 0, N + 1);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 |
Language: Java

import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
      
        Scanner in = new Scanner(System.in);
        TaskC2 taskC2 = new TaskC2();
         taskC2.solve(0,in);
    
    }
}
 
public class TaskC2 {
    public void solve(int testNumber, Scanner in) {
 
            int n = in.nextInt();
            int[] a = new int[n];
 
            for(int i = 0; i < n; i ++){
                a[i] = in.nextInt();
            }
 
            if(n == 1){
                System.out.println(0);
                return;
            }
            if(n == 2){
                System.out.println(Math.abs(a[1] - a[0]));
                return;
            }
 
            int[] dp = new int[n];
            dp[0] = 0;
            dp[1] = Math.abs(a[1] - a[0]);
 
            for(int i = 2; i < n; i++){
                dp[i] = Math.min(Math.abs(a[i]- a[i-1]) + dp[i-1], Math.abs(a[i]- a[i-2])+dp[i-2]);
            }
 
            System.out.println(dp[n-1]);
    }
 
    
 
}

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

import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	public static void main (String[] args) {
      
        Scanner in = new Scanner(System.in);
        TaskC2 taskC2 = new TaskC2();
         taskC2.solve(0,in,null);
    
    }
}

public class TaskC2 {
    public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int[] a = new int[n];

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

            if(n == 1){
                System.out.println(0);
                return;
            }
            if(n == 2){
                System.out.println(Math.abs(a[1] - a[0]));
                return;
            }

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

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

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

    

}


Compiler output:
Main.java:14: error: class TaskC2 is public, should be declared in a file named TaskC2.java
public class TaskC2 {
       ^
Main.java:15: error: cannot find symbol
    public void solve(int testNumber, Scanner in, PrintWriter out) {
                                                  ^
  symbol:   class PrintWriter
  location: class TaskC2
2 errors
Language: Java

import java.util.Scanner;
import java.io.PrintWriter;

public class TaskC2 {
    int i =0; int j = 0;



    public void solve(int testNumber, Scanner in, PrintWriter out) {

            int n = in.nextInt();
            int[] a = new int[n];

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

            if(n == 1){
                System.out.println(0);
                return;
            }
            if(n == 2){
                System.out.println(Math.abs(a[1] - a[0]));
                return;
            }

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

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

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

    public static void main (String[] args) {
        Scanner in = new Scanner(System.in);
        TaskC2 taskC2 = new TaskC2();
        taskC2.solve(0,in,null);
    }

}


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

/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 

/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( string X, string Y, int m, int n ) 
{ 
int L[m+1][n+1]; 

/* Following steps build L[m+1][n+1] in bottom up fashion. Note 
	that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
for (int i=0; i<=m; i++) 
{ 
	for (int j=0; j<=n; j++) 
	{ 
	if (i == 0 || j == 0) 
		L[i][j] = 0; 
	else if (X[i-1] == Y[j-1]) 
		L[i][j] = L[i-1][j-1] + 1; 
	else
		L[i][j] = max(L[i-1][j], L[i][j-1]); 
	} 
} 

// Following code is used to print LCS 
int index = L[m][n]; 

// Create a character array to store the lcs string 
char lcs[index+1]; 
lcs[index] = '\0'; // Set the terminating character 

// Start from the right-most-bottom-most corner and 
// one by one store characters in lcs[] 
int i = m, j = n; 
while (i > 0 && j > 0) 
{ 
	// If current character in X[] and Y are same, then 
	// current character is part of LCS 
	if (X[i-1] == Y[j-1]) 
	{ 
		lcs[index-1] = X[i-1]; // Put current character in result 
		i--; j--; index--;	 // reduce values of i, j and index 
	} 

	// If not same, then find the larger of two and 
	// go in the direction of larger value 
	else if (L[i-1][j] > L[i][j-1]) 
		i--; 
	else
		j--; 
} 

// Print the lcs 
cout  << lcs; 
} 

/* Driver program to test above function */
int main() 
{ string X,Y; 
//char Y[] = "GXTXAYB";
 cin>>X>>Y;
int m = strlen(X); 
int n = strlen(Y); 
lcs(X, Y, m, n); 
return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:64:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   64 | int m = strlen(X);
      |                ^
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/cstring:43,
                 from a.cc:3:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:65:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   65 | int n = strlen(Y);
      |                ^
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
Language: C++

#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 3;

ll h[N], dp[N];                  

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    for (int i = 2; i <= n; ++i) {
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        dp[i] = min(dp[i], dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout << dp[n];
    return 0;
}

Compiler output:
a.cc:7:1: error: 'll' does not name a type
    7 | ll h[N], dp[N];
      | ^~
a.cc: In function 'int main()':
a.cc:15:16: error: 'h' was not declared in this scope
   15 |         cin >> h[i];
      |                ^
a.cc:17:9: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |         dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
      |         ^~
      |         dup
a.cc:17:31: error: 'h' was not declared in this scope
   17 |         dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
      |                               ^
a.cc:20:13: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |     cout << dp[n];
      |             ^~
      |             dup
Language: C++

#include <iostream>

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

Compiler output:
a.cc: In function 'int main()':
a.cc:12:23: error: expected ';' before 'for'
   12 |   dp[1]=abs(h[0]-h[1])
      |                       ^
      |                       ;
   13 |   for(i=2;i<n;i++){
      |   ~~~                  
a.cc:13:18: error: expected ';' before ')' token
   13 |   for(i=2;i<n;i++){
      |                  ^
      |                  ;
Language: C++

#include <iostream>
#include <math>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  int h[n],dp[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=Math.abs(h[0]-h[1])
  for(i=2;i<n;i++){
    dp[i]=max(Math.abs(h[i]-h[i-1]),Math.abs(h[i]-h[i-2]));
  }
  cout<<dp[n];
  return 0;
}

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

#include <iostream>
#include <math>
using namespace std;
int main(){
  int n,i;
  cin>>n;
  int h[n],dp[n];
  for(i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=Math.abs(h[0]-h[1])
  for(i=2;i<n;i++){
    dp[i]=max(Math.abs(h[i]-h[i-1]),Math.abs(h[i]-h[i-2]));
  }
}

Compiler output:
a.cc:2:10: fatal error: math: No such file or directory
    2 | #include <math>
      |          ^~~~~~
compilation terminated.
Language: Java

import java.util.Arrays;
import java.util.Scanner;


public class A {
    // public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int     MOD = (int) 1E9 + 7;

    public static void main(String[] args) {
        int N = nint();
        long[] h = nlongs(N, 1, 0);
        long[] cost = new long[N+1];
        cost[1] = 0;
        cost[2] = cost[1] + cost(h, 2, 1);
        
        for (int n = 3; n <= N; n++) {
            cost[n] = min(cost[n-1] + cost(h, n, n-1),
                          cost[n-2] + cost(h, n, n-2));
        }
        
        System.out.println(cost[N]);
    }
    
    static long cost(long[] h, int from, int to) {
        return abs(h[to] - h[from]);
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }

    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }

    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }

    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    private static long abs(long a) {
        return Math.abs(a);
    }
}


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

int main() {
  cin >> nStones >> hopLim;
  for(int i=1; i<=nStones; i++) {
    cin >> heights[i];  
  }

  //We make the following notation = dp[i][0] = min(dp[i][1], dp[i][2], .. dp[i][hopLim])
  for(int i=1; i<=nStones; i++){
    dp[i][0] = INF;
  }

  //solve 1st problem
  for(int i=1; i<=min(hopLim, nStones); i++){
    dp[1][i] = 0;
  }
  dp[1][0] = 0;

  //solve 2nd problem
  dp[2][1] = costOfHop(1, 2);
  for(int i=2; i<=min(hopLim, nStones); i++){
    dp[2][i] = INF;
  }
  dp[2][0] = dp[2][1];

  for(int i=3; i<=nStones; i++) { 
    int lim = min(hopLim, i-1); 
    for(int j=1; j<=lim; j++) {       
        dp[i][j] = dp[i-j][0] + costOfHop(i-j, i);
        dp[i][0] = min(dp[i][0], dp[i][j]);
    }
  }
  
  cout << dp[nStones][0];
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:3: error: 'cin' was not declared in this scope
    2 |   cin >> nStones >> hopLim;
      |   ^~~
a.cc:2:10: error: 'nStones' was not declared in this scope
    2 |   cin >> nStones >> hopLim;
      |          ^~~~~~~
a.cc:2:21: error: 'hopLim' was not declared in this scope
    2 |   cin >> nStones >> hopLim;
      |                     ^~~~~~
a.cc:4:12: error: 'heights' was not declared in this scope
    4 |     cin >> heights[i];
      |            ^~~~~~~
a.cc:9:5: error: 'dp' was not declared in this scope
    9 |     dp[i][0] = INF;
      |     ^~
a.cc:9:16: error: 'INF' was not declared in this scope
    9 |     dp[i][0] = INF;
      |                ^~~
a.cc:13:19: error: 'min' was not declared in this scope; did you mean 'main'?
   13 |   for(int i=1; i<=min(hopLim, nStones); i++){
      |                   ^~~
      |                   main
a.cc:14:5: error: 'dp' was not declared in this scope
   14 |     dp[1][i] = 0;
      |     ^~
a.cc:16:3: error: 'dp' was not declared in this scope
   16 |   dp[1][0] = 0;
      |   ^~
a.cc:19:14: error: 'costOfHop' was not declared in this scope
   19 |   dp[2][1] = costOfHop(1, 2);
      |              ^~~~~~~~~
a.cc:20:19: error: 'min' was not declared in this scope; did you mean 'main'?
   20 |   for(int i=2; i<=min(hopLim, nStones); i++){
      |                   ^~~
      |                   main
a.cc:21:16: error: 'INF' was not declared in this scope
   21 |     dp[2][i] = INF;
      |                ^~~
a.cc:26:15: error: 'min' was not declared in this scope; did you mean 'main'?
   26 |     int lim = min(hopLim, i-1);
      |               ^~~
      |               main
a.cc:33:3: error: 'cout' was not declared in this scope
   33 |   cout << dp[nStones][0];
      |   ^~~~
Language: C++

#include <iostream>
#include <cmath>

using namespace std;

int const NMAX = 1e5;
int const KMAX = 100;

int nStones;
int hopLim;
int ans;
int dp[1+NMAX][KMAX];
int heights[1+NMAX];

int costOfHop(int from, int to) {
  return abs(heights[from]-heights[to]);
}

int main() {
  cin >> nStones >> hopLim;
  for(int i=1; i<=nStones; i++) {
    cin >> heights[i];  
  }

  //We make the following notation = dp[i][0] = min(dp[i][1], dp[i][2], .. dp[i][hopLim])
  for(int i=1; i<=nStones; i++){
    dp[i][0] = INF;
  }

  //solve 1st problem
  for(int i=1; i<=hopLim; i++){
    dp[1][i] = 0;
  }
  dp[1][0] = 0;

  //solve 2nd problem
  dp[2][1] = costOfHop(1, 2);
  for(int i=2; i<=hopLim; i++){
    dp[2][i] = INF;
  }
  dp[2][0] = dp[2][1];

  for(int i=3; i<=nStones; i++) { 
    int lim = min(hopLim, i-1); 
    for(int j=1; j<=lim; j++) {       
        dp[i][j] = dp[i-j][0] + costOfHop(i-j, i);
        dp[i][0] = min(dp[i][0], dp[i][j]);
    }
  }
  
  cout << dp[nStones][0];
  return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
char util(int a, int b, int c)
{
  if(max({a, b, c}) == a)
    	return 'a';
  if(max({a, b, c}) == b)
      	return 'b';
  if(max({a, b, c}) == c)
    	return 'c';
}
char util2(int a, int b, int c)
{
  if(a+b+c - max({a, b, c}) - min({a, b, c}) == a)
    	return 'a';
  if(a+b+c - max({a, b, c}) - min({a, b, c}) == b)
    	return 'b';
  if(a+b+c - max({a, b, c}) - min({a, b, c}) == c)
    	return 'c';
}
int main()
{
  int n;
  cin>>n;
  int a[n], b[n], c[n];
  for(int i=0; i<n; i++)
    cin>>a[i]>>b[i]>>c[i];
  int dp1[n], dp2[n];
  int c1, c2;
  if(max({a[0], b[0], c[0]}) == a[0])
  {
    	c1 = 'a';
    	dp2[0] = max(b[0], c[0]);
    	if(max(b[0], c[0]) == b[0]) 	c2 = 'b';
   		else 	c2 = 'c';
  }
  if(max({a[0], b[0], c[0]}) == b[0])
  {
    	c1 = 'b';
    	dp2[0] = max(a[0], c[0]);
    	if(max(a[0], c[0]) == a[0]) 	c2 = 'a';
   		else 	c2 = 'c';
  }
  if(max({a[0], b[0], c[0]}) == c[0])
  {
    	c1 = 'c';
    	dp2[0] = max(b[0], a[0]);
    	if(max(b[0], a[0]) == b[0]) 	c2 = 'b';
   		else 	c2 = 'a';
  }
  dp1[0] = max({a[0], b[0], c[0]});
    for(int i=1; i<n; i++)
    {
        if(c1 != util(a[i], b[i], c[i]))
        {
          dp1[i] = dp1[i-1] + max({a[i], b[i], c[i]});
          c1 = util(a[i], b[i], c[i]);
        }
        else
        {
          dp1[i] = max(dp1[i-1] + a[i] + b[i] + c[i] - max({a[i], b[i], c[i]}) - min({a[i], b[i], c[i]}),
                       dp2[i-1] + max({a[i], b[i], c[i]}) );
          if( dp1[i-1] + a[i] + b[i] + c[i] - max({a[i], b[i], c[i]}) - min({a[i], b[i], c[i]})<
                       dp2[i-1] + max({a[i], b[i], c[i]}) )
            	c1 = util(a[i], b[i], c[i]);
          else
            	c1 = util2(a[i], b[i], c[i]);
        }
        if(c2 != util(a[i], b[i], c[i]))
        {
          dp2[i] = dp2[i-1] + max({a[i], b[i], c[i]});
          c2 = util(a[i], b[i], c[i]);
        }
        else
        {
          dp2[i] = max(dp2[i-1] + a[i] + b[i] + c[i] - max({a[i], b[i], c[i]}) - min({a[i], b[i], c[i]}),
                       dp1[i-1] + max({a[i], b[i], c[i]}) );
          if( dp2[i-1] + a[i] + b[i] + c[i] - max({a[i], b[i], c[i]}) - min({a[i], b[i], c[i]})<
                       dp1[i-1] + max({a[i], b[i], c[i]}) )
            	c2 = util(a[i], b[i], c[i]);
          else
            	c2 = util2(a[i], b[i], c[i]);
        }
    }
    cout<<max(dp1[n-1], cp2[n-1]);
}
      
      
      
      
      
      
      

Compiler output:
a.cc: In function 'int main()':
a.cc:85:25: error: 'cp2' was not declared in this scope; did you mean 'c2'?
   85 |     cout<<max(dp1[n-1], cp2[n-1]);
      |                         ^~~
      |                         c2
a.cc: In function 'char util(int, int, int)':
a.cc:11:1: warning: control reaches end of non-void function [-Wreturn-type]
   11 | }
      | ^
a.cc: In function 'char util2(int, int, int)':
a.cc:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  	cin>>n;
  	int* h = new int[n];
  	int* dp = new int[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;

Compiler output:
a.cc: In function 'int main()':
a.cc:11:20: error: expected ';' before 'i'
   11 |         for(int i=2 i<n; i++)
      |                    ^~
      |                    ;
a.cc:12:79: error: expected primary-expression before ']' token
   12 |       dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));]
      |                                                                               ^
a.cc:13:25: error: expected '}' at end of input
   13 |     cout<<dp[n-1]<<endl;
      |                         ^
a.cc:4:1: note: to match this '{'
    4 | {
      | ^
Language: Java

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		int[] heights = new int[n];
		for(int i = 0; i < n; i++) {
			heights[i] = sc.nextInt();
		}
		
		int[] dp = new int[n]; //min number of cost before reaching i
		for(int i = 0; i < n; i++) {
			dp[i] = 100000000;
		}
		
		
		dp[0] = 0; //initialise dp correctly if all to zero mistake dp[i] minimum cost until i. could either be itself or reached from previous
		for(int i = 0; i < n; i++) {
			if(i+1 < n) {
				dp[i+1] = Math.min(dp[i+1], dp[i]+ Math.abs(heights[i] - heights[i+1])); //overlaps here that's why it works.
			}
			if(i+2 < n) {
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(heights[i] - heights[i+2]));
			}
		}
		System.out.println(dp[n-1]);
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.Scanner;
import java.lang.*;
import java.util.*;

public class Frog1{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		int[] heights = new int[n];
		for(int i = 0; i < n; i++) {
			heights[i] = sc.nextInt();
		}
		
		int[] dp = new int[n]; //min number of cost before reaching i
		for(int i = 0; i < n; i++) {
			dp[i] = 10000;
		}
		
		
		dp[0] = 0; //initialise dp correctly if all to zero mistake dp[i] minimum cost until i. could either be itself or reached from previous
		for(int i = 0; i < n; i++) {
			if(i+1 < n) {
				dp[i+1] = Math.min(dp[i+1], dp[i]+ Math.abs(heights[i] - heights[i+1])); //overlaps here that's why it works.
			}
			if(i+2 < n) {
				dp[i+2] = Math.min(dp[i+2], dp[i] + Math.abs(heights[i] - heights[i+2]));
			}
		}
		System.out.println(dp[n-1]);
	}
}

Compiler output:
Main.java:5: 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 Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] stones = new int[n];
        for (int i = 0; i < n; i++) {
            stones[i] = scanner.nextInt();
        }
        int[] dp = new int[n];
        System.out.println(minInjured(stones, n - 1, dp));
    }

    public static int minInjured(int[] stones, int n,int[] dp) {
        if (n == 0) {
            return 0;
        }

        if (n == 1) {
            return Math.abs(stones[1] - stones[0]);
        }

        if (dp[n] > 0) {
            return dp[n];
        }

        return Math.min(minInjured(stones, n - 1) + Math.abs(stones[n] - stones[n - 1]),
                minInjured(stones, n - 2) + Math.abs(stones[n] - stones[n - 2]));
    }
}



Compiler output:
Main.java:28: error: method minInjured in class Main cannot be applied to given types;
        return Math.min(minInjured(stones, n - 1) + Math.abs(stones[n] - stones[n - 1]),
                        ^
  required: int[],int,int[]
  found:    int[],int
  reason: actual and formal argument lists differ in length
Main.java:29: error: method minInjured in class Main cannot be applied to given types;
                minInjured(stones, n - 2) + Math.abs(stones[n] - stones[n - 2]));
                ^
  required: int[],int,int[]
  found:    int[],int
  reason: actual and formal argument lists differ in length
2 errors
Language: C++

#include<iostream>
#include <iterator>
#include <vector>
#include <climits>
#include <queue>
#include "dp_template.h"
using namespace std;
typedef long long ll;
const ll INF = 1ll << 60;
ll dp[100001];
int h[100001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    for(int i = 0; i < 100001; i++) dp[i] = INF;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

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

    cout << dp[N - 1] << endl;
    return 0;
}

Compiler output:
a.cc:6:10: fatal error: dp_template.h: No such file or directory
    6 | #include "dp_template.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <cstddef>
#include <queue>
#include <math.h>
#include <cstdlib>
using namespace std;

int main()
{
    int N, a, b;#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <cstddef>
#include <queue>
#include <math.h>
#include <cstdlib>
using namespace std;

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

Compiler output:
a.cc:15:17: error: stray '#' in program
   15 |     int N, a, b;#include <iostream>
      |                 ^
a.cc: In function 'int main()':
a.cc:15:18: error: 'include' was not declared in this scope
   15 |     int N, a, b;#include <iostream>
      |                  ^~~~~~~
a.cc:15:35: error: expected primary-expression before '>' token
   15 |     int N, a, b;#include <iostream>
      |                                   ^
a.cc:25:1: error: expected primary-expression before 'using'
   25 | using namespace std;
      | ^~~~~
a.cc:27:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   27 | int main()
      |         ^~
a.cc:27:9: note: remove parentheses to default-initialize a variable
   27 | int main()
      |         ^~
      |         --
a.cc:27:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:28:1: error: a function-definition is not allowed here before '{' token
   28 | {
      | ^
Language: C++

#include <iostream>
using namespace std;

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

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

#include <stdio.h>
#include <math.h>

int n;

int main() {
  scanf("%d", &n);
  int height[n];
  int cost[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &height[i]);
  }
  cost[0] = 0;
  for (size_t i = 1; i < n; i++) {
    cost[i] = 1000000000;
  }
  for (size_t i = 0; i < n; i++) {
    if (i < n - 1) cost[i + 1] = fmin(cost[i] + fabs(height[i] - height[i + 1]), cost[i + 1]);
    if (i < n - 2) cost[i + 2] = fmin(cost[i] + fabs(height[i] - height[i + 2]), cost[i + 2]);
  }
  fprint("%d", cost[n - 1]);
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:21:3: error: implicit declaration of function 'fprint'; did you mean 'fprintf'? [-Wimplicit-function-declaration]
   21 |   fprint("%d", cost[n - 1]);
      |   ^~~~~~
      |   fprintf
Language: C++

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e6 + 5;
int a[N], dp[N];
//memset(dp, 0, sizeof(dp));
int n;
int help(int i)
{
	if (i >= n - 1) return 0;
	if (dp[i] != -1) return dp[i];
	int a1 = INT_MAX, b = INT_MAX;
	if (i < n - 1)
	{
		int x = a[i] - a[i + 1];
		a1 = abs(x) + help(i + 1);
	}
	if (i < n - 2)
	{
		int x = a[i] - a[i + 2];
		b = abs(x) + help(i + 2);
	}
	//bug(a1, b);
	return dp[i] = min(a1, b);
}
void solve()
{

	cin >> n;
	loop(i, 0, n)
	{
		cin >> a[i];
	}
  mset(dp,-1,sizeof(dp));
	cout << help(0);


	return;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	

	return 0;
}


Compiler output:
a.cc:82:24: error: macro "mset" passed 3 arguments, but takes just 2
   82 |   mset(dp,-1,sizeof(dp));
      |                        ^
a.cc:20:9: note: macro "mset" defined here
   20 | #define mset(a,f)       memset(a,f,sizeof(a))
      |         ^~~~
a.cc: In function 'void solve()':
a.cc:82:3: error: 'mset' was not declared in this scope
   82 |   mset(dp,-1,sizeof(dp));
      |   ^~~~
Language: C++

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 3e6 + 5;
int a[N];
int n;
int help(int i)
{
	if (i >= n - 1) return 0;
	int a1 = INT_MAX, b = INT_MAX;
	if (i < n - 1)
	{
		int x = a[i] - a[i + 1];
		a1 = abs(x) + help(i + 1);
	}
	if (i < n - 2)
	{
		int x = a[i] - a[i + 2];
		b = abs(x) + help(i + 2);
	}
	//bug(a1, b);
	return min(a1, b);
}
void solve()
{

	cin >> n;
	loop(i, 0, n)
	{
		cin >> a[i];
	}
	cout << help(0);


	return;

}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:99:56: error: 'z' was not declared in this scope
   99 |         cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
      |                                                        ^
Language: C++

#include<iostream>
#include<algorithm>
#include<set>
#include<climits>
using namespace std;
int n;
int arr[100002];
int dep[100002];
int dfs(int node, int cost) {
	if (node >= n + 1)
		return INT_MAX;
	if (node == n)
		return cost;
	else
		return min(dfs(node + 1, cost + abs(arr[node + 1]-arr[node])),dfs(node + 2, cost + abs(arr[node + 2]-arr[node])));
}

int main()
{
	  cin >> n;
	memset(dep, -1, n+1);
	for (int i = 1; i <= n; i++)
		cin >>  arr[i];

	cout << dfs(1, 0);
     
 	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:9: error: 'memset' was not declared in this scope
   21 |         memset(dep, -1, n+1);
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<climits>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int n;
int arr[100002];
int dep[100002];
int dfs(int node, int cost) {
	if (node >= n + 1)
		return INT_MAX;
	if (node == n)
		return cost;
	else
		return min(dfs(node + 1, cost + abs(arr[node + 1]-arr[node])),dfs(node + 2, cost + abs(arr[node + 2]-arr[node])));
}

int main()
{
	  cin >> n;
	memset(dep, -1, n+1);
	for (int i = 1; i <= n; i++)
		cin >>  arr[i];

	cout << dfs(1, 0);
     
 	return 0;
}

Compiler output:
a.cc: In function 'int dfs(int, int)':
a.cc:10:24: error: 'INT_MAX' was not declared in this scope
   10 |                 return INT_MAX;
      |                        ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include<set>
  +++ |+#include <climits>
    4 | using namespace std;
a.cc: In function 'int main()':
a.cc:20:9: error: 'memset' was not declared in this scope
   20 |         memset(dep, -1, n+1);
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include<set>
  +++ |+#include <cstring>
    4 | using namespace std;
Language: C++

// Example program
#include <bits/stdcpp.h>
using namespace std;

int main()
{
  vector<int> ar;
  vector<int> a;
  int score;
    for (int i = ar.begin(); i < ar.end(); i++){
        cin>>i;
        ar.push_back(i);
    }
  a.push_back(0);
  a.push_back(abs(ar[1]-ar[0]);
  i=ar.begin;
  i++;i++;
  	for (i; i < ar.end(); i++){
     if(abs(ar[i-1]-ar[i])>abs(ar[i-2]-ar[i])){
       a[i]=abs(ar[i-1]-ar[i])+a[i-1];
     }
      else{
        a[i]=abs(ar[i-2]-ar[i])+a[i-2];
      }
      cout<<a[i];
}


Compiler output:
a.cc:2:10: fatal error: bits/stdcpp.h: No such file or directory
    2 | #include <bits/stdcpp.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: Java

import java.io.*;
import java.util.*;
class Frog
{
  public static void main(String args[])throws IOException
   {
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tk=new StringTokenizer(tk.nextToken());
    int n=integer.parseInt(br.readLine());
    tk=new StringTokenizer(br.readLine());
    int a[]=new int[n];
    for(int i=0;i<n;i++)
    {
      a[i]=Integer.parseInt(tk.nextToken());
     }
    if(n<=2)
    {
      System.out.println(a[1]-a[0]);
      System.out.println();
    }
     int prev1=0;
     int prev2=a[1]-a[0];
    int minCost=Integer.MAX_VALUE;
    for(int i=2;i<n;i++)
    {
      minCost= Math.min(prev1+Math.abs(a[i-2] -a[i]) , prev2+ Math.abs(a[i-1]-a[i]));
      prev1=prev2;
      prev2=prev2+ Math.abs(a[i-1]-a[i])
    }
    System.out.println(minCost);
    
    
    
    
  }
  
}

    
  

Compiler output:
Main.java:28: error: ';' expected
      prev2=prev2+ Math.abs(a[i-1]-a[i])
                                        ^
1 error
Language: C

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;
	int h[n+1], ans[n+1];
	for(int i=1; i<=n; i++)
	{
		cin >> h[i];
		ans[i] = -1;
	}
	ans[0] = ans[1] = 0;
	for(int i=2; i<=n; i++)
		if( ans[i] == -1 )
			ans[i] = min( abs(h[i]-h[i-1]) + ans[i-1] , abs(h[i]-h[i-2]) + ans[i-2] );
	cout << ans[n];
	return 0;
}

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

#include <iostream>
using namespace std;
int a[100001], dp[100001], n;
int solve(int i){
  if(dp[i] != -1){
		return dp[i];
	}
  if(i == n - 1){
		return 0;
	}
  	if(i + 2 < n){
      return dp[i] = min(solve(i + 1) + abs(a[i] - a[i + 1]), solve(i + 2) + abs(a[i] - a[i + 2]);
    }
    else{
      return dp[i]=solve(i+1)+abs(a[i]-a[i+1]);
    }
}
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
		dp[i] = -1;
	}
	cout << solve(0, 0);
	return 0;
}

Compiler output:
a.cc: In function 'int solve(int)':
a.cc:12:98: error: expected ')' before ';' token
   12 |       return dp[i] = min(solve(i + 1) + abs(a[i] - a[i + 1]), solve(i + 2) + abs(a[i] - a[i + 2]);
      |                         ~                                                                        ^
      |                                                                                                  )
a.cc: In function 'int main()':
a.cc:24:22: error: too many arguments to function 'int solve(int)'
   24 |         cout << solve(0, 0);
      |                 ~~~~~^~~~~~
a.cc:4:5: note: declared here
    4 | int solve(int i){
      |     ^~~~~
Language: C++

#include <iostream>
using namespace std;
int a[100001], dp[100001], n;
int solve(int i){
  if(dp[i] != -1){
		return dp[i];
	}
  if(i == n - 1){
		return 0;
	}
  	if(i + 2 < n){
      return dp[i] = min(solve(i + 1) + abs(a[i] - a[i + 1]), solve(i + 2) + abs(a[i] - a[i + 2]);
    }
    else{
      return dp[i]=solve(i+1)+abs(a[i]-a[i+1]);
}
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
		dp[i] = -1;
	}
	cout << solve(0, 0);
	return 0;
}

Compiler output:
a.cc: In function 'int solve(int)':
a.cc:12:98: error: expected ')' before ';' token
   12 |       return dp[i] = min(solve(i + 1) + abs(a[i] - a[i + 1]), solve(i + 2) + abs(a[i] - a[i + 2]);
      |                         ~                                                                        ^
      |                                                                                                  )
a.cc:17:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   17 | int main() {
      |         ^~
a.cc:17:9: note: remove parentheses to default-initialize a variable
   17 | int main() {
      |         ^~
      |         --
a.cc:17:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:17:12: error: a function-definition is not allowed here before '{' token
   17 | int main() {
      |            ^
a.cc:25:2: error: expected '}' at end of input
   25 | }
      |  ^
a.cc:4:17: note: to match this '{'
    4 | int solve(int i){
      |                 ^
Language: C

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

using namespace std;
const int MAX = 1e9;
const int MaxN = 1e5 + 5;

int n;
int h[MaxN], dp[MaxN];

int main()
{
	while (~scanf ("%d", &n)){
		for (int i = 1; i <= n; i++) dp[i] = MAX;
		for (int i = 1; i <= n; i++) scanf ("%d", &h[i]);
		dp[1] = 0;
		dp[2] = fabs (h[2] - h[1]);
		for (int i = 3; i <= n; i++){
			int h1 = fabs (h[i] - h[i - 1]);
			int h2 = fabs (h[i] - h[i - 2]);
			dp[i] = min (dp[i - 1] + h1, dp[i - 2] + h2);
		}
		printf ("%d\n", dp[n]);
	}
	return 0;
}


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

#include <stdio.h>
#include <algorithm>
#include <cmath>

using namespace std;

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

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

#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

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

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

#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

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

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

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

    cin >> N;

    int h[N];

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

    int c[N];

    c[0] = abs(h[0] - h[1]);
    c1 = c[0] + abs(h[1] - h[2]);
    c2 = abs(h[0] - h[2]);
    if(c1 < c2) c[1] = c1;
    else c[1] = c2;

    for(int i = 2; i < N-1; ++i){
        c1 = c[i-1] + abs(h[i] - h[i+1]);
        c2 = c[i-2] + abs(h[i-1] - h[i+1]);
        if(c1 < c2) c[i] = c1;
        else c[i] = c2;
    }

    cout << c[N-2];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'c1' was not declared in this scope; did you mean 'c'?
   18 |     c1 = c[0] + abs(h[1] - h[2]);
      |     ^~
      |     c
a.cc:19:5: error: 'c2' was not declared in this scope; did you mean 'c'?
   19 |     c2 = abs(h[0] - h[2]);
      |     ^~
      |     c
Language: C++

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

    cin >> N;

    int h[N];

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

    int c[N];

    c[0] = abs(h[0] - h[1]);
    c1 = c[0] + abs(h[1] - h[2])
    c2 = abs(h[0] - h[2])
    if(c1 < c2) c[1] = c1;
    else c[1] = c2;

    for(int i = 2; i < N-1; ++i){
        c1 = c[i-1] + abs(h[i] - h[i+1]);
        c2 = c[i-2] + abs(h[i-1] - h[i+1]);
        if(c1 < c2) c[i] = c1;
        else c[i] = c2;
    }

    cout << c[N-2];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:5: error: 'c1' was not declared in this scope; did you mean 'c'?
   18 |     c1 = c[0] + abs(h[1] - h[2])
      |     ^~
      |     c
a.cc:21:5: error: 'else' without a previous 'if'
   21 |     else c[1] = c2;
      |     ^~~~
a.cc:21:17: error: 'c2' was not declared in this scope; did you mean 'c'?
   21 |     else c[1] = c2;
      |                 ^~
      |                 c
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  long n,t[10000],ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int i=n-1;i>0;){
    if(abs(t[i]-t[i-1])>=abs(t[i]-t[i-2]) 1!=i){
      ans+=abs(t[i]-t[i-2]);
      i-=2;
    }
    else{
      ans+=abs(t[i]-t[i-1]);
      i--;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:42: error: expected ')' before numeric constant
   10 |     if(abs(t[i]-t[i-1])>=abs(t[i]-t[i-2]) 1!=i){
      |       ~                                  ^~
      |                                          )