func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   long long a[maxn];   pair<long long, long long> st[maxn];   long long top, n, m, k, l, r, rec, rec2;   long long ans;   int main() {     cin >> n >> k >> m;     for (long long i = 1; i <= n; i++) cin >> a[i];     for (long long i = 1; i <= n; i++) {       if (!top || st[top].first != a[i])         st[++top] = make_pair(a[i], 1);       else         st[top].second = (st[top].second + 1) % k;       if (st[top].second == 0) top--;     }     for (long long i = 1; i <= top; i++) {       rec += st[i].second;     }     l = 1, r = top;     while (l < r && st[l].first == st[r].first &&            (st[l].second + st[r].second) % k == 0) {       rec2 += st[l].second + st[r].second;       l++;       r--;     }     if (l == r) {       if (st[l].second * m % k == 0)         ans += m * rec - rec2 * (m) - (st[l].second * m / k * k);       else         ans += m * rec - rec2 * (m - 1) - (st[l].second * m / k * k);     } else {       if (st[l].first == st[r].first)         rec2 += (st[l].second + st[r].second) / k * k;       ans = m * rec - rec2 * (m - 1);     }     cout << ans << endl;     return 0;   }   