For this Question: Given a string S. Find number of pairs of substrings which are equal.Input contains a string S containing lowercase english alphabet.

Constraints:
1 <= |S| <= 500Print number of pairs of substrings which are equal.Sample Input
ababa

Sample Ouput
7

Explanation
Pairs are:
([0-0], [2-2])
([0-0], [4-4])
([2-2], [4-4])
([1-1], [3-3])
([0-1], [2-3])
([1-2], [3-4])
([0-2], [2-4]), I have written this Solution Code: def CountOccurrences(string, substring): 
  
    count = 0
    start = 0
  
    while start < len(string): 
  
        pos = string.find(substring, start) 
  
        if pos != -1: 
            start = pos + 1
  
            count += 1
        else: 
            break
    return count 
A=input()
ans=0
n=len(A)
d=dict()
for i in range(n-1):
	for j in range(i+1,n):
		s=A[i:j]
		if(d.get(s,-1)==-1):
			c=CountOccurrences(A,s)
			ans += (c*(c-1))//2
			d[s]=1
print(ans), In this Programming Language: Python, Now tell me if this Code is compilable or not?