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

    count = 0
    if N == 2:
        if a[0] == a[1]:
            count += 1
    else:
        for i, x in enumerate(a[1:-1]):
            idx = i + 1
            l = a[idx - 1]
            r = a[idx + 1]
            if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
                x = get(l, r)
                count += 1
                a[idx] = x
        # print(a)
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

li_int = [int(i) for i in range(1, 10001)]

li_use = set(li_int) - set(a)
li_use = list(li_use)

ans = 0

for j in range(len(a)-1):
    if a[j] == a[j+1]:
        a[j+1] = li_use[j]
        ans += 1
        li_use.remove(li_use[j])
else:
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=input()
a=map(int,raw_input().split())
ans=0
eq=0
for i in xrange(n):
	if i!=0 and a[i]!=a[i-1]:
		eq=0
	eq+=1
	if eq%2==0:
		ans+=1
print ans

Submission status: Accepted

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


mag = 0
con = 1
for i in range(1, n):
    #print(mag, con)
    if A[i-1] == A[i]:
        con += 1
    else:
        mag += con // 2
        con = 1
mag += con // 2
print(mag)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
a = input().split()
ans = 0
ci = -2
t = 1
for i in range(0,N):
	a[i] = int(a[i])
a.append(0)
for i in range(0,N):
	if a[i]==a[i+1]:
		ci = i
		t += 1
	if a[i]!=a[i+1]:
		if ci == i-1:
			ans += int(t/2)
			t = 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
a=[]
a=input().split()
sum=0
 
for i in range (1,N):
  if a[i-1]==a[i]:
    a[i]=i+10001
    sum=sum+1
 
print(sum)

Submission status: Accepted

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

# 何回変えるか
count = 0

i = 0

while i < N - 1:
    j = 1
    while A[i + j] == A[i]:
        j += 1
        if i + j > N-1:
            break

    count += int(j / 2)
    i = i + j

print(count)

Submission status: Accepted

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

pre = -1
num = 1
ans = 0
for i in a:
	if pre == i:
		num += 1
	else:
		ans += num // 2
		num = 1
	pre = i
ans += num // 2
print(ans)

Submission status: Accepted

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

change_cnt_fron_right = 0
change_cnt_fron_left = 0

for i in range(n-1):
    if a_list[i] == a_list[i+1]:
        change_cnt_fron_right += 1
        a_list[i + 1] = 0
        #print(a_list)

print(change_cnt_fron_right)
# print(min(change_cnt_fron_left, change_cnt_fron_right))

Submission status: Accepted

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

a.append(999)
magic = 0
series = 1
prev=0
for x in a:
#     print('prev:{} current:{}'.format(prev,x))
    if prev>0:
        if prev==x:
            series+=1
#             print('series:',series)
        else:
            magic+=int(series/2)
            series=1
#             print('magic:',magic)
    prev=x
print(magic)

Submission status: Accepted

Solution code:
import random
N = int(input())
cnt = 0
slime = list(map(int,input().split()))
for i in range(N):
  try:
    if slime[i]==slime[i+1]:
      cnt+=1
      while slime[i]==slime[i+1]:
        slime[i+1]=random.randint(1,10000)
  except IndexError:
    break;

print(cnt)

Submission status: Accepted

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

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        a[0] = a[1]+1
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = input().split()
prev = 0
flag = False
result = 0
for i in l:
    if flag == False and i == prev:
        flag = True
        result += 1
    elif flag == True:
        flag = False
    prev = i
print(result)

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split())
ans = 0
pr = 0
cnt = 0
for i in a:
 if i==pr:
  cnt+=1
 else:
  ans += cnt/2
  cnt = 1
 pr = i
ans += cnt/2
print ans

Submission status: Accepted

Solution code:
N = int(input())

a = [int(i) for i in input().split()]
b = -1
count = 0
ans = 0
for a_ in a:
    if b == a_:
        count += 1
    else:
        ans += count //2
        count = 1
    b = a_

ans += count //2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
num = int(raw_input())
num_li = list(map(int,raw_input().split()))
li = []
t  = -1
answer = 0
for i in range (num):
    if t != num_li[i]:
        li.append(1)
        t = num_li[i]
    else:
        li[-1] += 1
        t = num_li[i]
for i in li:
    answer += i//2
print answer

Submission status: Accepted

Solution code:


def solve():
    N = int(input())
    arr = list(map(int, input().split()))
    arr.append(0)

    i = 0
    magic_cnt = 0
    while i < N:
        adj_cnt = 1
        while i < N and arr[i] == arr[i + 1]:
            i += 1
            adj_cnt += 1
        magic_cnt += int(adj_cnt / 2)
        i += 1
    print(magic_cnt)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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
if same >= 2:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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(a,ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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 += int(count / 2)
		count = 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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
if b:
    ans += (-(-c//2))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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=[]

# print(tmpall)
        

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


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

print(S)

Submission status: Accepted

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
if a[n-1] == a[n-2]:
        counter += 1
print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
N=[0 for i in range(a)]
b=input()
#print(b)
N=b.split()
for i in range(a):
  N[i]=int(N[i])

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


if a2ans2%2==1 :
  a2ans2+=1
#print(a2ans2)
a2ans+=a2ans2/2
a2ans2=0



print(int(a2ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split(" ")))
#print(a)
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)

Submission status: Accepted

Solution code:
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
        #print(a)
    b = i
    if i == -1:
        count += odd//2
    #print(i,b,odd,count)
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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]:
        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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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
#	print((i,a[i],l,s))
s += (l-(l%2))//2
print(s)
#print((i,a[i],l,s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

result = 0
before_srime = 0

# 右隣にあるものが同じかどうかを判定
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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

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

# 同じ値が何個並んでいるか
sslen = [1]  # a[0]
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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
else:
    if con != 1:
        li.append(con)
print(sum([l//2 for l in li]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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)

Submission status: Accepted

Solution code:
n = int(input())						# 5
A = list( map(int, input().split()) )	# 1 2 3 4 5 ...

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#print(N,line)

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)