func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pii = pair<int, int>;   const int maxn = 2e5 + 100;   const int mod = 998244353;   mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());   ll fact[maxn], inv[maxn];   ll pwr(ll a, ll pw) {     ll ret = 1;     while (pw > 0) {       if (pw & 1) ret = ret * a % mod;       a = a * a % mod;       pw >>= 1;     }     return ret;   }   ll modinv(ll a) { return pwr(a, mod - 2); }   ll choose(ll N, ll K) { return fact[N] * inv[K] % mod * inv[N - K] % mod; }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0);     fact[0] = inv[0] = 1;     for (ll i = 1; i < maxn; i++) {       fact[i] = fact[i - 1] * i % mod;       inv[i] = modinv(fact[i]);     }     int n, k;     cin >> n >> k;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     int cnt = 0;     for (int i = 0; i < n; i++)       if (v[i] != v[(i + 1) % n]) ++cnt;     ll same = 0;     for (int c = 0; c * 2 <= cnt; c++)       same = (same + choose(cnt, c) * choose(cnt - c, c) % mod *                          pwr(k - 2, cnt - 2 * c)) %              mod;     same = same * pwr(k, n - cnt) % mod;     ll ans = ((pwr(k, n) - same + mod) % mod) * modinv(2) % mod;     cout << ans <<   n ;     return 0;   }   