Problem:


Score : 200 points

Problem Statement

There are N balls placed in a row.
AtCoDeer the deer is painting each of these in one of the K colors of his paint cans.
For aesthetic reasons, any two adjacent balls must be painted in different colors.

Find the number of the possible ways to paint the balls.

Constraints

1≦N≦1000

2≦K≦1000

The correct answer is at most 2^{31}-1.

Input

The input is given from Standard Input in the following format:

N K

Output

Print the number of the possible ways to paint the balls.

Sample Input 1

2 2

Sample Output 1

2

We will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.

Sample Input 2

1 10

Sample Output 2

10

Since there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.



Sample input:
2 2


Sample output:
2

Submission status: Accepted

Solution code:

N,K =  map(int,raw_input().split())

value = K
for i in range(1,N):
    value = value*(K-1)

print value

Submission status: Accepted

Solution code:
N,K = raw_input().split()
N=int(N)
K=int(K)
if N==1:
    print K
else:
    A = K*pow(K-1,N-1)
    print A

Submission status: Accepted

Solution code:
l = raw_input().split()
N = int(l[0])
K = int(l[1])

ans = 1
for i in range(N):
    if i==0:
        ans*=K
    else:
        ans*=(K-1)
print ans

Submission status: Accepted

Solution code:
l = input().split()
N = int(l[0])
K = int(l[1])
print(str(K*((K-1)**(N-1))))

Submission status: Accepted

Solution code:
nk= input().split(' ')
n = int(nk[0])
k = int(nk[1])

print(k*(k-1)**(n-1))

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
answer = K * ((K-1)**(N-1))
print answer

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
ans =  k * ((k-1)**(n-1))
print(ans)

Submission status: Accepted

Solution code:
d=[int(i) for i in input().split()]

print(d[1]*((d[1]-1)**(d[0]-1)))

Submission status: Accepted

Solution code:
[n, k] = map(int, input().split())
print(k * pow(k - 1, n - 1))

Submission status: Accepted

Solution code:
import sys

line = sys.stdin.readline()
line = line.rstrip().split(" ")
n,k = int(line[0]), int(line[1])

ret = 1
ret = ret*k
for l in range(n-1):
    ret = ret*(k-1)

print (ret)

Submission status: Accepted

Solution code:

N, K = [int(a) for a in raw_input().strip().split()]
print K*(K-1)**(N-1)

Submission status: Accepted

Solution code:
data = map(int, raw_input().split(" "))
ball_num = data[0]
color_num = data[1]

res = color_num

for _ in range(ball_num-1):
	res *= (color_num-1)

print res

Submission status: Accepted

Solution code:
N,K = map(int,raw_input().split(' '))
print K*(K-1)**(N-1)

Submission status: Accepted

Solution code:
n,k=map(int,raw_input().split())
#l=map(int,raw_input().split())
ans=chk=1
for i in range(n):
    if i==0:
        ans*=k
    else:
        ans*=(k-1)
print ans

Submission status: Accepted

Solution code:
s = input().split()
N = int(s[0])
K = int(s[1])
print(K * (K-1)**(N-1))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
print((k-1)**(n-1)*k)

Submission status: Accepted

Solution code:
N,K = map(int, raw_input().split())
print K*(K-1)**(N-1)

Submission status: Accepted

Solution code:
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(2)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def solve():
    buf = IO_for_Contest.read_from_input()
    n = buf[0]
    k = buf[1]
    print(k * ((k - 1) ** (n - 1)))


if __name__ == '__main__':
    # doctest.testmod()
    solve()

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
print K * pow(K-1, N-1)

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())

print K * ((K - 1) ** (N - 1))

Submission status: Accepted

Solution code:
from random import random
import math
import re
import fractions

# N = input()
N, K = map(int, raw_input().split(" "))
print K*(K-1)**(N-1)

Submission status: Accepted

Solution code:

n, k = list(map(lambda x: int(x), input().split()))

ans = k * (k-1) ** (n-1)

print(ans)

Submission status: Accepted

Solution code:
a = raw_input()
n,k = [int(i) for i in a.split()]

print k*pow(k-1,n-1)

Submission status: Accepted

