criyle/codenet-compile-errors huggingface dataset:
Language: Java

package dp;

import java.util.Scanner;

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

        System.out.println(solve(n,h)[n-1]);

    }



	private static int[] solve(int n, int[] h) {
		int[] dp = new int[n];

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

		return dp;

	}
}

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

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

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

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

#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

const long long INF = 1LL << 60;


long long h[100010];

long long dp[100010];

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

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

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

}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: 'chimin' was not declared in this scope; did you mean 'chmin'?
   34 |                 chimin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
      |                 ^~~~~~
      |                 chmin
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll n;
ll dp[maxn];
ll a[maxn];
int main()
{
    gbtb;
    cin>>n;
    repd(i,1,n)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    dp[2]=abs(a[2]-a[1]);
    repd(i,3,n)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));

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

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'gbtb' was not declared in this scope
   26 |     gbtb;
      |     ^~~~
Language: Java

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

public class Vacation {

    //https://atcoder.jp/contests/dp/tasks/dp_c
    public static void main( String[] args ) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        int[][] arr = new int[n][3];
        for (int i = 0; i < n; i++) {
            arr[i][0] = scanner.nextInt();
            arr[i][1] = scanner.nextInt();
            arr[i][2] = scanner.nextInt();
        }

        int[][] dp = new int[n + 1][3];
        for (int[] ay : dp)
            Arrays.fill(ay, -1);

        int ans = Math.max(solveTopDown(0, 0, arr, dp)
                , Math.max(solveTopDown(0, 1, arr, dp)
                        , solveTopDown(0, 2, arr, dp)));

        System.out.println(ans);
    }

private static int solveTopDown( int row, int curSelection, int[][] arr, int[][] dp ) {
        if (row >= arr.length)
            return 0;

        if (dp[row][curSelection] == -1) {

            int max = Integer.MIN_VALUE;

            //At each day Taro can do 3 activities...
            for (int j = 0; j < 3; j++) {

                //Next day activity should be different from Cur-selected Activity
                //For eg: during first function call we did : solveTopDown(0, 0, arr, dp)
                //here curSelection=0, so Taro can only choose from {1,2} activities to gain Max happiness.
                if (curSelection != j) {

                    int choice = solveTopDown(row + 1, j, arr, dp) + arr[row][j];

                    if (max < choice)
                        max = choice;
                }
            }

            dp[row][curSelection] = max;
        }

        return dp[row][curSelection];
    }
}

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

#include"bits/stdc++.h"
#include <iostream>
#include <vector>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

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

int main(){
  int n; cin >> n ;
   ll a[100010][3];
  ll dp[100010][3];
  rep(i,n)for(int j=0;j<3;j++) cin >> a[i][j];
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j!=k){
          dp[i+1][j]=max(dp[i+1][j],dp[i][k]+a[i][k]);}}}}
    ll res=0;
    res=max(dp[n][0],dp[n][1], dp[n][2]);
            cout << res << endl;}

Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:24:12:   required from here
   24 |     res=max(dp[n][0],dp[n][1], dp[n][2]);
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const int INF = 1e9+5;
	int len;
	cin >> len;
	vector<int> n(len);
	vector<int> dp(len,INF);
	for(auto &x:n){ 
		int w;
		cin >> w;
		x = w;
	}
	dp[0] = 0;
	for(int i=0;i<len;i++){
		for(int j :{i+1,i+2}){
			if (j < len){
			  dp[j] = min(dp[j],dp[i] + abs(n[i]-n[j]));
			}
		}
	}
	cout << dp[len-1];
}



Compiler output:
a.cc:35:9: error: 'cin' does not name a type
   35 |         cin >> len;
      |         ^~~
