Language: Java

public class Main {

    public static void main(String[] args) {
        FastScanner scanner = new FastScanner(System.in);
        int n = scanner.nextInt();
        String s = scanner.next();

        long base2 =1007;
        long mod2 = 1000000009;
        long[] hash2 = new long[n + 1];
        long[] pow2 = new long[n + 1];
        Arrays.fill(hash2, 0);
        Arrays.fill(pow2, 1);
        for(int i=0;i<n;i++) {
            hash2[i+1] = (hash2[i]+s.charAt(i)) * base2 % mod2;
            //  pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
        HashMap<Long, Integer> map = new HashMap(1 << 60);

        long max = 0;
        for(int i=0;i<n;i++) {
            for (int j=(i + 1);j<=n;j++) {
                long sub = ((hash2[j] - hash2[i] * pow2[j - i]) % mod2 + mod2) % mod2;
                //long sub = ((hash2[j] - hash2[i] * pow2[j - i]) % mod2 + mod2) % mod2;
                Integer lastIndex = map.get(sub);
                if (lastIndex == null) {
                    map.put(sub, j - 1);
                } else {
                    if ((int) lastIndex < i) {
                        max = Math.max(max, j - i);
                    }
                }
            }
        }

        PrintWriter printWriter = new PrintWriter(System.out);
        printWriter.printf("%d\n", max);
        printWriter.close();

    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

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

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

}


Compiler output:
Main.java:44: error: cannot find symbol
        private BufferedReader reader = null;
                ^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:45: error: cannot find symbol
        private StringTokenizer tokenizer = null;
                ^
  symbol:   class StringTokenizer
  location: class FastScanner
Main.java:47: error: cannot find symbol
        public FastScanner(InputStream in) {
                           ^
  symbol:   class InputStream
  location: class FastScanner
Main.java:12: error: cannot find symbol
        Arrays.fill(hash2, 0);
        ^
  symbol:   variable Arrays
  location: class Main
Main.java:13: error: cannot find symbol
        Arrays.fill(pow2, 1);
        ^
  symbol:   variable Arrays
  location: class Main
Main.java:19: error: cannot find symbol
        HashMap<Long, Integer> map = new HashMap(1 << 60);
        ^
  symbol:   class HashMap
  location: class Main
Main.java:19: error: cannot find symbol
        HashMap<Long, Integer> map = new HashMap(1 << 60);
                                         ^
  symbol:   class HashMap
  location: class Main
Main.java:37: error: cannot find symbol
        PrintWriter printWriter = new PrintWriter(System.out);
        ^
  symbol:   class PrintWriter
  location: class Main
Main.java:37: error: cannot find symbol
        PrintWriter printWriter = new PrintWriter(System.out);
                                      ^
  symbol:   class PrintWriter
  location: class Main
Main.java:48: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(in));
                         ^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:48: error: cannot find symbol
            reader = new BufferedReader(new InputStreamReader(in));
                                            ^
  symbol:   class InputStreamReader
  location: class FastScanner
Main.java:55: error: cannot find symbol
                    tokenizer = new StringTokenizer(reader.readLine());
                                    ^
  symbol:   class StringTokenizer
  location: class FastScanner
Main.java:56: error: cannot find symbol
                } catch (IOException e) {
                         ^
  symbol:   class IOException
  location: class FastScanner
Main.java:67: error: cannot find symbol
                } catch (IOException e) {
                         ^
  symbol:   class IOException
  location: class FastScanner
14 errors