Language: Java

import java.util.Scanner;

public class main
{
    static int CountPS(char str[], int n)
    {
        int dp[][] = new int[n][n];
      
        boolean P[][] = new boolean[n][n];
 
        for (int i= 0; i< n; i++)
            P[i][i] = true;
      
        for (int i=0; i<n-1; i++)
        {
            if (str[i] == str[i+1])
            {
                P[i][i+1] = true;
                dp[i][i+1] = 1 ;
            }
        }
        for (int gap=2 ; gap<n; gap++)
        {
            for (int i=0; i<n-gap; i++)
            {
                int j = gap + i;
                if (str[i] == str[j] && P[i+1][j-1] )
                    P[i][j] = true;
                if (P[i][j] == true)
                    dp[i][j] = dp[i][j-1] + dp[i+1][j] + 1 - dp[i+1][j-1];
                else
                    dp[i][j] = dp[i][j-1] + dp[i+1][j] - dp[i+1][j-1];
            }
        }
        return dp[0][n-1];
    }
    public static void main(String[] args)
    {
        String str;
        Scanner sc = new Scanner();
        str = sc.next();
       int n = str.length();
        System.out.println(n*(n-1)/2 + 1 + CountPS(str.toCharArray(), str.length()));
    }
}

Compiler output:
Main.java:3: error: class main is public, should be declared in a file named main.java
public class main
       ^
Main.java:40: error: no suitable constructor found for Scanner(no arguments)
        Scanner sc = new Scanner();
                     ^
    constructor Scanner.Scanner(Readable,Pattern) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Readable) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,CharsetDecoder) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel,Charset) is not applicable
      (actual and formal argument lists differ in length)
2 errors