Language: C

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EActiveInfants solver = new EActiveInfants();
        solver.solve(1, in, out);
        out.close();
    }

    static class EActiveInfants {
        pair[] arr;
        int n;
        long[][] memo;

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            n = sc.nextInt();
            arr = new pair[n];
            for (int i = 0; i < n; i++)
                arr[i] = new pair(sc.nextInt(), i);
            Arrays.sort(arr, (a, b) -> b.val - a.val);
            memo = new long[n][n];
            for (long[] x : memo)
                Arrays.fill(x, -1);
            pw.println(dp(0, n - 1));
        }

        private long dp(int l, int r) {
            if (l > r)
                return 0;
            if (memo[l][r] != -1)
                return memo[l][r];
            long takeL = arr[l + n - 1 - r].val * Math.abs(arr[l + n - 1 - r].idx - l) + dp(l + 1, r);
            long takeR = arr[l + n - 1 - r].val * Math.abs(arr[l + n - 1 - r].idx - r) + dp(l, r - 1);
            return memo[l][r] = Math.max(takeL, takeR);
        }

        class pair {
            int val;
            int idx;

            public pair(int val, int idx) {
                this.val = val;
                this.idx = idx;
            }

            public String toString() {
                return val + " " + idx;
            }

        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Compiler output:
main.c:1:1: error: unknown type name 'import'
    1 | import java.io.OutputStream;
      | ^~~~~~
main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    1 | import java.io.OutputStream;
      |            ^
main.c:2:1: error: unknown type name 'import'
    2 | import java.io.IOException;
      | ^~~~~~
main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    2 | import java.io.IOException;
      |            ^
main.c:3:1: error: unknown type name 'import'
    3 | import java.io.InputStream;
      | ^~~~~~
main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    3 | import java.io.InputStream;
      |            ^
main.c:4:1: error: unknown type name 'import'
    4 | import java.io.PrintWriter;
      | ^~~~~~
main.c:4:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    4 | import java.io.PrintWriter;
      |            ^
main.c:5:1: error: unknown type name 'import'
    5 | import java.util.Arrays;
      | ^~~~~~
main.c:5:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    5 | import java.util.Arrays;
      |            ^
main.c:6:1: error: unknown type name 'import'
    6 | import java.io.IOException;
      | ^~~~~~
main.c:6:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    6 | import java.io.IOException;
      |            ^
main.c:7:1: error: unknown type name 'import'
    7 | import java.io.InputStreamReader;
      | ^~~~~~
main.c:7:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    7 | import java.io.InputStreamReader;
      |            ^
main.c:8:1: error: unknown type name 'import'
    8 | import java.util.StringTokenizer;
      | ^~~~~~
main.c:8:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    8 | import java.util.StringTokenizer;
      |            ^
main.c:9:1: error: unknown type name 'import'
    9 | import java.io.BufferedReader;
      | ^~~~~~
main.c:9:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
    9 | import java.io.BufferedReader;
      |            ^
main.c:10:1: error: unknown type name 'import'
   10 | import java.io.FileReader;
      | ^~~~~~
main.c:10:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
   10 | import java.io.FileReader;
      |            ^
main.c:11:1: error: unknown type name 'import'
   11 | import java.io.InputStream;
      | ^~~~~~
main.c:11:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
   11 | import java.io.InputStream;
      |            ^
main.c:17:1: error: unknown type name 'public'
   17 | public class Main {
      | ^~~~~~
main.c:17:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
   17 | public class Main {
      |              ^~~~