human
Find sum of xor of all unordered triplets of the array | Iterative Function to calculate ( x ^ y ) % p in O ( log y ).
Initialize result.
Update x if it is more than or equal to p.
If y is odd , multiply x with result.
y must be even now y = y >> 1 y = y / 2.
Returns n ^ ( - 1 ) mod p.
Returns nCr % p using Fermat 's little theorem..
Base case.
Fill factorial array so that we can find all factorial of r , n and n - r.
Function returns sum of xor of all unordered triplets of the array.
Iterating over the bits.
Number of elements whith k 'th bit  1 and 0 respectively.
Checking if k 'th bit is 1.
Adding this bit 's part to the answer.
Drivers code"
Solution in Python:

Write me a code to find sum of xor of all unordered triplets of the array and the other steps required?
assistant
#Here is code to find sum of xor of all unordered triplets of the array and the other steps required.
 def power ( x , y , p ) :
	res = 1
	x = x % p
	while ( y > 0 ) :
		if ( y & 1 ) :
			res = ( res * x ) % p
		x = ( x * x ) % p
	return res
def modInverse ( n , p ) :
	return power ( n , p - 2 , p )
def nCrModPFermat ( n , r , p ) :
	if ( r == 0 ) :
		return 1
	if ( n < r ) :
		return 0
	fac = [ 0 ] * ( n + 1 )
	fac [ 0 ] = 1
	for i in range ( 1 , n + 1 ) :
		fac [ i ] = fac [ i - 1 ] * i % p
	return ( fac [ n ] * modInverse ( fac [ r ] , p ) % p * modInverse ( fac [ n - r ] , p ) % p ) % p
def SumOfXor ( a , n ) :
	mod = 10037
	answer = 0
	for k in range ( 32 ) :
		x = 0
		y = 0
		for i in range ( n ) :
			if ( a [ i ] & ( 1 << k ) ) :
				x += 1
			else :
				y += 1
		answer += ( ( 1 << k ) % mod * ( nCrModPFermat ( x , 3 , mod ) + x * nCrModPFermat ( y , 2 , mod ) ) % mod ) % mod
	return answer
if __name__ == ' _ _ main _ _ ' :
	n = 5
	A = [ 3 , 5 , 2 , 18 , 7 ]
	print ( SumOfXor ( A , n ) )