a.cc:38:9: error: expected unqualified-id before 'for'
   38 |         for(auto &x:n){
      |         ^~~
a.cc:43:9: error: 'dp' does not name a type
   43 |         dp[0] = 0;
      |         ^~
a.cc:44:9: error: expected unqualified-id before 'for'
   44 |         for(int i=0;i<len;i++){
      |         ^~~
a.cc:44:21: error: 'i' does not name a type
   44 |         for(int i=0;i<len;i++){
      |                     ^
a.cc:44:27: error: 'i' does not name a type
   44 |         for(int i=0;i<len;i++){
      |                           ^
a.cc:51:9: error: 'cout' does not name a type
   51 |         cout << dp[len-1];
      |         ^~~~
a.cc:52:1: error: expected declaration before '}' token
   52 | }
      | ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const int INF = 1e9+5;
	int l;
	cin >> l;
	vector<int> n(l);
	vector<int> dp(l,INF);
	for(auto &x:n){ 
		int w;
		cin >> w;
		x = w;
	}
	dp[0] = 0;
	for(int i=0;i<l;i++){
		for(int j :{i+1,i+2}){
			if (j < l){
			  dp[j] = min(dp[j],dp[i] + abs(n[i]-n[j]));
			}
		}
	}
	cout << dp[l-1];
}



Compiler output:
a.cc:35:9: error: 'cin' does not name a type
   35 |         cin >> l;
      |         ^~~
a.cc:38:9: error: expected unqualified-id before 'for'
   38 |         for(auto &x:n){
      |         ^~~
a.cc:43:9: error: 'dp' does not name a type
   43 |         dp[0] = 0;
      |         ^~
a.cc:44:9: error: expected unqualified-id before 'for'
   44 |         for(int i=0;i<l;i++){
      |         ^~~
a.cc:44:21: error: 'i' does not name a type
   44 |         for(int i=0;i<l;i++){
      |                     ^
a.cc:44:25: error: 'i' does not name a type
   44 |         for(int i=0;i<l;i++){
      |                         ^
a.cc:51:9: error: 'cout' does not name a type
   51 |         cout << dp[l-1];
      |         ^~~~
a.cc:52:1: error: expected declaration before '}' token
   52 | }
      | ^
Language: C++

n = gets.chomp.to_i
h = gets.chomp.split(' ').map{ |e| e.to_i }

dp = [0, h[0]]

(n - 2).times{|ii|
  i = ii + 2
  cand1 = Math.abs(h[i - 1] - h[i])
  cand2 = Math.abs(h[i - 2] - h[i])
  min = cand1 < cand2 ? dp[i - 1] + cand1 : dp[i - 2] + cand2
  dp.push(min)
}
puts dp.last


Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n = gets.chomp.to_i
      | ^
a.cc:4:1: error: 'dp' does not name a type
    4 | dp = [0, h[0]]
      | ^~
a.cc:13:1: error: 'puts' does not name a type
   13 | puts dp.last
      | ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int INT =1e9+5;
int main()
{
   int n;
  cin>>n;
  int h[n];
  vector<int>dp(n,INF);
  dp[0]=0;
  for(int i=0;i<n;i++)
    cin>>h[i];
  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[i]-h[j]));
       }
    }
  }
  cout<<dp[n-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:19: error: 'INF' was not declared in this scope; did you mean 'INT'?
    9 |   vector<int>dp(n,INF);
      |                   ^~~
      |                   INT
a.cc:15:13: error: scalar object 'j' requires one element in initializer
   15 |     for(int j={i+1,i+2})
      |             ^
a.cc:15:24: error: expected ';' before ')' token
   15 |     for(int j={i+1,i+2})
      |                        ^
      |                        ;
a.cc:15:24: error: expected primary-expression before ')' token
a.cc:15:24: error: expected ';' before ')' token
   15 |     for(int j={i+1,i+2})
      |                        ^
      |                        ;
Language: C++

const int MAX_N = 100025;
ll dp[MAX_N],arr[MAX_N];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;scanf("%d",&n);
    for(int i = 1;i<=n;++i) scanf("%lld",&arr[i]);
    for(int i = 2;i<=n;++i)
    {
        if(i==2) dp[i] = dp[i-1]+abs(arr[i]-arr[i-1]);
        else dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    printf("%lld\n",dp[n]);
    //fclose(stdin);
    //fclose(stdout);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Compiler output:
a.cc:2:1: error: 'll' does not name a type
    2 | ll dp[MAX_N],arr[MAX_N];
      | ^~
a.cc: In function 'int main()':
a.cc:8:11: error: 'scanf' was not declared in this scope
    8 |     int n;scanf("%d",&n);
      |           ^~~~~
a.cc:9:43: error: 'arr' was not declared in this scope
    9 |     for(int i = 1;i<=n;++i) scanf("%lld",&arr[i]);
      |                                           ^~~
a.cc:12:18: error: 'dp' was not declared in this scope
   12 |         if(i==2) dp[i] = dp[i-1]+abs(arr[i]-arr[i-1]);
      |                  ^~
a.cc:12:38: error: 'arr' was not declared in this scope
   12 |         if(i==2) dp[i] = dp[i-1]+abs(arr[i]-arr[i-1]);
      |                                      ^~~
a.cc:12:34: error: 'abs' was not declared in this scope
   12 |         if(i==2) dp[i] = dp[i-1]+abs(arr[i]-arr[i-1]);
      |                                  ^~~
a.cc:13:14: error: 'dp' was not declared in this scope
   13 |         else dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
      |              ^~
a.cc:13:38: error: 'arr' was not declared in this scope
   13 |         else dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
      |                                      ^~~
a.cc:13:34: error: 'abs' was not declared in this scope
   13 |         else dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
      |                                  ^~~
a.cc:13:22: error: 'min' was not declared in this scope; did you mean 'main'?
   13 |         else dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
      |                      ^~~
      |                      main
a.cc:15:21: error: 'dp' was not declared in this scope
   15 |     printf("%lld\n",dp[n]);
      |                     ^~
a.cc:15:5: error: 'printf' was not declared in this scope
   15 |     printf("%lld\n",dp[n]);
      |     ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | const int MAX_N = 100025;
Language: C++

#include<bits/stdc++.h>
#define push_back pb
using namespace std;
vector<int> h;
vector<int> ans(100000, -1);
int cost(long int n)
{
	if(ans[n]!=-1)
		return ans[n];
	if(n==1)
	{
		ans[1]=0;
		return ans[0];
	}
	if(n==2)
	{
		ans[2]=abs(h[1]-h[2]);
		return ans[2]; 
	}
	ans[n]=min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]));
	return ans[n];
}
void main()
{
	long int n,i;
	int h1;
	h.pb(0);
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		cin>>h1;
		h.pb(h1);
	}
	cout<<cost(n);
}

