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



Sample input:
5
1 1 2 2 2


Sample output:
2

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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(a)
print(c)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8
#


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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# A - Colorful Slimes 2
# https://beta.atcoder.jp/contests/agc026/tasks/agc026_a

# A_Colorful_Slimes_2.py

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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:

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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
#coding: UTF-8
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)

Submission status: Accepted

Solution code:
#!python
# -*- coding: utf-8 -*-


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()

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

bef = 100000
count = 1
ans = 0

for a in A:
    # print("ans = %d" % ans)
    # print("now is %d" % a)
    if bef == a:
        count += 1
    else:
        ans += count // 2
        count = 1
        bef = a

ans += count // 2

print(ans)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
n=int(input())
arr = list(map(int,input().split()))
cur = 0
seq=1
ans=0
for i in range(n):
    if cur==arr[i]:
        seq+=1
    else:
        cur=arr[i]
        ans+=seq//2  
        seq=1
else:
    ans+=seq//2
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
from copy import deepcopy

n=int(input())
a=list(map(int,input().split()))
c=0
j=0
for i in range(0,n-1):
    if(j>=n-1):break
    if(a[j]==a[j+1]):
        c+=1
        j+=2
        continue
    j+=1
print(c)

Submission status: Accepted

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

res = 0
cnt = 1
prev = A[0]
for idx in range(1, N):
    if A[idx] == prev:
        cnt += 1
    else:
        cnt = 1
    if cnt > 1:
        cnt = 0
        res += 1
    prev = A[idx]

print(res)

Submission status: Accepted

Solution code:
import sys
import socket

if socket.gethostname() in ['N551J', 'F551C']:
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve():
    n = read_int()
    a = read_int_list()
    res = 0
    i = 0
    while i < n:
        j = i + 1
        while j < n and a[j - 1] == a[j]:
            j += 1
        l = j - i
        res += l // 2
        i = j
    return res


def main():
    res = solve()
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
res = 0

def plus(n):
    if n == 1:
        return 0
    elif n <= 3:
        return 1
    else:
        return n // 2

tmp=1
for i in range(1,N):
    if a[i-1] == a[i]:
        tmp += 1
    else:
        res += plus(tmp)
        tmp = 1
res += plus(tmp)


print(res)

Submission status: Accepted

Solution code:
N=input()
A=map(int,raw_input().split())

ans=0
prev=""

for x in A:
	if prev==x:
		ans+=1
		prev=-1
	else:
		prev=x

print ans

Submission status: Accepted

Solution code:
n = int(input())
list = list(map(int, input().strip().split()))
list.append(10001)
list.append(10002)
count = 0
i = 0
while i < n:
    if list[i] == list[i + 1] and list[i + 1] and list[i + 2]:
        count += 1
        i += 2
        continue
    elif list[i] == list[i + 1]:
        count += 1
    i += 1
print(count)

Submission status: Accepted

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

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

ans = 0
for i in range(len(sequence)):
    ans += (sequence[i] // 2)

print(ans)

Submission status: Accepted

Solution code:
from math import floor
N = int(input())
a = list(map(int,input().split()))
a.append(0)
s = 0
S = 0
ans = 0
for i in range(N+1):
    if a[i] != s:
        s = a[i]
        ans += floor((S+1)/2)
        S = 0
    else:
        S += 1
print(ans)

Submission status: Accepted

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

ans = 0
res = 1

for i in range(N-1):
    if A[i+1] != A[i]:
        ans += res//2
        res = 1
        
    else:
        res += 1
        
ans += res//2

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(_) for _ in input().split()]

result = 0
flag = False
for i in range(1,n):
  if flag == True:
    flag = False
    continue
  if a[i-1] == a[i]:
    result += 1
    flag = True

print(result)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
counter = 0
i = 1
while i < n-1:
	if a[i-1] != a[i] and a[i] != a[i+1]:
		i += 2
	elif a[i-1] == a[i] == a[i+1]:
		counter += 1
		i += 2
	elif a[i] == a[i+1]:
		i += 1
	elif a[i-1] == a[i]:
		i += 1
		counter += 1
