Language: C++

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author Milo
 */
class Homework {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    static FastReader in = new FastReader();
    public static void main(String[] args) {
        int t = 1; //in.nextInt();
        while (t-- > 0)
            solve();
    }
 
    public static void solve() {
        
        int N = in.nextInt();
        int M = in.nextInt();
        int t;
        long sum = 0;
        
        for(int i = 0; i < M; ++i){
            t = in.nextInt();
            sum += t;
        }
        if(sum > N){
            System.out.println("-1");
        }else{
            System.out.println((N-sum));
        }
    }
 
    public static int max(int a, int b) {
        return a > b ? a : b;
    }
 
    public static int min(int a, int b) {
        return a < b ? a : b;
    }
 
    public static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, (a % b));
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.BufferedReader;
      | ^~~~~~
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.IOException;
      | ^~~~~~
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.io.InputStreamReader;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.StringTokenizer;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:12:9: error: 'BufferedReader' does not name a type
   12 |         BufferedReader br;
      |         ^~~~~~~~~~~~~~
a.cc:13:9: error: 'StringTokenizer' does not name a type
   13 |         StringTokenizer st;
      |         ^~~~~~~~~~~~~~~
a.cc:15:15: error: expected ':' before 'FastReader'
   15 |         public FastReader() {
      |               ^~~~~~~~~~~
      |               :
a.cc:19:9: error: 'String' does not name a type
   19 |         String next() {
      |         ^~~~~~
a.cc:42:9: error: 'String' does not name a type
   42 |         String nextLine() {
      |         ^~~~~~
a.cc:52:5: error: duplicate 'static' specifier
   52 |     static FastReader in = new FastReader();
      |     ^~~~~~
a.cc:52:12: error: expected ';' at end of member declaration
   52 |     static FastReader in = new FastReader();
      |            ^~~~~~~~~~
      |                      ;
a.cc:52:23: error: 'in' does not name a type; did you mean 'int'?
   52 |     static FastReader in = new FastReader();
      |                       ^~
      |                       int
a.cc:53:11: error: expected ':' before 'static'
   53 |     public static void main(String[] args) {
      |           ^~~~~~~
      |           :
a.cc:53:29: error: 'String' has not been declared
   53 |     public static void main(String[] args) {
      |                             ^~~~~~
a.cc:53:38: error: expected ',' or '...' before 'args'
   53 |     public static void main(String[] args) {
      |                                      ^~~~
a.cc:59:11: error: expected ':' before 'static'
   59 |     public static void solve() {
      |           ^~~~~~~
      |           :
a.cc:77:11: error: expected ':' before 'static'
   77 |     public static int max(int a, int b) {
      |           ^~~~~~~
      |           :
a.cc:81:11: error: expected ':' before 'static'
   81 |     public static int min(int a, int b) {
      |           ^~~~~~~
      |           :
a.cc:85:11: error: expected ':' before 'static'
   85 |     public static int gcd(int a, int b) {
      |           ^~~~~~~
      |           :
a.cc:88:2: error: expected ';' after class definition
   88 | }
      |  ^
      |  ;
a.cc: In constructor 'Homework::FastReader::FastReader()':
a.cc:16:13: error: 'br' was not declared in this scope
   16 |             br = new BufferedReader(new InputStreamReader(System.in));
      |             ^~
a.cc:16:22: error: expected type-specifier before 'BufferedReader'
   16 |             br = new BufferedReader(new InputStreamReader(System.in));
      |                      ^~~~~~~~~~~~~~
a.cc: In member function 'int Homework::FastReader::nextInt()':
a.cc:31:20: error: 'Integer' was not declared in this scope
   31 |             return Integer.parseInt(next());
      |                    ^~~~~~~
a.cc:31:37: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   31 |             return Integer.parseInt(next());
      |                                     ^~~~
      |                                     nextInt
a.cc: In member function 'long int Homework::FastReader::nextLong()':
a.cc:35:20: error: 'Long' was not declared in this scope; did you mean 'long'?
   35 |             return Long.parseLong(next());
      |                    ^~~~
      |                    long
a.cc:35:35: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   35 |             return Long.parseLong(next());
      |                                   ^~~~
      |                                   nextInt
a.cc: In member function 'double Homework::FastReader::nextDouble()':
a.cc:39:20: error: 'Double' was not declared in this scope; did you mean 'double'?
   39 |             return Double.parseDouble(next());
      |                    ^~~~~~
      |                    double
a.cc:39:39: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   39 |             return Double.parseDouble(next());
      |                                       ^~~~
      |                                       nextInt
a.cc: In static member function 'static void Homework::solve()':
a.cc:61:17: error: 'in' was not declared in this scope; did you mean 'min'?
   61 |         int N = in.nextInt();
      |                 ^~
      |                 min
a.cc:71:13: error: 'System' was not declared in this scope
   71 |             System.out.println("-1");
      |             ^~~~~~
a.cc:73:13: error: 'System' was not declared in this scope
   73 |             System.out.println((N-sum));
      |             ^~~~~~