Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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)

Fixed submission:
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))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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)

Fixed submission:
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))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- 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)

Fixed submission:
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))

Buggy python submission (verdict: Runtime Error):
#include <stdio.h>
long long int pw(long long int x,long long int n){
  long long int result = 1;
  if(n > 0){
    result = pw(x,n/2);
    if(n % 2 == 0){
      result = result * result;
    }else{
      result = (result * result)*x;
	}
  }
  return result;
}

int main(){
  long long int m;
  long long int n;
  scanf("%lld %lld",&m,&n);
  printf("%lld\n",pw(m,n)%1000000007);
  return 0;
}

Fixed submission:
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))

Buggy python submission (verdict: Time Limit Exceeded):
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)

Fixed submission:
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))

Buggy python submission (verdict: Time Limit Exceeded):
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)

Fixed submission:
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))