if i == n-1:
	if a[i] == a[i-1]:
		counter += 1
print(counter)

Submission status: Accepted

Solution code:
#coding:utf-8

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

cnt = 0
Q = [string[0]]
for i in range(1,n):
    if Q[0] == string[i]:
        Q.append(string[i])
    else:
        cnt += len(Q) //2
        Q = [string[i]]

cnt += len(Q) // 2

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

i = 0
ans = 0

while i < N - 1:
    if A[i + 1] == A[i]:
        if i < N - 2:
            A[i + 1] == A[i] + A[i + 2]
        if i == N - 1:
            A[i + 1] += 1
        i += 1
        ans += 1
    i += 1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = 0
c = 0
for i in a:
  if b == i:
    c += 1
    b = 0
  else:
    b = i

print(c)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.append(0)

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

print(ans)

Submission status: Accepted

Solution code:
_ = input()
aa = list(map(int, input().split()))

prev = aa[0]
cnt = 1
ops = 0
for a in aa[1:]:
    if a == prev:
        cnt += 1
    else:
        ops += cnt // 2
        cnt = 1
    prev = a

ops += cnt // 2

print(ops)

Submission status: Accepted

Solution code:
N=int(input())

a=list(map(int,input().split()))
count=1
countlist=[]

for i in range(1,N):
  if a[i]==a[i-1]:
    count+=1
    if i==N-1:
      countlist.append(count)
  else:
    countlist.append(count)
    count=1

if countlist==[]:
  print(0)
  exit()

answer=0
for i in range(len(countlist)):
  answer+=(countlist[i])//2
print(answer)

Submission status: Accepted

Solution code:

N = int(raw_input())
a = map(int,raw_input().split())

same_color_list = []
same=1

for i in range(N):
    if i != 0:
        if a[i] == a[i-1]:
            same+=1
        else:
            if same!=1:
                same_color_list.append(same)
                same=1
if same!=1:
    same_color_list.append(same)

count = 0
for same in same_color_list:
    count += same/2

print count

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
L = []
c = 0
for i in range(N - 2):
	if a[i] == a[i + 1]:
		c += 1
	else:
		L.append(c + 1)
		c = 0
if a[N - 2] == a[N - 1]:
		c += 1
L.append(c + 1)

s = 0
for i in L:
	s += i // 2
print(s)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

count = 0
i = 0
while i < N - 1:
    if A[i] == A[i+1]:
        count += 1
        i += 1
    i += 1

print(count)

Submission status: Accepted

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

ans = 0

count = 1
pre_num = a[0]
for i in range(1, len(a)):
    if a[i] == pre_num:
        count += 1
    else:
        ans += count // 2
        count = 1
        pre_num = a[i]
ans += count // 2
print(ans)

Submission status: Accepted

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

ans = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        ans += 1
        a[i+1] = (a[i+1] + 1) % 10000
        if i != (n-2) and a[i+1] == a[i+2]:
            a[i+1] = (a[i+1] + 1) % 10000

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int, input().split()))
suc = []
point = A[0]
count = 1
for i in range(1,N):
    if A[i] == point:
        count += 1
    else:
        suc.append(count)
        count = 1
        point = A[i]
suc.append(count)
ans=0
for x in suc:
    ans += x//2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a_list = [int(i) for i in input().split()]

ans = 0
tmp = 0
before = 0
a_list.append(100000)

