Language: C++

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        long[] A = new long[N];
        for(int i=0;i<N;++i)A[i]=scan.nextLong();
        Map<Long,Integer> map = new HashMap<>();
        map.put(0L,1);
        long sum=0;
        long ans = 0;
        for(int i=0;i<N;++i){
            sum+=A[i];
            if(map.containsKey(sum))ans+=map.get(sum);
            else map.put(sum, 0);
            map.put(sum, map.get(sum)+1);
        }
        System.out.println(ans);
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.HashMap;
      | ^~~~~~
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.util.Map;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:11: error: expected ':' before 'static'
    6 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
a.cc:6:29: error: 'String' has not been declared
    6 |     public static void main(String[] args){
      |                             ^~~~~~
a.cc:6:38: error: expected ',' or '...' before 'args'
    6 |     public static void main(String[] args){
      |                                      ^~~~
a.cc:23:2: error: expected ';' after class definition
   23 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:7:9: error: 'Scanner' was not declared in this scope
    7 |         Scanner scan = new Scanner(System.in);
      |         ^~~~~~~
a.cc:8:17: error: 'scan' was not declared in this scope
    8 |         int N = scan.nextInt();
      |                 ^~~~
a.cc:9:13: error: structured binding declaration cannot have type 'long int'
    9 |         long[] A = new long[N];
      |             ^~
a.cc:9:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:9:13: error: empty structured binding declaration
a.cc:9:16: error: expected initializer before 'A'
    9 |         long[] A = new long[N];
      |                ^
a.cc:10:29: error: 'A' was not declared in this scope
   10 |         for(int i=0;i<N;++i)A[i]=scan.nextLong();
      |                             ^
a.cc:11:9: error: 'Map' was not declared in this scope
   11 |         Map<Long,Integer> map = new HashMap<>();
      |         ^~~
a.cc:11:13: error: 'Long' was not declared in this scope; did you mean 'long'?
   11 |         Map<Long,Integer> map = new HashMap<>();
      |             ^~~~
      |             long
a.cc:11:18: error: 'Integer' was not declared in this scope
   11 |         Map<Long,Integer> map = new HashMap<>();
      |                  ^~~~~~~
a.cc:11:27: error: 'map' was not declared in this scope
   11 |         Map<Long,Integer> map = new HashMap<>();
      |                           ^~~
a.cc:11:37: error: 'HashMap' does not name a type
   11 |         Map<Long,Integer> map = new HashMap<>();
      |                                     ^~~~~~~
a.cc:11:45: error: expected primary-expression before '>' token
   11 |         Map<Long,Integer> map = new HashMap<>();
      |                                             ^
a.cc:11:47: error: expected primary-expression before ')' token
   11 |         Map<Long,Integer> map = new HashMap<>();
      |                                               ^
a.cc:16:18: error: 'A' was not declared in this scope
   16 |             sum+=A[i];
      |                  ^
a.cc:21:9: error: 'System' was not declared in this scope
   21 |         System.out.println(ans);
      |         ^~~~~~