Number of Excellent Pairs

Given an array of integers and a threshold k, count the number of ordered pairs (i, j) where popcount(nums[i] & nums[j]) + popcount(nums[i] | nums[j]) >= k.

Examples
Input: [[1,2,3,1],3]
Output: 5
Hints

Number of Excellent Pairs

Given an array of integers and a threshold k, count the number of ordered pairs (i, j) where popcount(nums[i] & nums[j]) + popcount(nums[i] | nums[j]) >= k.