for a in a_list:

    if a == before:
        tmp += 1
    elif tmp > 0:

        ans += (tmp+1) // 2
        tmp = 0
    before = a
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
stan = A[0]
ans = 0
k = 0
for i in range(1,N):
    if stan == A[i]:
        ans += 1 + k
        k = -((k-1)%2)
    else:
        k = 0
    stan = A[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = [int(i) for i in list(input().split())]
same_flag = False
cnt = 0
for i, color in enumerate(a):
    if i == 0:
        tmp = color
    else:
        if same_flag:
            cnt += 1
            same_flag = False
            tmp = color
        else:            
            if color == tmp:
                same_flag = True
                tmp = color
            else:
                tmp = color
if same_flag:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
input()
cnt=0
now=0
res=0
for a in map(int,input().split()):
    if a==now:
        cnt+=1
    else:
        res+=cnt//2
        cnt=1
    now=a
print(res+cnt//2)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]

i=0
count=0
while(i < N-1):
    if A[i] == A[i+1]:
        count+=1
        i+=2
    else:
        i+=1
print(count)

Submission status: Accepted

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

cnt = 0

al = False
for i, a in enumerate(a_list):
    if i == 0:
        pre = a
    else:
        if a == pre:
            if not al:
                al = True
                cnt += 1
            else:
                al = False
        else:
            al = False
            
        pre = a
        
print(cnt)

Submission status: Accepted

Solution code:
def LI(): return list(map(int, input().split()))
n = int(input())
a = LI()
cnt = 0
tmp_cnt = 1
start = a[0]
for i in range(1, n):
    if a[i] != start:
        start = a[i]
        cnt += tmp_cnt//2
        tmp_cnt = 1
    else:
        tmp_cnt += 1
cnt += tmp_cnt // 2
print(cnt)

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-


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

    idx, t = 0, 0
    while idx < n:
        cnt = 1
        while idx < n-1 and a[idx] == a[idx+1]:
            cnt += 1
            idx += 1
        t += cnt // 2
        idx += 1

    print(t)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import groupby

if __name__ == "__main__":
    n = int(input())
    xs = [int(s) for s in input().split()]
    ans = sum(length // 2 for length in [len(list(l)) for t, l in groupby(xs)])
    print(ans)

Submission status: Accepted

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

spell_cnt = 0
spelled = False
for i, color in enumerate(a[1:]):
    # print(a[i], color, spelled)
    if a[i] == color and not spelled:
        # print(i)
        spell_cnt += 1
        spelled = True
    else:
        spelled = False

print(spell_cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

n = int(input().strip())
an = map(int, input().strip().split(' '))

cnt = 0
b_a = None
for a in an:
    if a == b_a:
        cnt += 1
        b_a = None
    else:
        b_a = a

print(cnt)

Submission status: Accepted

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

counter = 0
cont = 1
prev = -1

for a in A:
    if a == prev:
        cont += 1
    else:
        counter += cont // 2
        cont = 1
    prev = a

counter += cont // 2

print(counter)

Submission status: Accepted

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
result = 0
prev = a[0]
change = False
for i in range(1, N):
	if prev == a[i] and not change:
		result += 1
		change = True
	else:
		change = False
	prev = a[i]
print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
L = len(a)

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().strip().split()))
cnt=0
i=0
while i<n-1:
    if l[i]==l[i+1]:
        cnt+=1
        i+=2
    else:
        i+=1

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
s=input().split()
l=[None]*n
for i in range(n):
    l[i]=int(s[i])
res=0
i=1
while True:
    if i>=n:
        break
    if l[i-1]==l[i]:
        res+=1
        i+=1
    i+=1
print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=input()
L=L.rstrip().split(" ")
list1=[]
for i in range(N):
    list1.append(int(L[i]))
#print(list1)
count=0
for j in range(1,N):
    if list1[j]==list1[j-1]:
        count+=1
        list1[j]=-1
#print(list1)
print(count)

Submission status: Accepted

Solution code:
import numpy as np

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

a = np.array(a)

b = 1000

k = 0
for k in range(len(a)-1):
    temp = a[k]
    if a[k+1] == temp:
        a[k+1] = b
        b += 1


print(b - 1000)

Submission status: Accepted

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

ans = 0
idx = 1
while (idx < n):
    if a[idx] == a[idx-1]:
        ans += 1
        idx += 2
    else:
        idx += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
dif = []
a = list(map(int,input().split()))
bef = a[0]
for i,j in enumerate(a):
    if i==0:
        bef = j
        sum = 1
    elif j==bef:
        sum += 1
    else:
        dif.append(sum)
        sum = 1
        bef = j
dif.append(sum)

res = 0
for i in dif:
    res += i//2
print(res)

Submission status: Accepted

Solution code:
n = int(input())
array = [int(x) for x in input().split()]
array.append(0)

tmp = array[0]
cnt = []
cnt_tmp = 0
for i in array:
    if tmp == i:
        cnt_tmp += 1
    else:
        cnt.append(cnt_tmp)
        tmp = i
        cnt_tmp = 1

res = 0
for i in cnt:
    if i != 1:
        if i %2:
            res += i//2
        else:
            res += i//2
print(res)

Submission status: Accepted

Solution code:
N = int(input())
lis = [int(i) for i in input().split()]
i = 0
same = 1
ans = 0
while i < N-1:
  if lis[i] == lis[i+1]:
    same += 1
  else:
    ans += same//2
    same = 1
  i += 1
ans += same//2
print(ans)

Submission status: Accepted

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

ans = 0
pre = 0
for i in a:
        if i == pre:
                ans += 1
                pre = 0
        else:
                pre = i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
s = A[0]
c = 1
ans = 0
for a in A[1:]:
    if a == s:
        c += 1
    else:
        ans += c//2
        s = a
        c = 1
ans += c//2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int,input().split()))
count = 0

for i in range(0,N-1):
    if L[i] == L[i+1]:
        L[i+1] = 101
        count += 1

print(count)

Submission status: Accepted

Solution code:
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

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

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

main()

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
count = 0
conti = 0
last = None
for _ in A:
    if _ == last:
        conti += 1
        if conti % 2 == 1:
            count += 1
    else:
        conti = 0
    last = _
print(count)

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split())
magic = 0
seq = 1
pre_a = 0
for a in A:
  if a == pre_a:
    seq += 1
  else:
    magic += seq // 2
    seq = 1
  pre_a = a
magic += seq // 2
print(magic)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=[int(x) for x in input().split()]

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

Submission status: Accepted

Solution code:
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] = 1000000
print(ans)

