Language: C++

import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
 
        for(int i = 0; i<n; i++) a[i] = sc.nextInt();
        for(int i = 0; i<n; i++) b[i] = sc.nextInt();
        for(int i = 0; i<n; i++) c[i] = sc.nextInt();
 
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
 
//        for(int ca:a) System.out.print(ca + " ");
//        System.out.println();
//        for(int cb:b) System.out.print(cb+ " ");
//        System.out.println();
//        for(int cc:c) System.out.print(cc+ " ");
//        System.out.println();
 
        long ans = 0;
        for(int i = 0; i<n; i++) {
            int x = countCandy(a, b[i], 1);
            int y = countCandy(c, b[i], 1);
            //System.out.println(x +" "+ y);
            ans += (long)x*(long)y;
        }
        System.out.println(ans);
 
    }
    public static int countCandy(int[] sortedA, int num, int a) {
        int head = 0;
        int end = sortedA.length-1;
        int middle = (head+end)/2;
 
        while(head<=end) {
            if(sortedA[middle]==num) {
                if(a==1) return middle;
                else return sortedA.length - middle-1;
            }
            else if(sortedA[middle]<num) {
                head = middle+1;
                middle = (head+end)/2;
            }else {
                end = middle-1;
                middle = (head+end)/2;
            }
        }
        if(a==1) return end+1;
        else return sortedA.length - head;
 
    }
}

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:3:11: error: expected ':' before 'static'
    3 |     public static void main(String[] args) {
      |           ^~~~~~~
      |           :
a.cc:3:29: error: 'String' has not been declared
    3 |     public static void main(String[] args) {
      |                             ^~~~~~
a.cc:3:38: error: expected ',' or '...' before 'args'
    3 |     public static void main(String[] args) {
      |                                      ^~~~
a.cc:35:11: error: expected ':' before 'static'
   35 |     public static int countCandy(int[] sortedA, int num, int a) {
      |           ^~~~~~~
      |           :
a.cc:35:40: error: expected ',' or '...' before 'sortedA'
   35 |     public static int countCandy(int[] sortedA, int num, int a) {
      |                                        ^~~~~~~
a.cc:57:2: error: expected ';' after class definition
   57 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:4:9: error: 'Scanner' was not declared in this scope
    4 |         Scanner sc = new Scanner(System.in);
      |         ^~~~~~~
a.cc:5:17: error: 'sc' was not declared in this scope
    5 |         int n = sc.nextInt();
      |                 ^~
a.cc:6:12: error: structured binding declaration cannot have type 'int'
    6 |         int[] a = new int[n];
      |            ^~
a.cc:6:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:6:12: error: empty structured binding declaration
a.cc:6:15: error: expected initializer before 'a'
    6 |         int[] a = new int[n];
      |               ^
a.cc:7:12: error: structured binding declaration cannot have type 'int'
    7 |         int[] b = new int[n];
      |            ^~
a.cc:7:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:7:12: error: empty structured binding declaration
a.cc:7:15: error: expected initializer before 'b'
    7 |         int[] b = new int[n];
      |               ^
a.cc:8:12: error: structured binding declaration cannot have type 'int'
    8 |         int[] c = new int[n];
      |            ^~
a.cc:8:12: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:8:12: error: empty structured binding declaration
a.cc:8:15: error: expected initializer before 'c'
    8 |         int[] c = new int[n];
      |               ^
a.cc:10:34: error: 'a' was not declared in this scope
   10 |         for(int i = 0; i<n; i++) a[i] = sc.nextInt();
      |                                  ^
a.cc:11:34: error: 'b' was not declared in this scope
   11 |         for(int i = 0; i<n; i++) b[i] = sc.nextInt();
      |                                  ^
a.cc:12:34: error: 'c' was not declared in this scope
   12 |         for(int i = 0; i<n; i++) c[i] = sc.nextInt();
      |                                  ^
a.cc:14:9: error: 'Arrays' was not declared in this scope
   14 |         Arrays.sort(a);
      |         ^~~~~~
a.cc:14:21: error: 'a' was not declared in this scope
   14 |         Arrays.sort(a);
      |                     ^
a.cc:15:21: error: 'b' was not declared in this scope
   15 |         Arrays.sort(b);
      |                     ^
a.cc:16:21: error: 'c' was not declared in this scope
   16 |         Arrays.sort(c);
      |                     ^
a.cc:32:9: error: 'System' was not declared in this scope
   32 |         System.out.println(ans);
      |         ^~~~~~
a.cc: In static member function 'static int Main::countCandy(int*)':
a.cc:37:19: error: 'sortedA' was not declared in this scope
   37 |         int end = sortedA.length-1;
      |                   ^~~~~~~
a.cc:41:33: error: 'num' was not declared in this scope; did you mean 'enum'?
   41 |             if(sortedA[middle]==num) {
      |                                 ^~~
      |                                 enum
a.cc:42:20: error: 'a' was not declared in this scope
   42 |                 if(a==1) return middle;
      |                    ^
a.cc:53:12: error: 'a' was not declared in this scope
   53 |         if(a==1) return end+1;
      |            ^