Short sol
Complexity\n- Time complexity: O(q\log^2 m) \n- Space complexity: O(q)\n\n# Explanation\n- Read this explanation: https://leetcode.com/problems/find-products-of
# Complexity\n- Time complexity: $$O(q\\log^2 m)$$ \n- Space complexity: $$O(q)$$\n\n# Explanation\n- Read this explanation: https://leetcode.com/problems/find-products-of-elements-of-big-array/solutions/5143875/python-3-bisearch-count-1-s-and-accumulate-0-s/\n\n# Code\n```py\nclass Solution:\n    def findProductsOfElements(self, queries: List[List[int]]) -> List[int]:\n        def cnt(x, k):\n            w = 1<<k+1\n            return (x-x%w)//2 + max(x%w-w//2, 0)\n        def count(x):\n            return sum(cnt(x, k) for k in range(x.bit_length()))\n        def sol(n):\n            x = bisect_right(range(0, n+5), n, key=count)-1\n            res = sum(k*cnt(x, k) for k in range(x.bit_length()))\n            for _ in range(n-count(x)):\n                res += (x&-x).bit_length()-1\n                x &= x-1\n            return res\n        return [pow(2, sol(r+1)-sol(l), mod) for l, r, mod in queries]\n```
['Binary Search', 'Python3']