Language: C++

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ga = sc.nextInt();
        int sa = sc.nextInt();
        int ba = sc.nextInt();
        int gb = sc.nextInt();
        int sb = sc.nextInt();
        int bb = sc.nextInt();

        long[][] dp_1 = new long[3+1][N+1];
        int[] w_1 = {ga, sa, ba};
        int[] v_1 = {gb-ga, sb-sa, bb-ba};
        for (int j=0;j<N+1;j++) {
            dp_1[0][j] = N-j;
        }
        for (int i=0;i<3;i++) {
            for (int j=0;j<N+1;j++) {
                dp_1[i+1][j] = dp_1[i][j];
            }
            for (int j=0;j<N+1;j++) {
                if (0<=j-w_1[i]) {
                    dp_1[i+1][j] = Math.max(dp_1[i+1][j], dp_1[i+1][j-w_1[i]]+v_1[i]);
                }
            }
        }

        int N_max = (int)dp_1[3][N];
        long[][] dp_2 = new long[3+1][N_max+1];
        int[] w_2 = {gb, sb, bb};
        int[] v_2 = {ga-gb, sa-sb, ba-bb};
        for (int j=0;j<N_max+1;j++) {
            dp_2[0][j] = N_max-j;
        }
        for (int i=0;i<3;i++) {
            for (int j=0;j<N_max+1;j++) {
                dp_2[i+1][j] = dp_2[i][j];
            }
            for (int j=0;j<N_max+1;j++) {
                if (0<=j-w_2[i]) {
                    dp_2[i+1][j] = Math.max(dp_2[i+1][j], dp_2[i+1][j-w_2[i]]+v_2[i]);
                }
            }
        }
        System.out.println(dp_2[3][N_max]);
    }
}

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:4:11: error: expected ':' before 'static'
    4 |     public static void main(String[] args) {
      |           ^~~~~~~
      |           :
a.cc:4:29: error: 'String' has not been declared
    4 |     public static void main(String[] args) {
      |                             ^~~~~~
a.cc:4:38: error: expected ',' or '...' before 'args'
    4 |     public static void main(String[] args) {
      |                                      ^~~~
a.cc:50:2: error: expected ';' after class definition
   50 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:5:9: error: 'Scanner' was not declared in this scope
    5 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:6:17: error: 'sc' was not declared in this scope
    6 |         int N = sc.nextInt();
      |                 ^~
a.cc:14:13: error: structured binding declaration cannot have type 'long int'
   14 |         long[][] dp_1 = new long[3+1][N+1];
      |             ^~
a.cc:14:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:14:13: error: empty structured binding declaration
a.cc:14:15: error: expected initializer before '[' token
   14 |         long[][] dp_1 = new long[3+1][N+1];
      |               ^
a.cc:15:12: error: structured binding declaration cannot have type 'int'
   15 |         int[] w_1 = {ga, sa, ba};
      |            ^~
a.cc:15:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:15:12: error: empty structured binding declaration
a.cc:15:15: error: expected initializer before 'w_1'
   15 |         int[] w_1 = {ga, sa, ba};
      |               ^~~
a.cc:16:12: error: structured binding declaration cannot have type 'int'
   16 |         int[] v_1 = {gb-ga, sb-sa, bb-ba};
      |            ^~
a.cc:16:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:16:12: error: empty structured binding declaration
a.cc:16:15: error: expected initializer before 'v_1'
   16 |         int[] v_1 = {gb-ga, sb-sa, bb-ba};
      |               ^~~
a.cc:18:13: error: 'dp_1' was not declared in this scope
   18 |             dp_1[0][j] = N-j;
      |             ^~~~
a.cc:22:17: error: 'dp_1' was not declared in this scope
   22 |                 dp_1[i+1][j] = dp_1[i][j];
      |                 ^~~~
a.cc:25:26: error: 'w_1' was not declared in this scope
   25 |                 if (0<=j-w_1[i]) {
      |                          ^~~
a.cc:26:21: error: 'dp_1' was not declared in this scope
   26 |                     dp_1[i+1][j] = Math.max(dp_1[i+1][j], dp_1[i+1][j-w_1[i]]+v_1[i]);
      |                     ^~~~
a.cc:26:36: error: 'Math' was not declared in this scope
   26 |                     dp_1[i+1][j] = Math.max(dp_1[i+1][j], dp_1[i+1][j-w_1[i]]+v_1[i]);
      |                                    ^~~~
a.cc:26:79: error: 'v_1' was not declared in this scope
   26 |                     dp_1[i+1][j] = Math.max(dp_1[i+1][j], dp_1[i+1][j-w_1[i]]+v_1[i]);
      |                                                                               ^~~
a.cc:31:26: error: 'dp_1' was not declared in this scope
   31 |         int N_max = (int)dp_1[3][N];
      |                          ^~~~
a.cc:32:13: error: structured binding declaration cannot have type 'long int'
   32 |         long[][] dp_2 = new long[3+1][N_max+1];
      |             ^~
a.cc:32:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:32:13: error: empty structured binding declaration
a.cc:32:15: error: expected initializer before '[' token
   32 |         long[][] dp_2 = new long[3+1][N_max+1];
      |               ^
a.cc:33:12: error: structured binding declaration cannot have type 'int'
   33 |         int[] w_2 = {gb, sb, bb};
      |            ^~
a.cc:33:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:33:12: error: empty structured binding declaration
a.cc:33:15: error: expected initializer before 'w_2'
   33 |         int[] w_2 = {gb, sb, bb};
      |               ^~~
a.cc:34:12: error: structured binding declaration cannot have type 'int'
   34 |         int[] v_2 = {ga-gb, sa-sb, ba-bb};
      |            ^~
a.cc:34:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:34:12: error: empty structured binding declaration
a.cc:34:15: error: expected initializer before 'v_2'
   34 |         int[] v_2 = {ga-gb, sa-sb, ba-bb};
      |               ^~~
a.cc:36:13: error: 'dp_2' was not declared in this scope
   36 |             dp_2[0][j] = N_max-j;
      |             ^~~~
a.cc:40:17: error: 'dp_2' was not declared in this scope
   40 |                 dp_2[i+1][j] = dp_2[i][j];
      |                 ^~~~
a.cc:43:26: error: 'w_2' was not declared in this scope
   43 |                 if (0<=j-w_2[i]) {
      |                          ^~~
a.cc:44:21: error: 'dp_2' was not declared in this scope
   44 |                     dp_2[i+1][j] = Math.max(dp_2[i+1][j], dp_2[i+1][j-w_2[i]]+v_2[i]);
      |                     ^~~~
a.cc:44:36: error: 'Math' was not declared in this scope
   44 |                     dp_2[i+1][j] = Math.max(dp_2[i+1][j], dp_2[i+1][j-w_2[i]]+v_2[i]);
      |                                    ^~~~
a.cc:44:79: error: 'v_2' was not declared in this scope
   44 |                     dp_2[i+1][j] = Math.max(dp_2[i+1][j], dp_2[i+1][j-w_2[i]]+v_2[i]);
      |                                                                               ^~~
a.cc:48:9: error: 'System' was not declared in this scope
   48 |         System.out.println(dp_2[3][N_max]);
      |         ^~~~~~
a.cc:48:28: error: 'dp_2' was not declared in this scope
   48 |         System.out.println(dp_2[3][N_max]);
      |                            ^~~~