Buggy python submission (verdict: Runtime Error):
def main():
    def kaizyo(x):
        ans = 1
        for i in range(2, x+1):
            ans *= i
        return ans

    n, m, k = map(int, input().split())
    MAX = 998244353
    ans = 0
    kaizyos = [None]*n
    ki = 1
    kaizyos[0] = ki
    for i in range(1, n):
        ki *= i
        ki %= MAX
        kaizyos[i] = ki
    def comb(a, b):
        return kaizyos[a]//(kaizyos[b]*kaizyos[a-b])
    ruizyos = [None]*(k+1)
    ruizyo = 1
    for i in range(n-1-k):
        ruizyo *= m-1
        ruizyo %= MAX
    ruizyos[0] = ruizyo
    for i in range(n-k, n):
        ruizyo *= m-1
        ruizyo
        ruizyos[i-n-k+1] = ruizyo
    pattern = lambda x: (comb(n-1, x)*m*ruizyos[x])%MAX
    for i in range(k+1):
        ans += pattern(i)
        ans %= MAX
    print(ans)


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, m, k = map(int, input().split())
    mod = 998244353
    ans = 0
    m1 = [None]*(n+1)
    kaizyo = [None]*(n+1)
    nm1 = 1
    kai = 1
    for i in range(n+1):
        m1[i] = nm1
        nm1 *= m-1
        nm1 %= mod
        kaizyo[i] = kai
        kai *= i+1
        kai %= mod
    
    def comb(a, b):
        return (kaizyo[a]*fermat(kaizyo[a-b]*kaizyo[b], mod))%mod

    for i in range(k+1):
        ans += m*m1[n-i-1]*comb(n-1, i)
        ans %= mod
    
    print(ans)

def fermat(x, p):
    """
    1/x (mod p) を返す
        x**(p-1) ≡ 1    [if gcd(x, p) == 1]
        x**(p-2) ≡ 1/x
        繰返し二乗法 
            ex: x**50  = (x**25)**2
                x**25  = (x**12)**2 * x
                x**12  = (x**6)**2
                x**6   = (x**3)**2
    """
    times = []
    mod = p
    p -= 2
    while p > 1:
        times.append(p%2)
        p //= 2
    x %= mod
    out = x
    for i in times[::-1]:
        if i:
            out = (x*pow(out, 2, mod))%mod
        else:
            out = pow(out, 2, mod)
    return out



if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    def comb(a, b):
        numerator = 1
        denominator = 1
        if a-b < 0:
            return None
        b = min(a-b, b)
        for i in range(a-b+1, a+1):
            numerator *= i
        for i in range(1, b+1):
            denominator *= i
        return numerator//denominator


    n, m, k = map(int, input().split())
    MAX = 998244353
    ans = 0
    pattern = lambda x: (comb(n-1, x)*m*(((m-1)**(n-1-x))%MAX))%MAX
    for i in range(k+1):
        ans += pattern(i)
        ans %= MAX
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, m, k = map(int, input().split())
    mod = 998244353
    ans = 0
    m1 = [None]*(n+1)
    kaizyo = [None]*(n+1)
    nm1 = 1
    kai = 1
    for i in range(n+1):
        m1[i] = nm1
        nm1 *= m-1
        nm1 %= mod
        kaizyo[i] = kai
        kai *= i+1
        kai %= mod
    
    def comb(a, b):
        return (kaizyo[a]*fermat(kaizyo[a-b]*kaizyo[b], mod))%mod

    for i in range(k+1):
        ans += m*m1[n-i-1]*comb(n-1, i)
        ans %= mod
    
    print(ans)

def fermat(x, p):
    """
    1/x (mod p) を返す
        x**(p-1) ≡ 1    [if gcd(x, p) == 1]
        x**(p-2) ≡ 1/x
        繰返し二乗法 
            ex: x**50  = (x**25)**2
                x**25  = (x**12)**2 * x
                x**12  = (x**6)**2
                x**6   = (x**3)**2
    """
    times = []
    mod = p
    p -= 2
    while p > 1:
        times.append(p%2)
        p //= 2
    x %= mod
    out = x
    for i in times[::-1]:
        if i:
            out = (x*pow(out, 2, mod))%mod
        else:
            out = pow(out, 2, mod)
    return out



if __name__ == "__main__":
    main()