Source Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define Endl '\n'
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define loop(n)          for(int i = 0; i < (n); i++)
const long long inf = (long long) 1e18;
#define fast    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N = 1e5 + 5;
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"

void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

/*********** Solution start from here *************/

int main() {
    file();
    fast
    int tc=1;
    //cin >> tc;
    while (tc--) {
        int n;
        cin>>n;
        vector<int>v(n);

        loop(n) cin>>v[i];

        ll cnt=0;

        for (int i = 1; i < n; ++i) {
            if (v[i]!=v[i-1])
                cnt++ ,i++;
        }
        cout<<cnt<<Endl;
    }
}
Copy
Tha Bits AhmedEzzat
GNU G++17
13 ms
760 KB
Accepted