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(raw_input())
a = map(int, raw_input().split())
dp = [0, 0]
p = -1
for x in a:
    if p == x:
        dp = [dp[1], min(dp[0], dp[1]) + 1]
    else:
        dp = [min(dp[0], dp[1]), min(dp[0], dp[1]) + 1]
    p = x
print min(dp)

Submission status: Accepted

Solution code:
#
import sys
import math
import numpy as np
import itertools

n = int(input())

a = [int(i) for i in input().split()] 

answer = 0
ren = 0
for i in range(1,n):
    if a[i] == a[i-1]:
        ren += 1
    else:
        if ren > 0:
            answer += (ren+1) // 2
            ren = 0
answer += (ren+1) // 2
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input(""))
a = list(map(int, input("").split(" ")))
f = int(1e4)

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

print(count)

Submission status: Accepted

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

ans = 0
temp = 200000
c = 0
for i in a:
    if temp != i:
        ans += c//2
        c = 0
    c += 1
    temp = i
ans += c//2
print(ans)

Submission status: Accepted

Solution code:
# encoding:utf-8
 
def main():
	n = int(input())
	nums = list(map(int, input().split()))

	ans = 0
	flag = 0
	for i in range(n - 1):

		if flag == 1:
			flag = 0
			continue

		if nums[i + 1] == nums[i]:
			ans += 1
			flag = 1


	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

count = 0

for i in range(0, len(nums)-1):
    if nums[i] == nums[i+1]:
        nums[i+1] = -1
        count += 1

print(count)

Submission status: Accepted

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

count = 0

for i in range(1,len(a)):
    if a[i] == a[i-1]:
        count += 1
        if i < len(a)-1 :
            a[i] = a[i-1] + a[i+1]
        
print(count)

Submission status: Accepted

Solution code:
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split(' '))

res, l, r = 0, 0, 0
while r < n:
  l = r
  while r+1 < n and a[r+1] == a[l]:
    r += 1
  res += (r - l + 1) / 2
  r += 1
print res

Submission status: Accepted

Solution code:
# cook your dish here
#import numpy as np
n=int(input())
a = list(map(int,input().split()))

c =0
k = 0

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

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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def solve():
    n = int(input())
    al = [int(i) for i in input().split()]
    ans = 0
    for i in range(n - 1):
        if al[i] == al[i + 1]:
            ans += 1
            al[i + 1] = 99999
    print(ans)

if __name__=="__main__":
    solve()

Submission status: Accepted

Solution code:
import sys

sys.stdin.readline()
As= map(int, sys.stdin.readline().split())
last = None
cnt = 0
for a in As:
    if last is not None and a == last:
        cnt += 1
        last = None
    else:
        last = a
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A
N=input()
A_list=list(map(int,input().split()))
n=0
for i in range(len(A_list)-1):
    if A_list[i]==A_list[i+1]:
        A_list[i+1]+=10000
        n+=1
print(n)

Submission status: Accepted

Solution code:
N = int(input())
s = list(map(int, input().split()))
res = 0
for i in range(N-1):
    if s[i] == s[i+1]:
        res += 1
        s[i+1] = -1

print(res)

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:
def main():
    ret = 0
    n = int(input())
    a = list(map(int, input().split()))
    current = a[0]
    temp = 1
    for i in a[1:]:
        if i != current:
            ret += temp // 2
            temp = 1
            current = i
        else:
            temp += 1
    print(ret + temp // 2)
    return 0
main()

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] = -1
    count+=1


print(count)

Submission status: Accepted

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

continum = 0
prev_num = 0