Submission status: Accepted

Solution code:
def main():
    input()
    cc = map(int, raw_input().split())
    s = 0
    pre = -1
    cont = 0
    for c in cc:
        if c == pre:
            cont += 1
        else:
            s += cont / 2
            pre = c
            cont = 1
    s += cont / 2
    print s


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
gou = 0
j=1
for i in range(1,len(a)):
  i=j
  if j >= len(a):
    break
  if a[i-1] == a[i]:
    gou += 1
    j = i+2
  else:
    j = i+1
print(gou)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
same = 1
front = a[0]
for i in range(1, n):
    temp = a[i]
    if temp == front:
        same += 1
    else:
        ans += same // 2
        front = temp
        same = 1
else:
    ans += same // 2

print(ans)

Submission status: Accepted

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

num=1
score=0
for i in range(1,N+1):
    if slime[i]==slime[i-1]:
        num+=1
    else:
        score+=num//2
        num=1

    #print(score,num)

print(score)

Submission status: Accepted

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

ans = 0
tmp = 0
prev = -1
for a in A:
  if a == prev:
    tmp += 1
  else:
    ans += tmp // 2
    tmp = 1
  prev = a
ans += tmp // 2
print(ans)

Submission status: Accepted

Solution code:
#! /usr/bin/env python3

n = int(input())

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

res = 0

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

print(res)

Submission status: Accepted

Solution code:
N=int(input())

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

prev = 10001
count = 0

for i in range(N):
  if prev == li[i]:
    count += 1
    prev = 10001
  else:
    prev = li[i]
    
print(count)

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().strip())
li = list(map(int, stdin.readline().split()))

ans = 0
p = 0
cnt = 1
for i in range(n):
    if li[i]!=p:
        ans += cnt // 2
        p = li[i]
        cnt = 1
    else:
        cnt += 1
ans += cnt // 2

print(ans)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = input().rstrip().split(' ')
    N = int(N[0])
    line = input().rstrip().split(' ')
    count = 0
    skip_flag = False
    for i in range(len(line)-1):
        if skip_flag:
            skip_flag = False
            continue
        if line[i] == line[i+1]:
            count += 1
            skip_flag = True
    print(count)