Language: C++

import java.util.*;
import java.io.*;
 
class Main {
 
  static int INF = (int) 1e9 + 7;
  static List<List<Integer>> adj;
 
  public static void main(String[] args) {
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    
    int n = in.nextInt();
    int[] h = new int[n], a = new int[n];
    for (int i = 0; i < n; i++) {
      h[i] = in.nextInt();
    }
    for (int i = 0; i < n; i++) {
      a[i] = in.nextInt();
    }

    long[] dp = new long[n];
    dp[0] = a[0];
    long res = 0;
    for (int i = 1; i < n; i++) {
      long prevMax = 0;
      for (int j = 0; j < i; j++) {
        if (h[j] < h[i]) {prevMax = Math.max(prevMax, dp[j]);}
      }
      dp[i] = prevMax + a[i];
      res = Math.max(res, dp[i]);
    }

   
    System.out.println(res);
  }

  static int[] dfs(int cur, int parent) {

    // res[0]: counts when cur is painted black
    // res[1]: counts when cur is painted white
    int[] res = new int[2]; 
    Arrays.fill(res, 1);

    for (int next : adj.get(cur)) {
      if (next != parent) {
        int[] child = dfs(next, cur);
        res[0] = mul(res[0], child[1]);
        res[1] = mul(res[1], add(child[0], child[1]));
      }
    }

    return res;
    


    //System.out.println(cur);
  }

  static void add(int[] a, int i, int j) {
    a[i] += a[j];
    if (a[i] >= INF) {a[i] -= INF;}
  }

  static int add(int a, int b) {
    a = a + b;
    if (a >= INF) {a -= INF;}
    return a;
  }

  static int mul(int a, int b) {
    long res = a * b;
    
    return (int) (res % INF);
  }

  static int countSetBit(int a) {
    int count = 0; 
    while (a > 0) {
      count += (a & 1);
      a = a >> 1;
    }
    return count;
  }

 
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:14: error: ISO C++ forbids in-class initialization of non-const static member 'Main::INF'
    6 |   static int INF = (int) 1e9 + 7;
      |              ^~~
a.cc:7:10: error: 'List' does not name a type
    7 |   static List<List<Integer>> adj;
      |          ^~~~
a.cc:9:9: error: expected ':' before 'static'
    9 |   public static void main(String[] args) {
      |         ^~~~~~~
      |         :
a.cc:9:27: error: 'String' has not been declared
    9 |   public static void main(String[] args) {
      |                           ^~~~~~
a.cc:9:36: error: expected ',' or '...' before 'args'
    9 |   public static void main(String[] args) {
      |                                    ^~~~
a.cc:37:13: error: expected unqualified-id before '[' token
   37 |   static int[] dfs(int cur, int parent) {
      |             ^
a.cc:59:25: error: expected ',' or '...' before 'a'
   59 |   static void add(int[] a, int i, int j) {
      |                         ^
a.cc:86:2: error: expected ';' after class definition
   86 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:10:5: error: 'Scanner' was not declared in this scope
   10 |     Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
      |     ^~~~~~~
a.cc:12:13: error: 'in' was not declared in this scope; did you mean 'int'?
   12 |     int n = in.nextInt();
      |             ^~
      |             int
a.cc:13:8: error: structured binding declaration cannot have type 'int'
   13 |     int[] h = new int[n], a = new int[n];
      |        ^~
a.cc:13:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:13:8: error: empty structured binding declaration
a.cc:13:11: error: expected initializer before 'h'
   13 |     int[] h = new int[n], a = new int[n];
      |           ^
a.cc:15:7: error: 'h' was not declared in this scope
   15 |       h[i] = in.nextInt();
      |       ^
a.cc:18:7: error: 'a' was not declared in this scope
   18 |       a[i] = in.nextInt();
      |       ^
a.cc:21:9: error: structured binding declaration cannot have type 'long int'
   21 |     long[] dp = new long[n];
      |         ^~
a.cc:21:9: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:21:9: error: empty structured binding declaration
a.cc:21:12: error: expected initializer before 'dp'
   21 |     long[] dp = new long[n];
      |            ^~
a.cc:22:5: error: 'dp' was not declared in this scope
   22 |     dp[0] = a[0];
      |     ^~
a.cc:22:13: error: 'a' was not declared in this scope
   22 |     dp[0] = a[0];
      |             ^
a.cc:27:13: error: 'h' was not declared in this scope
   27 |         if (h[j] < h[i]) {prevMax = Math.max(prevMax, dp[j]);}
      |             ^
a.cc:27:37: error: 'Math' was not declared in this scope
   27 |         if (h[j] < h[i]) {prevMax = Math.max(prevMax, dp[j]);}
      |                                     ^~~~
a.cc:30:13: error: 'Math' was not declared in this scope
   30 |       res = Math.max(res, dp[i]);
      |             ^~~~
a.cc:34:5: error: 'System' was not declared in this scope
   34 |     System.out.println(res);
      |     ^~~~~~
a.cc: In static member function 'static void Main::add(int*)':
a.cc:60:5: error: 'a' was not declared in this scope
   60 |     a[i] += a[j];
      |     ^
a.cc:60:7: error: 'i' was not declared in this scope
   60 |     a[i] += a[j];
      |       ^
a.cc:60:15: error: 'j' was not declared in this scope
   60 |     a[i] += a[j];
      |               ^