Language: C++

#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define erep(i,n) for (int i = 1; i <= (n); ++i)
#define brep(i,n) for (int i = n; i >= 0; i--)
#define pb push_back
using namespace std;
using P = pair<int,int>;
using ll = long long;
using Graph = vector<vector<int> > ;

const double PI=3.14159265358979323846;
const int INF = 100005;
const int MAX_K = 55;
const int MAX_W = 200005; 
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
ll dp[100005];


// ユークリッド互除法
unsigned gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}
*/

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }
 
    ll size(int x){
        return Size[root(x)];
    }
};

int main(){
 int n,m,k;
  cin >> n >> m >> k;
  mint ans = 0;
  COMinit();
  mint col = m;
  mint now;
  for(int x = n-1; x >= 0; x--){
    mint now = col;
    now *= COM(n-1,x);
    if(x <= k) ans += now;
    col *= m-1;
  }
  cout << ans << endl;
}#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define erep(i,n) for (int i = 1; i <= (n); ++i)
#define brep(i,n) for (int i = n; i >= 0; i--)
#define pb push_back
using namespace std;
using P = pair<int,int>;
using ll = long long;
using Graph = vector<vector<int> > ;

const double PI=3.14159265358979323846;
const int INF = 100005;
const int MAX_K = 55;
const int MAX_W = 200005; 
const int MAX = 510000;
const int MOD = 998244353;
long long fac[MAX], finv[MAX], inv[MAX];
ll dp[100005];


// ユークリッド互除法
unsigned gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}
*/

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime MOD
  mint inv() const { return pow(MOD-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }
 
    ll size(int x){
        return Size[root(x)];
    }
};

int main(){
 int n,m,k;
  cin >> n >> m >> k;
  mint ans = 0;
  COMinit();
  mint col = m;
  mint now;
  for(int x = n-1; x >= 0; x--){
    mint now = col;
    now *= COM(n-1,x);
    if(x <= k) ans += now;
    col *= m-1;
  }
  cout << ans << endl;
}

Compiler output:
a.cc:167:2: error: stray '#' in program
  167 | }#include<algorithm>//sort,二分探索,など
      |  ^
a.cc:167:3: error: 'include' does not name a type
  167 | }#include<algorithm>//sort,二分探索,など
      |   ^~~~~~~
a.cc:196:14: error: redefinition of 'const double PI'
  196 | const double PI=3.14159265358979323846;
      |              ^~
a.cc:30:14: note: 'const double PI' previously defined here
   30 | const double PI=3.14159265358979323846;
      |              ^~
a.cc:197:11: error: redefinition of 'const int INF'
  197 | const int INF = 100005;
      |           ^~~
a.cc:31:11: note: 'const int INF' previously defined here
   31 | const int INF = 100005;
      |           ^~~
a.cc:198:11: error: redefinition of 'const int MAX_K'
  198 | const int MAX_K = 55;
      |           ^~~~~
a.cc:32:11: note: 'const int MAX_K' previously defined here
   32 | const int MAX_K = 55;
      |           ^~~~~
a.cc:199:11: error: redefinition of 'const int MAX_W'
  199 | const int MAX_W = 200005;
      |           ^~~~~
a.cc:33:11: note: 'const int MAX_W' previously defined here
   33 | const int MAX_W = 200005;
      |           ^~~~~
a.cc:200:11: error: redefinition of 'const int MAX'
  200 | const int MAX = 510000;
      |           ^~~
a.cc:34:11: note: 'const int MAX' previously defined here
   34 | const int MAX = 510000;
      |           ^~~
a.cc:201:11: error: redefinition of 'const int MOD'
  201 | const int MOD = 998244353;
      |           ^~~
a.cc:35:11: note: 'const int MOD' previously defined here
   35 | const int MOD = 998244353;
      |           ^~~
a.cc:202:11: error: redefinition of 'long long int fac [510000]'
  202 | long long fac[MAX], finv[MAX], inv[MAX];
      |           ^~~
a.cc:36:11: note: 'long long int fac [510000]' previously declared here
   36 | long long fac[MAX], finv[MAX], inv[MAX];
      |           ^~~
a.cc:202:21: error: redefinition of 'long long int finv [510000]'
  202 | long long fac[MAX], finv[MAX], inv[MAX];
      |                     ^~~~
a.cc:36:21: note: 'long long int finv [510000]' previously declared here
   36 | long long fac[MAX], finv[MAX], inv[MAX];
      |                     ^~~~
a.cc:202:32: error: redefinition of 'long long int inv [510000]'
  202 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                ^~~
a.cc:36:32: note: 'long long int inv [510000]' previously declared here
   36 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                ^~~
a.cc:203:4: error: redefinition of 'll dp [100005]'
  203 | ll dp[100005];
      |    ^~
a.cc:37:4: note: 'll dp [100005]' previously declared here
   37 | ll dp[100005];
      |    ^~
a.cc:207:10: error: redefinition of 'unsigned int gcd(unsigned int, unsigned int)'
  207 | unsigned gcd(unsigned a, unsigned b) {
      |          ^~~
a.cc:41:10: note: 'unsigned int gcd(unsigned int, unsigned int)' previously defined here
   41 | unsigned gcd(unsigned a, unsigned b) {
      |          ^~~
a.cc:217:6: error: redefinition of 'void COMinit()'
  217 | void COMinit() {
      |      ^~~~~~~
a.cc:51:6: note: 'void COMinit()' previously defined here
   51 | void COMinit() {
      |      ^~~~~~~
a.cc:229:11: error: redefinition of 'long long int COM(int, int)'
  229 | long long COM(int n, int k){
      |           ^~~
a.cc:63:11: note: 'long long int COM(int, int)' previously defined here
   63 | long long COM(int n, int k){
      |           ^~~
a.cc:245:8: error: redefinition of 'struct mint'
  245 | struct mint {
      |        ^~~~
a.cc:79:8: note: previous definition of 'struct mint'
   79 | struct mint {
      |        ^~~~
a.cc:274:10: error: redefinition of 'std::istream& operator>>(std::istream&, const mint&)'
  274 | istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
      |          ^~~~~~~~
a.cc:108:10: note: 'std::istream& operator>>(std::istream&, const mint&)' previously defined here
  108 | istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
      |          ^~~~~~~~
a.cc:275:10: error: redefinition of 'std::ostream& operator<<(std::ostream&, const mint&)'
  275 | ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
      |          ^~~~~~~~
a.cc:109:10: note: 'std::ostream& operator<<(std::ostream&, const mint&)' previously defined here
  109 | ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
      |          ^~~~~~~~
a.cc:277:8: error: redefinition of 'struct UnionFind'
  277 | struct UnionFind {
      |        ^~~~~~~~~
a.cc:111:8: note: previous definition of 'struct UnionFind'
  111 | struct UnionFind {
      |        ^~~~~~~~~
a.cc:319:5: error: redefinition of 'int main()'
  319 | int main(){
      |     ^~~~
a.cc:153:5: note: 'int main()' previously defined here
  153 | int main(){
      |     ^~~~