Problem:
 Score : 200 points    Problem Statement Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000 .  Takahashi has N slimes, and they are standing in a row from left to right. The color of the i -th slime from the left is a_i .
If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic.  Takahashi can change the color of one slime to any of the 10000 colors by one spell.
How many spells are required so that no slimes will start to combine themselves?      Constraints  2 \leq N \leq 100  1 \leq a_i \leq N  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  a_1  a_2  ...  a_N       Output Print the minimum number of spells required.        Sample Input 1 5
1 1 2 2 2      Sample Output 1 2  For example, if we change the color of the second slime from the left to 4 , and the color of the fourth slime to 5 , the colors of the slimes will be 1, 4, 2, 5, 2 , which satisfy the condition.       Sample Input 2 3
1 2 1      Sample Output 2 0  Although the colors of the first and third slimes are the same, they are not adjacent, so no spell is required.       Sample Input 3 5
1 1 1 1 1      Sample Output 3 2  For example, if we change the colors of the second and fourth slimes from the left to 2 , the colors of the slimes will be 1, 2, 1, 2, 1 , which satisfy the condition.       Sample Input 4 14
1 2 2 3 3 3 4 4 4 4 1 2 3 4      Sample Output 4 4

Solution (Python):
from itertools import groupby

N = int(input())
A = list(map(int, input().split()))

A = groupby(A)
cnt = 0
for _, a in A:
    cnt += len(list(a)) // 2

print(cnt)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  if A[i] == A[i+1]:
    A[i+1] = -1
    ans += 1
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 0
i = 0
while i < N - 1:
  if A[i] == A[i+1]:
    ans += 1
    i += 1
  i += 1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
c=0
for i in range(n-1):
    if a[i]==a[i+1]:
        c+=1
        a[i+1]=0
print(c)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
c=0
for i in range(n-1):
    if a[i]==a[i+1]:
        c+=1
        a[i+1]=0
print(c)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

chunk = []
now = 1
for i in range(1, N):
    if A[i] == A[i - 1]:
        now += 1
    else:
        if now != 1:
            chunk.append(now)
            now = 1
    if i == N - 1 and now != 1:
        chunk.append(now)
ans = 0
for c in chunk:
    ans += c // 2

print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
changed = [False]*N
count = 0
for num in range(N-1):
  if not changed[num] and a[num] == a[num + 1]:
    changed[num+1] = True
    count += 1
print(count)

Solution (Python):



a=int(input())





f = list(map(int,input().split()))





count=1
ans=0
for i in range(a-1):
    if f[i]==f[i+1]:
        count+=1
    elif f[i]!=f[i+1]:
        count=1
    if count==2 :
        ans+=1
        count=0

print(ans)

Solution (Python):
n = int(input())
bit = -1
l = list(map(int,input().split()))
ans = 0
for i in range(1,n):
  if l[i] == l[i-1]:
    l[i] = bit
    ans += 1
print(ans)

Solution (Python):
N=int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if a[i]==a[i+1]:
        ans += 1
        a[i+1]=0

print(ans)

Solution (Python):
import sys, math
from functools import lru_cache
from collections import defaultdict
from decimal import Decimal
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    a = list(mi())

    for i in range(N-1):
        if a[i] == a[i+1]:
            a[i+1] = -1
    print(a.count(-1))

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = [int(s) for s in input().split()]

count = 0
same_color = 1
for i in range(1, n):
    if a[i] == a[i - 1]:
        same_color += 1
    else:
        count += same_color // 2
        same_color = 1
if same_color > 1:
    count += same_color // 2
print(count)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
x = a[0]
y = 1
ans = 0
for i in range(1,n):
    if a[i] == x:
        y += 1
    else:
        ans += y // 2
        x = a[i]
        y = 1
print(ans + y // 2)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))

ans=0
for i in range(n-1):
    if l[i]==l[i+1]:
        ans+=1
        l[i+1]=-1

print(ans)

Solution (Python):
def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    cnt = 0

    for i in range(n - 1):
        if a_list[i] == a_list[i + 1]:
            a_list[i + 1] = -1
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
    if A[i] == A[i-1]:
        ans += 1
        A[i] += 10000
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
i = 1; x = 0
while i < n:
    if a[i] == a[i-1]: x += 1; i += 1
    i += 1
print(x)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1] = 10**9
        cnt += 1
