Language: Java

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

public class Main {
    private static final class FastInput {
        private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer st;

        private int nextInt() throws Exception {
            return Integer.parseInt(nextWord());
        }

        private long nextLong() throws Exception {
            return Long.parseLong(nextWord());
        }

        private String nextWord() throws Exception {
            if (st == null || !st.hasMoreElements()) st = new StringTokenizer(br.readLine(), " ");
            return st.nextToken();
        }

        private long[] lineToIntArr(int len) throws Exception {
            long[] arr = new long[len];
            for (int i = 0; i < arr.length; i++) arr[i] = nextLong();
            return arr;
        }
    }

    public static void main(String[] args) throws Exception {
        FastInput in = new FastInput();
        int n = in.nextInt();
        long[] a = in.lineToIntArr(n);
        dp[0] = 0;
       	for(int i = 1; i <n; ++i){
          	if(i + 1) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-1]));
          	if(i + 2) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-2]));
        }
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        bw.write(String.valueOf(dp[n - 1]));
        bw.flush();
    }
}


Compiler output:
Main.java:36: error: cannot find symbol
        dp[0] = 0;
        ^
  symbol:   variable dp
  location: class Main
Main.java:38: error: incompatible types: int cannot be converted to boolean
          	if(i + 1) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-1]));
          	     ^
Main.java:38: error: cannot find symbol
          	if(i + 1) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-1]));
          	          ^
  symbol:   variable dp
  location: class Main
Main.java:38: error: cannot find symbol
          	if(i + 1) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-1]));
          	                           ^
  symbol:   variable dp
  location: class Main
Main.java:38: error: cannot find symbol
          	if(i + 1) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-1]));
          	                                    ^
  symbol:   variable dp
  location: class Main
Main.java:39: error: incompatible types: int cannot be converted to boolean
          	if(i + 2) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-2]));
          	     ^
Main.java:39: error: cannot find symbol
          	if(i + 2) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-2]));
          	          ^
  symbol:   variable dp
  location: class Main
Main.java:39: error: cannot find symbol
          	if(i + 2) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-2]));
          	                           ^
  symbol:   variable dp
  location: class Main
Main.java:39: error: cannot find symbol
          	if(i + 2) dp[i] = Math.max(dp[i-1], dp[i] + Math.abs(a[i] - a[i-2]));
          	                                    ^
  symbol:   variable dp
  location: class Main
Main.java:42: error: cannot find symbol
        bw.write(String.valueOf(dp[n - 1]));
                                ^
  symbol:   variable dp
  location: class Main
10 errors