Problem:


Power

For given integers m and n, compute mn (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.

Input

m n

Two integers m and n are given in a line.

Output

Print mn (mod 1,000,000,007) in a line.

Constraints

1 ≤ m ≤ 100

1 ≤ n ≤ 109

Sample Input 1

2 3

Sample Output 1

8

Sample Input 2

5 8

Sample Output 2

390625



Sample input:
2 3


Sample output:
8

Submission status: Wrong Answer

Solution code:
try:
    (m,n)  =  map(int,input().split())
except:
    exit

print(m,n)
r = pow(m,n) %  1000000007
print (r)

Submission status: Wrong Answer

Solution code:
M, N = map(int, input().split())

def power(m, n):
    y = 1
    while n > 0:
        if n%2 == 0:
            m *= m
            n /= 2
        else:
            y = y * m
            n -= 1

    return y

print(power(M, N))

Submission status: Wrong Answer

Solution code:
m,n = map(int,raw_input().split())
print pow(m,n)

Submission status: Wrong Answer

Solution code:
def pos(x,n,M):
    if n==0:
        return 1
    res = pow(x*x%M, n /2)
    if n%2 ==1:
        res = res * x%M
    return res

m,n = map(int,raw_input().split())

print pos(m,n,1000000007)

Submission status: Wrong Answer

Solution code:
def power(m, n):
    if n == 1:
        return m
            
    div = 1000000007

    ret = power(m * m, n // 2) % div
    if n % 2:
        ret %= div
    return ret
    

from sys import stdin
readline = stdin.readline


m, n = map(int, readline().split())
print(power(m, n))

Submission status: Wrong Answer

Solution code:
M = 1000000007
m, n = map(int, raw_input().split())
mod = m
while 1:
    if n == 1: break
    if n % 2 == 0:
        mod = (mod * mod) % M 
    else:
        mod = ((mod * mod) % M * m) % M
    n /= 2
print mod

Submission status: Wrong Answer

Solution code:
m, n = [int(i) for i in input().split()]
p = 1 
for i in range(n):
  p *= m

print(p)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 8

output:
390625
"""

import sys


def mod_pow(x, n, _mod):
    res = 1
    while n > 0:
        # check n is odd number
        if n & 1:
            res = res * x % _mod
        x = pow(x, 2) % _mod
        n >>= 1
    return res


def mod_pow_2(x, n, _mod):
    if not n:
        return 1
    res = pow(x * x % _mod, n // 2)
    if n & 1:
        res = res * x % _mod
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    M = 1000000007
    # print(pow(n1, n2, M))
    print(mod_pow_2(n1, n2, M))

Submission status: Wrong Answer

Solution code:
l=map(int,raw_input().split())
print(l[0]**l[1])

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
def my_pow(x,n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return pow((x**2),int(n/2))
    else:
        return pow(x,int(n-1))*x
    
n,m = map(int,input().split())
x = 1000000007
print(my_pow(n,m))

Submission status: Wrong Answer

Solution code:
m, n = map(int, input().split())
print(pow(m, n))

Submission status: Wrong Answer

Solution code:
def power(m,n):
  a = m**n % 1000000007
  return a

Submission status: Wrong Answer

Solution code:
m,n= map(int,input().split())
print(m**n/1000000007)

Submission status: Wrong Answer

Solution code:
m,n= map(int,input().split())
print(m**n//1000000007)

Submission status: Wrong Answer

Solution code:
num=[]
num=input().split()
base=int(num[0])
index=int(num[1])
number=1
for i in range(index):
    number=number*base
print(number)

Submission status: Wrong Answer

Solution code:
C = 1e9 + 7

def pow(x, n):
    if n == 0:
        return 1
    
    res = pow(x*x % C, n // 2)
    
    if n % 2 != 0:
        res *= x % C
        
    return int(res)

m, n = map(int, input().split())
print(pow(m, n))

Submission status: Wrong Answer

Solution code:
m,n= map(int,input().split())
a=m
for i in range(n):
        a*=m
        if a>1000000007:
            a//=1000000007
print(a)

Submission status: Wrong Answer

Solution code:
m,n= map(int,input().split())
a=m
for i in range(n-1):
        a*=m
        if a>1000000007:
            a//=1000000007
print(a)

Submission status: Wrong Answer

Solution code:
m,n= map(int,input().split())
a=1
i=0
N=1000000007
while a<N:
    a*=m
    i+=1
a%=N
for i in range(n%i):
    a*=m
a%=N
print(a)

Submission status: Wrong Answer

Solution code:
m,n=(int(i) for i in input().split())
m2=1
while n>0:
    m1=m
    l=1
    while l<n:
        m1*=m1
        l*=2
    n-=l
    m2*=m1
    if m2>1000000007:
        m2//=1000000007
print(m2)

Submission status: Wrong Answer

Solution code:
# your code goes here
m,n=(int(i) for i in input().split())
m2=1
while n>0:
    m1=m
    l=1
    while l*2<=n:
        m1*=m1
        l*=2
    n-=l
    m2*=m1
    if m2>1000000007:
        m2//=1000000007
    #print(m2)
print(m2)

Submission status: Wrong Answer

Solution code:
m,n = map(int,input().split())
print(m**n/1000000007)

Submission status: Wrong Answer

Solution code:
def pow2(m, n):
    M = 1000000007
    if n == 0:
        return 1
    res = pow(m*m%M, n/2)
    if n%2 == 1:
        res = res*m%M
    return res

m,n = map(int,input().split())
print(int(pow2(m,n)))

Submission status: Wrong Answer

Solution code:
m,n=map(int, input().split())
print(m**n)

Submission status: Wrong Answer

Solution code:
m,n=map(int,input().split())
print(m**n)

Submission status: Wrong Answer

Solution code:
import math
print(int(math.pow(*map(int,input().split()))))

Submission status: Wrong Answer

Solution code:
m,n=map(int,input().split());print(m**n)

Submission status: Wrong Answer

Solution code:
x, n = list(map(lambda x: int(x), input().split(" ")))
ans = 1
while n > 0:
    if(n & 1) == 1:
        ans *= x
    x = x * x
    n >>= 1
print(ans)

Submission status: Wrong Answer

Solution code:
m,n=map(int,input().split())
print(pow,m,n,1000000007)

Submission status: Wrong Answer

Solution code:
m,n=map(int,raw_input().split())
N=n
M=10**9+7

ans=m
c=1
while n>1:
	ans=ans**2
	ans%=M
	n/=2
	c*=2

print ans*(m**(N-c))

Submission status: Wrong Answer

Solution code:
m, n = [int(x) for x in input().split(' ')]
bi_n = bin(n)

ans = 1
dig = m
for i in range(len(bi_n)-1, 1, -1):
    if bi_n[i] == '1':
        ans *= dig
    dig *= dig

print(ans)

Submission status: Wrong Answer

Solution code:
def bin2(n):
    L=[]
    while n!=0:
        L.append(n%2)
        n=n//2       
    return L
      
m,n=[ int(x) for x in input().split()]    
k=1000000007

L=bin2(n)[:]
length=len(L)

r=m%k

if L[0]==1:
   ret=r
else:
    ret=1
    
for e in L[1:]:
    r=r*(r%k)
    if e==1:
        ret=ret*(r%k)

print(ret)

Submission status: Wrong Answer

Solution code:
import math
m, n = map(int, raw_input().split())
nlm = n * math.log(m,10)
la = math.log(1000000007)
while nlm > 0:
    nlm -= la
print int(10**(nlm+la+1.e-8))

Submission status: Wrong Answer

Solution code:
import math
m, n = map(int, raw_input().split())
nlm = n * math.log(m,10)
la = math.log(1000000007)
while nlm > 0:
    nlm -= la
print int(10**(nlm+la+1.e-10))

Submission status: Wrong Answer

Solution code:
import math
m, n = map(int, raw_input().split())
nlm = n * math.log(m,10)
la = math.log(1000000007)
while nlm > 0:
    nlm -= la
print int(10**(nlm+la+1.e-12))

Submission status: Wrong Answer

Solution code:
import math
m, n = map(int, raw_input().split())
if m > 1:
    nlm = n * math.log(m,10)
    la = math.log(1000000007)
    while nlm > 0:
        nlm -= la
    print int(10**(nlm+la+1.e-10))
else:
    print 0

Submission status: Wrong Answer

Solution code:
import math
m, n = map(int, raw_input().split())
if m > 1:
    nlm = n * math.log(m,10)
    la = math.log(1000000007)
    nlm -= int(nlm/la)*la
    print int(10**(nlm+1.e-10))
else:
    print 0

Submission status: Time Limit Exceeded

Solution code:
try:
    (m,n)  =  map(int,input().split())
except:
    exit

r = pow(m,n) %  1000000007
print (r)

Submission status: Time Limit Exceeded

Solution code:
m, n = map(int, input().split())
result = m**n % 1000000007
print(result)

Submission status: Time Limit Exceeded

Solution code:
M, N = map(int, input().split())

def power(m, n):
    y = 1
    while n > 0:
        if n%2 == 0:
            m *= m
            n /= 2
        else:
            y = y * m
            n -= 1

    return y
    
    
result = power(M, N) % 1000000007
print(result)

Submission status: Time Limit Exceeded

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r] % self.mod
        return ret


N, M = map(int, input().split())
MOD = 1000000007
ans = N
for _ in range(M-1):
    ans = ans * N % MOD
print(ans)

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,input().split())
print(m**n%(1000000007))

Submission status: Time Limit Exceeded

Solution code:
def power(m, n):
    if n == 1:
        return m
            
    div = 1000000007

    ret = power(m * m, n // 2) % div
    if n % 2:
        ret = (ret * m) % div
    return ret
    

from sys import stdin
readline = stdin.readline


m, n = map(int, readline().split())
print(power(m, n))

Submission status: Time Limit Exceeded

Solution code:
def power(m, n):
    if n == 1:return m
    return power(m * m, n // 2) * (m if n % 2 else 1) % 1000000007
    

from sys import stdin
readline = stdin.readline

m, n = map(int, readline().split())
print(power(m, n))

Submission status: Time Limit Exceeded

Solution code:
a,b=map(int,raw_input().split())
print a**b%1000000007

Submission status: Time Limit Exceeded

Solution code:
def mod_binary(m, n, p):
    v = 1
    while n != 0:
        if n & 1 == 1:
            v *= m
        m *= m
        n //= 2
        v %= p
    return v

m, n = map(int, input().split())
print(mod_binary(m, n, 1000000007))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
a = n**m%1000000007
print(a)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
a = 1
for i in range(m):
    a *= n
    if a > 1000000007:
        a %= 1000000007
print(a)

Submission status: Time Limit Exceeded

Solution code:
D = 1000000007
m, n = [int(i) for i in input().split()]
p = 1 
for i in range(n):
  p *= m

print(p % D)

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,input().split())
print(m**n%1000000007)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 8

output:
390625
"""

import sys


def mod_pow(x, n, _mod):
    res = 1
    while n > 0:
        # check n is odd number
        if n % 2:
            res = res * x % _mod
        x = pow(x, 2) % _mod
        n //= 1
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    M = 1000000007
    # print(pow(n1, n2, M))
    print(mod_pow(n1, n2, M))

Submission status: Time Limit Exceeded

Solution code:
m=input().split()
mod=1000000007
m[0] = int(m[0])
m[1]=int(m[1])
i=1

for x in range(0, m[1]):
	i *= m[0]
	i %= mod

print(i)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
def pow(x,n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return pow(x**2, int(n/2))
    else:
        return pow(x**2, int(n/2))*x
    
n,m = map(int,input().split())
x = 1000000007
print(pow(n,m)%x)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
def my_pow(x,n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return pow((x**2),int(n/2))
    else:
        return pow(x,int(n-1))*x
    
n,m = map(int,input().split())
x = 1000000007
print(my_pow(n,m)%x)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
def my_pow(x,n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return my_pow(x**2,n/2)
    else:
        return my_pow(x,int(n-1))*x
    
n,m = map(int,input().split())
x = 1000000007
print(my_pow(n,m)%x)

Submission status: Time Limit Exceeded

Solution code:
m,n = map(int,raw_input().split())

print pow(m,n)%1000000007

Submission status: Time Limit Exceeded

Solution code:
def my_pow(x,n):
    if n == 0:
        return 1
    if n % 4 == 0:
        return my_pow(x**4,int(n/4))
    elif n%4 == 1:
        return my_pow(x,int(n-1))*x
    elif n%4 == 2:
        return my_pow(x,int(n-2))*x*x
    elif n%4 == 3:
        return my_pow(x,int(n-3))*x*x*x
n,m = map(int,input().split())
x = 1000000007
print(my_pow(n,m)%x)

Submission status: Time Limit Exceeded

Solution code:
def mpow(x,n):
    if n == 0:
        return 1
    if n % 4 == 0:
        return mpow(x**4,int(n/4))
    elif n%4 == 1:
        return mpow(x,int(n-1))*x
    elif n%4 == 2:
        return mpow(x,int(n-2))*x*x
    elif n%4 == 3:
        return mpow(x,int(n-3))*x*x*x
n,m = map(int,input().split())
x = 1000000007
print(mpow(n,m)%x)

Submission status: Time Limit Exceeded

Solution code:
m,n = map(int,input().split())
print(m**n % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
m,n = map(int,input().split())
k = m
for i in range(1,n):
    m *= k
    if m > 1000000007:
        m  %= 1000000007
        
print(m)

Submission status: Time Limit Exceeded

Solution code:
m, n = map(int, input().split())
print(divmod(pow(m, n), 1000000007)[1])

Submission status: Time Limit Exceeded

Solution code:
M = (int)(1e9 + 7)
m, n = map(int, input().split())
ans = 1;

for i in range(n):
    ans *= m
    ans %= M

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

mod = 10**9 + 7

def solve():
    m, n = map(int, input().split())

    ans = modpow(m, n, mod)

    print(ans)

def modpow(x, y, mod):
    res = 1

    while y:
        if y & 1:
            res = (res * x) % mod

        x *= x
        y >>= 1

    return res

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
a=1000000007

def isuu(m,n):
    result=m
    i=1
    while i<n:
        result=(result*m)%a
        if result==1:
            return [0,i]
        i+=1
    return [1,result]


m,n=[int(i) for i in input().split(" ")]

i=isuu(m,n)
if i[0]==1:
    print(i[1])
else:
    print((m**(n%i[1]))%a)

Submission status: Time Limit Exceeded

Solution code:
a=1000000007

m,n=[int(i) for i in input().split(" ")]
print((m**n)%a)

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,input().split())
i=0
rem=m%1000000007
while i<=n:
    rem=rem*n
    if rem>=1000000007:
        rem = rem%100000007

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,input().split())
i=1
rem=m%1000000007
while i<=n-1:
    rem=rem*m
    if rem>=1000000007:
        rem = rem%1000000007
    i=i+1
print(rem)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    m, n = map(int, input().split())
    print(m ** n % 1000000007)

solve()

Submission status: Time Limit Exceeded

Solution code:
C = 10**9 + 7
m, n = map(int, input().split())
print(pow(m, n)%C)

Submission status: Time Limit Exceeded

Solution code:
m,n= map(int,input().split())
a=1
for i in range(n):
        a*=m
a%=1000000007
print(a)

Submission status: Time Limit Exceeded

Solution code:
m,n= map(int,input().split())
a=1
for i in range(n):
        a*=m
        if a>1000000007:
            a%=1000000007
print(a)

Submission status: Time Limit Exceeded

Solution code:
m,n = map(int,input().split())
print((m**n)%1000000007)

Submission status: Time Limit Exceeded

Solution code:
m,n = map(int,input().split())
print(pow(m,n)%1000000007)

Submission status: Time Limit Exceeded

Solution code:
def pow(x,n):
    tmp=0
    if n==0:
        tmp=1
    elif n%2==0:
        tmp=pow(x*x,n//2)
    else:
        tmp=pow(x*x,n//2)*x

    return tmp

mn=input().split()

m=int(mn[0])
n=int(mn[1])

N=pow(m,n)

print(N%1000000007)

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,input().split())
ans=1
for i in range(n):
    ans*=m
    if ans>=1000000007:
        ans%=1000000007
print(ans)

Submission status: Time Limit Exceeded

Solution code:
m, n = map(int, input().split())
print(m**n % 1000000007)

Submission status: Time Limit Exceeded

Solution code:
m, n = map(int, input().split())
mod = 1000000007
print(((m % mod) ** (n % mod)) % mod)

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,input().split())
print(m**n%1000000007)

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,input().split())
mn=m**n
if mn<=1000000007:
    print(mn)
else:
    print(mn%1000000007)

Submission status: Time Limit Exceeded

Solution code:
m,n=map(int,raw_input().split())
N=n
M=10**9+7

ans=m
c=1
while n>1:
	ans=ans**2
	ans%=M
	n/=2
	c*=2

print ( ans*(m**(N-c)) )%M

Submission status: Time Limit Exceeded

Solution code:
MAX = 1000000007

m, n = [int(x) for x in input().split(' ')]
bi_n = bin(n)

ans = 1
dig = m
for i in range(len(bi_n)-1, 1, -1):
    if bi_n[i] == '1':
        ans *= dig
    dig *= dig
    if ans >= MAX:
        ans %= MAX

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def check(a,b):
    temp = 1
    for i in range(b):
        temp = temp*a
        if temp >= 1000000007:
            break
    return (i+1)
        
def cul(a,b,i):
    temp = b % i
    answer = b // i
    test = (a**i)%1000000007
    t = 1
    for i in range(answer):
        t = (test*t)%1000000007
    return (t*(a**temp)%1000000007)

a,b = map(int, input().strip().split(' '))
print(cul(a,b,check(a,b)))

Submission status: Time Limit Exceeded

Solution code:
from math import *

def main():
    m, n = [int(_) for _ in input().split()]
    print(int((m ** n) % 1000000007))

main()

Submission status: Memory Limit Exceeded

Solution code:
def power(x, y):
          answer = x
          for i in range(y-1):
                  answer *= x
                  answer = answer % 1000000007
          return answer
  
l = raw_input().split()
print power(int(l[0]), int(l[1]))

Submission status: Memory Limit Exceeded

Solution code:
def power(m,mm,n):
  for i in range(n-1):
    mm = mm*m
    if mm > 1000000007:
      mm = mm % 1000000007
  return mm

l = map(int, raw_input().split())
print power(l[0],l[0],l[1])

Submission status: Accepted

Solution code:
n,m=map(int,input().split())

print(pow(n,m,int(1e9+7)))

Submission status: Accepted

Solution code:
print(pow(*map(int,input().split()),10**9+7))

Submission status: Accepted

Solution code:
m,n=map(int,input().split())
bitn=format(n,'b')
flag=[0]*len(bitn)
flag[0]=m
for i in range(1,len(bitn)):
    flag[i]=(flag[i-1]**2)%1000000007
ans=1
bitn=bitn[::-1]
for i in range(len(bitn)):
    if bitn[i]=='1':
        ans=(ans*flag[i])%1000000007
print(ans)

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
print(pow(m, n, 10**9 + 7))

Submission status: Accepted

Solution code:
m,n=map(int,input().split())
print(pow(m,n,1000000007))

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
print(pow(m, n, 1000000007))

Submission status: Accepted

Solution code:
m,n=map(int,input().split())
print(pow(m,n,1000000007))

Submission status: Accepted

Solution code:
import sys

MOD = 1000000007

def pow_mod(m, n):
    if n == 1:
        return m % MOD
    else:
        tmp = pow_mod(m, n / 2)
        if n % 2 == 0:
            return tmp * tmp % MOD
        else:
            return tmp * tmp * m % MOD
    
if __name__ == '__main__':
    line = sys.stdin.readline()
    m, n = line.split()
    m, n = int(m), int(n)
    
    sys.stdout.write(str(pow_mod(m, n)) + '\n')

Submission status: Accepted

Solution code:
def power(m, n):
    if n:return power(m * m % 1000000007, n // 2) * (m if n % 2 else 1) % 1000000007
    return 1


from sys import stdin
readline = stdin.readline

m, n = map(int, readline().split())
print(power(m, n))

Submission status: Accepted

Solution code:
def pos(x,n,M):
    if n==0:
        return 1
    res = pos(x*x%M, n /2, M)
    if n%2 ==1:
        res = res * x%M
    return res
 
m,n = map(int,raw_input().split())
 
print pos(m,n,1000000007)

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
print(pow(m, n, 10**9+7))

Submission status: Accepted

Solution code:
try:
  while True:
    d = raw_input()
    d = map(int, d.split(" "))
    print pow(d[0], d[1], 1000000007)
except: pass

Submission status: Accepted

Solution code:
a, b = map(int, raw_input().split())
print pow(a, b, 1000000007)

Submission status: Accepted

Solution code:
def power(a, n, M):
    tmp = 1
    if n > 0:
        tmp = power(a, n/2, M)
        if n % 2 == 0:
            tmp =(tmp*tmp)%M
        else:
            tmp = (((tmp*tmp)%M)*a)%M
    return tmp
m, n = map(int, raw_input().split())
print power(m, n, 1000000007)

Submission status: Accepted

Solution code:
def power(a, n, M):
    if n == 0: return 1
    tmp = power(a*a%M, n/2, M)
    if n % 2 == 1:
        tmp = tmp * a % M
    return tmp
m, n = map(int, raw_input().split())
print power(m, n, 1000000007)

Submission status: Accepted

Solution code:
def power(a, n, M):
    res = 1
    if n > 0:
        res = power(a*a%M, n/2, M)
        if n % 2 == 1:
            res = res * a % M
    return res
m, n = map(int, raw_input().split())
print power(m, n, 1000000007)

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
p, q, d = 1, m, 1000000007

while True:
    if n & 1:
        p *= q
        p %= d
    n >>= 1
    if not n:
        break
    q *= q
    q %= d

print(p)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    m, n = map(int, input().split())
    print(pow(m, n, 1000000007))

Submission status: Accepted

Solution code:
NUM = 1000000007

def power(m, n):
    if n == 0:
        return 1
    if n == 1:
        return m
    if n % 2 == 0:
        tmp = power(m, n/2) % NUM
        return tmp ** 2 % NUM
    if n % 2 == 1:
        tmp = power(m, n/2) % NUM
        return m * (tmp**2) % NUM

s = map(int, raw_input().split())
print "%d" % (power(s[0], s[1]) % NUM)

Submission status: Accepted

Solution code:
m,n=map(int, input().split())
print(pow(m,n,1000000007))

Submission status: Accepted

Solution code:
m,n = map(int,raw_input().split())
print pow(m,n,1000000007)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**5)

def expsq(n,k):
    global mod

    if k==0:
        return 1
    elif k%2==0:
        return pow(expsq(n,k/2),2,mod)
    else:
        return expsq(n,k-1)*n%mod

m,n=map(int,raw_input().split())
mod=10**9+7
print(expsq(m,n)%mod)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**5)

def expsq(n,k):
    global mod

    if k==0:
        return 1
    elif k%2==0:
        return pow(expsq(n,k/2),2,mod)
    else:
        return expsq(n,k-1)*n%mod

m,n=map(int,input().split())
mod=10**9+7
print(expsq(m,n)%mod)

Submission status: Accepted

Solution code:
print pow(*map(int, raw_input().split())+[10**9+7])

Submission status: Accepted

Solution code:
def power(n,m):
    if m == 0:
        return 1
    if m % 2 == 0:
        return power(n*n%1000000007,m//2)
    else:
        return n * power(n,m-1) % 1000000007
        
n,m = map(int, input().split())
print(power(n,m))

Submission status: Accepted

Solution code:
m,n = map(int, raw_input().split())
MOD = 1000000007
lst = [m]
i = 0
while True:
  lst.append(lst[i]*lst[i]%MOD)
  i += 1
  if i > 30:
    break

ans = 1
i = 0
while True:
  if n % 2 == 1:
    ans = ans * lst[i] % MOD
    n -= 1
  i += 1
  n /= 2
  if n == 0:
    break

print ans

Submission status: Accepted

Solution code:
D = 1000000007
m, n = [int(i) for i in input().split()]
print(pow(m,n,D))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 8

output:
390625
"""

import sys


def mod_pow(x, n, _mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * x % _mod
        x = pow(x, 2) % _mod
        n >>= 1
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    M = 1000000007
    # print(pow(n1, n2, M))
    print(mod_pow(n1, n2, M))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5 8

output:
390625
"""

import sys


def mod_pow(x, n, _mod):
    res = 1
    while n > 0:
        # check n is odd number
        if n % 2:
            res = res * x % _mod
        x = pow(x, 2) % _mod
        n //= 2
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1, n2 = map(int, _input[0].split())
    M = 1000000007
    # print(pow(n1, n2, M))
    print(mod_pow(n1, n2, M))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
print(pow(a,b,1000000007))

Submission status: Accepted

Solution code:
def mpow(x,n,mod):
    if n == 0:
        return 1
    if n % 4 == 0:
        return mpow((x**4)%mod,int(n/4),mod)
    elif n%4 == 1:
        return (mpow(x,int(n-1),mod)*x)%mod
    elif n%4 == 2:
        return (mpow(x,int(n-2),mod)*(x**2))%mod
    elif n%4 == 3:
        return (mpow(x,int(n-3),mod)*(x**3))%mod
n,m = map(int,input().split())
mod = 1000000007
print(mpow(n,m,mod))

Submission status: Accepted

Solution code:
m,n = map(int,input().split())

def amari(m,n):
    if n == 0:
        return 1
    
    if n % 2 == 0:
        return amari(m,n/2)**2%1000000007 
    else:
        return  m*amari(m,n-1)%1000000007 
print(amari(m,n))

Submission status: Accepted

Solution code:
mod = 1000000007
m, n = map(int, input().split())
print(pow(m,n,mod))

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))

m = A[0]
n = A[1]
M = 1000000007

def pos(m, n):
    if n == 0:
        return 1
    res = pos(m * m % M, int(n / 2))
    if n % 2 == 1:
        res *= m
        res = res % M
    return res

r = pos(m, n)
print(r)

Submission status: Accepted

Solution code:
def modpow(m, n, mod):
    if n == 0:
        return 1

    return ((modpow(m, n//2, mod)**2 % mod) * m**(n & 1)) % mod

mod = 10**9 + 7

m, n = map(int, input().split())

print(modpow(m, n, mod))

Submission status: Accepted

Solution code:
mod = 10**9 + 7
m, n = map(int, input().split())
print(pow(m, n, mod))

Submission status: Accepted

Solution code:
import sys

mod = 10**9 + 7

def solve():
    m, n = map(int, input().split())

    ans = modpow(m, n, mod)

    print(ans)

def modpow(x, y, mod):
    return ((modpow(x, y >> 1, mod)**2 % mod) * x**(y & 1)) % mod if y else 1

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys

mod = 10**9 + 7

def solve():
    m, n = map(int, input().split())

    ans = modpow(m, n, mod)

    print(ans)

def modpow(x, y, mod):
    res = 1

    while y:
        if y & 1:
            res = (res * x) % mod

        x = (x * x) % mod
        y >>= 1

    return res

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys

mod = 10**9 + 7

def solve():
    m, n = map(int, input().split())
    print(pow(m, n, mod))

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
m, n = [int(_) for _ in raw_input().split()]
MOD = 1000000007

# print pow(m, n, MOD)


ans = 1
r = m
while n:
    if n & 1:
        ans = (ans * r) % MOD
    r = (r * r) % MOD
    n >>= 1

print ans

Submission status: Accepted

Solution code:
import math
a=1000000007

m,n=[int(i) for i in input().split(" ")]

pow_list=[m]
x=int(math.log2(n))
for i in range(x+1):
    pow_list.append((pow_list[-1]**2)%a)

result=1
for i in range(x+1):
    if n>=2**(x-i):
        n-=2**(x-i)
        result=(result*pow_list[x-i])%a

print (result)

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
ans = 1
while n:
    ans = ans *(m if n%2 else 1) % 1000000007
    m = m*m%1000000007
    n>>=1
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
m, n = map(int, stdin.readline().split())
print(pow(m, n, 1000000007))

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
print(pow(m, n, int(1e9) + 7))

Submission status: Accepted

Solution code:
def solve():
    m, n = map(int, input().split())
    print(pow(m, n, 1000000007))

solve()

Submission status: Accepted

Solution code:
def power(x, n, d):
    rem = 1
    if n > 0:
        rem = power(x, n // 2, d)
        if n % 2 == 0:
            rem = rem ** 2 % d
        else:
            rem = ((rem ** 2 % d) * x) % d
    return rem

def solve():
    m, n = map(int, input().split())
    print(power(m, n, 1000000007))

solve()

Submission status: Accepted

Solution code:
d = 1000000007

def pow_rem(x, n):
    if n == 0:
        return x ** n % d
    if n % 2 == 0:
        return pow_rem(x, n // 2) ** 2 % d
    else:
        return ((pow_rem(x , n // 2) ** 2) * x) % d

def solve():
    m, n = map(int, input().split())
    print(pow_rem(m, n))

solve()

Submission status: Accepted

Solution code:
C = 10**9 + 7
m, n = map(int, input().split())
print(pow(m, n, C))

Submission status: Accepted

Solution code:
def new_pow(x, n):
    C = 10**9+7
    
    if n == 0:
        return 1
    
    if n:
        return new_pow(x*x%C, n//2) * (x if n % 2 else 1) % C
    
m, n = map(int,input().split())
print(new_pow(m,n))

Submission status: Accepted

Solution code:
# Aizu Problem NTL_1_B: Power
#
import itertools
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input2.txt", "rt")

m, n = [int(_) for _ in input().split()]
mod = 1000000007
print(pow(m, n, mod))

Submission status: Accepted

Solution code:
# your code goes here
m,n=(int(i) for i in input().split())
m2=1
while n>0:
    m1=m
    l=1
    while l*2<=n:
        m1*=m1
        if m1>1000000007:
            m1%=1000000007
 #       print(m1)
        l*=2
    n-=l
    m2*=m1
    if m2>1000000007:
        m2%=1000000007
#    print(m2)
print(m2)

Submission status: Accepted

Solution code:
m,n = map(int,input().split())
print(pow(m,n,1000000007))

Submission status: Accepted

Solution code:
print(int(pow(*map(int,input().split()),10**9+7)))

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
print(pow(m, n, 1000000007))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def pow(x, n, M=1):
    if n == 0:
        return 1
    res = pow((x * x) % M, n // 2, M)
    if n % 2 == 1:
        res = (res * x) % M
    return res


if __name__ == '__main__':

    M = 1000000007
    m, n = map(int, input().split())
    print(pow(m, n, M))

Submission status: Accepted

Solution code:
m,n=map(int,raw_input().split())
M=10**9+7

def a(m,n):
	N=n
	ans=m
	c=1
	while n>1:
		ans=ans**2
		ans%=M
		n/=2
		c*=2

	N=N-c
	return ans,N


x=m; y=n

ans=1
while y>1:
	x,y=a(m,y)
	ans=(ans*x)%M

if y==1:
	print (ans*m)%M
else:
	print ans

Submission status: Accepted

Solution code:
#! python3
# power.py

m, n = [int(x) for x in input().split(' ')]
print(pow(m, n, 1000000007))