func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long double EPS = 1e-6;   const int N = 200020, MOD = 998244353;   int n, k;   long long a[N + 20], fact[N + 20], inv[N + 20];   long long qpow(long long a, long long b, long long p = MOD) {     long long ans = 1;     for (; b; b >>= 1) {       if (b & 1) ans = ans * a % p;       a = a * a % p;     }     return ans % p;   }   void prework() {     fact[0] = 1;     for (int i = 1; i <= N; i++) fact[i] = fact[i - 1] * i % MOD;     inv[N - 1] = qpow(fact[N - 1], MOD - 2) % MOD;     for (int i = N - 2; ~i; i--) inv[i] = inv[i + 1] * (i + 1) % MOD;   }   long long C(int n, int m) {     if (n - m < 0 || m < 0) return 0;     return fact[n] % MOD * inv[m] % MOD * inv[n - m] % MOD % MOD;   }   int main() {     prework();     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> a[i];     long long ans = 0;     int c = 0, m = 0;     a[n + 1] = a[1];     for (int i = 1; i <= n; i++)       if (a[i] != a[i + 1]) m++;     for (int i = 0; i <= m / 2; i++) {       ans += C(m, i) % MOD * C(m - i, i) % MOD * qpow(k - 2, m - 2 * i) % MOD;       ans %= MOD;     }     ans = (qpow(k, m) - ans + MOD) % MOD * qpow(2, MOD - 2) % MOD;     cout << ans % MOD * qpow(k, n - m) % MOD << endl;     return 0;   }   