For this Question: Given a string S of uppercase English alphabets. The task is to count the occurrences of all the prefixes of the given string S.The first line of input contains the string S.

Constraints:
1<= |S| <= 500Print N space separated integers where the i<sup>th</sup> integer is the number of occurrence of prefix [0. i] in the string S. Here, N is the size of string.Sample Input 1:
AAAA

Output 
4 3 2 1

Explanation:
A occurs 4 times 
AA occurs 3 times. 
AAA occurs 2 times. 
AAAA occurs 1 times

Sample Input 2:
ABACABA

Output
4 2 2 1 1 1 1

Explanation
A occurs 4 times 
AB occurs 2 times 
ABA occurs 2 times 
ABAC occurs 1 times 
ABACA occurs 1 times 
ABACAB occurs 1 times 
ABACABA occurs 1 times, I have written this Solution Code: import java.io.*;
import java.util.*;

class Main
{
    static int[] prefix_function(String s)
    {
      int []LPS = new int[s.length()];
      LPS[0] = 0;
      for (int i = 1;i < s.length(); i++)
      {
        int j = LPS[i - 1];
        while (j > 0 && s.charAt(i) != s.charAt(j)) j = LPS[j - 1];
        if (s.charAt(i) == s.charAt(j))LPS[i] = j + 1;
        else LPS[i] = 0;
      }
      return LPS;
    }
    static void count_occurrence(String s)
    {
      int n = s.length();
      int[] LPS = prefix_function(s);
      int []occ = new int[n + 1];
      for (int i = 0; i < n; i++) occ[LPS[i]]++;
      for (int i = n - 1; i > 0; i--) occ[LPS[i - 1]] += occ[i];
      for (int i = 0; i <= n; i++) occ[i]++;
      for (int i = 1;i <= s.length(); i++) System.out.print(occ[i] +" ");
    }
   
    public static void main(String args[]) throws IOException
    {
    	BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
        String line = br.readLine();
    	count_occurrence(line);
    }
}

, In this Programming Language: Java, Now tell me if this Code is compilable or not?