Source Code
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <queue>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>
#include <deque>
using namespace std;
using ll = long long;
#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
//#define endl '\n'
const int mod=1e9+7;
void solve(int tccc)
{
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]!=a[i-1])
        {
            ans++;
            i++;
        }
    }
    cout<<ans<<endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
}

Copy
Tha Bits MrPie
GNU G++17
16 ms
1.1 MB
Accepted