Language: C++

int main() {
  I n; cin >> n;
  I v[n], v1[n];
  I count_num_kind[100001];
  memset(count_num_kind,0,sizeof(count_num_kind));
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v1[i] = v[i];
    count_num_kind[v[i]] = 1;
  }
  I count = 0;
  for (int i = 0; i < 100001; i++) {
    if (count_num_kind[i]==1) {
      count++;
    }
  }
  I ans = 0;
  if (count == 1) {
    ans = n/2;
  }
  else {
    for (int i = 2; i < n; i++) {
      if (v[i-2] != v[i]) {
        v[i] = v[i-2];
        ans++;
      }
    }
    I c = 0;
    for (int i = n-1; i >= 2; i--) {
      if (v1[i-2] != v1[i]) {
        v1[i-2] = v1[i];
        c++;
      }
    }
    ans = min(c,ans);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:2:3: error: 'I' was not declared in this scope
    2 |   I n; cin >> n;
      |   ^
a.cc:2:8: error: 'cin' was not declared in this scope
    2 |   I n; cin >> n;
      |        ^~~
a.cc:2:15: error: 'n' was not declared in this scope
    2 |   I n; cin >> n;
      |               ^
a.cc:3:4: error: expected ';' before 'v'
    3 |   I v[n], v1[n];
      |    ^~
      |    ;
a.cc:4:4: error: expected ';' before 'count_num_kind'
    4 |   I count_num_kind[100001];
      |    ^~~~~~~~~~~~~~~
      |    ;
a.cc:5:10: error: 'count_num_kind' was not declared in this scope
    5 |   memset(count_num_kind,0,sizeof(count_num_kind));
      |          ^~~~~~~~~~~~~~
a.cc:5:3: error: 'memset' was not declared in this scope
    5 |   memset(count_num_kind,0,sizeof(count_num_kind));
      |   ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | int main() {
a.cc:7:12: error: 'v' was not declared in this scope
    7 |     cin >> v[i];
      |            ^
a.cc:8:5: error: 'v1' was not declared in this scope
    8 |     v1[i] = v[i];
      |     ^~
a.cc:11:4: error: expected ';' before 'count'
   11 |   I count = 0;
      |    ^~~~~~
      |    ;
a.cc:14:7: error: 'count' was not declared in this scope
   14 |       count++;
      |       ^~~~~
a.cc:17:4: error: expected ';' before 'ans'
   17 |   I ans = 0;
      |    ^~~~
      |    ;
a.cc:18:7: error: 'count' was not declared in this scope
   18 |   if (count == 1) {
      |       ^~~~~
a.cc:19:5: error: 'ans' was not declared in this scope
   19 |     ans = n/2;
      |     ^~~
a.cc:23:11: error: 'v' was not declared in this scope
   23 |       if (v[i-2] != v[i]) {
      |           ^
a.cc:25:9: error: 'ans' was not declared in this scope
   25 |         ans++;
      |         ^~~
a.cc:28:6: error: expected ';' before 'c'
   28 |     I c = 0;
      |      ^~
      |      ;
a.cc:30:11: error: 'v1' was not declared in this scope
   30 |       if (v1[i-2] != v1[i]) {
      |           ^~
a.cc:32:9: error: 'c' was not declared in this scope
   32 |         c++;
      |         ^
a.cc:35:5: error: 'ans' was not declared in this scope
   35 |     ans = min(c,ans);
      |     ^~~
a.cc:35:15: error: 'c' was not declared in this scope
   35 |     ans = min(c,ans);
      |               ^
a.cc:35:11: error: 'min' was not declared in this scope; did you mean 'main'?
   35 |     ans = min(c,ans);
      |           ^~~
      |           main
a.cc:37:3: error: 'cout' was not declared in this scope
   37 |   cout << ans << endl;
      |   ^~~~
a.cc:37:11: error: 'ans' was not declared in this scope
   37 |   cout << ans << endl;
      |           ^~~
a.cc:37:18: error: 'endl' was not declared in this scope
   37 |   cout << ans << endl;
      |                  ^~~~