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: Wrong Answer

Solution code:
N = int(input())
arr = [int(_) for _ in input().split()]
count0 = 0
count1 = 0
for i in range(N):
    if i > 0 and i < N-1:
        if arr[i-1] == arr[i] or arr[i+1] == arr[i]:
            if i%2 == 0:
                count0 += 1
            else:
                count1 += 1
    elif i==0:
        if arr[i] == arr[i+1]:
            count0 += 1
    elif i == N-1:
        if arr[i] == arr[i-1]:
            if i%2 == 0:
                count0 += 1
            else:
                count1 += 1
print(min(count0,count1))

Submission status: Wrong Answer

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

slime = 10000

for i in range(N):
    if i == 0 or i == N-1:
        continue
    else:
        if inputs[i-1] == inputs[i] == inputs[i+1]:
            inputs[i] = slime
            slime -= 1
        elif i+2 <= N-1 and inputs[i] == inputs[i+1] == inputs[i+2]:
            continue
        elif inputs[i-1] == inputs[i] or inputs[i] == inputs[i+1]:
            inputs[i] = slime
            slime -= 1

print(10000-slime)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().split()
s = 0
for j in range(1, N//2+1):
	s += sum([all([S[i] == S[i+k] for k in range(1, j+1)]) for i in range(0, N-j)]) * ((-1) ** (j-1))
	
print(s, flush=True)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().split(' ')
s = sum([S[i-1] == S[i] or S[i] == S[i+1] for i in  range(1, N-1, 2)])
s -= sum([S[i-1]== S[i] == S[i+1] for i in  range(2, N-1, 2)])
print(s, flush=True)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
ans=chk=0
for i in l:
    if i==chk:
        chk=0
        ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()

for i in range(1, n+1):
    str_i = str(i)
    s = s.replace(str_i+" "+str_i, str_i)

print(n-len(s))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input().replace(" ", "")

for i in range(1, n+1):
    str_i = str(i)
    s = s.replace(str_i*2, str_i)

print(n-len(s))

Submission status: Wrong Answer

Solution code:
N = int(input())
pre_a = 0
cont = 0
ans = 0

for a in input().split():
	if pre_a == a:
		cont += 1
	else:
		ans += cont // 2
		cont = 1
	pre_a = a

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=0
l=[]
for i in range(1,n):
  l.append(a[i]-a[i-1])
p=l.pop(0)
while len(l)!=0:
  if p!=0:
    p=l.pop(0)
  else:
    c+=1
    while len(l)>1:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    while len(l)>0:
      if l[0]==0:
        p=l.pop(0)
      else:
        p=l.pop(0)
        break
print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
c=0
l=[]
for i in range(1,n):
  l.append(a[i]-a[i-1])
p=l.pop(0)
while len(l)!=0:
  if p!=0:
    p=l.pop(0)
  if p==0:
    c+=1
    while len(l)>1:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    while len(l)>0:
      if l[0]==0:
        p=l.pop(0)
        if len(l)>0:
          p=l.pop(0)
        else:
          break
      else:
        p=l.pop(0)
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
iN = int(input())
aS = [int(x) for x in input().rstrip().split()]

#はぁ こんなのを一発で通れるようなものも書けないのか.. つらい





iCounter = 0
if iN == 2:
    if aS[0] == aS[1]:
        iCounter += 1
else:
    for i in range(1,iN-1):
        if aS[i] == aS[i-1]:
            if aS[i] == aS[i+1]:
                if aS[i] < 10000:
                    aS[i] += 1
                else:
                    aS[i] -= 1
                iCounter += 1
            else:
                iU = max(aS[i],aS[i+1])
                if iU < 10000:
                    iU += 1
                else:
                    iU -= 1
                    if iU == min(aS[1],aS[i+1]):
                        iU -= 1
                aS[i] = iU
                iCounter += 1
print(iCounter)

Submission status: Wrong Answer

Solution code:
iN = int(input())
aS = [int(x) for x in input().rstrip().split()]

#はぁ こんなのを一発で通れるようなものも書けないのか.. つらい

iCounter = 0
if iN == 2:
    if aS[0] == aS[1]:
        iCounter += 1
else:
    for i in range(1,iN-1):
        if aS[i] == aS[i-1]:
            if aS[i] == aS[i+1]:
                if aS[i] != 10000:
                    aS[i] += 1
                else:
                    aS[i] -= 1
                iCounter += 1
            else:
                if i == iN - 2:
                    continue
                else:
                    iU = max(aS[i],aS[i+1])
                    if iU < 10000:
                        iU += 1
                    else:
                        iU -= 1
                        if iU == min(aS[1],aS[i+1]):
                            iU -= 1
                    aS[i] = iU
                    iCounter += 1
print(iCounter)

Submission status: Wrong Answer

Solution code:
iN = int(input())
aS = [int(x) for x in input().rstrip().split()]

iCounter = 0
for i in range(1,iN-1):
    if aS[i] == aS[i-1]:
        if aS[i] == aS[i+1]:
            aS[i] += 1
            iCounter += 1
        else:
            if i == iN - 2:
                continue
            else:
                iU = max(aS[i],aS[i+1])
                if iU < 10000:
                    iU += 1
                else:
                    iU -= 1
                    if iU == min(aS[1],aS[i+1]):
                        iU -= 1
                aS[i] = iU
                iCounter += 1
print(iCounter)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
count = 0
if (N==len(a))and(2<=N):
    for i in range(1,N-1):
        if (a[i-1]==a[i]):
            a[i] += 1
            if a[i] > 10000:
                a[i] = 1
            if a[i]==a[i+1]:
                a[i] += 1
                if a[i] > 10000:
                    a[i] = 1
            count += 1
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def a_colorful_slimes_2(N, A):
    ans = 0
    used_color = set(A)
    for k in range(1, N - 1):
        if A[k - 1] == A[k]:
            ans += 1
            for num in range(1, 100001):
                if num not in used_color:
                    A[k] = num
                    used_color.add(num)
                    break
    return ans

N = int(input())
A = [int(i) for i in input().split()]
print(a_colorful_slimes_2(N, A))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = input().split(" ")

ans = 0
count = 0

for i in range(n-1):
	count += 1

	if(d[i] != d[i+1]):
		ans += int(count/2);
		count = 0;

if(count > 1):
	ans += int(count/2)

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

d = input().split(" ")
ans = 0

for i in range(1,n-1):
	if(d[i] == d[i-1] and d[i] == d[i+1]):
		ans += 1
		d[i] = -i;

	elif(d[i] == d[i-1]):
		ans += 1
		d[i-1] = -i

	elif(d[i] == d[i+1]):
		ans += 1
		d[i+1] = -i

# print(d)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = input()

v = map(int, raw_input().split(' '))

found = 0

i = 0
while i < N:
	j = i
	while j < N - 1 and v[i] == v[j + 1]:
		j += 1

	found += (j - i) / 2

	i = j + 1

print found

Submission status: Wrong Answer

Solution code:
N = input()

v = map(int, raw_input().split(' '))

found = 0

i = 0
while i < N:
	if v[i - 1] == v[i]:
		found += 1
		i += 1

	i += 1

print found

Submission status: Wrong Answer

Solution code:
N = input()

v = map(int, raw_input().split(' '))

found = 0

i = 0
while i < N - 1:
	if v[i - 1] == v[i]:
		found += 1
		i += 1

	i += 1

print found

Submission status: Wrong Answer

Solution code:
#agc026a
import sys

n=int(raw_input())
a=map(int,raw_input().split())
if len(set(a))==1:
 print n/2
 sys.exit()
cnt=0
temp=1
for i in xrange(1,n):
 if a[i]==a[i-1]:
  temp+=1
 else:
  cnt+=temp/2
  temp=1
print cnt

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()

arr = input().split()

temp = ""
count = 1

length = len(arr)

magic = 0

for i in range(length):
	if i is 0:
		temp = arr[0]
	elif i is length - 1:
		magic += int(count / 2)
	elif arr[i] is not temp:
		magic += int(count / 2)
		temp = arr[i]
		count = 1
	else:
		count += 1

print(magic)

Submission status: Wrong Answer

Solution code:
n = input()

arr = input().split()

temp = ""
count = 0

length = len(arr)

magic = 0

for i in range(length):
	if i is 0:
		temp = arr[0]
	elif i is length - 1:
		magic += int(count / 2)
	elif arr[i] is not temp:
		magic += int(count / 2)
		temp = arr[i]
		count = 1
	else:
		count += 1

print(magic)

Submission status: Wrong Answer

Solution code:
n = input()

arr = input().split()

print(arr)

temp = ""
count = 0

length = len(arr)

magic = 0

for i in range(length):
	if i is 0:
		temp = arr[0]
	elif i is length - 1:
		magic += int(count / 2)
	elif arr[i] is not temp:
		magic += int(count / 2)
		temp = arr[i]
		count = 1
	else:
		count += 1

print(magic)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

length = len(arr)
total = 0
cur = ""
temp = 0

for i in range(length):
    if (i is length - 1) or (arr[i] is not arr[i + 1]):
        total += int(temp / 2)
        temp = 0
    else:
        temp += 1

print(total)

Submission status: Wrong Answer

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

ans = []

i = 1
adjacent = 1

while i < n:
  if a[i] == a[i - 1]:
    adjacent += 1
  else:
    ans.append((adjacent + 1) // 2)
    adjacent = 1
  i += 1
  
print(sum(ans))

Submission status: Wrong Answer

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

ans = []

i = 1
adjacent = 1

while i < n:
  if a[i] == a[i - 1]:
    adjacent += 1
  else:
    ans.append((adjacent + 1) // 2)
    adjacent = 1
  i += 1
  
ans.append((adjacent + 1) // 2)
print(sum(ans))

Submission status: Wrong Answer

Solution code:
def main():
    """
    2 <= N <= 100
    1 <= ai <= N

    色の種類は10^4存在するが、N<=100より色は気にしなくて良い
    もし2色なら奥の色を考慮する必要がある

    abab: 0
    aaab: 1 (abab)
    aabb: 2 (acbc)
    aaaa: 2 (acac)
        2つ目のaを変更したあと、2と3つ目の関係を気にする必要がないので4つ目を考える
        4つ目を考慮することで3/5との関係を考慮できる
    """
    N = int(input())
    *A, = map(int, input().split())

    # A.append(-1)
    ans = 0
    i = 0
    while i < N:
        if A[i-1] == A[i]:
            ans += 1
            i += 2
        else:
            i += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

count = 0
for i in range(0, N-1):
    if a[i] == a[i+1]:
        count += 1
    while a[i] == a[i+1]:
        a[i+1] = random.randint(1, N)
print(count)

Submission status: Wrong Answer

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

count = 0
for i in range(0, N-2):
    if a[i] == a[i+1]:
        count += 1
    while a[i] == a[i+1]:
        a[i+1] = random.randint(1, N)
print(count)

Submission status: Wrong Answer

Solution code:
# n = int(input())
# colors = list(map(int, input().split()))
n = 14
colors = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 1, 2, 3, 4]
ans = []
i = 0
cnt = 0
while True:
    if i == n-1:
        cnt += 1
        ans.append(cnt)
        break
    if colors[i] != colors[i+1]:
        cnt += 1
        ans.append(cnt)
        cnt = 0
    else:
        cnt += 1
    i += 1


ans = list(map(lambda x: x //2, ans))
print(sum(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(" ")))
num_n =[]
i=1
for j in range(N-1):
    if l[j] == l[j+1]:
        i+=1
    else:
        num_n.append(int(i/2))
        i=1
print(sum(num_n))

Submission status: Wrong Answer

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

c = 0
i = 0

while i+2 < len(l):
    if l[i] == l[i+1]:
        if l[i+1] == l[i+2]:
            c += 1
            i += 2
        else:
            c += 1
            i += 2
    else:
        i += 1

print(c)

Submission status: Wrong Answer

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

    for i in range(1, N-1):
        if slimes[i-1] == slimes[i]:
            slimes[i] = 10001 + ans
            assert slimes[i] != slimes[i-1]
            assert slimes[i] != slimes[i+1]
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

i = 1
count = 0
while i <= (N-1):  # A[N-1] まで
    if A[i] == A[i-1]:
        j = i
        # 隣り合うものを比較
        while A[j] == A[j-1]:  # １回目は通る
            j += 1  # 必ず(j-i) >= 1 となる
            if j == N:  # リストの最後の処理
                j -= 1  # N=100 なら 99になる
                break

        # while終わった後、何個連続か計算
        if ((j-1) - (i-1)) == 1:
            count += 2
        else:
            count += ((j-1) - (i-1)) + 1
        i = j + 1  # i を j+1 まで一気に進める

    else:
        i += 1

print(count // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(map(int, input().split()))
c = 0

for i in range(1, N):
	if s[i] == s[i - 1]:
		c += 1
	else:
		pass
print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.append(0)
tl=0
count=0
for i in range(n):
    if a[i+1]==a[i]:
        tl+=1
    elif tl!=0:
        count+=tl//2
        tl=0
print(count)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0
for i in range(1,N-1,1):
    if data[i-1] == data[i]:
        if i < N-2:
            data[i] = 0
        else:
            data[i] = 0
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
a = map(int, raw_input().split())
ans = 0
i = 0
while i < N-1:
  if a[i] == a[i+1]:
    if i+2 < N and a[i] == a[i+2]:
      a[i+1] = 101+ans
      i += 3
    else:
      a[i] = 101+ans
      i += 2
    ans += 1
  else:
    i += 1
print ans

Submission status: Wrong Answer

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

count = 0
for i in range(1,N-1,1):
    if data[i-1] == data[i]:
        if i < N-2:
            data[i] = (data[i+1]+data[i+2])%10000
            i=i+1
        else:
            data[i] = data[i+1]%10000
        count+=1

print(count)

Submission status: Wrong Answer

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

count = 0
for i in range(1,N-1,1):
    if data[i-1] == data[i]:
        if i < N-2:
            data[i] = (data[i+1]+data[i+2])%10000
        else:
            data[i] = data[i+1]%10000
        count+=1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0
for i in range(1,N-1,1):
    if data[i-1] == data[i]:
        if i != N-1:
  	      data[i] = 10000-(data[i+1]+1)
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import random

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

cnt = 0
C = set(range(1, N + 1))
idx = 1
while idx < N:

    B = (A[idx - 1:-1][0], A[idx:][0], (A[idx + 1:] + [-1])[0], )
    DS = C - set(B)
    D = sorted(DS)

    if B[0] == B[1] or B[1] == B[2]:
        cnt += 1
        A[idx] = random.choice(D)
        idx += 1

    idx += 1

    print('A: {}'.format(A))

print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input()
c=0
cnt=0
q=2*n-1

for i in range(0,q-2,2):
  if a[i+2]==a[i]:
    c=c+1
  else:
    p=int(c/2+0.5)
    cnt=cnt+p
    c=0

p=int(c/2+0.5)
cnt=cnt+p

print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
flag = 0
for i in range(1,10001):
	if not(i in a) and flag == 0:
		a = [i] + a
		flag += 1
	elif not(i in a) and flag == 1:
		a = a + [i]
		flag += 1
	elif flag == 2:
		break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
flag = 0
for i in range(1,10001):
	if not(i in a) and flag == 0:
		a = [i] + a
		flag += 1
	elif not(i in a) and flag == 1:
		a = a + [i]
		flag += 1
	elif flag == 2:
		break

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

Submission status: Wrong Answer

Solution code:
import random as rd
a = int(input())
b = rd.sample(list(range(1, 10001)), k=a)
print(b)
result = 0
for num in range(0, len(b)-1):
    if b[num] == b[num+1]:
        result = result+1

print(result)

Submission status: Wrong Answer

Solution code:
import random

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

cnt = 0
C = set(range(1, N + 1))
for idx in range(1, N - 1):

    B = set([A[idx - 1:-1][0], A[idx:][0], (A[idx + 1:] + [-1])[0]])
    D = sorted(list(C - B))

    if len(B) != 3:
        cnt += 1
        A[idx] = random.choice(D)

print(cnt)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def check(a):
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if l == x or x == r:
            return False
    return True


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]

    if check(a):
        print(0)
        return

    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
            x = get(l, r)
            count += 1
            a[idx] = x
    # print(a)
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def check(a):
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        assert l != x and x != r, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
            x = get(l, r)
            count += 1
            a[idx] = x
    # print(a)
    check(a)
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
            x = get(l, r)
            count += 1
            a[idx] = x
    # print(a)
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if (l == x and x != r) or (l == x == r) or ((idx == len(a) - 2) and x == r):
            x = get(l, r)
            count += 1
            a[idx] = x
    print(a)
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

Solution code:
N = input()
inp = raw_input().split()
flag = 0
for i in xrange(len(inp)-1):
  if (int(inp[i]) - int(inp[i+1])) == 0:
    flag += 1
  else:
    continue
if flag == 0:
  print 0
elif flag != 0 and flag%2 == 0:
  print flag-2
elif flag != 0 and flag%2 == 1:
  print flag-1

Submission status: Wrong Answer

Solution code:
N = input()
inp = raw_input().split()
flag = 0
for i in xrange(len(inp)-1):
  if (int(inp[i]) - int(inp[i+1])) == 0:
    flag += 1
  else:
    continue
if flag == 0:
  print 0
elif flag%2 == 0:
  print flag-2
else:
  print flag-1

Submission status: Wrong Answer

Solution code:
N = input()
inp = raw_input().split()
flag = 0
for i in xrange(len(inp)-1):
  if (int(inp[i]) - int(inp[i+1])) == 0:
    flag += 1
  else:
    continue
if flag%2 == 0:
  print flag-2
else:
  print flag-1

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if (l == x and x != r) or (l == x == r):
            x = get(l, r)
            count += 1
            a[idx] = x
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = [int(x) for x in input().split()]

count = 0

# 一つ先を見たときに今の色と同じなら
# 今の色と二つ先の色以外の色に変更する
for i in range(n - 2):
    if nums[i] == nums[i + 1]:
        for j in range(1, n + 1):
            if j != nums[i] and j != nums[i + 2]:
                nums[i + 1] = j
                count += 1
                break
            else:
                continue

print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[]
a=input().split()
sum=0

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

print(sum)

Submission status: Wrong Answer

Solution code:
import random as rd
a = int(input())
b = rd.sample(list(range(0, 10001)), k=a)
print(b)
c = print(a//2)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=[]
a=input().split()
sum=0

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

print(sum)

Submission status: Wrong Answer

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

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        count = count + 1

if a[N-2] == a[N-1]:
    count = count + 1

print(count)

Submission status: Wrong Answer

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

if N != 2:
    for i in range(1,N-1):
        if a[i] == a[i-1]:
            a[i] = a[i+1] + 1
            count = count + 1
else:
    if a[0] == a[1]:
        count = count + 1


print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin
n = int(stdin.readline())
a = map(int,stdin.readline().split())
ans = 0
pr = 0
cnt = 0
for i in a:
 if i==pr:
  cnt+=1
 else:
  ans += cnt/2
 pr = i
ans += cnt/2
print ans

Submission status: Wrong Answer

Solution code:
from sys import stdin


def get(l, r):
    for i in range(1, 10001):
        if i != l and i != r:
            return i
    assert False, 'damepo'


def main():
    N = int(stdin.readline().rstrip())
    a = [int(x) for x in stdin.readline().rstrip().split()]
    l = a[0]
    count = 0
    for i, x in enumerate(a[1:-1]):
        idx = i + 1
        l = a[idx - 1]
        r = a[idx + 1]
        if l != x != r:
            pass
        elif (idx + 3) < len(a):
            if x == r == a[idx + 2] and x != a[idx + 3]:
                continue
        elif (idx + 2) < len(a):
            if x == r == a[idx + 2]:
                continue
        x = get(l, r)
        count += 1
        a[idx] = x
    # print(a)
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans,cnt, idx = 0,0,0
temp = 0
while(idx<n-1):
    if a[idx] != temp:
        temp = a[idx]
        ans += cnt//2
        cnt = 1
    else:
        cnt += 1
    idx += 1
ans += cnt//2
print(ans)