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:
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:50:41 2019

@author: shinjisu
"""

#import numpy as np
#import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]

def zeros(n): return [0]*n
def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntLines(n): return [int(input()) for i in range(n)]

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat


ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18


class Debug():
    def __init__(self):
        self.debug = True

    def off(self):
        self.debug = False

    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N = getInt()
    A = getIntList()
    d.dmp(A)
    magicCount = 0
    i = 0
    while i < N-1:
        cont = 1
        while A[i] == A[i+cont]:
            cont += 1
            if i+cont == N:
                break
        d.dmp(cont,'cont')
        magicCount += cont//2
        d.dmp(magicCount,'magicCount')
        i += cont
    return magicCount


ans = prob()
if ans is None:
    pass
else:
    print(ans)
#elif ans[0] == 'col':
#    for elm in ans[1]:
#        print(elm)

Submission status: Accepted

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

len_l = len(l)
st = l[0]
count = 1
count_l = []
for i in range(1,len_l):
    if l[i]==st:
        count+=1
    else:
        count_l.append(count//2)
        st = l[i]
        count = 1
count_l.append(count//2)
print(sum(count_l))

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:
n = int(input())
A = list(map(int,input().split()))
ans = 0
temp = [A[0]]

for a in A[1:]:
    if a != temp[-1]:
        if len(temp)>=2:
            ans += int(len(temp)/2)
            temp.clear()
        else:
            temp.clear()
    temp.append(a)
    

ans += int(len(temp)/2)
            
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

X = list(map(int, input().split()))
X.append(1000000)
ans = 0

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

Submission status: Accepted

Solution code:
n = int(input())
l = input().split()
cnt = 0
for i in range(1,n):
  if l[i] == l[i-1]:
    l[i] = "x"
    cnt += 1
print(cnt)

Submission status: Accepted

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

if __name__=="__main__":
    main()

Submission status: Accepted

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

ans = 0
for i in range(1, N):
    # 単純に「同じ色が隣接していたら、色を変える」を繰り返す
    if lst_slimes[i]==lst_slimes[i-1]:
        lst_slimes[i] = -1
        ans += 1

print(ans)

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

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

    return res


print(main())

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
count=0
i=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_i = map(int,input().split())
index = 0
count = 0
a_i_list = list(a_i)
while index < N-1:
    if a_i_list[index] == a_i_list[index+1]:
        count+=1
        index+=1
    index+=1
print(count)

Submission status: Accepted

Solution code:
N = int(input())

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

stack = []
ans = 0

for a in A:
    if len(stack)==0:
        stack.append(a)
    elif stack[-1]!=a:
        stack.remove(stack[0])
        stack.append(a)
    else:
        ans += 1
        stack.clear()

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
T=list(map(int,input().split()))
c=1
ans=0
for i,t in enumerate(T):
        try:
                if t==T[i+1]:
                        c+=1
                else:
                        ans+=c//2
                        c=1
        except:
                ans+=c//2
                pass
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import*;input();a=map(int,input().split());print(sum(len(list(v))//2for k,v in groupby(a)))

Submission status: Accepted

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

Submission status: Accepted

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

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

ans += count // 2
print(ans)

Submission status: Accepted

Solution code:
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = IL()+[int(10e10)]

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

print(ans)

Submission status: Accepted

Solution code:
# 色は10000色、Nは高々100なのでどの色に変えるかは考えなくてよい。

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

# 同じ色で連続している匹数(block_size)のリストを作成する。
s_block_list = []
block_size = 1
for i in range(1, N):
  if s_list[i] == s_list[i-1]:
    block_size += 1
  else:
    s_block_list.append(block_size)
    block_size = 1
s_block_list.append(block_size)
# block_size // 2の総和
print(sum([s // 2 for s in s_block_list]))

Submission status: Accepted

Solution code:
N = int(input())

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

cnt = 1
re = a[0]
Ans = 0

for i in a[1:]:
  if i == re:
    cnt += 1
  else:
    Ans += cnt // 2
    cnt = 1
    re = i
Ans += cnt // 2

print(Ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/agc026/tasks/agc026_a

import itertools
import collections
import bisect

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

    count = 0
    prev = -1
    for i in range(N):
        if prev == A[i]:
            count += 1
            A[i] = -1

        prev = A[i]
    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())
data=[int(x) for x in stdin.readline().rstrip().split()]
data.append(0)

ans=0
memo=0
cnt=0
for i in data:
    if i == memo:
        cnt+=1
    else:
        ans+=(cnt//2)
        cnt=1
    memo=i
print(ans)

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]:
        cnt += 1
        a[i+1]=101+i
print(cnt)

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if i == 0:
        continue
    if A[i-1] == A[i]:
        A[i] += 1
        cnt += 1
        if i != N -1 and A[i] == A[i+1]:
            A[i] += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

def pleaseConform(caps):
    start = 0
    intervals = []
    for i in range(1, len(caps)):
        if caps[start] != caps[i]:
            intervals.append((start, i-1, caps[start]))
            start = i
    intervals.append((start, len(caps)-1, caps[start]))
    return intervals

n = input()
cap1 = input().split()

go = pleaseConform(cap1)

ans = 0

for t in go:
    ans += (t[1]-t[0]+1)//2

print(ans)

Submission status: Accepted

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
s = ar[0]
count = 0
for i in range(a-1):
    if s == ar[i+1]:
        count += 1
        ar[i+1] = 0
    s = ar[i+1]
print(count)

Submission status: Accepted

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
slimes = list(map(int, input().split()))
change = 0
color = 0
cont = 0
for s in slimes:
  if (color != s):
    color = s
    change += cont // 2
    cont = 1
  else:
    cont += 1
change += cont // 2
print(change)

Submission status: Accepted

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

cnt = 0
prev = 0
for i in range(n):
    if prev == a[i]:
        cnt += 1
        prev = 0
    else:
        prev = a[i]

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

tmp = a[0]
tc = 1
ans = 0
for i in range(1, n):
    if a[i] == tmp:
        tc += 1
    else:
        ans += tc // 2
        tmp = a[i]
        tc = 1
else:
    ans += tc // 2
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
arr = [int(i) for i in input().split()]
b = {}
length = []
tmp = -1
for i in range(N):
    if i == N-1 :
        length.append(i-tmp)
        break
    if arr[i] != arr[i+1]:
        length.append(i-tmp)
        tmp = i
count = 0
for i in length:      
    count += i//2
print(count)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()

    prev = -1
    cont_count = 1
    majic_num = 0
    for i in range(N):
        a = int(input_raw[i])
        if a == prev:
            cont_count += 1
        else:
            majic_num += cont_count/2
            cont_count = 1
        prev = a
    majic_num += cont_count/2
    print majic_num

if __name__ == '__main__':
    main()

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())
inputs = [int(i) for i in input().split()]

slime = 10000

for i in range(N):
    if i == 0:
        continue
    else:
        if inputs[i] == inputs[i-1]:
            inputs[i] = slime
            slime -= 1

print(10000-slime)

Submission status: Accepted

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

slime = 10000

if N == 2 and inputs[0] == inputs[1]:
    print(1)
    exit()
else:
    for i in range(N):
        if i == 0 or i == N-1:
            continue
        else:
            if inputs[i-1] == inputs[i] == inputs[i+1]:
                inputs[i] = slime
                slime -= 1
            elif i+2 <= N-1 and inputs[i] == inputs[i+1] == inputs[i+2]:
                continue
            elif inputs[i-1] == inputs[i] or inputs[i] == inputs[i+1]:
                inputs[i] = slime
                slime -= 1

print(10000-slime)

Submission status: Accepted

Solution code:
N=int(input())
a = list(map(int,input().split()))
prev = a[0]
line = 1
score=0
for i in range(1,N):
    if a[i]==prev:
        line+=1
    else:
        prev=a[i]
        score += line//2
        line=1
score+=line//2

print(score)

Submission status: Accepted

Solution code:
from itertools import groupby as gb

N = int(input())
a = list(map(int,input().split()))
g = gb(a)
res = 0
for k,v in g:
    res += len(list(v)) // 2
print(res)

Submission status: Accepted

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

if N == 2:
    if a[0] == a[1]:
        count += 1
else:
    for i in range(N-1):
        if skip:
            skip = False
            continue
        else:
            if a[i] == a[i+1]:
                count += 1
                skip = True

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding: utf-8
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] = -1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
t = []
d = False
k = 0
for i in range(1,n):
  if a[i-1] == a[i]:
    if d:
      t[k].append(a[i])
    else:
      t.append([a[i-1], a[i]])
      d = True
  elif d:
    d = False
    k += 1
c = 0
for j in t:
  c += len(j)//2
print(c)

Submission status: Accepted

Solution code:
N = int(input())
S = input().split()
s = 0
for i in range(1, N):
	if S[i-1] == S[i]:
		S[i] = N + 1000000000
		s += 1
	
print(s, flush=True)

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int,input().split()))
count=0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
cnt = 1
b = []
for i in range(n-1):
    if a[i] == a[i+1]:
        cnt += 1
    else:
        b.append(cnt)
        cnt = 1
        
    if i == n-2:
        b.append(cnt)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
ans=chk=0
for i in l:
    if i==chk:
        chk=0
        ans+=1
    else:
        chk=i
print(ans)

Submission status: Accepted

Solution code:
# A 200
N = int(input())
a = list(map(int, input().split()))
cur = a[0]
ans = 0
for ai in a[1:]:
    nex = ai
    if nex==cur:
        ans += 1
        cur = -1
    else:
        cur = nex
print(ans)

Submission status: Accepted

Solution code:
import sys


def next_str() -> str:
    result = ""
    while True:
        tmp = sys.stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


def next_int() -> int:
    return int(next_str())


def main() -> None:
    n = next_int()
    pre = -1
    ans = 0

    for i in range(n):
        a = next_int()
        if a == pre:
            ans += 1
            pre = -1
        else:
            pre = a

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

c = 0
i = 0
ans = 0
while i < n-1:
    if a[i] == a[i+1]:
        c += 1
        i += 1
    else:
        ans += (c+1)//2
        c = 0
        i += 1
print((ans+(c+1)//2,ans)[c==0])

Submission status: Accepted

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

ans = 0
past = -1
for i in range(N):
    now = A[i]
    if now == past:
        past = -1
        ans += 1
    else:
        past = now

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(_) for _ in 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
cnt=0
for i in range(1,n):
    if a[i]==a[i-1]:
        cnt+=1
        a[i]=0
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(cnt)

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

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] = 101+i
        count += 1
print(count)

Submission status: Accepted

Solution code:
a = int(input())
b = list(input().split())
n = 0

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

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
s=-1
ans=0
for i in range(N):
    if s!=A[i]:
        s=A[i]
    else:
        ans+=1
        s=-1
print(ans)

Submission status: Accepted

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

ans = 0
idx = 0

while idx < N - 1:
    if a[idx] == a[idx + 1]:
        ans += 1
        idx += 1
    idx += 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
j=False #i-1番目を変えたか
for i in range(1,n):
    if a[i]==a[i-1] and not j:
        ans+=1
        j=True
    elif a[i]==a[i-1]:
        j=False
    else:
        j=False
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
flag = True
for i, a in enumerate(A):
    if i == 0:
        continue
    if a == A[i-1] and flag:
        cnt += 1
        flag = False
    else:
        flag = True

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
s = tuple(map(int, input().split(" ")))

count = 0
before = None
for s_i in s:
    if before == s_i:
        count += 1
        before = None
    else:
        before = s_i
print(count)

Submission status: Accepted

Solution code:
N = int(input())
pre_a = 0
cont = 0
ans = 0

for a in input().split():
	if pre_a == a:
		cont += 1
	else:
		ans += cont // 2
		cont = 1
	pre_a = a
else:
	ans += cont // 2

print(ans)

Submission status: Accepted

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

cnt = 0
ans = 0

for i, s in enumerate(ss):
    cnt += 1
    if i+1 < n and ss[i] != ss[i+1]:
        ans += cnt // 2
        cnt = 0

if cnt:
    ans += cnt // 2

print(ans)

Submission status: Accepted

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

cnt = 0
ans = 0

for i, s in enumerate(ss):
    cnt += 1
    flg = True
    if i+1 < len(ss):
        if ss[i] != ss[i+1]:
            ans += (cnt // 2)
            cnt = 0

            flg = False

if(flg):
    ans = (cnt // 2) + ans


print(ans)

Submission status: Accepted

Solution code:
N=map(int,input().split())
list=[int(_) for _ in input().split()]


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

sum=0

for num in countlist:
    if num>=2:
        sum+=int(num/2)

print(sum)

Submission status: Accepted

Solution code:
input()
ans = 0
prevcolor = 0
for a in map(int, input().split()):
    if a == prevcolor:
        ans += 1
        prevcolor = 0
    else:
        prevcolor = a
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
list_n = list((map(int, input().split())))
count = 0
ans = 0
while count < n-1:
    if list_n[count] == list_n[count+1]:
        if count == n-2:
            if list_n[count] != 1:
                list_n[count+1] = 1
            else:
                list_n[count+1] = 2
        else:
            if list_n[count] != 1 and list_n[count+2] != 1:
                list_n[count+1] = 1
            elif list_n[count] != 2 and list_n[count+2] != 2:
                list_n[count+1] = 2
            else:
                list_n[count+1] = 3
        ans += 1
    count += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N = int(input())
aa = inpl()
aa.append(-1)
tmp = 1
ans = 0
for i in range(1,N+1):
    if aa[i] == aa[i-1]:
        tmp += 1
    else:
        ans += tmp//2
        tmp = 1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=0
l=[]
for i in range(1,n):
  l.append(a[i]-a[i-1])
if len(l)==1 and l[n-2]==0:c+=1
if len(l)>1 and l[n-2]==0 and l[n-3]!=0:c+=1
p=l.pop(0)
while len(l)!=0:
  if p!=0:
    p=l.pop(0)
  else:
    c+=1
    while len(l)>1:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    while len(l)>0:
      if l[0]==0:
        p=l.pop(0)
      else:
        p=l.pop(0)
        break
print(c)

Submission status: Accepted

Solution code:
import math
from itertools import groupby

n = int(input())
a = list(map(int,input().split()))
ans = 0
for key, value in groupby(a):
    ans += math.floor(len(list(value))/2)
print(ans)

Submission status: Accepted

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

def main():
	count = 0
	for i in range(0, n):
		if i == 0:
			continue
		if a[i - 1] == a[i]:
			a[i] = 0
			count += 1
	print(count)

main()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
res = 0
new_color = max(a) + 1
cnt = 1
for i in range(len(a)-1):
    next_slime = a[i + 1]
    if next_slime == a[i]:
        cnt += 1
    else:
        res += (cnt // 2)
        cnt = 1
if cnt > 0:
    res += (cnt // 2)
print(res)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
res = 0
new_color = max(a) + 1
for i in range(1, len(a) - 1):
    prev_slime = a[i - 1]
    next_slime = a[i + 1]
    if a[i] == prev_slime and a[i] == next_slime:
        a[i] = new_color
        new_color += 1
        res += 1
for i in range(1, len(a)):
    prev_slime = a[i - 1]
    if a[i] == prev_slime:
        a[i] = new_color
        new_color += 1
        res += 1
print(res)

Submission status: Accepted

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

i = 0
r = 0

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

print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby

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

n = sum(len(list(s))//2 for _,s in groupby(a))
print(n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
iN = int(input())
aS = [int(x) for x in input().rstrip().split()]

#はぁ こんなのを一発で通れるようなものも書けないのか.. つらい

#つけたしつけたしで条件追加しててやっててつらい



iCounter = 0
if iN == 2:
    if aS[0] == aS[1]:
        iCounter += 1
else:
    for i in range(1,iN-1):
        if aS[i] == aS[i-1]:
            if aS[i] == aS[i+1]:
                if aS[i] < 10000:
                    aS[i] += 1
                else:
                    aS[i] -= 1
                iCounter += 1
            else:
                iU = max(aS[i],aS[i+1])
                if iU < 10000:
                    iU += 1
                else:
                    iU -= 1
                    if iU == min(aS[1],aS[i+1]):
                        iU -= 1
                aS[i] = iU
                iCounter += 1
    if aS[iN-2] == aS[iN-1] :
        iCounter += 1
print(iCounter)

Submission status: Accepted

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

ans = 0
f = 0

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

Submission status: Accepted

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

color = a[0]
cnt = 1
magic = 0
for slime in a[1:]:
    if slime == color:
        cnt += 1
    else:
        color = slime
        magic = magic + cnt //2
        cnt = 1

if cnt > 1:
    magic = magic + cnt //2
    
print(magic)

Submission status: Accepted

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

Submission status: Accepted

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

print(res)

Submission status: Accepted

Solution code:
import itertools

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

res = 0
g = itertools.groupby(a)
for k,v in g:
    vv = len(list(v))
    res += vv//2
print(res)