func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     int l, r, x, y;   };   vector<node> p[500010];   int a[500010], b[500010], c[500010];   int main() {     int i, j, k, n, m, s;     node e;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     b[0] = 0;     for (i = 1; i <= n + 1; i++) {       b[i] = b[i - 1];       if (a[i] == m) b[i]++;     }     a[n + 1] = 0;     j = 0;     k = 0;     for (i = 1; i <= n + 1; i++) {       if (a[i] == a[i - 1])         k++;       else {         e.l = j;         e.r = k;         e.x = k - j + 1;         p[a[i - 1]].push_back(e);         j = i;         k = i;       }     }     s = 0;     for (i = 1; i <= 500010 - 10; i++) {       k = p[i].size();       if (k == 0) continue;       e.l = n + 1;       e.r = n + 1;       e.x = 0;       p[i].push_back(e);       p[i][0].y = p[i][0].x + b[n] - b[p[i][0].r] + b[p[i][0].l - 1];       s = max(s, p[i][0].y);       c[p[i][0].l] = b[p[i][0].l - 1] + p[i][0].x;       for (j = 1; j < k; j++) {         p[i][j].y = p[i][j].x + max(c[p[i][j - 1].l], b[p[i][j].l - 1]) + b[n] -                     b[p[i][j].r];         s = max(s, p[i][j].y);         c[p[i][j].l] =             max(c[p[i][j - 1].l] + p[i][j].x, p[i][j].x + b[p[i][j].l - 1]);       }     }     printf( %d n , s);     return 0;   }   