human
Count distinct pairs with given sum | Function to count distinct pairs in array whose sum equal to K.
Stores count of distinct pairs whose sum equal to K.
Store frequency of each distinct element of the array.
Update frequency of arr [ i ].
Traverse the map.
Stores key value of the map.
If i is the half of K.
If frequency of i greater than 1.
Update cntPairs.
Update cntPairs.
Driver Code"
Solution in Python:

Write me a code to count distinct pairs with given sum and the other steps required?
assistant
#Here is code to count distinct pairs with given sum and the other steps required.
 def cntDisPairs ( arr , N , K ) :
	cntPairs = 0
	cntFre = { }
	for i in arr :
		if i in cntFre :
			cntFre [ i ] += 1
		else :
			cntFre [ i ] = 1
	for key , value in cntFre . items ( ) :
		i = key
		if ( 2 * i == K ) :
			if ( cntFre [ i ] > 1 ) :
				cntPairs += 2
		else :
			if ( cntFre [ K - i ] ) :
				cntPairs += 1
	cntPairs = cntPairs / 2
	return cntPairs
arr = [ 5 , 6 , 5 , 7 , 7 , 8 ]
N = len ( arr )
K = 13
print ( int ( cntDisPairs ( arr , N , K ) ) )