func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const int p = 998244353;   int n, k, cnt, a[N], d[N], jc[N], ny[N];   long long s = 1, ans;   inline int read() {     int ans = 0;     char c = getchar();     while (c < 48 || c > 57) c = getchar();     while (c >= 48 && c <= 57)       ans = (ans << 3) + (ans << 1) + (c ^ 48), c = getchar();     return ans;   }   inline long long ksm(long long x, int y) {     long long z = 1;     while (y) {       if (y & 1) z = z * x % p;       x = x * x % p, y >>= 1;     }     return z;   }   inline long long C(int x, int y) {     return 1ll * jc[x] * ny[y] % p * ny[x - y] % p;   }   int main() {     n = read(), k = read() % p;     for (register int i = 1; i <= n; ++i) {       int u = read();       if (u != a[cnt])         a[++cnt] = u;       else         s = s * k % p;     }     if (a[1] == a[cnt]) --cnt, s = s * k % p;     if (cnt <= 1) {       putchar(48);       return 0;     }     d[0] = jc[0] = 1, ans = ksm(k, cnt);     for (register int i = 1; i <= cnt; ++i)       d[i] = 1ll * d[i - 1] * (k - 2) % p, jc[i] = 1ll * jc[i - 1] * i % p;     ny[cnt] = ksm(jc[cnt], p - 2);     for (register int i = cnt - 1; i >= 0; --i)       ny[i] = 1ll * ny[i + 1] * (i + 1) % p;     for (register int i = 0; (i << 1) <= cnt; ++i)       ans = (ans - C(cnt, i) * C(cnt - i, i) % p * d[cnt - (i << 1)] % p + p) % p;     ans = ans * ny[2] % p * s % p;     printf( %lld , ans);     return 0;   }   