func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n, k, m, x, ans = 0;     cin >> n >> k >> m;     vector<pair<long long, long long> > v;     for (int i = 0; i < n; i++) {       cin >> x;       if (v.empty() || (v.back().first != x)) {         v.push_back({x, 1});       } else if (v.back().first == x) {         v.back().second = (v.back().second + 1) % k;         if (v.back().second == 0) v.pop_back();       }     }     if (v.size() == 0) return cout << 0, 0;     if (v.size() == 1) {       return cout << ((v[0].second * m) % k), 0;     }     for (auto &i : v) {       ans += m * i.second;     }     if (m == 1) return cout << ans, 0;     long long rem = 0;     int back = v.size() - 1, front = 0;     while (back > front) {       if ((v[front].first != v[back].first)) {         break;       } else {         rem += ((v[front].second + v[back].second) -                 ((v[front].second + v[back].second) % k)) *                (m - 1);         if ((v[front].second + v[back].second) % k) break;       }       back--;       front++;     }     if (back == front) {       rem += ((v[back].second) * m) - ((v[back].second) * m) % k;       if (((v[back].second) * m) % k == 0) {         back--;         front++;       }     }     if (back < front)       while (back >= 0) {         if ((v[front].first != v[back].first)) {           break;         } else {           rem += ((v[front].second + v[back].second) -                   ((v[front].second + v[back].second) % k));           if ((v[front].second + v[back].second) % k) break;         }         back--;         front++;       }     cout << (ans - rem);     return 0;   }   