Simple Java Solution
\nclass Solution {\n    public long countExcellentPairs(int[] nums, int k) {\n        long[] arr = new long[33];\n        Set<Integer> visited = new HashSet();\
```\nclass Solution {\n    public long countExcellentPairs(int[] nums, int k) {\n        long[] arr = new long[33];\n        Set<Integer> visited = new HashSet();\n        for(int i : nums) {\n            int count = 0;\n            if(visited.contains(i)) {\n                continue;\n            }\n            \n            visited.add(i);\n            while(i > 0) {\n                if((i&1) == 1) {\n                    count++;\n                }\n                i >>= 1;\n            }\n            arr[count]++;\n        }\n        \n        long res = 0;\n        for(int i=1; i<arr.length; i++) {\n            int j = Math.max(k-i,1);\n            for(; j<arr.length; j++) {\n                res += arr[i]*arr[j];\n            }\n        }\n        \n        return res;\n    }\n}\n```
['Java']