Solution code:
n, k =  map(int, raw_input().split())
print k * (k-1)**(n-1),

Submission status: Accepted

Solution code:
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

n,k=ii()

def f(x):
    if x==0:
        return 1
    elif x==1:
        return k-1
    elif x%2==0:
        return f(x/2)**2
    else:
        return f(x/2)**2*(k-1)

print k*f(n-1)

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split()]
print(k * ((k - 1) ** (n - 1)))

Submission status: Runtime Error

Solution code:
lst = list(map(int,input().strip()))
N = lst[0]
K = lst[1]
print(K * (N-1)*(K-1))

Submission status: Runtime Error

Solution code:
lst = list(map(int,input().strip()))
N = lst[0]
K = lst[1]
total = K * (N-1)*(K-1)

Submission status: Runtime Error

Solution code:
def fib(n):
  if n <= 1:
    return 1
  return fib(n-1)*n

n,k = map(int, input().split())
print(int(fib(k)/fib(k-n)))

Submission status: Runtime Error

Solution code:
def fib(n):
  if n == 1:
    return 1
  else:
    return fib(n-1)*n

n,k = map(int, input().split())
print(int(fib(k)/fib(k-n)))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
print(K * ((K - 1) ** (N - 1))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
print(k*((k-1)**(n-1))

Submission status: Runtime Error

Solution code:
ans = 1
for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= K-1
print(ans)

Submission status: Runtime Error

Solution code:
L = list(map(int,input().split()))
N = L[0]
K = L[1]

print(K(K-1)^(N-1))

Submission status: Runtime Error

Solution code:
sample = input() # two numbers in a string
new_sample = sample.split(" ")

ball = int(new_sample[0]) # number of balls
color = int(new_sample[1]) # number of colors
if color == 1 and ball > 1:
  print(0)
else:
	product = color


# for i in range(1, ball):
  for i in range(1, ball):
    product *= (color-1)
  print(product)

  
# 3 balls, 10 colors
# 1st spot, 10 choices
# 2nd spot, 9 choices
# 3rd spot, 9 choices

Submission status: Runtime Error

Solution code:
sample = input() # two numbers in a string
new_sample = sample.split(" ")
ball = new_sample[0] # number of balls
color = new_sample[1] # number of colors
product = color


# for i in range(1, ball):
for i in range(1, ball):
  product *= product-1
print(product)
  
  
# 3 balls, 10 colors
# 1st spot, 10 choices
# 2nd spot, 9 choices
# 3rd spot, 9 choices

Submission status: Runtime Error

Solution code:
sample = input() # two numbers in a string
new_sample = sample.split(" ")
ball = new_sample[0] # number of balls
color = new_sample[1] # number of colors
product = color

for i in range(1, ball+1):
  product *= color-1
print(product)
  
  
# 2 balls, 10 colors
# 1st spot, 10 choices
# 2nd spot, 9 choices

Submission status: Runtime Error

Solution code:
sample = input() # two numbers in a string
new_sample = sample.split(" ")
ball = new_sample[0]
color = new_sample[1]
product = color

for i in range(1, ball):
  product *= color-1
print(product)

Submission status: Runtime Error

Solution code:
i = input()
j = i.split()
num_balls = j[0]
num_colors = j[1]
product = num_colors
if(num_balls > 1 and num_colors == 1):
  print(0)
for i in range(1, num_balls):
  product *= (num_balls - 1)
print(product)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())

ans=1

for i in range(k):
  ans = ans*n
  n -= 1
  
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input()) %10
hon=[2,4,5,7,9]
bon=[3]

if N in hon:
    print("hon")
elif N in bon:
    print("bon")
else:
    print("pon")

Submission status: Runtime Error

Solution code:
def I_dont_know_what_to_do():
    n = int(input())
    k = int(input())

    s = k * ((k - 1) ** (n - 1))
    print(s)

I_dont_know_what_to_do()

Submission status: Runtime Error

Solution code:
def I_dont_know_what_to_do():
    n = int(input())
    k = int(input())

    s = k * ((k - 1) ** (n - 1))

I_dont_know_what_to_do()

Submission status: Runtime Error

Solution code:
N=int(input())
K=int(input())
print(K*(K-1)**(N-1))

