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:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    tmp = 1
    ans = 0
    for i in range(n - 1):
        if a[i + 1] == a[i]:
            tmp += 1
        else:
            ans += tmp // 2
            tmp = 1
    print(ans + tmp // 2)
    return


#main
if __name__ == '__main__':
    solve()

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

Submission status: Accepted

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

cnt=1
flag=False
renzoku=[]
for i in range(N):
    if i==N-1:
        renzoku.append(cnt)
    elif a[i]==a[i+1]:
        cnt+=1
    else:
        flag=False
        renzoku.append(cnt)
        cnt = 1

cnt=0
for i in renzoku:
    if i==1:
        continue
    else:
        cnt+=i//2

print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import math
N=int(input())
A=list(map(int,input().split()))
cnt=0
ans=0
for i in range(N-1):
    #print(cnt)
    if A[i]==A[i+1]:
        cnt+=1
    else:
        ans+=(math.ceil(cnt/2))
        cnt=0
ans+=math.ceil(cnt/2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

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

i = 0
ans = 0

while i < n:
	if i==0:
		i = i + 1
	if l[i]==l[i-1]:
		l[i]=max(l)+1
		i = i + 1
		ans = ans + 1
	else:
		i = i + 1

print(ans)
#print(l)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

N,*A = map(int,read().split())

answer = 0
for _,it in itertools.groupby(A):
    x = len(list(it))
    answer += x//2

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

counter = 0

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

print(counter)

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

Submission status: Accepted

Solution code:
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    cur = 1
    pre = A[0]
    for a in A[1:]:
        if pre == a:
            cur += 1
        else:
            ans += cur//2
            cur = 1
        pre = a
    else:
        ans += cur//2
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
u = int(input())
A = list(map(int,input().split()))
count = 0
for a in range(u-1):
  a = A.pop(0)
  if a == A[0]:
    A[0] = -1
    count += 1
print(count)

Submission status: Accepted

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

ans=0
for i in range(1,n):
    if a[i] == a[i-1]:
        a[i] = -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(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
befor = a[0]
for i in range(1,n-1):
    after = a[i+1]
    if a[i] == befor:
        ans += 1
        for j in range(1,10001):
            if j != after:
                a[i] = j
                break
    befor = a[i]
if befor == a[-1]:
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ret)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
L = [0]
for i in range(N-1):
  if A[i] != A[i+1]:
    L.append(i+1)
L.append(N)
S = 0
for i in range(len(L)-1):
  S += (L[i+1] - L[i]) // 2
print(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, a: "List[int]"):
    ans = 0
    c = 1
    n = a[0]
    for i in range(1, N):
        # print(c)
        if a[i] == n:
            c += 1
            continue
        else:
            if c >= 2:
                ans += c//2
                
            n = a[i]
            c = 1

    if c >= 2:
        n = a[i]
        ans += c//2

    
    print(ans)

    return



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:
n = int(input())
A = input().split()
A.append("#")
ans = 0
c = 0
for i in range(n):
  c += 1
  if A[i] != A[i+1]:
    ans += c//2
    c = 0
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
import itertools
ans=0
for key,g in itertools.groupby(A):
  ans+=len(list(g))//2
print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby

n = int(input())
ans = 0
for key, elems in groupby(map(int,input().split())):
  num = len(list(elems))
  if num >= 2: ans += num//2
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
res = 0
for i in range(n-1):
    if a[i+1] == a[i]:
        a[i+1] = INF
        res += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import mul
from functools import reduce
from collections import Counter
# from itertools import combinations as comb
# from itertools import permutations as perm
# from copy import copy
# 配列二分法アルゴリズム
# https://docs.python.jp/3/library/bisect.html
# import bisect
# 桁数指定
# print('{:.3f}'.format(X))
# from collections import defaultdict
# dic = defaultdict(lambda: ...)
# 値で辞書をソート
# sorted(dic.items(), key=lambda x:x[1])
# ヒープキュー
# https://docs.python.org/ja/3/library/heapq.html
# import heapq
# 正規表現(regular expression)のためのモジュール
# import re

import sys

sys.setrecursionlimit(2000)


def inpl():
    return list(map(int, input().split()))


# 重複組み合わせは nHr = (n + r - 1)Cn
def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


N = int(input())
A = inpl()
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:
# AGC026
N = int(input())
A = list(map(str, 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:
def main(n: int, a: list):
    prev = [0, 0]
    ans = 0

    for _a in a:
        if _a == prev[0]:
            if prev[1] % 2 == 0:
                ans += 1

            prev[1] += 1
        else:
            prev = [_a, 0]

    print(ans)


if __name__ == '__main__':
    n = int(input())
    a = map(int, input().split())

    main(n, a)

Submission status: Accepted

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

ans = 0
cnt = 0
temp = -1

for i in range(len(li)):
    if  temp == li[i]:
        cnt += 1
        continue
    else:
        temp = li[i]
        ans += cnt//2
        cnt = 1
else:
    ans += cnt//2
    
        
print(ans)

Submission status: Accepted

Solution code:
import math
import heapq
import sys
from collections import Counter

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
a=list(map(int,input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

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


print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

N = int(input().split()[0])
a_list = list(map(int, input().split()))
count = 0
for i in range(1, N):
    if a_list[i-1] == a_list[i]:
        a_list[i] = -1
        count += 1
ans = count
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def rle(s):
    import itertools
    return list(map(lambda x: (x[0], len(list(x[1]))), itertools.groupby(s)))


n = ri()
ls = ril()
ls = rle(ls)
res = 0
for _, x in ls:
    res += x // 2
print(res)

Submission status: Accepted

Solution code:
from itertools import groupby

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

ans = 0
for key, group in groupby(A):
    ans += len(list(group))//2

print(ans)

Submission status: Accepted

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

    a.append(0)

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

N = int(input())

s = 1

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

ans = 0

for i in range(N):

    i += 1
    if a[i-1] == a[i]:
        s += 1

    else:
        ans += s//2
        s = 1

print (ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
B = [A[0]]
for i in range(1, n):
    if A[i] == B[-1]:
        B.append(0)
        ans += 1
    else:
        B.append(A[i])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

ans=0
x=a[0]
length=1

for ai in a[1:]:
    if ai==x:
        length+=1
    else:
        ans+=length//2
        x=ai
        length=1
ans+=length//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] = -1
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    cnt = 1
    t_cnt = 0
    for i in range(1, n):
        if a[i] != a[i-1]:
            t_cnt += (cnt // 2)
            cnt = 1
        else:
            cnt += 1
    t_cnt += (cnt // 2)
    print(t_cnt)


if __name__ == '__main__':
    slove()

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

Submission status: Accepted

Solution code:
def run_length_compress(string):
    string = string + [-1]
    n = len(string)

    begin = 0
    end = 1
    cnt = 1
    ans = []
    while True:
        if end >= n:
            break
        if string[begin] == string[end]:
            end += 1
            cnt += 1
        else:
            ans.append((cnt, string[begin]))
            begin = end
            end = begin + 1
            cnt = 1

    return ans


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

ans = 0
for i, j in a:
    ans += i // 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] = -1
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
from itertools import groupby

N, *A = map(int, open(0).read().split())
print(sum(len(tuple(v)) // 2 for _, v in groupby(A)))

Submission status: Accepted

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

Submission status: Accepted

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

slime = []
cnt = 0
color = 0
for i in range(n):
    if i == 0:
        cnt = 1
        color = a[i]
        continue
    if a[i] == color:
        cnt += 1
    else:
        slime.append(cnt)
        cnt = 1
        color = a[i]
else:
    slime.append(cnt)

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

Submission status: Accepted

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

Submission status: Accepted

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

a_L.append(-99)
tmp_num = -1
result_L = []
counter = 0

for val in range(len(a_L)):
    #print(tmp_num,a_L[val])

    if tmp_num == a_L[val]:
        counter += 1
    if tmp_num != a_L[val] and counter != 0:
        counter +=1
        result_L.append(counter)
        #print("a",tmp_num,a_L[val],counter)
        counter = 0

    tmp_num = a_L[val]


result_L = [i//2 for i in result_L]


print(sum(result_L))

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int, input().split()))
r = 0
cA = -1
cl = 0
As.append(-1)
for A in As:
  if A != cA:
    r += cl//2
    cA = A
    cl = 1
  else:
    cl += 1
print(r)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# AGC026A - Colorful Slimes 2
def main():
    N, *A = map(int, open(0).read().split())
    ans, flg = 0, 0  # flg: change j (i in next pair) or not
    for i, j in zip(A, A[1:]):
        if flg:
            flg ^= 1
        else:
            if i == j:
                ans += 1
                flg ^= 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np

n = int(input())
a = list(int(i) for i in input().split())

cnt = 0
b = np.arange(n) + 20000
for i in range(1,n):
  if a[i - 1] == a[i]:
    a[i] = b[i]
    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()))
count = 0
counter = 0

for i in range(len(a)-1):
    if i == len(a)-2 and a[i]==a[i+1]:
        count += int((i+2-counter)//2)
    if a[i]!=a[i+1]:
        count += int((i+1-counter)//2)
        counter = i + 1

print(count)

Submission status: Accepted

Solution code:
numbers=input()
slimmes=raw_input()
slimmes=slimmes.split(" ")

prev=slimmes[0]
count=0
spell=False
for i in range(1,numbers):
    if (prev==slimmes[i] and spell==False):
        count+=1
        spell=True
    else:
        spell=False
        
    prev=slimmes[i]
    
print count

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    if i == 0:
        a = A[i]
        count = 1
    else:
        if a == A[i]:
            count += 1
            continue
        else:
            ans += count // 2
            a = A[i]
            count = 1
ans += count // 2
print(ans)

Submission status: Accepted

Solution code:

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    k = 10001
    for i in range(n - 2):
        if a[i] == a[i + 1] and a[i + 1] == a[i + 2]:
            ans += 1
            a[i + 1] = k
            k += 1
    for i in range(n - 1):
        if a[i] == a[i + 1]:
            ans += 1
            a[i + 1] = k
            k += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#AGC26 A

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
cnt = 1
ans = 0
for i in range(1,n):
    if a[i] == a[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
tmp = 1
for i in range(N-1):
    if A[i] == A[i+1]:
        tmp += 1
    else:
        ans += tmp // 2
        tmp = 1
ans += tmp // 2
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
from collections import deque

N = int(input())
a = deque(list(map(int, input().split())))
tmp_a = []
tmp_c = 0
tmp_n = 0
ctr = 0

for i in range(N):
    tmp_n = a.popleft()
    if tmp_a == [] or tmp_a[-1] == tmp_n:
        tmp_c += 1
    else:
        ctr += tmp_c // 2
        tmp_c = 1
        tmp_a.clear()
    tmp_a.append(tmp_n)
    if a == deque([]) and tmp_a[-1] == tmp_n:
        ctr += tmp_c // 2
print(ctr)

Submission status: Accepted

Solution code:
s=l=c=0
for a in open(0).read().split()[1:]+[0]:
 if a!=l:l=a;s+=c//2;c=0
 c+=1
print(s)

Submission status: Accepted

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

sequence_num=a[0]
sequence_count=1
count=0

for i in range(1,n):
    if a[i]==sequence_num:
        sequence_count+=1
        if sequence_count%2==0:
            count+=1
    else:
        sequence_num=a[i]
        sequence_count=1
print(count)

Submission status: Accepted

Solution code:
def solve(n, a):
    ans = 0
    for i in range(1, n):
        if a[i-1] == a[i]:
            a[i] *= -1
            ans += 1
    return ans

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

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.append(999)
a=l[0]
l.remove(a)
c=1
l2=[]
for i in l:
  if a==i:
    c+=1
  else:
    if c!=1:
      l2.append(c)
    c=1
  a=i
c2=0
for i in l2:
  c2+=i//2
print(c2)

Submission status: Accepted

Solution code:
# 2019/09/03

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

ans = 0
c = 1
for i in range(1, N):
    if a[i] == a[i - 1]:
        c += 1
    else:
        ans += c // 2
        c = 1
ans += c // 2
print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    i = 0
    prev = -1
    count = 0
    while i < N:
        if prev == A[i]:
            prev = -1
            count += 1
        else:
            prev = A[i]
        i += 1
    return count

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
cl = 0
c = 0
for a in A:
  if cl != a:
    cl = a
  else:
    cl = 0
    c += 1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    t_cnt = 1
    for i in range(1, len(a)):
        if a[i-1] != a[i]:
            cnt += (t_cnt // 2)
            t_cnt = 1
        else:
            t_cnt += 1
    cnt += (t_cnt // 2)
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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 += 1
        i += 2
    else:
        i += 1

print (ans)

Submission status: Accepted

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

s = []
ap = a[0]
count = 0
for i in range(n):
    if ap == a[i]:
        count += 1
    else:
        if count > 1:
            s.append(count)
        ap = a[i]
        count = 1
if count > 1:
    s.append(count)

ans = 0
for x in s:
    ans += x//2
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, a: "List[int]"):
    res = 0
    c = -1
    if a[0] == a[1]:
        a[1] = c
        c -= 1
        res += 1
    for i in range(1, N-1):
        if a[i+1] == a[i]:
            a[i+1] = c
            c -= 1
            res += 1
    print(res)
    return


# Generated by 1.1.4 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:
n = int(input())
a = list(map(int, input().split()))

l = a[0]
cnt = 1
ans = 0

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

ans += cnt // 2

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
da=list(map(int,input().split()))
co=0
no=-1
ko=0
ans=0
while co<n:
    if no==da[co]:
        ko+=1
    else:
        ans+=ko//2
        no=da[co]
        ko=1
    co+=1
ans+=ko//2
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]=a[i+1]*3+10000
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(e) for e in input().split()]
p = a[0]
result = 0
for i in range(1, n):
  if p == a[i]:
    result += 1
    p = -1
  else:
    p = a[i]
print(result)

Submission status: Accepted

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

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

def runLength(s):
    a = []
    for c in s:
        if len(a)==0 or a[-1][0]!=c:
            a.append([c,1])
        else:
            a[-1][1] += 1
    return a

r = runLength(a)
ans = 0
for i in r:
    ans += i[1]//2
print(ans)