Problem:


Score : 200 points

Problem Statement

Takahashi lives in another world. There are slimes (creatures) of 10000 colors in this world. Let us call these colors Color 1, 2, ..., 10000.

Takahashi has N slimes, and they are standing in a row from left to right. The color of the i-th slime from the left is a_i.
If two slimes of the same color are adjacent, they will start to combine themselves. Because Takahashi likes smaller slimes, he has decided to change the colors of some of the slimes with his magic.

Takahashi can change the color of one slime to any of the 10000 colors by one spell.
How many spells are required so that no slimes will start to combine themselves?

Constraints

2 \leq N \leq 100

1 \leq a_i \leq N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

Print the minimum number of spells required.

Sample Input 1

5
1 1 2 2 2

Sample Output 1

2

For example, if we change the color of the second slime from the left to 4, and the color of the fourth slime to 5, the colors of the slimes will be 1, 4, 2, 5, 2, which satisfy the condition.

Sample Input 2

3
1 2 1

Sample Output 2

0

Although the colors of the first and third slimes are the same, they are not adjacent, so no spell is required.

Sample Input 3

5
1 1 1 1 1

Sample Output 3

2

For example, if we change the colors of the second and fourth slimes from the left to 2, the colors of the slimes will be 1, 2, 1, 2, 1, which satisfy the condition.

Sample Input 4

14
1 2 2 3 3 3 4 4 4 4 1 2 3 4

Sample Output 4

4



Sample input:
5
1 1 2 2 2


Sample output:
2

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	n=int(input())
	vA=linput()
	
	res = 0
	pp = 0
	
	for a in vA:
		if pp==a:
			res += 1
			pp = 0
		else:
			pp = a
	
	#sT = "No Yes".split()
	#print(sT[res])
	print(res)

if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from random import randint
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range (len(l)-1) :
  try:
    if l[i] == l[i + 1]:
        ans += 1
        l[i + 1] = randint(0, 10000)
  except:
    continue
print(ans)

Submission status: Accepted

Solution code:
# 26 
#try 2

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

for i in range(n-1):
    if a[i] == a[i+1]:
        sum += 1
        a[i+1] = 1.36
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from numpy import random
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range (len(a) - 1) :
  if a[i] == a[i + 1]:
    b += 1
    a[i + 1] = random.randint(10000)
print(b)

Submission status: Accepted

Solution code:
from numpy import random
n = int(input())
a = list(map(int,input().split()))
b = 0
for i in range (len(a) - 1) :
  if a[i] == a[i + 1]:
    b += 1
    a[i + 1] = random.randint(10000)
print(b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_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(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
a = LIST()

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

print(ans)

Submission status: Accepted

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

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

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

    print(ret)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A = IL()

ans = 0
count = 0
prev = None

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]

    prev = A[0]
    ans = 0
    for a in A[1:]:
        if prev == a:
            ans += 1
            prev = -1
        else:
            prev = a

    print(ans)


    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
a = rl()
cnt = 0
for i in range(n-1):
    if a[i] == a[i+1]:
        a[i+1] = -1
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

ans += (x+1)//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]:
        ans+=1
        a[i+1]=(i+1)*-1
print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N = int(input())
an = [int(a) for a in input().strip().split()]
p = -1
ans = 0
for a in an:
  if a == p:
      ans += 1
      p = -1
  else:
      p = a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
i = 0
mae = 0
c = 0
while i < n:
  if mae == a[i]:
    c += 1
    mae = 0
  else:
    mae = a[i]
  i += 1
print(c)

Submission status: Accepted

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

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x < N - 2:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)

Submission status: Accepted

Solution code:
# coding: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] = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    before = -1
    cnt = 0
    ans = 0
    for a in A:
        if(before != a):
            ans += cnt//2
            cnt = 0
        cnt += 1
        before = a
    if(cnt):
        ans += cnt//2
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(len(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 = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(str, 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:
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    N = int(input().rstrip())
    vec =list(map(int, input().split())) 
    prev = -1
    cnt = 1
    ANS = 0
    for x in vec:
        if(prev == x):
            cnt += 1
        else:
            prev = x
            ANS += cnt//2
            cnt = 1
    
    ANS += cnt//2
    print(ANS)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

ans=0
for i in range(n-1):
  if a[i]==a[i+1]:
    ans+=1
    a[i+1]=-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] = 'x'
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# A - Colorful Slimes 2

N = int(input())
a = list(map(int,input().split()))
ans = 0
tmp = 1

for i in range(1,N):
    if a[i-1]==a[i]:
        tmp += 1
    else:
        tmp = 1
    ans += int(tmp%2==0)

print(ans)

Submission status: Accepted

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

cnt = 0
last = 0
row = 0
for i in range(N):
    #print(i, last, A[i])
    if(last == A[i]):
        row += 1
    elif(row > 0):
        cnt += int((row+1)/2)
        row = 0
    last = A[i]
    #print(row, cnt)
cnt += int((row+1)/2)
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] = 0
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, *a = map(int, open(0).read().split())
a.append('*')
cnt = 0
tmp_cnt = 0
tmp = '*'
for i in range(n+1):
    if a[i] == tmp:
        tmp_cnt += 1
    else:
        cnt += tmp_cnt//2
        tmp = a[i]
        tmp_cnt = 1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    cnt=0
    gr = groupby(A)
    for key, group in gr: # groupはイテレータ。list(group)でリスト化  
        """ex.
        0: [0, 0, 0]
        1: [1, 1]
        0: [0, 0, 0]
        1: [1, 1]
        0: [0]
        1: [1]
        """
        cnt+=len(list(group))//2

    
    print(cnt)
        
    


    
resolve()

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] = ""
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]=0
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=0
i=0
while i<N-1:
  if A[i]==A[i+1]:
    A[i+1]=0
    ans+=1
    i+=1
  else:
    i+=1
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]: cnt += 1
    else:
        ans += cnt//2
        cnt = 1
