For this Question: Aniket considers a string happy if at least one pair of characters exist at positions i and j (i < j) such that character at position i is lexographically smaller than character at position j. 
For example strings "aab", "aba", "zxy" are happy, while strings "aaa", "zyx", "ccb" are not happy.

You are given N strings, you need to find the number of pairs (k, l) such that s<sub>k</sub>+s<sub>l</sub> is a happy string. (Consider all N*N pairs)The first line of the input contains a single integer N.
Next N lines contain N strings consisting of only lowercase letters of the english alphabet.

Constraints
1 <= N <= 100000
1 <= length of string <= 5Output the number of pairs (k, l) such that the concatenation of strings s<sub>k</sub> and s<sub>l</sub> is happy.Sample Input
5
a
a
b
d
c

Sample Output
9

The happy strings are the concatenation of the following pairs (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (5, 4)

Sample Input
3
cbcb
fffee
d

Sample Output
7

Explanation: Concatenation of all pairs except (2, 3) and (3, 3) form happy strings., I have written this Solution Code: def ceilSearch(arr, low, high, x): 
  
    if x < arr[low]: 
        return low  
  
    if x >= arr[high]: 
        return -1  
   
    mid = (low + high)//2;  # low + (high - low)/2 */ 
   
  
    if arr[mid] <= x:  
        return ceilSearch(arr, mid+1, high, x) 
   
    else: 
        return ceilSearch(arr, low, mid, x) 
def isgood(s):
	flag=False
	for i in range(1,len(s)):
		if(s[i]<=s[i-1]):
			pass
		else:
			flag=True
	return flag
def minmax(s):
	mn=124
	mx=96
	for x in s:
		mn=min(mn,ord(x))
		mx=max(mx,ord(x))
	return [mn,mx]
n=int(input())
A=[]
B=[]
for i in range(n):
	st=str(input())
	st= st.replace('\r', '')
	if(isgood(st)):
		A.append(st)
	else:
		B.append(st)
la=len(A)
lb=len(B)
ans =la*la + 2*la*lb 
Cmin=[]
Cmax=[]
for i in range(lb):
	arr=minmax(B[i])
	Cmin.append(arr[0])
	Cmax.append(arr[1])

Cmax.sort()
for i in range(lb):
	v=Cmin[i]
	indx=ceilSearch(Cmax,0,lb-1,v)
	#print("infv",indx)
	if indx != -1:
		ans += lb-indx;

print(ans), In this Programming Language: Python, Now tell me if this Code is compilable or not?