def popcount(n: int) -> int:
    """Popcount.

    Args:
        n (int): an 64-bit signed or unsigned integer.

    Returns:
        int: popcount := count of active binary bits.

    Complexity:
        time: O(1)
        space: O(1)

    Examples:
        >>> popcount(0b1010)
        2
        >>> popcount(0b1100100)
        3
        >>> popcount(-1)
        64
    """
    n -= (n >> 1) & 0x5555555555555555
    n = (n & 0x3333333333333333) + ((n >> 2) & 0x3333333333333333)
    n = (n + (n >> 4)) & 0x0F0F0F0F0F0F0F0F
    n = n + (n >> 8)
    n = n + (n >> 16)
    n = n + (n >> 32)
    return n & 0x0000007F