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

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

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

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

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

Solution (Python):

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)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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


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



if __name__ == '__main__':
    solve()

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

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

Solution (Python):


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

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

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

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

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

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

Solution (Python):

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)

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

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

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):

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):
        
        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))  
    a = [int(next(tokens)) for _ in range(N)]  
    solve(N, a)

if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
from operator import mul
from functools import reduce
from collections import Counter


















import sys

sys.setrecursionlimit(2000)


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



def cmb(n, r):
    
    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):
    
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    
    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)

Solution (Python):

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)

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

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

Solution (Python):
import math
import heapq
import sys
from collections import Counter




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

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


print(cnt)

Solution (Python):


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)

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

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

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

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

Solution (Python):

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)

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

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

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

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

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

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

Solution (Python):


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)

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

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

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

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

Solution (Python):
from itertools import groupby

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

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

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

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

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

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

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

    if tmp_num == a_L[val]:
        counter += 1
    if tmp_num != a_L[val] and counter != 0:
        counter +=1
        result_L.append(counter)
        
        counter = 0

    tmp_num = a_L[val]


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


print(sum(result_L))

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

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

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

Solution (Python):

def main():
    N, *A = map(int, open(0).read().split())
    ans, flg = 0, 0  
    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()

Solution (Python):






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)

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

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

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

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

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

Solution (Python):

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

Solution (Python):



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)

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

Solution (Python):


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)

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

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

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

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

Solution (Python):


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)

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

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

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

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

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

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

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