Source Code
#include <iostream>
#include<bits/stdc++.h>
#include <cmath>
#include <string>
#include <algorithm>
#define sareeeee3 ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
using namespace std;
using veci=vector<int>;
using vecl=vector<long long>;
#define ll long long
/*
ll kwys(ll k){

}
*/




void result()
{
    int n;
    cin>>n;
    int a[n];
    int c{};
    for (int i = 0; i <n ; ++i) {
        cin>>a[i];
    }
    for (int i = 1; i <n ; ++i) {
        if(a[i]!=a[i-1]){
            c++;
            i++;
        }


    }
    cout<<c<<"\n";



}

int main ()
{
    sareeeee3
    int t=1;
   // cin>>t;
#ifndef ONLINE_JUDGE
   // freopen("tests.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    while (t--)
    {
        result();
        cout<<"\n";
    }

}
Copy
Tha Bits Mostafa_Fouad
GNU G++17
15 ms
684 KB
Accepted