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

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    
    m = -1
    for i in range(1, N):
        if A[i-1] == A[i]:
            A[i] = m
            m -= 1
            ans += 1
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

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



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
As = map(int, input().split())

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

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

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

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

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
pre = a[0]
num = 0
for i in range(1, n):
    if pre == a[i]:
        num += 1
        pre = -1
    else:
        pre = a[i]

print(num)

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

ans = 0
flag = False
for i in range(1,N):
	if a[i] == a[i-1] and flag == False:
		ans += 1
		flag = True
	else:
		flag = False
print(ans)

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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

ans = 0
now = -1
for e in a:
    if e == now:
        ans += 1
        now = -1
    else:
        now = e
print(ans)

Solution (Python):

import sys

input=sys.stdin.readline

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

ans=0
lo=0
while lo<n:
    hi=lo+1
    while hi<n and a[lo]==a[hi]: hi+=1
    ans+=(hi-lo)//2
    lo=hi
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split(" ")))
prev = A[0]
cnt = 0
for i in range(1,N):
	if prev == A[i]:
		cnt += 1
		prev = (-1)
	else:
		prev = A[i]

print(cnt)

Solution (Python):


import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq





def solve(f):
    n = f.read_int()
    a = f.read_int_list()

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

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case 
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Solution (Python):

n=int(input())
a=list(map(int,input().split()))
p=-1
c=10000
for i in range(n):
    if a[i]!=p:
        p=a[i]
    else:
        p=c
        c-=1
print(10000-c)

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

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

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