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):
import numpy as np

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

a = np.array(a)
a = np.diff(a)
b = []
for i in range(n-1):
    if a[i] != 0:
        b.append(i)
if len(b)>1:
    b = np.array(b)
    b1 = np.diff(b)
    b1 = b1.tolist()
    c = [b1[i]//2 for i in range(len(b1))]
    sum = sum(c) - (-b[0]//2) - (b[-1] - n + 2)//2
elif len(b)==1:
    sum = - (-b[0] // 2) - (b[0] - n + 2)//2
else:
    sum = n//2
print(sum)

Solution (Python):
N = input()
list = list(map(int,input().split()))
l = [1]
j = 0

for i in range(1,len(list)):
 if list[i] == list[i - 1]:
  l[j] += 1
 else:
  l.append(1)
  j += 1
ans = 0
for u in range(0,len(l)):
 ans += int(l[u] / 2)

print(ans)

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

slimes_cp = slimes[:]
num_list = [i+1 for i in range(len(slimes))]
count = 0

for i in range(1, len(slimes_cp)):
    num_list = [i+1 for i in range(len(slimes))]
    
    if slimes_cp[i-1] == slimes_cp[i]:
        num_list.remove(slimes_cp[i-1])
        
        try:
            num_list.remove(slimes_cp[i+1])
            
            slimes_cp[i] = num_list[0]
        except:
            slimes_cp[i] = num_list[0]
            
        count+=1
        
print(count)

Solution (Python):
 

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

same = False
same_cnt = 0
cnt = 0
for i in range(0, N-1):

	if same == False:
		same_cnt = 0

	if aN[i] == aN[i+1]:
		same = True
		same_cnt += 1
		if i == N-2:
			cnt += (same_cnt + 1) // 2
			break
	else:
		same = False
		if same_cnt != 0:
		 	cnt += (same_cnt + 1) // 2

print(cnt)

Solution (Python):
from sys import stdin

n = stdin.readline()
n_i = int(n)

a = stdin.readline().rstrip().split()
a_list = list(a)

n_count = 0

if len(a_list) == 2 and a_list[0] == a_list[1] :
    print(n_count + 1)
else :
    for i in range(n_i):
        if i == n_i - 1 :
            break
        if a_list[i] == a_list[i + 1]:
            n_count = n_count + 1
            a_list[i + 1] = "X"

    print(n_count)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
output = 0
counter = 0
while n-1 > counter:
    if a[counter] == a[counter+1]:
        a[counter+1] = max(a)+1
        output += 1
    counter += 1
print(output)

Solution (Python):
n = int(input())
a_tmp = input().split()
a = []
ans = 0
for _ in a_tmp:
    a.append(int(_))
i = 0
same = 1
while i < n-1:
    tmp = a[i]
    i += 1
    if a[i] == tmp:
        same += 1
        if same == 3:
            ans += 1
            same = 1
    else:
        if same >= 2:
            ans += 1
            same = 1
if same >= 2:
    ans += 1

print(ans)

Solution (Python):


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

a=1
ans=0
for i in range(n):
    if i > 0:
        if s[i] == s[i-1]:
            a+=1
        else: 
            ans += a//2
            a=1
    if i==n-1 and  s[i] == s[i-1]:
            ans += a//2


print(ans)

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

Solution (Python):
import math
n = int(input())
a = list(map(int,input().split()))
i = 0
ans = 0
while i < n:
    var = a[i]
    sub = 1
    while i+1 < n:
        if a[i+1] == var:
            i += 1
            sub += 1
        else:
            break
    ans += math.floor(sub//2)
    i += 1
print(ans)

Solution (Python):
import math

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

cnt = 0
prog = 1
for i in range(n):
	if i > 0:
		if a[i] == a[i-1]:
			prog += 1
		elif prog > 1:
			cnt += math.floor(prog/2)
			prog = 1
		if i == n-1 and prog > 1:
			cnt += math.floor(prog/2)
print(cnt)

Solution (Python):
N = int(input())
A = [int(x) for x in input().split()]
A.append(-1)
start = 0
ans = 0
for i in range(N):
    if A[i] != A[i + 1]:
        ans += (i - start + 1) // 2
        start = i + 1
print(ans)

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
res = int()
co = 0
now = -1
flg = 0

while True:
    now += 1
    if now == n-1 and flg == 1:
        res += (co+1)//2
        break
    if now == n-1:
        break
    if l[now] == l[now+1]:
        co += 1
        flg = 1
        continue
    else:
        res += (co+1) // 2
        co = 0

print(res)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ans = 0
count = 1
for i in range(1, len(a)):
	if a[i] == a[i-1]:
		count += 1
		if i == len(a) - 1 and count > 2:
			ans += int(count / 2)
		elif i == len(a) - 1 and count == 2:
			ans += 1
	elif a[i] != a[i-1] and count == 2:
		ans += 1
		count = 1
	elif a[i] != a[i-1] and count > 2:
		ans += int(count / 2)
		count = 1
print(ans)

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
a.append(a[N-1]+1)
List = []
counter = 0
series = 0
while counter < N:
  if a[counter +1] == a[counter]:
    series += 1
  else:
    List.append(series)
    series = 0
  counter += 1
List2 = [(i+1)//2 for i in List]
print(sum(List2))

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

count=0
for i in range(len(l)-1):
    if i == len(l)-2:
        if l[i] == l[i+1]:
            l[i] = l[i]+1
            count=count+1
            break
    if l[i] == l[i+1]:
        if l[i+1]+l[i+2]< 10000:
            l[i+1] = l[i]+l[i+2]
        elif l[i+1] - l[i+2] > 0:
            l[i+1] = l[i]-l[i+2]
        else:
            l[i+1] = l[i]+1
        count=count+1
print(count)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
i=0
l=0
while True:
    if i>n-1:break
    j=i
    while j<n-1 and a[j+1]==a[j]:
        j+=1
    l+=(j-i+1)//2
    i=j+1
print(l)

Solution (Python):
if __name__ == '__main__':
    N = input()
    array = list(map(int, input().split()))

    old_color = array[0]
    count = 0

    for num in range(1, len(array)):
        color = array[num]
        if old_color == color:
            count += 1
            array[num] = -1
        old_color = array[num]
    print(count)

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

left = m[0]
ans = 0
for i in range(1,len(m)):
    if left == m[i]:
        ans += 1
        left = 0
    else:
        left = m[i]
        
print(ans)

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

magic_counter = 0
index = 1
while index <= N - 1:
    if array[index] == array[index - 1]:
        array[index] = -1
        magic_counter += 1
    index += 1

print(magic_counter)

Solution (Python):
n = int(input())
a = [i for i in map(int , input().split())]
cnt = [1 for i in range(n)]
j = 0

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


ans = 0
for i in range(j+1) :
    if cnt[i] != 1 :
        ans += cnt[i] // 2

print(ans)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
d = [(L[i+1]-L[i]) for i in range(len(L)-1)]
b = False
c = 0
ans = 0
for i in d:
    if i==0:
        b = True
    else :
        b = False
    if b:
        c += 1
    else :
        ans += (-(-c//2))
        c = 0
if b:
    ans += (-(-c//2))
print(ans)

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

count=0
p=1
while p<n:
    if a[p-1] == a[p]:
        try:
         if a[p-1] == a[p] == a[p+1]:
             a[p]=a[p-1]+a[p]+a[p+1]
             p+=1
             count+=1
         else:
             a[p]=a[p-1]+a[p]+a[p+1]
             p+=1
             count+=1
        except:
            if a[p-1]==a[p]:
                p+=1
                count+=1
    p+=1
print(count)

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

print(ans)

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

same = [a1 == a2 for a1, a2 in zip(a[:-1], a[1:])] + [False]
tmp = 0
ans = 0
for s in same:
  if s:
    tmp += 1    
  else:
    ans += (tmp + 1) // 2
    tmp = 0
print(ans)

Solution (Python):
N = int(input())
s = input().rstrip().split(' ')
a = list(map(int, s))
b = list(map(int, s))

a.insert(len(a),-1)
b.insert(0,-1)

c =[a[i]-b[i] for i in range(len(a))]

tmpall = []
tmp = []

for i in range(len(a)):
    if c[i] == 0:
        tmp.append(i)
    else:
        tmpall.append(tmp)
        tmp=[]


        

tout = [len(t) for t in tmpall]


S = 0
for kk in tout:
    S += kk//2  + kk%2

print(S)

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

Solution (Python):
def run():
	N = int(input())
	stock = 0
	ans = 0
	count = 0
	clr = [int(x) for x in input().split()]

	for i in clr:
		if stock == i:
			count += 1

		else:
			ans += count // 2
			count = 1
			stock = i

	ans += count // 2
	print(ans)



if __name__ == '__main__':
	run()

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

counter = 0
tsuzu = 0
for i,a in enumerate(a_list):
  if i <= n-2:
    if a == a_list[i+1]:
      if tsuzu == 0:
        tsuzu = 2
      else:
        tsuzu += 1
    else:
      counter += int(tsuzu/2)
      tsuzu = 0
  else:
    counter += int(tsuzu/2)
    tsuzu = 0

print(counter)

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

tmp_counter = 1
total_counter = 0
before_color =0
for color in color_list:
        if color == before_color:
            tmp_counter += 1
        else:
            total_counter += tmp_counter // 2
            tmp_counter=1         
        before_color = color
total_counter += tmp_counter // 2
        
print(total_counter)

Solution (Python):
a=int(input())
N=[0 for i in range(a)]
b=input()

N=b.split()
for i in range(a):
  N[i]=int(N[i])


  
a2ans=0
a2ans2=0
for i in range(a-1):
  if N[i]==N[i+1]:
    a2ans2+=1
    
  else :
    if a2ans2%2==1 :
      a2ans2+=1
    
    a2ans+=a2ans2/2
    a2ans2=0


if a2ans2%2==1 :
  a2ans2+=1

a2ans+=a2ans2/2
a2ans2=0



print(int(a2ans))

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

while i < N:
    hol = a[i]
    count = 1
    if i == N-1:
        break
    while hol == a[i+1]:
        count += 1
        i += 1
        if i == N-1:
            break
    i += 1
    ans += count//2
print(ans)

Solution (Python):
num_slimes = int(input())
input_line = input().split()

slimes = list(map(int, input_line))

emerged_slimes = []

past_color = slimes[0]
block = 0

for color in slimes:
    if past_color == color:
        block += 1
    else:
        emerged_slimes.append(block)
        past_color = color
        block = 1
else:
    emerged_slimes.append(block)

summon = 0
for element in emerged_slimes:
    if element > 1:
        summon += element // 2

print(str(summon))

Solution (Python):
n = int(input())
ai = list(map(int, input().split()))
ans = 0
tmp = 1
prev = 0
for a in ai:
    if prev == a:
        tmp += 1
    else:
        ans += tmp // 2
        tmp = 1
    prev = a
ans += tmp // 2
print(ans)

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

magic = 0
for i in range(len(a)):
    if i == 0:
        continue
    elif a[i] == a[i-1]:
        a[i]=0
        magic += 1

print(magic)

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

count = 0
odd = 1
b = -1
a.append(-1)
for i in a:
    
    if i == b and b != -1:
        odd += 1
    if i != b and b != -1:
        count += odd//2
        odd = 1
        
    b = i
    if i == -1:
        count += odd//2
    
print(count)

Solution (Python):
N = map(int, input())
a = list(map(int, input().split()))
all_set = set(range(1, 10000))

use_set = list(set(all_set - set(a)))

count = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        a[i+1] = use_set[0]
        use_set = use_set[1:]
        count += 1
    
print(count)

Solution (Python):
import math

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

renzoku=1
ans = 0


for i in range(len(a_list)):
  if i!=0:
    if(a_list[i]==a_list[i-1]):
      renzoku += 1
      if(i==len(a_list)-1):
        ans += math.floor(renzoku/2)
    else:
      if renzoku!=1:
        ans += math.floor(renzoku/2)
        renzoku=1


print(ans)

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

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(N-2):
    if a[i] == a[i+1]:
        if min(a[i],a[i+2]) != 0:
            a[i+1]=(max(a[i],a[i+2])+1)%10001
        else:
            if max(a[i],a[i+2]) <= 1:
                a[i+1] = 2
            else:
                a[i+1] = 1
        ans+=1
if a[N-2] == a[N-1]:
    ans+=1
print(ans)

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

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

count = 0
for i in range(N - 1):

  if slime_list[i] == slime_list[i + 1]:
    if slime_list[i + 1] > 0:
      slime_list[i + 1] = 0
    else:
      slime_list[i + 1] = 1
    count += 1

print(count)

Solution (Python):
def solution():
    n = int(input())
    arr = list(map(int, input().split()))
    res = 0
    index = 1
    while index < n:

        if arr[index] == arr[index - 1]:
            res += 1
            index += 2
        else:
            index += 1
    return res


print(solution())

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

s = 0
l = 1
for i in range(N):
	if a[i-1] == a[i] and i!= 0:
		l += 1
	else:
		s += (l-(l%2))//2
		l = 1

s += (l-(l%2))//2
print(s)

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

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

s = 0
for i in range(N-1):
    if a[i]==a[i+1] and a[i]*a[i+1]!=0:
        a[i+1]=0
        s=s+1

print(s)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counter %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))

Solution (Python):
N = int(input())
srimes = input().split(" ")

result = 0
before_srime = 0


for i, srime in enumerate(srimes):
    
    
    
    if before_srime == srime:
        
        result += 1
        before_srime = int(before_srime) + 10001
        continue
    before_srime = srime

print(result)

Solution (Python):
n = int(input())
a = input().split()
count = 0
for i in range(n - 1):
	if a[i] == a[i + 1]:
		if i + 1 < n - 1:
			if a[i] != 1 and a[i + 2] != 1:
				a[i + 1] = 1
				count += 1
			elif a[i] != 2 and a[i + 2] != 2:
				a[i + 1] = 2
				count += 1
			elif a[i] != 3 and a[i + 2] != 3:
				a[i + 1] = 3
				count += 1

		if i == n - 2:
			if a[i] == 1:
				a[i + 1] = 2
				count += 1
			else:
				a[i + 1] = 1
				count += 1

print(count)

Solution (Python):
n=int(input())
res=0
x=[]
for i in range(1,10001):
    x.append(i)
a=list(map(int,input().split()))
a_=list(set(x)-set(a))

c=a[0]
for i in range(1,n):
    b=a[i]
    if b==c:
        res+=1
        b=a_[i]
    c=b
print(res)

Solution (Python):
N = input()
data = input().split()
bef = -1
count = 0
result = 0

for i in range(len(data)):
	t = int(data[i])
	if bef != t:
		if count > 1:
			result += int(count / 2)
		count = 1
		bef = t
	else:
		count += 1

if count > 1:
	result += int(count / 2)
print(result)

Solution (Python):



N = int(input())
a = [int(t) for t in input().split()]
assert len(a) == N


sslen = [1]  
for i in range(1, len(a)):
    if a[i] == a[i-1]:
        sslen[-1] += 1
    else:
        sslen.append(1)

print(sum(l//2 for l in sslen))

Solution (Python):
n = int(input())
a = list(map(int, input().split(' ')))
a.append(-1)
lasti = -1
count = 0
result = 0
for i in a:
    if i == lasti:
        count += 1
    else:
        result += int((count + 1) / 2)
        count = 0
        lasti = i

print(result)

Solution (Python):
N = int(input())
a = list(map(int, input().split(" ")))
a_list = []

a_small = a[0]
for i in range(1, len(a)):
    a_large = a[i]
    if a_small == a_large:
        a_list.append(1)
    else:
        a_list.append(0)
    
    a_small = a_large

count = 0

i = 0
while i < len(a_list):
    if a_list[i] == 1:
        count += 1
        i = i + 2
    else:
        i = i + 1
print(count)

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] = 10001
        count+=1
    else:
        pass
print(count)

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

for i in range(len(colors)-1):
    if colors[i] == colors[i+1]:
        count += 1
        colors[i+1] = -1 * i

print(count)

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

ret = 0
num = -1
c = 0
for x in a:
	if num != x:
		ret += c // 2
		num = x
		c = 1
	else:
		c += 1

ret += c // 2

print(ret)

Solution (Python):

def main():
    n = int(input())
    a = list(map(int,input().split()))
    onaji =[]
    tmp = 0
    now = 0

    for i in range(n):

        if now == a[i]:
            tmp+=1
        else:
            onaji.append(tmp)
            tmp = 1
            now = a[i]

    onaji.append(tmp)

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


    print(ans)





if __name__ == "__main__":
        main()

Solution (Python):
_ = input()
slime = list(map(int,input().split()))
tmp = 0
con = 1
li = []
for s in slime:
    if tmp == s:
        con += 1
    else:
        if con != 1:
            li.append(con)
            con = 1
    tmp = s
else:
    if con != 1:
        li.append(con)
print(sum([l//2 for l in li]))

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]:
            add_num = a_list[i+1]
            while True:
                add_num += 1
                if add_num not in a_list:
                    a_list[i+1] = add_num
                    break
            cnt += 1
    
    print(cnt)
    


    

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
As = list(map(int, input().split())) + [0]

ans = 0
num = 1
aPrev = As[0]
for a in As[1:]:
    if a == aPrev:
        num += 1
    else:
        ans += num // 2
        num = 1
    aPrev = a

print(ans)

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

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

print(ans)

Solution (Python):


N = int(input())

a = [int(x) for x in input().split()]

colors = {}

l=[1 for _ in range(N)]

i=0
prev=0
flag=False
for n in a:
    if n==prev:
        flag=True
        l[i]+=1
    else:
        if flag:
            i+=1
            flag=False
    prev=n
    

count=0

for x in l:
    if x <= 1:
        break
    else:
        count+=x//2

print(count)

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

count=0
j=0
for i in range(n-1):
	if A[i]==A[i+1]:
		j += 1
	else:
		count += (j+1)//2
		j=0

count += (j+1)//2

print(count)

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

count = 1
colour = a[0]
magic = 0
a.append(-1)
for i in range(1,N+1):
    if a[i] == colour:
        count += 1
    else:
        magic += count//2
        count = 1
        colour = a[i]

print(magic)

Solution (Python):
def run(n, a):
    now = a[0]
    cnt = 0
    if n == 1:
        return 0
    i = 1
    while(True):
        if now == a[i]:
            cnt += 1
            i += 1
            if i >= n:
                return cnt
            now = a[i]
            i += 1
            if i >= n:
                return cnt
        else:
            now = a[i]
            i += 1
            if i >= n:
                return cnt


def read_line():
    n = int(input())
    a = list(map(int, input().split()))
    return (n, a)


def main():
    n, a = read_line()
    print(run(n, a))


if __name__ == '__main__':
    main()

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



i=0
t=0

while i < N-1:
    k=1
    s=0
    while line[i] == line[i+k]:
        s+=1
        if i+k+1 <= N-1:
            k+=1
        else:
            break
    t += (s+1) // 2
    i += k
    
print(t)

Solution (Python):

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


b = A[0]
cnt = 0
D = []
for i in range(N):
    if b != A[i]:
        D.append(cnt)
        b = A[i]
        cnt = 1
    else:
        cnt += 1
        b = A[i]        
D.append(cnt)
b = A[i]

re = 0
for val in D:
    re += val // 2

print(re)

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

result = 0
prev = -1
count = 1
for i in range(len(a)):
    if a[i] == prev:
        count += 1
        if i == N - 1:
            result += count // 2
    else:
        result += count // 2
        prev = a[i]
        count = 1

print(result)

Solution (Python):



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

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

Solution (Python):
N = int(input())
a = list(input().split())
counter = 1
old_a = 0
ref = 0
for i in range(len(a)):
    if i == 0:
        old_a = a[i]
    elif old_a == a[i]:
        counter +=1
        if i == len(a)-1:
            ref += int(counter /2)
    else:
        ref += int(counter /2)
        counter = 1
    old_a = a[i]
print(ref)

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

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

print(ct)

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

bs = []
temp = 0

for a in aas:
    if temp == a:
        bs[-1] = bs[-1]+1
    else:
        bs.append(1)
        temp = a


print(sum(map(lambda x:x//2,bs)))

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

A.append(0)
ans = 0
tmp = 1
tmp2 = 0
bef = A[0]
che = A[0]
for i in range(1,N):
    if A[i] == bef:
        tmp += 1
    else:
        bef = A[i]
        ans += tmp//2
        tmp = 1
ans += tmp//2
print(ans)

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
i=0
m=max(a)+1
c=0
while i+1<n:
    if a[i]==a[i+1]:
        a[i+1]=m
        m+=1
        c+=1
    i+=1
    
print(c)

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

ans = 0
tmp = -1
count = 1
for i in a:
    if(tmp == i): count += 1
    else:
        ans += count // 2
        count = 1
        tmp = i
ans += count // 2

print(ans)

Solution (Python):

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

ans = 0
previous = 0
same_count = 0
for i in range(N):
    if previous != a[i]:
        previous = a[i]
        if same_count != 0:
            ans += (same_count + 1) // 2
            same_count = 0
    else:
        previous = a[i]
        same_count += 1

    if i == N-1 and same_count != 0:
        ans += (same_count + 1) // 2

print(ans)

Solution (Python):
import math
n = int(input())
alst = list(map(int, input().split()))
lst = []
ind = 0
num = 0
while ind < n - 1:
  if alst[ind] == alst[ind + 1]:
    num += 1
  else:
    if num != 0:
      lst.append(num + 1)
    num = 0
  ind += 1
if num != 0:
  lst.append(num + 1)

ans = 0
for i in lst:
  if i % 2:
    ans += (i - 1) // 2
  else:
    ans += i // 2
print(ans)

Solution (Python):
input()
ip = input().split()
data = []
for i in ip:
    data.append(int(i))

buf = -1
enc = 0
for i in data:
    if buf == i:
        enc += 1
        buf = -1
    else:
        buf = i

print(enc)

Solution (Python):





def main(n, input_list):
    slime_list = []
    l = list(map(int, input_list.split(' ')))
    
    slime_list.append([l[0], 1])
    for i in range(1, len(l)):
        if l[i] == slime_list[-1][0]:
            slime_list[-1][1] += 1
        else:
            slime_list.append([l[i], 1])
    retval = 0
    for i in range(len(slime_list)):
        if 1 == slime_list[i][1] % 2:
            retval += (slime_list[i][1] - 1) / 2
        elif 0 == slime_list[i][1] % 2:
            retval += slime_list[i][1] / 2

    print(int(retval))

if __name__ == '__main__':
    try:
        n = int(input().strip())
        input_list = input().strip()
        main(n, input_list)
    except EOFError:
        pass

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

lst = []
c = 1
for i in range(n-1):
    if a[i+1]==a[i]:
        c+=1
    else:
        lst.append(c)
        c = 1
if c > 1: lst.append(c)

ans = 0
for c in lst:
    ans += int(c/2)
print(ans)

Solution (Python):





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

count = 0
last = 101
for a in A:
    if last == a:
        count += 1
        last = 101
    else:
        last = a
print(count)

Solution (Python):
N = int(input())
a = list(map(int, input().split())) + [-1]

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

print(ans)

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

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

front = array[0]
count = 0
length = len(array)
for i in range(1, len(array)):
    if front == array[i]:
        array[i] = length
        length -= 1
        count += 1
    front = array[i]
print(count)

Solution (Python):

def main():
    n = int(input())
    a = [int(i) for i in input().split()]

    s = max(list(set(a))) + 1
    
    c = 0
    for i in range(1, n):
        if a[i-1] == a[i]:
            c += 1
            a[i] = s
            s += 1

    print(c)
            
if __name__ == '__main__':
    main()

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

count = 0

color = list(map(int, input().split(" ")))
  
for i in range(N - 1):
  if color[i+1] == color[i]:
    color[i+1] += 10000
    count += 1
  
print(count)

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

ans = 0
seq = 1

for i in range(1,N):
  if a[i] == a[i-1]:
    seq += 1
  else:
    ans += seq // 2
    seq = 1
ans += seq // 2

print(ans)

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

count = 0
prev = 0

for a in a_list:
  if prev == a:
    count += 1
    prev = 0
    continue
  else:
    prev = a
    continue

print(count)

Solution (Python):
N  = int(input())
a = [int(i) for i in input().split()]
a.append(N+1)
dupe = []

temp = 1
for i in range(N):
    if a[i] == a[i+1]:
        temp += 1
    elif temp != 0:
        dupe.append(temp)
        temp = 1

b = [int(i/2) for i in dupe]
print(sum(b))

Solution (Python):

import math

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

for i,a in enumerate(A):
    if i > 0:
        if a == A[i-1]:
            cont+=1
            if i != int(N) - 1:
                if (a+1) == A[i+1]:
                    A[i] = a+2
                else:
                    A[i] = a+1

print(cont)

Solution (Python):




def main():
    N = int(input())
    A = list(map(int, input().split()))
    ANS = 0
    i = 0
    while i + 1 < N:
        if A[i] == A[i + 1]:
            ANS += 1
            i += 1
        i += 1
    print(ANS)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
lines = input().split()
result = 0
for i in range(n-1):
    if lines[i] == lines[i+1]:
        lines[i+1]=int(lines[i])+1
        result+=1
print(result)

Solution (Python):
import math
N =int(input())

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

count=0
flag=False
for i in range(N):
    if i != 0:
        if li[i] == li[i - 1]:
            if flag==False:
                count += 1
                flag = True
            else:
                flag = False
        else:
            flag=False
        
print(count)

Solution (Python):
a = int(input())
b = list(map(int,input().split()))
c = [1]
j = 0
su = 0
for i in range(1,a):
	if b[i] == b[i-1]:
		c[j] += 1
	else:
		c.append(1)
		j += 1

for i in c:
	su += i //2

print(su)

Solution (Python):
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    b = 0
    c = 0
    d = 0
    for a in A:
        if a == b:
            c += 1
        if a != b:
            d += c//2
            b = a
            c = 1
    d += c//2
    b = a
    c = 0
    print(d)
    

if __name__ == '__main__':
    solve()

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

bef = 100000
count = 1
ans = 0

for a in A:
    
    
    if bef == a:
        count += 1
    else:
        ans += count // 2
        count = 1
        bef = a

ans += count // 2

print(ans)

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

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

time = 0

change = 0
k = 100000
for i in range(N):
  if k == slime[i]:
    change += 1
  else:
    time += (change+1) // 2
    change = 0
  k = slime[i]
time += (change+1) // 2
print(time)

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

b = []
memo = a[0]
count = 0
for i in range(n):
    if a[i] == memo:
        count += 1
        if i == n-1:
            b.append(count)
    else:
        b.append(count)
        memo = a[i]
        count = 1


ans = 0
for j in b:
    ans += (j//2)

print(ans)