print(cnt)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1] = 10**9
        cnt += 1
print(cnt)

Solution (Python):
n = int(input())
s = list(map(int,input().split()))
prev = 0
ch = 0
for c in s:
  if prev == c:
    ch += 1
    prev = 0
  else:
    prev = c
print(ch)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1] = 0
        ans += 1
print(ans)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
ans=0

for i in range(N-1):
  if A[i]==A[i+1]:
    A[i+1]=max(A)+1
    ans+=1
print(ans)

Solution (Python):
n = int(input())
colors = list(map(int, input().split()))

cnt = 0
for r in range(n-1):
    if colors[r] == colors[r+1]:
        cnt += 1
        colors[r+1] = '*'

print(cnt)

Solution (Python):
'''
Created on 2020/08/21

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  a=list(map(int,pin().split()))
  cnt=0
  before=0
  for i in a:
    if before==i:
      before=0
      cnt+=1
    else:
      before=i
  print(cnt)
  return
main()

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b=[1]
c=1
for i in range(1,len(a)):
    if a[i-1]==a[i]:
        c+=1
        b.append(c)
    if a[i-1]!=a[i]:
        c=1
        b.append(c)
d=[]
for i in range(len(b)-1):
    if b[i]>=b[i+1]:
        d.append(b[i])
d.append(b[len(b)-1])
e=0
for i in range(len(d)):
    e+=d[i]//2
print(e)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
i = 1
ans = 0
while i < n:
    if a[i] == a[i-1]:
        ans += 1
        i += 1
    i += 1

print(ans)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
i = 0
ans = 0
while i < N-1:
    if a[i] == a[i+1]:
        i += 2
        ans += 1
    else:
        i += 1
print(ans)

Solution (Python):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    ans = 0
    s = A[0]
    count = 0
    for a in A:
        if a == s:
            count += 1
        else:
            s = a
            ans += count // 2
            count = 1
    
    ans += count // 2
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):


n = int(input())
a = list(map(int, input().split()))

s = []
tmp = 1 
for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
        if i == n-2:
            s.append(tmp)
    else:
        if tmp != 1:
            s.append(tmp)
        tmp = 1 

ans = 0 
for i in s:
    ans += i//2

print(ans)

Solution (Python):


n = int(input())
a = list(map(int, input().split()))

s = []
tmp = 1 
for i in range(1, n): 
    if a[i] == a[i-1]:
        tmp += 1
        if i == n-1:
            s.append(tmp)
    else:
        if tmp != 1:
            s.append(tmp)
        tmp = 1 

ans = 0 
for i in s:
    ans += i//2

print(ans)

Solution (Python):
n = int(input())
d = list(map(int,input().split()))
ans = 0
tmp = 0
for i in range(n-1):
  if d[i] == d[i+1] and tmp%2 ==0:
    tmp += 1
    ans += 1
  else:
    tmp = 0
print(ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(1,N):
  if a[i]==a[i-1]:
    a[i]=0
    ans+=1
print(ans)

Solution (Python):
import math
import sys
readline = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    for i in range(n - 1):
        if A[i + 1] == A[i]:
            cnt += 1
            A[i + 1] = "s" + str(i + 1)
    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    count = 0
    for i in range(1,N):
        if A[i] == A[i-1]:
            count += 1
            A[i] = -1
    print(count)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
ans = 0
l = list(map(int,input().split()))
for i in range(1,n):
    if l[i] == l[i-1]:
        ans += 1
        l[i] = 1000000
print(ans)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
a=l[0]
b=0
c=[]
for i in range(1,n):
  if l[i]==a:
    b+=1
  else:
    c.append(b)
    b=0
  a=l[i]
c.append(b)
for i in range(len(c)):
  c[i]=(c[i]+1)//2
print(sum(c))

Solution (Python):
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  ans = 0
  i = 0
  while i<N-1:
    if A[i]==A[i+1]:
      ans += 1
      i += 1
    i += 1
  return ans
print(solve())

Solution (Python):
N=int(input())
a=list(map(int,input().split()))

Q=0
for i in range(N-1):
    if a[i]==a[i+1]:
        a[i+1]=0
        Q+=1
print(Q)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
flag = False
for i in range(1, n):
    if a[i] == a[i - 1]:
        if not flag:
            ans += 1
        flag = not flag
    else:
        flag = False
print(ans)

Solution (Python):
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    count = 1
    for i in range(N-1):
        if A[i] == A[i+1]:
            count += 1
        else:
            if count > 1:
                ans += count//2
            count = 1
    if count > 1:
        ans += count//2
    print(ans)
resolve()

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ans = 0
for n in range(1, N):
    if a[n-1] == a[n]:
        ans += 1
        a[n] = "n"
print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    ans = 0
    b = -1
    cnt = 0
    for a in A:
        if b == a:
            cnt += 1
        else:
            ans += cnt // 2
            cnt = 1
            b = a
    ans += cnt // 2

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))
ans = 0
flag = 0
for i in range(n-1):
    if flag:
        flag = 0
        continue
    if lst1[i] == lst1[i+1]:
        ans += 1
        flag = 1

print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

prev = A[0]
cnt = 1
ans = 0
for i in range(1, N):
    if A[i] == prev:
        cnt += 1
    else:
        ans += cnt // 2
        cnt = 1
        prev = A[i]
ans += cnt // 2
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
  if a[i - 1] == a[i]:
    ans += 1
    a[i] = 0
print(ans)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))
    ans = 0

    for i in range(1, n):
        if a[i] == a[i - 1]:
            a[i] = 1001
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans, pre = 0, 0
for i in a:
    if pre == i:
        ans += 1
        pre = 0
    else:
        pre = i
print(ans)

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
A = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(1, N):
    if A[i-1] == A[i]:
        A[i] = -1
        ans += 1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
res = 0
i = 0
if n%2:
    a.append(a[n-1]+1)


while i < n-1:
    if a[i] == a[i+1]:
        res += 1
        i+=1
    i+=1
print(res)

Solution (Python):
N=int(input())
*A,=map(int,input().split())
now=A[0]
i=1
ans=0
while i<N:
    if A[i]==now:
        ans+=1
        A[i]+=100
    now=A[i]
    i+=1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
skip = False
for i in range(1, n):
    if skip:
        skip = False
        continue
    if a[i-1] == a[i]:
        ans += 1
        skip = True
print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = l()

i=1
while i < n:
    if a[i] == a[i-1]:
        ans += 1
        i += 1
    i += 1

print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
p = 0
x = 0
y = 1

for i in range(n):
    if a[i] != x:
        if y == 1:
            x = a[i]
        else:
            p += y // 2
            x = a[i]
            y = 1
    else:
        y += 1

if y == 1:
    print(p)
else:
    print(p + y // 2)

Solution (Python):
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

pre = 0
res = 0
for a in A:
    if a == pre:
        res += 1
        pre = 0
    else:
        pre = a

print(res)

Solution (Python):
n = int(input())
lst = list(map(int, input().split())) + [0]
cnt = 1
res = 0
for i in range(n):
  if lst[i + 1] == lst[i]:
    cnt += 1
  else:
    res += (cnt // 2)
    cnt = 1
print(res)

Solution (Python):
"""agc026_a"""
N = int(input())
A = list(map(int, input().split()))

ANS = 0
CNT = 0
LAST = 0

for a in A:
    if a == LAST:
        CNT += 1
        LAST = 0
    else: 
        LAST = a

print(CNT)

Solution (Python):
N=int(input())
A=list(map(int,input().split()))
count = 0
for i in range(N-1):
  if A[i]==A[i+1]:
    A[i+1]=0
    count +=1
print(count)

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if A[i]==A[i+1]:
    ans+=1
    A[i+1]=0
print(ans)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))
count = 0
INF = 10**9
for i in range(1,N):
  if a[i] == a[i-1]:
    a[i] = INF
    count += 1
print(count)

Solution (Python):
import sys
input = sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	n=int(input())
	vA=linput()
	
	res = 0
	pp = 0
	
	for a in vA:
		if pp==a:
			res += 1
			pp = 0
		else:
			pp = a
	
	
	
	print(res)

if __name__ == "__main__":
	main()

Solution (Python):
Num = int(input())
a = list(map(int, input().split()))
k = 0
for i in range(1, Num):
    if a[i-1] == a[i]:
        a[i] = 0
        k += 1
print(k)

Solution (Python):
from random import randint
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range (len(l)-1) :
  try:
    if l[i] == l[i + 1]:
        ans += 1
        l[i + 1] = randint(0, 10000)
  except:
    continue
print(ans)

Solution (Python):



n= int(input())
a = list(map(int, input().split()))
sum = 0

for i in range(n-1):
    if a[i] == a[i+1]:
        sum += 1
        a[i+1] = 1.36
print(sum)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=0
i=1
while i<n:
  if a[i]==a[i-1]:
    ans=ans+1
    i=i+1
  i=i+1
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
k = 0
for i in range(1, N):
    if A[i-1] == A[i]:
        A[i] = 0
        k += 1
print(k)

Solution (Python):
from numpy import random
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range (len(a) - 1) :
  if a[i] == a[i + 1]:
    b += 1
    a[i + 1] = random.randint(10000)
print(b)

Solution (Python):
from numpy import random
n = int(input())
a = list(map(int,input().split()))
b = 0
for i in range (len(a) - 1) :
  if a[i] == a[i + 1]:
    b += 1
    a[i + 1] = random.randint(10000)
print(b)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
x=a[0]
cnt=0
ans=0
for i in a:
  if x!=i:
    ans+=cnt//2
    cnt=1
    x=i
  else:
    cnt+=1
ans+=cnt//2
print(ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1,N):
    if A[i-1] == A[i]:
        A[i] = 0
        ans += 1
print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
a = LIST()

ans = 0
for i in range(1, N):
	if a[i] == a[i-1]:
		ans += 1
		a[i] = 0

print(ans)

Solution (Python):



def main():
    N = int(input())
    A = list(map(int, input().split()))

    ret = 0
    for i in range(1,N):
        if A[i]==A[i-1]:
            ret+=1
            A[i]=1000

    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    for i in range(1, N):
        if A[i] == A[i-1]:
            A[i] = 0
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
c = 1
ans = 0
prev = a[0]
for num in a[1:]:
    if num==prev:
        c += 1
    else:
        ans += (c//2)
        c = 1
    prev = num
ans += (c//2)
print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(1,N):
    if a[i-1] == a[i]:
        a[i] = 0
        cnt += 1
print(cnt)

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
A = IL()

ans = 0
count = 0
prev = None

for a in A:
  now = a
  if prev != now:
    ans += count//2
    count = 1
  else:
    count += 1
  prev = a
ans += count//2
  
  
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    prev = A[0]
    ans = 0
    for a in A[1:]:
        if prev == a:
            ans += 1
            prev = -1
        else:
            prev = a

    print(ans)


    

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
a = rl()
cnt = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1] = -1
        cnt += 1
print(cnt)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
before = 0
ans = 0
for num in a:
    if num == before:
        ans += 1
        before = 0
    else:
        before = num
print(ans)

Solution (Python):
n = int(input())
li = list(map(int,input().split()))
ans = 0
x = 0

for i in range(1,n):
    if li[i] == li[i-1]:
        x += 1
    else:
        ans += (x+1)//2
        x = 0

ans += (x+1)//2
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]==a[i+1]:
        ans+=1
        a[i+1]=(i+1)*-1
print(ans)

Solution (Python):
def solve():
    n = int(input())
    a = list(map(int, input().split()))
    cost = 0
    for i in range(n-1):
        if a[i] == a[i+1]:
            cost += 1
            a[i+1] = -1
    print(cost)
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
N = int(input())
an = [int(a) for a in input().strip().split()]
p = -1
ans = 0
for a in an:
  if a == p:
      ans += 1
      p = -1
  else:
      p = a

print(ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
num = 1000
ans = 0
for i in range(1, len(a)):
    if(a[i] == a[i - 1]):
        a[i] = num
        num += 1
        ans += 1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
i = 0
mae = 0
c = 0
while i < n:
  if mae == a[i]:
    c += 1
    mae = 0
  else:
    mae = a[i]
  i += 1
print(c)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x < N - 2:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
ans = 0

for i in range(1, n):
    if a[i] == a[i - 1]:
        ans += 1
        a[i] = 0

print(ans)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, n):
    if A[i] == A[i - 1]:
        ans += 1
        A[i] = i + 200
print(ans)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    before = -1
    cnt = 0
    ans = 0
    for a in A:
        if(before != a):
            ans += cnt//2
            cnt = 0
        cnt += 1
        before = a
    if(cnt):
        ans += cnt//2
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
*A, = map(int, input().split())
ans = 0
i = 1
while i < N:
    if A[i-1] == A[i]:
        ans += 1
        i += 2
    else:
        i += 1
print(ans)

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
x.append('?')
ch = 1
ans = 0
for i in range(1,n+1):
    if x[i]==x[i-1]:
        ch+=1
    else:
        ans+=ch//2
        ch=1
print(ans)

Solution (Python):
n = int(input())
a_list = list(map(int,input().split()))
ans = 0
check = a_list[0]
for i in range(1,n):
    if check == a_list[i]:
        a_list[i] = 10001
        ans += 1
    check = a_list[i]
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(len(a)-1):
    if(a[i] == a[i+1]):
        a[i+1]=-1
        ans+=1
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

b = 101
cnt = 0
for i in range(n-1):
	if a[i] == a[i+1]:
		cnt += 1
		a[i+1] = b
		b += 1
print (cnt)

Solution (Python):
n = int(input())
a = list(map(str, input().split()))

cnt = 0
for i in range(1, n):
    if a[i] == a[i - 1]:
        a[i] = -1
        cnt += 1
        
print(cnt)

Solution (Python):
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    vec =list(map(int, input().split())) 
    prev = -1
    cnt = 1
    ANS = 0
    for x in vec:
        if(prev == x):
            cnt += 1
        else:
            prev = x
            ANS += cnt//2
            cnt = 1
    
    ANS += cnt//2
    print(ANS)

if __name__ == '__main__':
    solve()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

ans=0
for i in range(n-1):
  if a[i]==a[i+1]:
    ans+=1
    a[i+1]=-1
print(ans)

Solution (Python):
n=int(input())

a = list(map(int,input().split()))

ans = 0

for i in range(1,n):
    if a[i-1] == a[i]:
        ans += 1
        a[i] = 'x'
print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(1,n):
    if(a[i] == a[i-1]):
        a[i] = 0
        ans += 1

print(ans)

Solution (Python):


N = int(input())
a = list(map(int,input().split()))
ans = 0
tmp = 1

for i in range(1,N):
    if a[i-1]==a[i]:
        tmp += 1
    else:
        tmp = 1
    ans += int(tmp%2==0)

print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

cnt = 0
last = 0
row = 0
for i in range(N):
    
    if(last == A[i]):
        row += 1
    elif(row > 0):
        cnt += int((row+1)/2)
        row = 0
    last = A[i]
    
cnt += int((row+1)/2)
print(cnt)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(1,N):
    if A[i-1] == A[i]:
        A[i] = 0
        ans += 1
print(ans)

Solution (Python):
n, *a = map(int, open(0).read().split())
a.append('*')
cnt = 0
tmp_cnt = 0
tmp = '*'
for i in range(n+1):
    if a[i] == tmp:
        tmp_cnt += 1
    else:
        cnt += tmp_cnt//2
        tmp = a[i]
        tmp_cnt = 1
print(cnt)

Solution (Python):
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product








import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    cnt=0
    gr = groupby(A)
    for key, group in gr: 
        """ex.
        0: [0, 0, 0]
        1: [1, 1]
        0: [0, 0, 0]
        1: [1, 1]
        0: [0]
        1: [1]
        """
        cnt+=len(list(group))//2

    
    print(cnt)
        
    


    
resolve()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1,n):
  if a[i-1] == a[i]:
    ans += 1
    a[i] = ""
print(ans)