Submission status: Runtime Error

Solution code:
a = list(map(int,input().strip())
b = a[0] #色の数
c = a[1] #ボールの数

ans  = (b*(b-1)**(c-1))
print(ans)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().spkit())
print(k*(k-1)**(n-1))

Submission status: Runtime Error

Solution code:
a=input().split(" ")
part=0

for i in range(a[0]):
	if i==0:
		part=a[1]
	else:
		part=part*(a[1]-1)

print(part)

Submission status: Runtime Error

Solution code:
list=[x for x in input()]
print(max(x))

Submission status: Runtime Error

Solution code:
a = input().split()
n = int[0]
k = int[1]
print(2**(n-1)*k)

Submission status: Runtime Error

Solution code:
from itertools import permutations
import sys

sys.setrecursionlimit(10 ** 6)
from bisect import *
from collections import *
from heapq import *
from math import gcd

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n,k=MI()
    ans=k*pow(k-1,n-1)
    print(ans)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
if n % k == 0:
	x= n//k
    print(x*math.factorial(k))
"""else:
	r= n % k
	div=n-r
	y=div//k
	sum= y*(math.factorial(k))
	z=nCr(k,r)
	sum+=z
	print(sum)
    """


def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

Submission status: Runtime Error

Solution code:
import math
n,k=map(int,input().split())
if n % k == 0:
	x= n//k
	print(x*math.factorial(k))
else:
	r= n % k
	div=n-r
	y=div//k
	sum= y*(math.factorial(k))
	z=nCr(k,r)
	sum+=z
	print(sum)


def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

Submission status: Runtime Error

Solution code:
import math
N,K=map(int,input().split())
print(int(math.factorial(N)/math.factorial(N-K)))

Submission status: Runtime Error

Solution code:
N, K input().split()
print(K * (K - 1) ** (N - 1))

Submission status: Runtime Error

Solution code:
n,k=(map(int,input().split())
print(k*((k-1)**(n-1)))

Submission status: Runtime Error

Solution code:
N, K = map(int,input())
cnt = K*(K-1)**(N-1)
print(cnt)

Submission status: Runtime Error

Solution code:
N,K = int(input().split())
print(int(K*((K-1)**(N-1))))

Submission status: Runtime Error

Solution code:
ilne = input().split(' ')
print(int(line[0])*((int(line[0])-1)**(int(line[1])-1))

Submission status: Runtime Error

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

print(k*((k-1)**(n-1))

Submission status: Runtime Error

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

print(k*((k-1)*(n-1))

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;


int main()
{
	long long int n,k;
	cin>>n>>k;
	long long int ans = (long long int) (k*pow(k-1,n-1));
        cout<<ans;
	return 0;
}

Submission status: Runtime Error

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

ans = K * ((K-1) ** (N-1))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
def pt(n,k):
  if n==1:
    return k
  else:
    return pt(n-1,k)*(k-1)
print(pt(n,k))

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())
val = k;
for i in range(n-1):
  val *= k -1
print(val)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().spllt())
n=b+(a-1)*(b-1)
print(n)

Submission status: Runtime Error

Solution code:
N,K = map(int, input().split())
print(K * (k-1)**(N-1))

Submission status: Runtime Error

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

ans = K
for i in range(N-1):
  K *= (k-1)
  
print(ans)

Submission status: Runtime Error

Solution code:
n, k = (int(x) for x in input().split())
count = 0
s = [[0 for i in range(n)] for j in range(k)]

for i in range(n):
    for j in range(k):
        if i == 0 or s[i][j] != s[i - 1][j]:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:
a, b , x = map(int,input().split())
cnt = 0
a = (a - 1 ) // x
b //= x
print(b - a)

Submission status: Runtime Error

Solution code:
N, K = [int(input()) for _ in range(2)]
A =int((K - 1) ** N)
print(int(A * K))

Submission status: Runtime Error

Solution code:
a=map(int(input()))
print(((a[1]-1)**(a[0]-1))*a[1])

Submission status: Runtime Error

Solution code:
def solve():
    N, K = list(map(int, input().split()))

    TABLE = [[-1 for x in range(K + 3)] for y in range(N + 3)]

    def recur(i, k):
        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        if not i < N:
            return 1

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)

Submission status: Runtime Error

Solution code:
def solve():
    N, K = list(map(int, input().split()))

    TABLE = [[-1 for x in range(K + 1)] for y in range(N + 1)]

    def recur(i, k):
        if not TABLE[i][k] == -1:
            return TABLE[i][k]

        if not i < N:
            return 1

        ans = 0
        for a in range(K):
            if not a == k:
                ans += recur(i + 1, a)

        TABLE[i][k] = ans
        return TABLE[i][k]

    return recur(0, -1)


if __name__ == '__main__':
    res = solve()
    print(res)

Submission status: Runtime Error

Solution code:
n,k=map(int,input())

s=k*(k-1)**(n-1)

print(s)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
c = b * (b-1) ** (a-1)
print(c)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
t=n//2+n%2 
h=n//2 
ans=pow(k,tot) *pow(k-1,h) 
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())

