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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
a = LIST()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
a = input().split()
li = []
s = 1
for i in range(1,N):
    if a[i] != a[i-1]:
        li.append(s)
        s = 1
        continue
    if a[i] == a[i-1]:
        s +=1
if s != '':
    li.append(s)
n = len(li)
ans = 0
for i in range(n):
    l = li[i]
    ans += l//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = 0
for ln in l:
    ans += ln // 2

print(ans)

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
A = iil()
ans = 0
for i in range(1,n):
    if A[i-1] == A[i]:
        ans += 1
        A[i] = -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):
  if a[i]==a[i-1]:
    a[i]=0
    cnt +=1
    
print(cnt)

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
a = iln()

count = 0
for i in range(1, N):
    if a[i-1] == a[i]:
        a[i] = 1000
        count += 1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
pre_col = A[0]
flg = False
res = 0
for i in range(1, n):
    if flg or A[i] != pre_col:
        pre_col = A[i]
        flg = False
    elif A[i] == pre_col:
        res += 1
        flg = True
print(res)

Submission status: Accepted

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans = 0
flg = False
for i in range(1,N):
    if flg:
        flg = False
        continue
    if arr[i] == arr[i-1]:
        ans += 1
        flg = True
    else:
        flg = False
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
count=0
i=0
while(1):
	if i>=N-1:
		break
	elif L[i]==L[i+1]:
		count+=1
		i+=2
	else:
		i+=1
print(count)

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

dummy = -9999
prev = dummy
ct = 0
for i in l:
    if i == prev:
        ct += 1
        prev = dummy
    else:
        prev = i
        
print(ct)

Submission status: Accepted

Solution code:
#AGC26 A問題
#1:連続する文字列ごとに分割する。（もしくは連続する文字列の長さを記録していく）
#2:連続する文字列内で魔法を使い、連続しないようにするためには？　偶数と奇数でどうなるか

def main():
    n = int(input())
    slimes = list(map(int,input().split()))
    length = length_of_sequences(slimes)
    total = 0
    for l in length:
        total += l//2
    print(total)

def length_of_sequences(l):
    length = []
    counter = 1
    for i,slime in enumerate(l):

        if i == 0:
            continue
        if l[i-1] == l[i]:
            counter += 1
        else:
            length.append(counter)
            counter = 1
        if i == len(l)-1:
            length.append(counter)

    return length



if __name__ == '__main__':
    main()

Submission status: Accepted

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

pre=A[0]
ans=0

for i in range(1,len(A)):
    if pre==A[i]:
        ans+=1
        pre=101
    
    else:
        pre=A[i]
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

ans = 0
count = [0 for _ in range(n)]
j = 0
for i in range(n - 1):
    if a[i] == a[i + 1]:
        count[j] += 1
    if a[i] != a[i + 1]:
        count[j] += 1
        j += 1
count[j] += 1
#print(count)

for i in count:
    ans += i // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

    if temp%2==0:
        cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    count = 0
    for i in range(1, N):
        if A[i] == A[i-1]:
            count += 1
            A[i] = -1
    print(count)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
l=[]
t=0

for i in range(n-1):
    if i==n-2:
        if a[i+1]==a[i]:
            t+=2
            l.append(t)
        else:
            t+=1
            l.append(t)
            l.append(1)
        continue      
    if a[i+1]==a[i]:
        t+=1
    else:
        t+=1
        l.append(t)
        t=0
# print(l)
ans=0
for ll in l:
    ans+=ll//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem A - Colorful Slimes 2

# input process
N = int(input())
a_list = list(map(int, input().split()))

# initialization
magic_num = 0
chohuku_num = 0

# count process
for i in range(0, N):
    if i==0:
        continue

    if a_list[i]==a_list[i-1]:
        chohuku_num += 1
    else:
        magic_num += (chohuku_num + 1) // 2
        chohuku_num = 0
magic_num += (chohuku_num + 1) // 2

print(magic_num)

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

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

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