ans += cnt//2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
from itertools import groupby as gb
ans=0
for a,b in gb(list(map(int,input().split()))):
    ans+=len(list(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] == a[i+1]:
        ans+=1
        a[i+1]=0
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] = 0
    ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
ans=0
x=1#連続して隣り合っている数
for i in range(N-1):
    if i!=(N-2):
        if a[i]==a[i+1]:
            x+=1
        else:
            ans+=(x//2)
            x=1#xをリセット
    else:
        if a[i]==a[i+1]:
            x+=1
        ans+=(x//2)
print(ans)

Submission status: Accepted

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

r = 0
c = 1
h = a[0]
for i in range(1, n):
    if h == a[i]:
        c += 1
        if c%2==0:
            r += 1
    else:
        c = 1
        h = a[i]
print(r)

Submission status: Accepted

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

Submission status: Accepted

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

pre = 0
answer = 0
for a in A:
    if pre == a:
        answer += 1
        pre = 101
    else:
        pre = a
    
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def kansuu(list_x):
    result = []
    cnt = 1
    for i in range(len(list_x)-1):
        if list_x[i] == list_x[i+1]:
            cnt += 1
        else:
            num = list_x[i]
            result.append((num,cnt))
            cnt = 1
    result.append((list_x[-1],cnt))
    return result

a_li = list(map(int,input().split()))
ans = 0
for _,i in kansuu(a_li):
    if i == 1:
        continue
    else:
        ans += i//2
print(ans)

Submission status: Accepted

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    A = readInts()
    ans = 0
    # 隣り合うものを比較する
    for i in range(1,n):
        if A[i] == A[i-1]:
            ans += 1
            A[i] = -1
    print(ans)
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]

N = ri()
a = ri_()
ans = 0
cnt = 0
now = 10000
for i in range(N):
    if a[i] == now:
        cnt += 1
    else:
        ans += -(-cnt//2)
        cnt = 0
        now = a[i]  
ans += -(-cnt//2)
print(ans)

Submission status: Accepted

Solution code:
# AGC 026: A – Colorful Slimes 2
N = int(input())
a = [int(s) for s in input().split()]

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

print(a.count(0))

Submission status: Accepted

Solution code:
n=int(input())
a = [int(_) for _ in 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()))
tmp = 1
res = 0
for i in range(1,n):
  if a[i-1] == a[i]:
    tmp += 1
  else:
    res += tmp//2
    tmp = 1
res += tmp//2
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def agc026_a():
  n = int(input())
  A = list(map(int, input().split()))
  # 同じ数が連続した個数を2で切り捨て？
  B = []
  num = A[0]
  count = 1
  for i in range(1, n):
    if A[i] == num:
      count += 1
    else:
      B.append(count)
      num = A[i]
      count = 1
  else:
    B.append(count)
  ans = 0
  for b in B:
    ans += b // 2
  print(ans)

agc026_a()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

# A - Colorful Slimes 2
N = int(input())
a = list(input().split())
prev = a[0]

for i in range(1, N):
	if a[i] == prev:
		a[i] = 'changed'
	
	prev = a[i]

print(a.count('changed'))

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    res = 0
    cnt = 0
    while cnt < n-1:
        if a[cnt] == a[cnt+1]:
            res += 1
            cnt += 2
        else:
            cnt += 1
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import*;input();print(sum(len(list(j))//2for _,j in groupby(input().split())))

Submission status: Accepted

Solution code:
from itertools import*
input()
print(sum(len(list(j))//2for _,j in groupby(input().split())))

Submission status: Accepted

Solution code:
from itertools import*
print(sum(len(list(j))//2 for _, j in groupby(open(0).read().split()[1:])))

Submission status: Accepted

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

c=itertools.groupby(a)

ans=0
for i,gr in c:
    ans+=len(list(gr))//2
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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
    else:
        ans += -(-cnt//2)
        cnt = 0

ans += -(-cnt//2)
cnt = 0

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a= list(map(int, input().split()))
before=a.pop(0)
ans=0
for i in a:
    if i==before:
        before=100000
        ans+=1
    else:
        before=i
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]:
        a[i]='some'
        count+=1
print(count)

Submission status: Accepted

Solution code:
import sys  
import numpy as np

input = sys.stdin.readline
A = int(input())
a = list(map(int, input().split()))
sum1 = 0
for i in range(1,A):
    if a[i-1] == a[i]:
        sum1+=1
        a[i] = 0

print(sum1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().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:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]==a[i+1]:
        a[i+1]=-1
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=[int(_) for _ in input().split()]
count=0
some=-1
for i in range(n-1):
    if a[i]==a[i+1]:
        count+=1
        a[i+1]=some
        some-=1
print(count)

Submission status: Accepted

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

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

print(cnt)

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