def pow_sq(x, y):
    """
    Compute x^y, without calling its pow,
    using exponentiation by squaring.
    """
    r = 1
    while y:
        if y & 1:
            r = r * x
        x = x * x
        y >>= 1
    return r