if(N==1):
  	print(K)
else:
	answer = K*(N-1)*(K-1)
	print(answer)

Submission status: Runtime Error

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

answer=K
if N>1:
  for _ range(N-1):
    answer*=(K-1)

print(answer)

Submission status: Runtime Error

Solution code:
n = int(input())
k = int(input())

print(k*(k-1)**(n-1))

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
print(k*((k-1)**(n-1))

Submission status: Runtime Error

Solution code:
import sys
from sys import stdin

N, k = [int(x) for x in stdin.readline().rstrip().split()]

if K < 2:
    raise Exception('Error!')

sum = K
for i in range(N-1):
    sum = sum*(K-1)

if __name__ == '__main__':
    print(sum)

"""
def myfunc(n, k):
    if n <= 0:
        return k
    n = int(n-1)
    k = k*(k-1)
    return myfunc( n,k )

if __name__ == '__main__':
    print(int(myfunc(N, K)))
"""

Submission status: Runtime Error

Solution code:
n, k = input()

print(k*(k-1)**(n-1))

Submission status: Runtime Error

Solution code:
a=list(map(int,input().split()))
print(a[1]+(a[0]-1)*(a[1]-1)

Submission status: Runtime Error

Solution code:
n,k-map(int,input().split())
ans=k
for i in range(n):
	ans*=k-1

Submission status: Runtime Error

Solution code:
N, K = map(int, imput().split())
p = K*((K-1)**(N-1))
print(p)

Submission status: Runtime Error

Solution code:
N, K = map(int, imput().split())
p = K*(K-1)^(N-1)
print(p)

Submission status: Runtime Error

Solution code:
n,k = map(int, input())

ans = 0
for i in range(n):
    if i == 0:
        ans = k
    else:
        ans = ans * (k-1)
        
print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int n,k;
  cin>>n>>k;
  
  if (n==1){
    cout<<k<<endl;
  }
  else {
    cout<<k*pow(k-1,n-1)<<endl;
  }
}

Submission status: Runtime Error

Solution code:
n,k = input().split()
print(k*(k-1)**(n-1))

Submission status: Runtime Error

Solution code:
import math


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    power = 1
    for i in range(1, N + 1):
        power = (i * power) % (10 ** 9 + 7)
    return power


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Runtime Error

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

def ans(cnt,a,b,c=0):
    if cnt == a :
        return c
    else :
        if cnt == 0: 
            c += b
            cnt += 1
            return ans(cnt,a,b,c) 
        else: 
            cnt += 1
            c = c*(b-1)
            return ans(cnt,a,b,c)

a = ans(cnt = 0,a = n,b = k,c=0)
print(a)

Submission status: Runtime Error

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

def ans(cnt,a,b,c=0):
    if cnt == a :
        return c
    else :
        if cnt == 0: 
            c += b
            cnt += 1
            return ans(cnt,a,b,c) 
        else: 
            cnt += 1
            c = c*(b-1)
            return ans(cnt,a,b,c)

a = ans(cnt = 0,a = n,b = k,c=0)
print(a)

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
print(k * ((nk - 1) ** (n - 1)))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
print(K*(K-1)**(N-1)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
ans = ((K-1)**(M-1))*K
print(ans)

Submission status: Runtime Error

Solution code:
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

a,b = map(int,input().split())
print(permutations_count(a,b))

Submission status: Runtime Error

Solution code:
j

Submission status: Runtime Error

Solution code:
n, k = map(int, input())
print(k * ((k - 1) ** (n - 1)))

Submission status: Runtime Error

Solution code:
n,k=input().split()
N=int(n)
K=int(k)
print(k*(k-1)**(n-1))

Submission status: Runtime Error

Solution code:
#B
N, K = [int(x) for x in input().split()]
#print(N, K)#
def count(n):
    if n<=0: return 1
    else:  return (K-1)*count(n-1)
print(K*count(N-1))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
print(K*((M-1)**(K-1)))

Submission status: Runtime Error

Solution code:

def abc046_b():
	n, k = map(int, input().split())
    return k * ((k - 1) ** (n - 1))


if __name__ == '__main__':
    print(abc046_b())

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
print(K * ((K-1)**(N-1))

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
print(K*((K-1)^^(N-1)))

Submission status: Runtime Error

Solution code:
N, K = list(map(int, input().rstrip()))
ans = K * (K-1)**(N-1)
print(ans)

Submission status: Runtime Error

Solution code:
<?php fscanf(STDIN,"%d%d",$n,$k);echo $k*($k-1)**~-$n;

Submission status: Runtime Error

Solution code:
N = int(input())
K = int(input())
result = K
for i in range(N-1) :
    result = result * (K -1)
print(result)

Submission status: Runtime Error

Solution code:
aaaaaaaaaa

Submission status: Runtime Error

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

def powk(n):
    if n == 1:
        return 1
    else:
        return (k - 1) * powk(n - 1)

print(k * powk(n))

Submission status: Runtime Error

Solution code:
N, K = tuple(map(int ,input().split(' ')))

print( K * int(power(float(K), float(N - 1))) )

Submission status: Runtime Error

Solution code:
N,K=int(input().split())
ans=K
for i in range(N-1):
  ans*=(K-1)
print(ans)

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <math.h>

int main(void) {
	int a, b, ans;
	scanf("%d %d",&a, &b);
	printf("%d",(b*(int)pow((double)(b-1),(double)(a-1))));
}

Submission status: Runtime Error

Solution code:
N, K = map(int, raw_input().split())
# N, K = 10, 8

print (K * (K-1) ** (N-1))

Submission status: Runtime Error

Solution code:
list = input().split()
a = bin(int(list[0])-1)
b = int(list[1])-1
print(pow(b,a)*int(list[1]))

Submission status: Runtime Error

Solution code:
def exp(x, n):
	if n == 0:
		return 1
	else:
		return x * exp(x, n-1)

def main():
	inpt = raw_input().split()
	n = int(inpt[0])
	k = int(inpt[1])
	print k * exp(k-1, n-1)
	
main()

Submission status: Runtime Error

Solution code:
n, m = list(map(int, input().split()))
a = [input() for i in range(n)]
print(n,m)

##
## Template
##

## map, filter, reduce

# map(lambda x: x*2, range(10))
# filter(lambda x: x % 2, range(10))
# from functools import reduce
# reduce(lambda sum,x: sum+x, range(10))
# [x * 2 for x in range(1, 10) if x % 3 == 1]
# => [2, 8, 14]

Submission status: Runtime Error

Solution code:
import sys

n, k = map(int, raw_input().split())
ans = k # first                                                                                                 
if n = 1 and k = 1:
    print ans
    sys.exit()
for i in range(n-1):
    ans *= k-1
print ans

Submission status: Runtime Error

Solution code:
import sys

n, k = map(int, raw_input().split())
ans = k # first                                                                                                 
if n = 1 and k = 1:
    print ans
    sys.exit()
for i in range(n-1):
    ans *= k-1

Submission status: Runtime Error

Solution code:
K = raw_input().split()
N=int(N)
K=int(K)
if N==1:
    print K
else:
    A = K*pow(K-1,N-1)
    print A

Submission status: Runtime Error

Solution code:

N,K = raw_input().split()
N=int(N)
K=int(K)
if N==1:
    print K
else:
    A = K*pow(K-1,N-1)
    print A