Language: C++

/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
  	int dp[];
  	Main(int n){
      dp = new int[n];
    }
	public static void main (String[] args) throws java.lang.Exception
	{
      	FastReader s = new FastReader();
		int  n = s.nextInt();
		int arr[] = new int[n];
		for(int i=0;i<n;i++)
		arr[i]= s.nextInt();
		Main ob = new Main(n);
		int ans = ob.getCost(n-1,arr);
		System.out.println(ans);
	}
	int getCost(int n, int arr[]){
      	if (dp[n]!=0) return dp[n];
		if(n==0) { 
          dp[0] = 4294967295;
          return dp[0];
        }
		if(n==1) {
          dp[1] = Math.abs(arr[1]-arr[0]);
          return Math.abs(arr[1]-arr[0]);
        }
      	dp[n]=Math.min(Math.abs(arr[n]-arr[n-1])+getCost(n-1,arr),Math.abs(arr[n]-arr[n-2])+getCost(n-2,arr));
		return dp[n];
	}
  static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Compiler output:
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.lang.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.io.*;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:14:15: error: expected ':' before 'static'
   14 |         public static void main (String[] args) throws java.lang.Exception
      |               ^~~~~~~
      |               :
a.cc:14:34: error: 'String' has not been declared
   14 |         public static void main (String[] args) throws java.lang.Exception
      |                                  ^~~~~~
a.cc:14:43: error: expected ',' or '...' before 'args'
   14 |         public static void main (String[] args) throws java.lang.Exception
      |                                           ^~~~
a.cc:14:47: error: expected ';' at end of member declaration
   14 |         public static void main (String[] args) throws java.lang.Exception
      |                                               ^
      |                                                ;
a.cc:14:49: error: 'throws' does not name a type
   14 |         public static void main (String[] args) throws java.lang.Exception
      |                                                 ^~~~~~
a.cc:40:9: error: 'BufferedReader' does not name a type
   40 |         BufferedReader br;
      |         ^~~~~~~~~~~~~~
a.cc:41:9: error: 'StringTokenizer' does not name a type
   41 |         StringTokenizer st;
      |         ^~~~~~~~~~~~~~~
a.cc:43:15: error: expected ':' before 'FastReader'
   43 |         public FastReader()
      |               ^~~~~~~~~~~
      |               :
a.cc:49:9: error: 'String' does not name a type
   49 |         String next()
      |         ^~~~~~
a.cc:80:9: error: 'String' does not name a type
   80 |         String nextLine()
      |         ^~~~~~
a.cc:93:6: error: expected ';' after class definition
   93 |     }
      |      ^
      |      ;
a.cc:38:3: error: a storage class can only be specified for objects and functions
   38 |   static class FastReader
      |   ^~~~~~
a.cc:10:13: error: flexible array member 'Main::dp' in an otherwise empty 'class Main'
   10 |         int dp[];
      |             ^~
a.cc:94:2: error: expected ';' after class definition
   94 | }
      |  ^
      |  ;
a.cc: In constructor 'Main::Main(int)':
a.cc:12:7: error: invalid use of array with unspecified bounds
   12 |       dp = new int[n];
      |       ^~
a.cc: In member function 'int Main::getCost(int, int*)':
a.cc:32:19: error: 'Math' was not declared in this scope
   32 |           dp[1] = Math.abs(arr[1]-arr[0]);
      |                   ^~~~
a.cc:35:15: error: 'Math' was not declared in this scope
   35 |         dp[n]=Math.min(Math.abs(arr[n]-arr[n-1])+getCost(n-1,arr),Math.abs(arr[n]-arr[n-2])+getCost(n-2,arr));
      |               ^~~~
a.cc: In constructor 'Main::FastReader::FastReader()':
a.cc:45:13: error: 'br' was not declared in this scope
   45 |             br = new BufferedReader(new
      |             ^~
a.cc:45:22: error: expected type-specifier before 'BufferedReader'
   45 |             br = new BufferedReader(new
      |                      ^~~~~~~~~~~~~~
a.cc: In member function 'int Main::FastReader::nextInt()':
a.cc:67:20: error: 'Integer' was not declared in this scope
   67 |             return Integer.parseInt(next());
      |                    ^~~~~~~
a.cc:67:37: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   67 |             return Integer.parseInt(next());
      |                                     ^~~~
      |                                     nextInt
a.cc: In member function 'long int Main::FastReader::nextLong()':
a.cc:72:20: error: 'Long' was not declared in this scope; did you mean 'long'?
   72 |             return Long.parseLong(next());
      |                    ^~~~
      |                    long
a.cc:72:35: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   72 |             return Long.parseLong(next());
      |                                   ^~~~
      |                                   nextInt
a.cc: In member function 'double Main::FastReader::nextDouble()':
a.cc:77:20: error: 'Double' was not declared in this scope; did you mean 'double'?
   77 |             return Double.parseDouble(next());
      |                    ^~~~~~
      |                    double
a.cc:77:39: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   77 |             return Double.parseDouble(next());
      |                                       ^~~~
      |                                       nextInt