def _exp(self, a, b):
        ret = 1
        b %= MOD
        while b > 0:
            if b & 1 == 0:
                b /= 2
                a *= a
                a %= MOD
            else:
                ret *= a
                ret %= MOD
                b -= 1
        return ret
Alternative to built-in pow()
dataset/ETHPy150Open algorhythms/HackerRankAlgorithms/AntiPalindromic Strings.py/Solution._exp