a.append(-1)
ans = 0
for a_i in a:
    if prev_num == a_i:
        continum += 1
    else:
        ans += max(0, (continum)//2)
        continum = 1
        prev_num = a_i

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N = int(input())
A = list(inpl()) + [0]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:
def read_ints():
    return [int(c) for c in input().split()]


def main():
    n = int(input())
    xs = read_ints()
    accs = []
    prev = -1
    cur = 0
    for x in xs:
        if x != prev:
            accs.append(cur)
            cur = 0
        cur += 1
        prev = x
    accs.append(cur)

    ans = sum(acc // 2 for acc in accs)
    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

slime = list(map(int,input().split()))

b = 0
c = 0

for i in range(n):
  if(b == slime[i]):
    c += 1
    b = 0
  else:
    b = slime[i]

print(c)

Submission status: Accepted

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

k=0
t=0
ans=0
for i in range(n):
	if a[i]==k:
		t+=1
	else:
		ans+=t//2
		k=a[i]
		t=1
ans+=t//2
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] = 10 ** 4
        count += 1
print(count)

Submission status: Accepted

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
a = reads()
a.append(-1)

ans = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = int(input())
A = list(map(int, input().split()))
prev = None
ans = 0
for a in A:
    if prev == a:
        ans += 1
        prev = None
    else:
        prev = a
print(ans)

Submission status: Accepted

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

prev = -1
seq = 1
ans = 0
for a in src:
    if prev == a:
        seq += 1
    else:
        ans += seq//2
        seq = 1
    prev = a

if seq > 1:
    ans += seq//2
print(ans)

Submission status: Accepted

Solution code:

    
def main():
    n = int(input())
    a = [int(x) for x in input().split(' ')]

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Ans = 0
sub = 1
for i in range(N-1):
    if A[i]==A[i+1]:
        sub += 1
    else:
        Ans += sub//2
        sub = 1
else:
    Ans += sub//2

print(Ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
#M = int(input())
#S = input()
#a, b = map(int, input().split())
A = list(map(int, input().split()))
#a = list(map(str, input().split()))

#data = []
#for i in range(N):
#    data.append(list(map(int, input().split())))
#print(data)

cnt = 0
i = 1
while True:
    if i >= N:
        break
    if A[i] == A[i-1]:
        cnt += 1
        i += 1
    i += 1

print(cnt)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

cnt = 0;
prev = -1
aa = []
for ai in a:
    if ai != prev:
        aa.append(cnt)
        cnt = 1
    else:
        cnt += 1
    prev = ai

aa.append(cnt)

ans = 0
for aai in aa:
    ans += aai // 2

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin, stdout

n = int(stdin.readline())
values = list(map(int, stdin.readline().split()))
ans = 0

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

stdout.write(str(ans))

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
L=[[A[0]]]
k=0
for i in range(1,N):
    if A[i-1]==A[i]:
        L[k].append(A[i])
    else:
        L.append([])
        k+=1
        L[k].append(A[i])
ans=0
for p in L:
    ans+=len(p)//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] = -1
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print ans

Submission status: Accepted

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

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def main():
    rl()
    A = srl(int)
    p = 0
    c = 1
    ret = 0
    for x in A:
        if x == p:
            c += 1
        else:
            ret += c / 2
            p = x
            c = 1
    ret += c / 2
    print ret


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(raw_input())
A=[int(x) for x in raw_input().split()]
ans=0
for i in range(1,N):
    if A[i]==A[i-1]:
        ans+=1
        A[i]=999999
print ans

Submission status: Accepted

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

count = 0
for i in range(1, n):
    if a[i-1] != -1 and a[i-1]==a[i]:
        count += 1
        a[i] = -1
print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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
    # error_print(A)
    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()

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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
#sys.stdin=open("data.txt")
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

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 #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Submission status: Accepted

Solution code:
# coding: utf-8
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)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

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

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
a = l()

i=1
while i < n:
    if a[i] == a[i+1]:
        ans += 1
        i += 1
    i += 1

print(ans)

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main() {
     long long int N;
     cin >> N;
     std::vector<long long int> v;
     for(long long int i=0;i<N;i+=1){
          long long int x;
          cin >> x;
          v.push_back(x);
     }
     std::vector<long long int> c(v);
     long long int ans = 0;
     long long int a = -1;
     for(long long int i=1;i<N;i+=2){
          if(c[i]==c[i-1] || c[i]==c[i+1]){
               c[i]=a;
               a-=1;
               ans+=1;
          }
     }
     a = -1;
     long long int ans2 = 0;
     for(long long int i=0;i<N;i+=2){
          if(i==0){
               if(v[i]==v[i+1]){
                    ans2+=1;
                    v[i]=a;
                    a-=1;
               }
               continue;
          }
          
          if(v[i]==v[i-1] || v[i]==v[i+1]){
               v[i]=a;
               ans2+=1;
               a-=1;
          }
     }
     cout << min(ans,ans2);
     
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main() {
     long long int N;
     cin >> N;
     std::vector<long long int> v;
     for(long long int i=0;i<N;i+=1){
          long long int x;
          cin >> x;
          v.push_back(x);
     }
     std::vector<long long int> c(v);
     long long int ans = 0;
     int a = -1;
     for(long long int i=1;i<N;i+=2){
          if(c[i]==c[i-1] || c[i]==c[i+1]){
               c[i]=a;
               a-=1;
               ans+=1;
          }
     }
     a = -1;
     long long int ans2 = 0;
     for(long long int i=0;i<N;i+=2){
          if(i==0){
               if(v[i]==v[i+1]){
                    ans2+=1;
                    v[i]=a;
                    a-=1;
               }
               continue;
          }
          
          if(v[i]==v[i-1] || v[i]==v[i+1]){
               v[i]=a;
               ans2+=1;
               a-=1;
          }
     }
     cout << min(ans,ans2);
     
}

Submission status: Runtime Error

Solution code:
n = int(input())
arr = list(map(int, input().split()))
from numpy import random
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: Runtime Error

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 + 1 < N:
                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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
from itertools import groupby as gb
ans=0
for a,b in gb(list(map(int,input().split()))):
    ans+=b//2
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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]:
        sum+=1
        a[i] = 0

print(sum1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int,input().split()))
result = 0
for i in range(N-1):
  if A[i] == A[i+1]:
    result += 1
    if A[i+2]!=A[i+1] :
      A[i+1] = abs(A[i+2]-A[i+1])
    elif A[i+2]==A[i+1] and A[i+1]==1:
      A[i+1] = 2
    else:
      A[i+1] = 1
print(result)

Submission status: Runtime Error

Solution code:

Enter a title here
Main.py 
Success  
  
        
出力
入力
コメント 0
(0.03 sec)
 
4

Submission status: Runtime Error

Solution code:
N = int(input())
L = list(map(int,input().split()))
res = 0
if len(L) == len(set(L)):
    print(0)
    
for S in range(N-1):
    if L[S] == L[S+1]:
        L[S+1] = L[S+1]+  L[S+2] if L[S+2] else L[S+1*3]
        res += 1
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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[0])
a=list(map(int,input[1].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: Runtime Error

Solution code:
from itertools import*;n,a=open(0);print(sum(len(list(g))

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():

    return
#B
def B():

    return

#C
def C():
    n = I()
    s = S()
    for i in range(n>>1):
      s[i],s[n-i-1] = s[n-i-1],s[i]
    d = defaultdict(lambda : 0)
    m = 1<<n
    for i in range(m):
        r = []
        b = []
        for j in range(n):
            if i&(1<<j):
                r.append(s[j])
            else:
                b.append(s[j])
        d[(tuple(r),tuple(b))] += 1
        
    ans = 0
    for i in range(m):
        r = []
        b = []
        for j in range(n):
            if i&(1<<j):
                r.append(s[j+n])
            else:
                b.append(s[j+n])
        ans += d[(tuple(r),tuple(b))]
    print(ans)
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()