parameters: (self, nums, low, high)
return_statement: return count(nums, high+1)-count(nums, low)
docstring: :type nums: List[int]
          :type low: int
          :type high: int
          :rtype: int
docstring_summary: :type nums: List[int]
          :type low: int
          :type high: int
          :rtype: int
docstring_tokens: : type nums : List [ int ] : type low : int : type high : int : rtype : int
function: def countPairs(self, nums, low, high):
          """
          :type nums: List[int]
          :type low: int
          :type high: int
          :rtype: int
          """
          def count(nums, x):
              result = 0
              dp = collections.Counter(nums)
              while x:
                  if x&1:
                      result += sum(dp[(x^1)^k]*dp[k] for k in dp.iterkeys())//2  # current limit is xxxxx1*****, count xor pair with xxxxx0***** pattern
                  dp = collections.Counter({k>>1: dp[k]+dp[k^1] for k in dp.iterkeys()})
                  x >>= 1
              return result
      
          return count(nums, high+1)-count(nums, low)
function_tokens: def countPairs ( self , nums , low , high ) : def count ( nums , x ) : result = 0 dp = collections . Counter ( nums ) while x : if x & 1 : result += sum ( dp [ ( x ^ 1 ) ^ k ] * dp [ k ] for k in dp . iterkeys ( ) ) // 2 # current limit is xxxxx1*****, count xor pair with xxxxx0***** pattern dp = collections . Counter ( { k >> 1 : dp [ k ] + dp [ k ^ 1 ] for k in dp . iterkeys ( ) } ) x >>= 1 return result return count ( nums , high + 1 ) - count ( nums , low )