x = 0
ans = 0
for i in A:
    if i == x:
        ans += 1
        x = 0
        continue
        
    x = i
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
cnt=0
flag=False
for i in range(1,n):
    if a[i]==a[i-1]:
        if flag:
            flag=False
        else:
            cnt+=1
            flag=True
    else:
        flag=False
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
f = 0
ans = 0
for k in range(1,N):
    if a[k] == a[k-1] and f == 0:
        ans += 1
        f = 1
    else:
        f = 0
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    pre = A[0]
    changed = False
    for a in A[1:]:
        if changed:
            changed = False
        elif pre == a:
            ans += 1
            changed = True
        pre = a
    print(ans)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
n=int(input())
a = [int(i) for i in input().split()]
ans = 0
b = 0
j = -1
for i in a:
    if i != j:
        ans += b // 2
        b=1
    else:
        b += 1
    j = i
ans += b // 2

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] != -1 and A[i] == A[i + 1]:
        A[i + 1] = -1
        ans += 1

print(ans)

Submission status: Accepted

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

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

print(cnt)

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]:
    a[i]=-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+1<=N-1:
  if a[i]!=a[i+1]:
    i+=1
  else:
    tmp=1
    while i+1<=N-1 and a[i]==a[i+1]:
      tmp+=1
      i+=1
    i+=1
    ans+=(tmp//2)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from itertools import groupby

def solve(N: int, a: "List[int]"):
    group = groupby(a)
    answer = 0
    for key,value in group:
        answer += len(list(value))//2
    print(answer)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split(' ')))

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

print(ret)

Submission status: Accepted

Solution code:
n = int(input())
li = [int(x) for x in input().split()]
a = 10**6
ans = 0
for i in range(n-1):
    if li[i]==li[i+1]:
        li[i+1] = a
        a += 1
        ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    slimes = int(input())
    color = list(input().split()) + ["-1"]
    before = color[0]
    count = 1
    answer = 0
    for i in range(1, slimes + 1):
        if before == color[i]:
            count += 1
        else:
            before = color[i]
            answer += count // 2
            count = 1
    print(answer)


if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

n = int(input().rstrip())

numbers = list(map(int, input().rstrip().split(" ")))

start = 0
ans = 0
for i in range(1,n):
    if numbers[i] != numbers[i - 1]:
        tmp = i - start
        ans += int(tmp/2)
        start = i

ans += int((n-start)/2)

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
id=1
ans=0
while(id<N):
  if a[id]==a[id-1]:
    ans+=1
    id+=2
  else:
    id+=1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

#print(a)
for i in range(n-1):
    if a[i] == a[i+1]:
        ans += 1
        a[i+1] = 500 + i

#print(a)

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
count = 1
key = a[0]
ans = 0
if n==1:
    print(0)
else:
    for i in range(1,n):
        if key == a[i]:
            count += 1
        else:
            ans += count//2
            key = a[i]
            count = 1
ans += count//2
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] = a[i+1] + 10
        ans = ans + 1


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
before = 0
i = 0
for x in a_list:
    if x == before:
        i += 1
        before = None
        continue
    before = x

print(i)

Submission status: Accepted

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

cont = []
c = 1
for i in range(N-1):
    if A[i] == A[i+1]:
        c += 1
    else:
        cont.append(c)
        c = 1
else:
    cont.append(c)

# print(cont)
ans = 0
for ci in cont:
    ans += ci // 2
print(ans)

Submission status: Accepted

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

ans = 0
be = A[0]
for ai in A[1:]:
    if be == ai:
        ans += 1
        be = -1
    else:
        be = ai

print(ans)

Submission status: Accepted

Solution code:
import math
N=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(N-1):
    if a[i]==a[i+1]:
        cnt=cnt+1
        a[i]=""
        a[i+1]=""
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]:
        ans+=1
        if i==n-2:
            a[i+1]=(a[i])%10000+1
        else:
            a[i+1]=10001
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
before = A[0]
for i in range(1, n):
    if A[i] == before:
        ans += 1
        before = 0
    else:
        before = A[i]
print(ans)

Submission status: Accepted

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

