Language: Java

import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.StringTokenizer;

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

    static class TaskE {
        BitSet currentGroup;
        BitSet currentOtherGroup;
        int maxMinSize = -1;
        ArrayList<Integer> options;
        int n;
        BitSet[] edges;
        long start;
        PrintWriter out;
        int p = 0;
        int pMax = 10;

        boolean stateIsValid() {
            BitSet COG = new BitSet(n);
            COG.or(currentOtherGroup);
            int card = COG.cardinality();
            for (int i = 0; i < n; i++) {
                if (COG.get(i)) {
                    COG.and(edges[i]);
                    if (COG.cardinality() != card) return false;
                    COG.or(currentOtherGroup);
                }
            }
            return true;
        }

        void findOne() {
            if (stateIsValid()) {
                int card = currentGroup.cardinality();
                maxMinSize = Math.max(maxMinSize, Math.min(card, n - card));
                p++;
                if (pMax < p) return;
            }
            for (int i1 = 0; i1 < n && p < pMax && checkTime(); i1++) {
                int i = options.get(i1);
                if (currentOtherGroup.get(i)) {
                    for (int j1 = i1 + 1; j1 < n && p < pMax; j1++) {
                        int j = options.get(j1);
                        if (currentOtherGroup.get(j)) {
                            if (!edges[i].get(j)) {
                                BitSet x = (BitSet) edges[i].clone();
                                x.and(currentGroup);
                                boolean r1 = tryToContinue(i, x);
                                x = (BitSet) edges[j].clone();
                                x.and(currentGroup);
                                r1 |= tryToContinue(j, x);
                                if(!r1) return;
                            }
                        }
                    }
                }
            }
        }

        boolean tryToContinue(int j, BitSet x) {
            if (x.cardinality() == currentGroup.cardinality()) {
                currentOtherGroup.flip(j);
                currentGroup.flip(j);
                findOne();
                currentOtherGroup.flip(j);
                currentGroup.flip(j);
                return true;
            }
            return false;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            start = System.nanoTime();
            n = in.NextInt();
            int m = in.NextInt();
            edges = new BitSet[n];
            for (int i = 0; i < n; i++) {
                edges[i] = new BitSet(n);
                edges[i].set(i, true);
            }
            for (int i = 0; i < m; i++) {
                int u = in.NextInt() - 1;
                int v = in.NextInt() - 1;
                edges[u].set(v, true);
                edges[v].set(u, true);
            }

            currentGroup = new BitSet(n);
            currentOtherGroup = new BitSet(n);
            currentOtherGroup.set(0, n, true);
            options = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                options.add(i);
            }
            this.out = out;
            while (checkTime()) {
                Collections.shuffle(options);
                p = 0;
                findOne();
            }
            if (maxMinSize == -1) {
                out.println(-1);
            } else {
                out.println(maxMinSize * (maxMinSize - 1) / 2 + (n - maxMinSize) * (n - maxMinSize - 1) / 2);
            }
        }

        boolean checkTime() {
            return (System.nanoTime() - start < 1_800_000_000L);
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine(), " \t\n\r\f,");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Compiler output:
Main.java:31: error: cannot find symbol
        PrintWriter out;
        ^
  symbol:   class PrintWriter
  location: class TaskE
Main.java:89: error: cannot find symbol
        public void solve(int testNumber, InputReader in, PrintWriter out) {
                                                          ^
  symbol:   class PrintWriter
  location: class TaskE
Main.java:132: error: cannot find symbol
        BufferedReader reader;
        ^
  symbol:   class BufferedReader
  location: class InputReader
Main.java:135: error: cannot find symbol
        public InputReader(InputStream stream) {
                           ^
  symbol:   class InputStream
  location: class InputReader
Main.java:14: error: cannot find symbol
        InputStream inputStream = System.in;
        ^
  symbol:   class InputStream
  location: class Main
Main.java:15: error: cannot find symbol
        OutputStream outputStream = System.out;
        ^
  symbol:   class OutputStream
  location: class Main
Main.java:17: error: cannot find symbol
        PrintWriter out = new PrintWriter(outputStream);
        ^
  symbol:   class PrintWriter
  location: class Main
Main.java:17: error: cannot find symbol
        PrintWriter out = new PrintWriter(outputStream);
                              ^
  symbol:   class PrintWriter
  location: class Main
Main.java:136: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
                         ^
  symbol:   class BufferedReader
  location: class InputReader
Main.java:136: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
                                            ^
  symbol:   class InputStreamReader
  location: class InputReader
Main.java:144: error: cannot find symbol
                } catch (IOException e) {
                         ^
  symbol:   class IOException
  location: class InputReader
11 errors