Python | Runtime 100%, Memory 100%
```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        counter = {}\n        for i in range(len(nums)):\n            if nums[i
```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        counter = {}\n        for i in range(len(nums)):\n            if nums[i] in counter:\n                counter[nums[i]].append(i)\n            else:\n                counter[nums[i]]= [i]\n\n        ans = 0\n        for key, val in counter.items():\n            length = len(val)\n            for i in range(length-1):\n                for j in range(i+1, length):\n                    if val[i] * val[j] % k == 0:\n                        ans += 1\n        return ans\n
['Python']