func_code_string: #include <bits/stdc++.h>   using namespace std;   long long mod = 998244353;   long long powmod(long long a, long long b) {     long long r = 1;     while (b) {       if (b & 1) r = (r * a) % mod;       a = (a * a) % mod, b >>= 1;     }     return r;   }   long long modd(long long a, long long b) { return ((a % b) + b) % b; }   long long extendedEuclid(long long a, long long b, long long& x, long long& y) {     long long xx = y = 0, yy = x = 1, t;     while (b) {       long long q = a / b;       a %= b;       swap(a, b);       t = xx;       xx = x - q * xx;       x = t;       t = yy;       yy = y - q * yy;       y = t;     }     return a;   }   long long modularInverse(long long a) {     long long x, y, d = extendedEuclid(a, mod, x, y);     if (d > 1) return -1;     return modd(x, mod);   }   long long f[300000], fi[300000];   long long binom(long long a, long long b) {     return (((f[a] * fi[a - b]) % mod) * fi[b]) % mod;   }   int n, k, h[300000];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout << fixed << setprecision(10);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> h[i];     f[0] = 1;     fi[0] = 1;     for (int i = 1; i <= n; i++)       f[i] = (f[i - 1] * i) % mod, fi[i] = modularInverse(f[i]);     int c = 0;     for (int i = 0; i < n; i++) c += h[i] != h[(i + 1) % n];     long long r = 0;     for (int s = 1; s <= c; s++) {       long long h = powmod(2, s);       if ((s & 1) == 0) h = (h + mod - binom(s, s / 2)) % mod;       h = (h * fi[2]) % mod;       h = (h * binom(c, s)) % mod;       r = (r + h * powmod(k - 2, c - s)) % mod;     }     r = (r * powmod(k, n - c)) % mod;     cout << r <<   n ;   }   