human
Count of pairs in an array whose sum is a perfect square | Function to return an ArrayList containing all the perfect squares upto n.
while current perfect square is less than or equal to n.
Function to print the sum of maximum two elements from the array.
Function to return the count of numbers that when added with n give a perfect square.
temp > n is checked so that pairs ( x , y ) and ( y , x ) don 't get counted twice .
Function to count the pairs whose sum is a perfect square.
Sum of the maximum two elements from the array.
List of perfect squares upto max.
Contains all the array elements.
Add count of the elements that when added with arr [ i ] give a perfect square.
Driver code"
Solution in Python:

What is a code to count of pairs in an array whose sum is a perfect square and the other steps required?
assistant
#Here is code to count of pairs in an array whose sum is a perfect square and the other steps required.
 def getPerfectSquares ( n ) :
	perfectSquares = [ ] ;
	current = 1 ;
	i = 1 ;
	while ( current <= n ) :
		perfectSquares . append ( current ) ;
		i += 1 ;
		current = int ( pow ( i , 2 ) ) ;
	return perfectSquares ;
def maxPairSum ( arr ) :
	n = len ( arr ) ;
	max = 0 ;
	secondMax = 0 ;
	if ( arr [ 0 ] > arr [ 1 ] ) :
		max = arr [ 0 ] ;
		secondMax = arr [ 1 ] ;
	else :
		max = arr [ 1 ] ;
		secondMax = arr [ 0 ] ;
	for i in range ( 2 , n ) :
		if ( arr [ i ] > max ) :
			secondMax = max ;
			max = arr [ i ] ;
		elif ( arr [ i ] > secondMax ) :
			secondMax = arr [ i ] ;
	return ( max + secondMax ) ;
def countPairsWith ( n , perfectSquares , nums ) :
	count = 0 ;
	for i in range ( len ( perfectSquares ) ) :
		temp = perfectSquares [ i ] - n ;
		if ( temp > n and ( temp in nums ) ) :
			count += 1 ;
	return count ;
def countPairs ( arr ) :
	n = len ( arr ) ;
	max = maxPairSum ( arr ) ;
	perfectSquares = getPerfectSquares ( max ) ;
	nums = [ ] ;
	for i in range ( n ) :
		nums . append ( arr [ i ] ) ;
	count = 0 ;
	for i in range ( n ) :
		count += countPairsWith ( arr [ i ] , perfectSquares , nums ) ;
	return count ;
arr = [ 2 , 3 , 6 , 9 , 10 , 20 ] ;
print ( countPairs ( arr ) ) ;