Compiler output:
a.cc:23:1: error: '::main' must return 'int'
   23 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:27:11: error: 'class std::vector<int>' has no member named 'pb'
   27 |         h.pb(0);
      |           ^~
a.cc:33:19: error: 'class std::vector<int>' has no member named 'pb'
   33 |                 h.pb(h1);
      |                   ^~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:13:13: error: conflicting declaration 'int a [0]'
   13 |         int a[0]=0;
      |             ^
a.cc:12:13: note: previous declaration as 'int a [n]'
   12 |         int a[n];
      |             ^
a.cc:14:13: error: conflicting declaration 'int a [1]'
   14 |         int a[1]=abs(arr[0]-arr[1]);
      |             ^
a.cc:12:13: note: previous declaration as 'int a [n]'
   12 |         int a[n];
      |             ^
Language: C++

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	cin>>h[i];
	
	vector<int> dp(n+1,INT_MAX);
	dp[0]=0;
	dp[1]=0;
	
for(int i=2;i<=n;i++)
{
	dp[i]=min(d[i],dp[i-1]+abs(h[i]-h[i-1]));
}
for(int i=3;i<=n;i++)
{
	dp[i]=min(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:19: error: 'd' was not declared in this scope
   18 |         dp[i]=min(d[i],dp[i-1]+abs(h[i]-h[i-1]));
      |                   ^
Language: C++

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	cin>>h[i];
	
	vector<int> dp(n+1,INT_MAX);
	dp[0]=0;
	dp[1]=0;
	
for(int i=2;i<=n;i++)
{
	dp[i]=min(d[i],dp[i-1]+abs(h[i]-h[i-1]));
}
for(int i=3;i<=n;i++)
{
	dp[i]=min(d[i],dp[i-2]+abs(h[i]-h[i-2]));
}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:18:19: error: 'd' was not declared in this scope
   18 |         dp[i]=min(d[i],dp[i-1]+abs(h[i]-h[i-1]));
      |                   ^
a.cc:22:19: error: 'd' was not declared in this scope
   22 |         dp[i]=min(d[i],dp[i-2]+abs(h[i]-h[i-2]));
      |                   ^
Language: Java

import java.util.*;
import java.io.*;
import java.lang.*;
public class test{

public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt();
       int[] arr=new int[n];
       for(int i=0;i<n;i++){arr[i]=s.nextInt();}
        int[] dp=new int[n];
      dp[1]=Math.abs(arr[1]-arr[0]);
      for(int i=2;i<n;i++){
        dp[i]=Math.min(Math.abs(arr[i]-arr[i-1])+dp[i-1],Math.abs(arr[i]-arr[i-2])+dp[i-2]);
      }
      System.out.println(dp[n-1]);
    }
}
    
  












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

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const INF 1e9+7;
int main(){ IOS;
  int n;
  cin>>n;
  vector<int>dp(n,INF);
  vector<int>h(n);
  dp[0]=0;
  for(int i=0;i<n;i++)
    cin>>h[i];
  for(int i=0;i<n;i++){
    for(int j:{i+1,i+2}){
      dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
    }
  }
  cout<<dp[n-1];
}

Compiler output:
a.cc:4:7: error: 'INF' does not name a type
    4 | const INF 1e9+7;
      |       ^~~
a.cc: In function 'int main()':
a.cc:8:19: error: 'INF' was not declared in this scope
    8 |   vector<int>dp(n,INF);
      |                   ^~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>

using namespace std;

typedef long long ll;

#define rep(i,n) for(ll (i) = 0; (i) < (n); (i)++)

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

int main(void){
    int N;
    cin >> N;
    int A[100010];
    rep(i,N) cin >> A[i];
    long long INF = 1LL << 60;
    long long dp[100010];
    for(int i = 0;i < 100010; ++i) dp[i] = INF;
    dp[0] = 0;

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

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

Compiler output:
a.cc:14:6: error: variable or field 'chmin' declared void
   14 | void chmin(T& a, T b){
      |      ^~~~~
a.cc:14:12: error: 'T' was not declared in this scope
   14 | void chmin(T& a, T b){
      |            ^
a.cc:14:15: error: 'a' was not declared in this scope
   14 | void chmin(T& a, T b){
      |               ^
a.cc:14:18: error: 'T' was not declared in this scope
   14 | void chmin(T& a, T b){
      |                  ^
a.cc: In function 'int main()':
a.cc:29:9: error: 'chmin' was not declared in this scope
   29 |         chmin(dp[i],dp[i-1] + abs(A[i] - A[i - 1]));
      |         ^~~~~
Language: C++

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <set>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n; i>=0; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e10
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<lli>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using lli = long long int;
template<typename T> bool chmax(T &a, T &b){ if(a<b) { a=b; return 1; }}
template<typename T> bool chmin(T &a, T &b){ if(b<a) { a=b; return 1; }}
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> T vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> T arrdebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


int main(){
	int n, tmph;
	vector<int> h;
	cin >> n;
	rep(i, n){
		cin >> tmph;
		h.push_back(tmph);
	}
	
	int dp[100001];
	dp[0] = 0;

	rep(i, n-1){
		if(i==0) dp[i+1] = h[i+1] - h[i];
		else dp[i+1] = min(dp[i] + abs(h[i+1]-h[i]), dp[i-1] + abs(h[i+1]-h[i-1]))
	}
	
	cout << dp[n-1] << endl;
}


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

#include<iostream>
#include<cmath>
#include<string.h>
using namespace std;
int dp[100005];
int h[100005];
int frog1(int n)
{ if(n==1)
  return 0;
  if(n==2)
    return abs(h[1]-h[0]);
  if(dp[n-1]!=-1)
    return dp[n-1];
 
  dp[n-1] = min(frog1(n-1)+abs(h[n-1]-h[n-2]),frog1(n-2)+abs(h[n-1]-h[n-3]));
   return dp[n-1];
}
int main()
{ int n;
  cin>>n;
 for(int i=0;i<n;i++)
   cin>>h[i];
 memset(-1,dp,sizeof(dp));
 cout<<frog1(n);
 return 0;
}
 

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: invalid conversion from 'int' to 'void*' [-fpermissive]
   23 |  memset(-1,dp,sizeof(dp));
      |         ^~
      |         |
      |         int
In file included from a.cc:3:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc:23:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   23 |  memset(-1,dp,sizeof(dp));
      |            ^~
      |            |
      |            int*
/usr/include/string.h:61:37: note:   initializing argument 2 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                                 ~~~~^~~
Language: C++

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

Compiler output:
a.cc:17:10: warning: missing terminating ' character
   17 |   cin>>n;'
      |          ^
a.cc:17:10: error: missing terminating ' character
Language: C++

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

Compiler output:
a.cc:17:10: warning: missing terminating ' character
   17 |   cin>>n;'
      |          ^
a.cc:17:10: error: missing terminating ' character
Language: C++

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

Compiler output:
a.cc:19:10: warning: missing terminating ' character
   19 |   cin>>n;'
      |          ^
a.cc:19:10: error: missing terminating ' character
a.cc:7:1: error: expected unqualified-id before '{' token
    7 | { if(n==0)
      | ^
Language: C++

#include <iostream>
#include <bits/stdc++.h>
#define NMAX 10000
using namespace std;
int dp[NMAX];


int frogSolver(int n, int h[]){
 //https://atcoder.jp/contests/dp/tasks/dp_a

 //dp; //dp[i] = minimum cost we are required to spend to reach i-th stone    
 dp[n] = 0;
 if(1<=n){ 
   dp[n-1] = abs(h[n]-h[n-1]);
 }
 if(2<=n){
   dp[n-2] = abs(h[n]-h[n-2]
 } 
 for(int i = n-3; i>=0;i--){
   dp[i] = min(abs(h[i+1]-h[i])+dp[i+1],abs(h[i+2]-h[i])+dp[i+2]);     
 }
 
 return dp[0]; 

}

int main(void) {
  int n,t;
  int h[NMAX];
  cin >> n;
  for(int i =0;i<n;i++){
    cin >> t;
    h[i] = t;
  }


  printf("%d \n",frogSolver(n-1,h));
  return 0;
}


Compiler output:
a.cc: In function 'int frogSolver(int, int*)':
a.cc:17:29: error: expected ')' before '}' token
   17 |    dp[n-2] = abs(h[n]-h[n-2]
      |                 ~           ^
      |                             )
   18 |  }
      |  ~
Language: Java

import java.util.Scanner;

public class A {
    public  static  void main(String args[]){
        Scanner sc= new Scanner(System.in);
        int n= sc.nextInt();
        int h []=new int[n];
        for(int j=0;j<n;j++)
            h[j]=sc.nextInt();
        int cost[]= new int [n];
        cost[0]=0;
        cost[1]=Math.abs(h[1]-h[0]);
        for (int i=2;i<n;i++){
            cost[i]=Math.min(cost[i-1]+Math.abs(h[i]-h[i-1]),cost[i-2]+Math.abs(h[i]-h[i-2]));
        }
        System.out.println(cost[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: C++

#include <iostream>
#include <bits/stdc++.h>
#define NMAX 1e9
using namespace std;
int dp[NMAX];
 
 
int frogSolver(int n, int h[]){
 dp[n] = 0;
 dp[n-1] = abs(h[n]-h[n-1]);
 dp[n-2] = abs(h[n]-h[n-2]);
 for(int i = n-3; i>=0;i--){
   dp[i] = min(abs(h[i+1]-h[i])+dp[i+1],h[i+2]-h[i]+dp[i+2]);     
 }
 
 return dp[0]; 
 
}
 
int main(void) {
  int n,t;
  int h[NMAX];
  cin >> n;
  for(int i =0;i<n;i++){
    cin >> t;
    h[i] = t;
  }
 
 
  printf("%d \n",frogSolver(n-1,h));
  return 0;
}

Compiler output:
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define NMAX 1e9
      |              ^~~
a.cc:5:8: note: in expansion of macro 'NMAX'
    5 | int dp[NMAX];
      |        ^~~~
a.cc:3:14: error: could not convert '1.0e+9' from 'double' to 'long unsigned int'
    3 | #define NMAX 1e9
      |              ^~~
      |              |
      |              double
a.cc:5:8: note: in expansion of macro 'NMAX'
    5 | int dp[NMAX];
      |        ^~~~
a.cc:3:14: error: size of array 'dp' has non-integral type 'double'
    3 | #define NMAX 1e9
      |              ^~~
a.cc:5:8: note: in expansion of macro 'NMAX'
    5 | int dp[NMAX];
      |        ^~~~
a.cc: In function 'int main()':
a.cc:3:14: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
    3 | #define NMAX 1e9
      |              ^~~
a.cc:22:9: note: in expansion of macro 'NMAX'
   22 |   int h[NMAX];
      |         ^~~~
a.cc:3:14: error: could not convert '1.0e+9' from 'double' to 'long unsigned int'
    3 | #define NMAX 1e9
      |              ^~~
      |              |
      |              double
a.cc:22:9: note: in expansion of macro 'NMAX'
   22 |   int h[NMAX];
      |         ^~~~
a.cc:3:14: error: size of array 'h' has non-integral type 'double'
    3 | #define NMAX 1e9
      |              ^~~
a.cc:22:9: note: in expansion of macro 'NMAX'
   22 |   int h[NMAX];
      |         ^~~~
Language: C++

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

Compiler output:
a.cc:9:19: error: 'n' was not declared in this scope; did you mean 'yn'?
    9 | long long int ans[n];
      |                   ^
      |                   yn
a.cc: In function 'long long int func(long long int*, long long int)':
a.cc:12:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   12 |   ans[1]=abs(a[0]-a[1]);
      |   ^~~
      |   abs
a.cc:14:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |   ans[0]=0 ;
      |   ^~~
      |   abs
a.cc:17:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   17 |   ans[n]=k;
      |   ^~~
      |   abs
a.cc:19:1: warning: no return statement in function returning non-void [-Wreturn-type]
   19 | }
      | ^
Language: C++

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define ppb pop_back

using namespace std;
template<typename T> using vec = vector<T>;
using ll = long long;

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

const long long INF = 1LL << 60;

int main(int argc,char* argv[])
{
   int n;
   cin>>n;
   if(n =< 1){
       cout<<0<<endl;
       return 0;
   }

   vec<int> h(n);
   rep(i,n)cin>>h[i];
   
   vec<int> h1(n);
   h1[0] = 0;
   h1[1] = h[1] - h[0];
   for(int i = 2; i < n; i++)
   {
       if(abs(h[i]-h[i-1]) > abs(h[i]-h[i-2]))
       {
           h1[i] = h1[i-2] + abs(h[i]-h[i-2]); 
       }
       else 
       {
           h1[i] = h1[i-1] + abs(h[i]-h[i-1]); 
       }
   }

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

    return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:22:10: error: expected primary-expression before '<' token
   22 |    if(n =< 1){
      |          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 4e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 998244353;
 
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;

ll n;cin>>n;

ll a[n];repup(0,n-1,i)cin>>a[i];

ll ans[n];
ans[0]=0;ans[1]= abs(a[1]-a[0]);
repup(2,n-1,i){
	ans[i]= min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2]+abs(h[i]-h[i-2]));
}

cout<<ans[n-1];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:34: error: 'h' was not declared in this scope
   41 |         ans[i]= min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2]+abs(h[i]-h[i-2]));
      |                                  ^
Language: C++

#include<chrono>
#include<random>
#include <iostream>
#include <vector>
using namespace std;
using namespace chrono;

int n; // number of vertices
vector<vector<int>> adj; // adjacency list of graph
vector<bool> visited;
vector<int> ans;

void dfs(int v) {
	visited[v] = true;
	for (int u : adj[v]) {
		if (!visited[u])
			dfs(u);
	}
	ans.push_back(v);
}

void topological_sort() {
	visited.assign(n, false);
	ans.clear();
	for (int i = 0; i < n; ++i) {
		if (!visited[i])
			dfs(i);
	}
	reverse(ans.begin(), ans.end());
}

int main() {

	int m;

	cin >> n >> m;
	
	int x, y;

	vector<int> d;
	vector<int> p;

	adj.assign(n, vector<int>());
	// dp.assign(n + 1, vector<vector<int>>());

	for (int i = 0; i < m; i++) {
		cin >> x >> y;
		adj[x-1].push_back(y-1);
	}

	topological_sort();

	vector<int> dp(n);

	for (auto i : ans) {
		for (auto v : adj[i]) {
			dp[v] = max(dp[i] + 1, dp[v]);
		}
	}

	cout << *max_element(dp.begin(), dp.end()) << "\n";


	return 0;

}








Compiler output:
a.cc: In function 'void topological_sort()':
a.cc:29:9: error: 'reverse' was not declared in this scope
   29 |         reverse(ans.begin(), ans.end());
      |         ^~~~~~~
a.cc: In function 'int main()':
a.cc:61:18: error: 'max_element' was not declared in this scope
   61 |         cout << *max_element(dp.begin(), dp.end()) << "\n";
      |                  ^~~~~~~~~~~
Language: C++

int main(){
   int n;
  cin >> n;
  int a[n];
  for(int i = 0;i<n;i++){
    cin >> a[i];
  }
  int dp[n];
  
  dp[n-1] = 0;
  
  dp[n-2] = abs(a[n-1] - a[n-2]);
  int diff;
  for(int i = n-3;i>=0;i--){
  	dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] + a[i]));
  }
  return dp[0];
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> n;
      |   ^~~
a.cc:12:13: error: 'abs' was not declared in this scope
   12 |   dp[n-2] = abs(a[n-1] - a[n-2]);
      |             ^~~
a.cc:15:17: error: 'min' was not declared in this scope; did you mean 'main'?
   15 |         dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] + a[i]));
      |                 ^~~
      |                 main
Language: C++

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

#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (l); i > (r); --i)

const int N = (int)2e5 + 1;

int dp[N];//min cost 1 -> i

int main() {
    cin >> n;
    rep(i, 1, n + 1) {
        cin >> h[i]
    }

    dp[1] = 0;
    rep(i, 2, n + 1) {
        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        if (i - 2 >= 1) dp[i] = min(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
    } 
    cout << dp[n];
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: 'n' was not declared in this scope
   12 |     cin >> n;
      |            ^
a.cc:14:16: error: 'h' was not declared in this scope
   14 |         cin >> h[i]
      |                ^
a.cc:19:33: error: 'h' was not declared in this scope
   19 |         dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
      |                                 ^
Language: Java

public class Main {

    //https://atcoder.jp/contests/dp/tasks/dp_a

    private static int[] dp = null;

    public static void main( String[] args ) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

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

        //System.out.println(dfs(arr, n, 0));

        dp = new int[n + 1];
        Arrays.fill(dp, -1);

        System.out.println(solve(n - 1, arr));
    }

    private static int dfs( int[] arr, int n, int i ) {

        if (i > n) {
            return 0;
        }

        if (i < n) {
            int val = arr[i] - dfs(arr, n, i + 1);
            int val_1 = arr[i] - dfs(arr, n, i + 2);

            return Math.max(Math.abs(val), Math.abs(val_1));
        }
        return 0;
    }

    private static int solve( int i, int[] h ) {
        if (dp[i] != -1)
            return dp[i];

        if (i == 1) //if only element in an array then
            return 0;

        else if (i == 2) //if two elements in array then difference of two will be the cost.
            return Math.abs(h[i] - h[i - 1]);

        else return dp[i] = Math.min(Math.abs(h[i] - h[i - 1]) + solve(i - 1, h)
                    , Math.abs(h[i] - h[i - 2]) + solve(i - 2, h));
    }
}

Compiler output:
Main.java:8: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:8: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
Main.java:19: error: cannot find symbol
        Arrays.fill(dp, -1);
        ^
  symbol:   variable Arrays
  location: class Main
3 errors
Language: C++

#include<bits/stdc++.h>
#define push_back pb
using namespace std;
vector<int> h;
vector<int> ans(100000, -1);
int cost(long int n)
{
	if(ans[n]!=-1)
		return ans[n];
	if(n==1)
	{
		ans[1]=0;
		return ans[0];
	}
	if(n==2)
	{
		ans[2]=abs(h[1]-h[2]);
		return ans[2]; 
	}
	ans[n]=min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]));
	return ans[n];
}
int main()
{
	long int n,i;
	int h1;
	h.push_back(0);
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		cin>>h1;
		h.push_back(h1);
	}
	cout<<cost(n);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:19: error: 'class std::vector<int>' has no member named 'pb'
    2 | #define push_back pb
      |                   ^~
a.cc:27:11: note: in expansion of macro 'push_back'
   27 |         h.push_back(0);
      |           ^~~~~~~~~
a.cc:2:19: error: 'class std::vector<int>' has no member named 'pb'
    2 | #define push_back pb
      |                   ^~
a.cc:33:19: note: in expansion of macro 'push_back'
   33 |                 h.push_back(h1);
      |                   ^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#define push_back pb
using namespace std;
vector<int> h;
vector<int> ans(100000, -1);
int cost(long int n)
{
	if(ans[n]!=-1)
		return ans[n];
	if(n==1)
	{
		ans[1]=0;
		return ans[0];
	}
	if(n==2)
	{
		ans[2]=abs(h[1]-h[2]);
		return ans[2]; 
	}
	ans[n]=min(cost(n-1)+abs(h[n]-h[n-1]),cost(n-2)+abs(h[n]-h[n-2]));
	return ans[n];
}
int main()
{
	long int n,i;
	int h1;
	h.pb(0);
	cin>>n;
	
	for(i=0;i<n;i++)
	{
		cin>>h1;
		h.pb(h1);
	}
	cout<<cost(n);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:11: error: 'class std::vector<int>' has no member named 'pb'
   27 |         h.pb(0);
      |           ^~
a.cc:33:19: error: 'class std::vector<int>' has no member named 'pb'
   33 |                 h.pb(h1);
      |                   ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int t;
    cin>>t;
  while(t--){
    int n,i,j;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
      cin>>a[i];
    vector<int>T(n,0);
    T[1]=abs(a[1]-a[0]);
    int ans=-1;
    if(n<=2){
      cout<<T[1]<<"\n";
      continue;
    }
    for(i=2;i<n;i++){
        T[i]=min(T[i-1]+abs(a[i]-a[i-1]),
                 T[i-2]+abs(a[i]-a[i-2]));
      ans=max(T[i],ans);
    }
    cout<<ans<<"\n";
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:25:4: error: expected '}' at end of input
   25 |   }
      |    ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int t;'
    cin>>t;
  while(t--){
    int n,i,j;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
      cin>>a[i];
    vector<int>T(n,0);
    T[1]=abs(a[1]-a[0]);
    int ans=-1;
    if(n<=2){
      cout<<T[1]<<"\n";
      continue;
    }
    for(i=2;i<n;i++){
        T[i]=min(T[i-1]+abs(a[i]-a[i-1]),
                 T[i-2]+abs(a[i]-a[i-2]));
      ans=max(T[i],ans);
    }
    cout<<ans<<"\n";
  }

Compiler output:
a.cc:4:9: warning: missing terminating ' character
    4 |   int t;'
      |         ^
a.cc:4:9: error: missing terminating ' character
a.cc: In function 'int main()':
a.cc:25:4: error: expected '}' at end of input
   25 |   }
      |    ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

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

const long long INF = 1LL << 60; //2^60

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

// DP テーブル
long long dp[100010];

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

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

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

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

    // 答え
    cout << res << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'res' was not declared in this scope
   27 |         res = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
      |         ^~~
a.cc:31:13: error: 'res' was not declared in this scope
   31 |     cout << res << endl;
      |             ^~~
Language: C++

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

bool chmin(int &a, int b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60; //2^60

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

// DP テーブル
long long dp[100010];

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

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

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

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

    // 答え
    cout << dp[N-1] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:19: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   35 |         chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
      |               ~~~~^
a.cc:6:17: note:   initializing argument 1 of 'bool chmin(int&, int)'
    6 | bool chmin(int &a, int b) {
      |            ~~~~~^
a.cc:36:30: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int'
   36 |         if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
      |                          ~~~~^
a.cc:6:17: note:   initializing argument 1 of 'bool chmin(int&, int)'
    6 | bool chmin(int &a, int b) {
      |            ~~~~~^
Language: C++

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

bool chmin(&a, b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60; //2^60

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

// DP テーブル
long long dp[100010];

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

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

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

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

    // 答え
    cout << dp[N-1] << endl;
}

Compiler output:
a.cc:6:13: error: 'a' was not declared in this scope
    6 | bool chmin(&a, b) {
      |             ^
a.cc:6:16: error: 'b' was not declared in this scope
    6 | bool chmin(&a, b) {
      |                ^
a.cc:6:17: error: expression list treated as compound expression in initializer [-fpermissive]
    6 | bool chmin(&a, b) {
      |                 ^
a.cc: In function 'int main()':
a.cc:35:14: error: 'chmin' cannot be used as a function
   35 |         chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:36:25: error: 'chmin' cannot be used as a function
   36 |         if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//https://atcoder.jp/contests/dp/tasks/dp_a


int main(){
    ll n;
    cin >> n;
    vector <ll> h(n);
    REP(i,n)
    {
        cin >> h.at(i);
    }

    ll dp[n];

    REP(i,n)
    {
        dp[i] = INF;
    }

    dp[0] = 0;
    dp[1] = abs(height[1]-height[0]);
    
    for(ll 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]));
    }
    ll res = dp[n-1];

    cout << res << endl;

    return 0;    
}



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

#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//https://atcoder.jp/contests/dp/tasks/dp_a


int main(){
    ll n;
    cin >> n;
    vector <ll> h(n);
    REP(i,n)
    {
        cin >> h.at(i);
    }

    ll dp[n];

    REP(i,n)
    {
        dp[i] = INF;
    }

    dp[0] = 0;
    dp[1] = abs(height[1]-height[0]);
    
    for(ll 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]);
    }
    ll res = dp[n-1];

    cout << res << endl;

    return 0;    
}



Compiler output:
a.cc: In function 'int main()':
a.cc:34:17: error: 'height' was not declared in this scope
   34 |     dp[1] = abs(height[1]-height[0]);
      |                 ^~~~~~
a.cc:38:78: error: expected ')' before ';' token
   38 |         dp[i] = min(dp[i-1] + abs(h[i] - h[i-1], dp[i-2] + abs(h[i] - h[i-2]);
      |                                  ~                                           ^
      |                                                                              )
Language: C++

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

int main(){
  int n;
  cin>>n;
  int a[n];
  int c=n;
  while(c--){
  	cin>>a[n-c];
  }
  int dis[n];
  dis[0]=0;
  dis[1]=abs(a[0]-a[1]);
  
  for(int i=2;i<n;i++){
  	dis[i]=min(dis[i-1]+abs(a[i]-a[i-1]),dis[i-2]+abs(a[i]-a[i-2]))
  }
  
  cout<<dis[n-1];
  
  return 0;
}

Compiler output:
a.cc:1:10: error: #include expects "FILENAME" or <FILENAME>
    1 | #include #include <bits/stdc++.h>
      |          ^
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   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 | #include #include <bits/stdc++.h>
a.cc:14:10: error: 'abs' was not declared in this scope
   14 |   dis[1]=abs(a[0]-a[1]);
      |          ^~~
a.cc:17:16: error: 'min' was not declared in this scope; did you mean 'main'?
   17 |         dis[i]=min(dis[i-1]+abs(a[i]-a[i-1]),dis[i-2]+abs(a[i]-a[i-2]))
      |                ^~~
      |                main
a.cc:20:3: error: 'cout' was not declared in this scope
   20 |   cout<<dis[n-1];
      |   ^~~~
a.cc:20:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'