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: Wrong Answer

Solution code:
n=int(input())
a=[]
a=list(map(int,input().split()))
ans=0
flag=0
changeflag=[]
changeflag.append(0)
for i in range(n-1):
    if a[i]==a[i+1]:
        if i==0:
            changeflag.append(1)
            ans+=1
        elif i != 0 and changeflag[i-1]==1:
            changeflag.append(0)
        else:
            ans+=1
            changeflag.append(1)
    else:
        changeflag.append(0)
print(ans)

Submission status: Wrong Answer

Solution code:
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 += count - 2
		count = 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[]
a=input().split()
sum=0

for i in range (1,N-2):
  if a[i-1]==a[i] or a[i+1]==a[i]:
    i=i+1
    sum=sum+1

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
print(a//2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(1,n-1):
    if a[i]==a[i-1] and a[i]==a[i+1]:
        a[i]+=331
        c+=1
    elif a[i]==a[i-1]:
        a[i]+=225
        if a[i]==a[i+1]:
            a[i]+=1
        c+=1
    elif a[i]==a[i+1]:
        a[i+1]+=113
        if i+2<n and a[i+1]==a[i+2]:
            a[i+1]+=1
        c+=1
print(c)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    l = a[0]
    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        r = a[idx + 1]
        if x != l and x != r:
            l = x
            continue
        if (idx + 3) < len(a):
            if x == r == a[idx + 2] and x != a[idx + 3]:
                l = x
                continue
        elif (idx + 2) < len(a):
            if x == r == a[idx + 2]:
                l = x
                continue
        x = get(l, r)
        count += 1
        l = x
        a[idx] = x
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(1,n-1):
    if a[i]==a[i-1] and a[i]==a[i+1]:
        a[i]+=331
        c+=1
    elif a[i]==a[i-1]:
        a[i]+=225
        c+=1
    elif a[i]==a[i+1]:
        a[i+1]+=113
        c+=1
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
    if a[i] == a[i-1] and a[i] == a[i+1]:
        a[i]+=334
        c+=1
    elif a[i] == a[i-1]:
        a[i]+=222
        c+=1
    elif a[i] == a[i+1]:
        a[i+1]+=113
        c+=1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
    if a[i] == a[i-1] and a[i] == a[i+1]:
        a[i]+=300
        c+=1
    elif a[i] == a[i-1]:
        a[i]+=222
        c+=1
    elif a[i] == a[i+1]:
        if i+2<n and a[i+1]==a[i+2]:
            a[i+1]+=111
            c+=1
        else:
            a[i+1]+=333
            c+=1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(1,n-1):
    if a[i] == a[i-1] and a[i] == a[i+1]:
        a[i]+=300
        c+=1
    elif a[i] == a[i-1]:
        a[i]+=222
        c+=1
    elif a[i] == a[i+1]:
        if i+2<n and a[i]==a[i+2]:
            a[i+1]+=111
            c+=1
        else:
            a[i+1]+=333
            c+=1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

result = 0
before_srime = 0
flag = False

# 右隣にあるものが同じかどうかを判定
for i, srime in enumerate(srimes):
    
    # if i > 1:
    print("i : {}, srime : {}, before_srime : {}".format(i, srime, before_srime))
    if before_srime == srime:
        print("HIT!!!!!!!!!")
        result += 1
        before_srime = int(before_srime) + 10001
        continue
    before_srime = srime

print(result)

Submission status: Wrong Answer

Solution code:
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
			print(result)
		count = 1
		bef = t
	else:
		count += 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
count = 0
for i in range(n - 1):
	if a[i] == a[i + 1]:
		if i + 1 < n - 2:
			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)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
output = 0
counter = 0
while n > counter:
    if counter == n:
        break
    if a[counter] == a[counter-1]:
        output += 1
        a[counter] = str(counter*-1)
    counter += 1
print(output)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

sum = 0
if(slime[0] == slime[1]):
	sum += 1
	slime[1] = slime[1]+ 1 if (n > 3 and slime[2] != slime[1] + 1) else slime[1]-1
for i in range(1,n-1):
	if(slime[i] == slime[i+1]):
		slime[i+1] = slime[i-1]
		sum+=1
print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 += 2
    else:
        index += 1

print(magic_counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

cnt = 0
for i in range(1, N-1):
	if aN[i] == aN[i-1] or aN[i] == aN[i-1]:
		cnt += 1
		if aN[i] == aN[i-1]:
			for j in range(1, 10001):
				if j != aN[i-1] and j != aN[i+1]:
					aN[i] = j
					break
		if aN[i] == aN[i+1]:
			for j in range(1, 10001):
				if j != aN[i-1] and j != aN[i+1]:
					aN[i] = j
					break
print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split()
count = 0
for i in range(n - 1):
	if a[i] == a[i + 1]:
		if i + 1 < n - 2:
			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
				flag = 1
			else:
				a[i + 1] = 1
				count += 1
				flag = 1

print(count)

Submission status: Wrong Answer

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

count = 0
prev = 0

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

print(count)

Submission status: Wrong Answer

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:
  ans += math.ceil(i / 3)
print(ans)

Submission status: Wrong Answer

Solution code:
_ = 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
print(sum([l//2 for l in li]))

Submission status: Wrong Answer

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)

ans = 0
for i in lst:
  ans += math.ceil(i / 3)
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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-1):
    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: Wrong Answer

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lis = list(map(int,input().split()))
l = []
i = 0
x = 0
while(True):
  if i == N-1:
    x += 1
    l.append(x)
    break
  if lis[i] != lis[i+1]:
    x += 1
    l.append(x)
    x = 0
  else:
    x += 1
s = 0
for i in lis:
  s += (i//2)
print(s)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lis = list(map(int,input().split()))
l = []
i = 0
x = 0
while(True):
  if i == N-1:
    x += 1
    l.append(x)
    break
  if lis[i] != lis[i+1]:
    x += 1
    l.append(x)
    x = 0
  else:
    x += 1
s = 0
for i in lis:
  s += (i//1)
print(s)

Submission status: Accepted

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

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]:
    A[i+1] = -1
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import math
# import statistics
# import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# N,S,T= map(int,input().split())
f = list(map(int,input().split()))
# g = [int(input()) for _ in range(N)]
# h = []
# for i in range(a):
#     h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
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)

Submission status: Accepted

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

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]=0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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]:
        a[i+1] = 0
        ans += 1
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]:
    A[i+1]=max(A)+1
    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env 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)

Submission status: Accepted

Solution code:
#!/usr/bin/env 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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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