prev = -1
answer = 0
for a in li_a:
    if prev == a:
        answer += 1
        prev = -1
    else:
        prev = a
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
dat = list(map(int, input().split()))
p = dat[0]
res = 0
for i in range(1, len(dat)):
    if p == dat[i]:
        dat[i] = "x"
        p = "x"
        res += 1
    else:
        p = dat[i]
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby

def main():
    N = int(input())
    a = list(map(int,input().split()))
    gp = []
    for key,value in groupby(a):
        gp.append(list(value))
    ans = 0
    for i in range(len(gp)):
        ans += len(gp[i])//2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = 0
now = 1
while now < N:
    if A[now] == A[now-1]:
        ans += 1
        now += 2
    else:
        now += 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
s=list(map(int,input().split()))
ans=0
cnt=1
for i in range(n-1):
    if s[i]==s[i+1]:
        cnt+=1
    else:
        ans+=cnt//2
        cnt=1
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(n-1):
    if a[i] == a[i+1]:
        a[i+1] = 10001
        ans += 1
print(ans)

Submission status: Accepted

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

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

ans += count // 2
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int,input().split()))
cnt = 0
conseq = 1
for i in range(n-1):
    if a[i+1] == a[i]:
        conseq += 1
    else:
        cnt += conseq // 2
        conseq = 1
cnt += conseq // 2
print(cnt)

Submission status: Accepted

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

ans = 0
num = -1
for i in range(N):
    cnt = 0
    if(i <= num):
        continue
    for j in range(i+1, N):
        if(a[i] == a[j]):
            cnt += 1
            num = j
        else:
            break
    if(cnt%2 == 0):
        ans += cnt//2
    else:
        ans += cnt//2+1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
x = 0
i = 0
while i<N-1:
    j=1
    while i<N-1 and a[i]==a[i+1]:
        j=j+1
        i=i+1
    i=i+1
    if j%2==1:
        x=x+(j-1)//2
    else:
        x=x+j//2
print(x)

Submission status: Accepted

Solution code:
import itertools
n,l=int(input()),list(input().split())
g=itertools.groupby(l)
c=0
for key,group in g:
  gr=list(group)
  if len(gr)!=1:
    c+=len(gr)//2
print(c)

Submission status: Accepted

Solution code:
def run_length(a):
    result = []
    N = len(a)
    cnt = 1
    for i in range(N):
        if i == N - 1 or a[i] != a[i + 1]:
            result.append(cnt)
            cnt = 1
        else:
            cnt += 1
    return result

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

print(sum(map(lambda x: x // 2, run_length(a))))

Submission status: Accepted

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

c = 0

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

print(c)

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

Submission status: Accepted

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

    if a[i]==a[i-1]:
        cur+=1
    else:
        l.append(cur)
        cur=1

    if i==n-1:
        if a[i]==a[i-1]:
            l.append(cur)
        else:
            cur=1
            l.append(cur)
ans=0
for ll in l:
    ans+=ll//2

print(ans)

Submission status: Accepted

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

flag = False
before = -1
ans = 0
for a in al:
    if before == a:
        if flag == False:
            ans += 1
            flag = True
        else:
            flag = False
    else:
        flag = False
    before = a
print(ans)

Submission status: Accepted

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

cnt = 1
res = 0
for i in range(1, n):
  if s[i] == s[i-1]:
    cnt +=1
  else:
    res += int(cnt//2)
    cnt = 1
res += int(cnt//2)

print(res)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split( )))
###連続区間に分ける

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

Submission status: Accepted

Solution code:
from sys import stdin
from itertools import groupby
n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for key, value in groupby(li):
    lin.append(len(list(value)))
print(sum(i//2 for i in lin))

Submission status: Accepted

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

cnt = 0

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def examA():
    N = I()
    A = LI()
    ans = 0
    for i in range(N-1):
        if A[i+1]==A[i]:
            A[i+1] = 101
            ans +=1
    print(ans)
    return

def examB():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examA()

Submission status: Accepted

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

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

ans += (cnt+1) // 2

print(ans)

Submission status: Accepted

Solution code:
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]:
    a[i]=cnt
    cnt-=1
    ans+=1
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)