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

Solution code:
import math

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

  else:
    end += 1


print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

Submission status: Runtime Error

Solution code:
from collections import defaultdict

N = int(input())
S = input()
first = S[:N]
last = S[::-1][:N]

d = defaultdict(int)
ans = 0

def paint(str, ptn):
  return (red, blue)

for i in range(2**N):
  red = ''.join(s for j, s in enumerate(first) if 2**j & ptn)
  blue = ''.join(s for j, s in enumerate(first) if not 2**j & ptn)
  d[paint(red, blue)] += 1
  
for i in range(2**N):
  red = ''.join(s for j, s in enumerate(last) if 2**j & ptn)
  blue = ''.join(s for j, s in enumerate(last) if not 2**j & ptn)
  ans += d[paint(red, blue)]
  
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = input()
A = [int(x) for x in input().split()]

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

Submission status: Runtime Error

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

ans += count//2
print(ans)

Submission status: Runtime Error

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

ans += count//2
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
slime=list(map(int,input().split()))
stack=0
ans=0
for i in slime:
  if i!=stack:
    stack=i
    ans+=(count+1//2)
    count=0
    continue
  count+=1
ans+=(count+1//2)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

X = list(input().split())
X.append(1000000)
ans = 0

for i in range(1, n):
    if(X[i-1] == X[i]):
        ans+=1
        X[i] = X[i-1] + X[i+1]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(cnt)

Submission status: Runtime Error

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, 2)])
print(s, flush=True)

Submission status: Runtime Error

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, 2)])
print(s, flush=True)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(n-1):
    if li[i] == li[i+1]:
        li[i+1] = li[i]*li[i+2]+1
        count += 1

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

c = 0
i = 0
ans = 0
while i < n:
    if a[i] == a[i+1]:
        c += 1
        i += 1
    else:
        ans += c//2
        c = 0
        i += 1
print((ans+c//2,ans)[c==0])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=input()
maho=0
A=A.split()
for i in range(N-1):
    if A[i]==A[i+1]:
        if i!=N-1:
            A[i+1]=int(A[i+2])+1
        maho+=1
print(maho)

Submission status: Runtime Error

Solution code:
N=int(input())
A=input()
maho=0
A=A.split()
for i in range(N-1):
    if A[i]==A[i+1]:
        A[i+1]=int(A[i+2])+1
        maho+=1
print(maho)

Submission status: Runtime Error

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)>2:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    if l[0]==0:
      p=l.pop(0)
      if len(l)>0:
        p=l.pop(0)
      else:
         break
    else:
      p=l.pop(0)
if p==0:c+=1
print(c)

Submission status: Runtime Error

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)>2:
      if l[0]==0 and l[1]==0:
        p=l.pop(0)
        p=l.pop(0)
        c+=1
      else:
        break
    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: Runtime Error

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 l[0]==0 and l[1]==0:
      p=l.pop(0)
      p=l.pop(0)
      c+=1
    if l[0]==0:
      p=l.pop(0)
      p=l.pop(0)
    else:
      p=l.pop(0)
print(c)

Submission status: Runtime Error

Solution code:
iN = int(input())
aS = map(int,input().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:
      iU = max(aS[i],aS[i+1])
      if iU < 10000:
        iU += 1
      else:
        while iU not in aS[i:i+2]:
          iU -= 1
      aS[i] = iU
      iCounter += 1
print(iCounter)

Submission status: Runtime Error

Solution code:
T  = int(input())
def gcd(a,b):
    if b==0: return a
    return gcd(b, a%b)
for _ in range(T):
    a,b,c,d =list( map(int, input().split()) )
    if a<b or d<b:
        print('No')
        continue
    a %= b
    d%=b
    d = gcd(d,b)
    if c>= b:
        print('Yes')
        continue
    x = (b-a)//d
    y = a+ x*d
    if y == b: y-=d
    if y>c:
        print('No')
    else:
        print('Yes')

Submission status: Runtime Error

Solution code:
T  = int(input())
def gcd(a,b):
 if b==0: return a
 return gcd(b, a%b)
for _ in range(T):
 a,b,c,d =list( map(int, input().split()) )
 a %= b
 d%=b
 d = gcd(d,b)
 if c>= b:
  print('Yes')
  continue
 x = (b-a)//d
 y = a+ x*d
 if y == b: y-=d
 if y>=c:
  print('No')
 else:
  print('Yes')

Submission status: Runtime Error

Solution code:
import random
n=int(input())
a=input().split(' ')

count = 0
for i in range(n-1):
	if a[i]==a[i+1]:
		count+=1
		if i<n-1:
			while True:
				a[i+1]=random.randint(1,n)
				if a[i+1]!=a[i+2]:
					 break
				else:
					continue
print(count)

Submission status: Runtime Error

Solution code:
t = int(input())
a, b, c, d = map(int, input().split())
for i in range(t):
    if a>=b and c >=b and d>=b:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
n  = int(input())
a = map(int, [input() for i in range(n)])

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

i=1
count=0

while i<n:
  if a[i]=a[i-1]:
    count+=1
    i+=2
  else:
    i+=1

print(count)

Submission status: Runtime Error

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

i = 1
count = 0

while i < n:
  if a[i] = a[i-1]:
    count += 1
    i += 2
    else:
      i += 1

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
test_cases = input()

for test_case in range(test_cases):
	A, B, C, D = map(int, raw_input().split(' '))

	last_take = max(1, (A - C + B - 1) // B)
	A -= last_take * B

	if A < 0 or B > D:
		print "No"
	elif B == D or B <= C: 
		print "Yes"
	else:
		printed = False

		for i in range(10000):
			x = (C - A) // (D - B) + 1
			A += (D - B) * x
			last_take = max(1, (A - C + B - 1) // B)
			A -= last_take * B

			if A < 0:
				print "No"
				printed = True
				break
			
		if printed is False:
			print "Yes"

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
from collections import defaultdict

N = int(input())
S = input()
A, B = S[:N], S[N:]
D = defaultdict(int)
ans = 0

def paint(X, i):
    r = ""
    b = ""
    for j, k in enumerate(format(i, "b").zfill(N)):
        if k == "1":
            r += X[j]
        else:
            b += X[j]
    return r, b

for i in range(2**N):
    r, b = paint(A, i)
    D[(r, b)] += 1

for i in range(2**N):
    r, b = paint(B, i)
    ans += D[(b[::-1], r[::-1])]

print(ans)

Submission status: Runtime Error

Solution code:
n = int( input() )
a =  raw_input().split()
pas = 0
count = 0
for i in range(n):
   if a[i] == a[i+1] and pas != 1:
      count += 1
      if a[i+1] == a[i+2]:
         pas = 1
   else :
      pas = 0         
print(count)

Submission status: Runtime Error

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

c = 0


for i in range(1,n):
    if not boon and l[i] == l[i-1]:
        c += 1
        boon = True
    else:
        boon = False

print(c)

Submission status: Runtime Error

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

c = 0
i = 0
def s():
    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)
    return 0

s()

Submission status: Runtime Error

Solution code:
from sys import stdin
import math
columns = int(stdin.readline().rstrip())
datas = [stdin.readline().rstrip().split() for _ in range(columns)]
for data in datas:
    A = int(data[0])
    B = int(data[1])
    C = int(data[2])
    D = int(data[3])
    if A < B:
        print("No")
        continue
    if D < B:
        print("No")
        continue
    if C > B:
        print("Yes")
        continue
    g = math.gcd(B,D)
    if (B - g + A % g) >C :
        print("No")
    else:
        print("Yes")

Submission status: Runtime Error

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

    for i in range(1, N):
        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: Runtime Error

Solution code:
import numpy as np
if __name__ == "__main__":
    T = input().rstrip().split(' ')
    T = int(T[0])
    for t in range(T):
        line = input().rstrip().split(' ')
        A = int(line[0])
        B = int(line[1])
        C = int(line[2])
        D = int(line[3])
        A_list = []
        flag = True

        if B > A:
            print('No')
            continue
        if B > D:
            print('No')
            continue
        if C > B:
            print('Yes')
            continue

        while True:
            if A in A_list:
                flag = True
                break
            A_list.extend([A])
            if A < B:
                flag = False
                break
            q, A = divmod(A, B)
            for i in range(q-1):
                if A + B > C:
                    break
                A += B
            A_list.extend([A + B])
            if A <= C:
                A += D
        if flag:
            print('Yes')
        else:
            print('No')

Submission status: Runtime Error

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

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

count = 0
tmp = 1
for i in range(1, N):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)

Submission status: Runtime Error

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

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

count = 0
tmp = 1
for i in range(1, N+1):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)

Submission status: Runtime Error

Solution code:
import fractions
T = int(input())

L = []
for i in range(0,T):
    L = list(map(int, input().split()))
    A = L[0]
    B = L[1]
    C = L[2]
    D = L[3]

    ans = "Yes"
    if A < B: #前提条件
        ans = "No"
    elif D < B: #前提条件
        ans = "No"
    elif B - C <= 1: #BとCの差が1より小さければ何が来てもOK
        ans = "Yes"
    elif C < B-fractions.gcd(B,D)+(A%fractions.gcd(B,D)):
        ans = "No"


    print(ans)
    L = []

Submission status: Runtime Error

Solution code:
T = int(input())
a = []
for i in range(T):
    a.append(list(map(int, input().split())))
for r in a:
    s, b, c, d = r[0], r[1], r[2], r[3]
    mod_list = []
    if (s < b) or (b>d):
        print('No')
        continue
    if (c>b):
        print('Yes')
        continue
    while True:
        s = s%b
        if s > c:
            print('No')
            break
        s += d
        if s in mod_list:
            print('Yes')
            break
        mod_list.append(s)

Submission status: Runtime Error

Solution code:
T = int(input())
a = []
for i in range(T):
    a.append(list(map(int, input().split())))
for r in a:
    s, b, c, d = r[0], r[1], r[2], r[3]
    mod_list = []
    if (s < b) or (b>d):
        print('No')
        break
    if (c>b):
        print('Yes')
        break
    while True:
        s = s%b
        if s > c:
            print('No')
            break
        s += d
        if s in mod_list:
            print('Yes')
            break
        mod_list.append(s)

Submission status: Runtime Error

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

def shout():
    N = int(input())
    a = int(input().split(" "))
    for N in range(N):
      if a[i] != a[i + 1]:
        print(a[i] + a[i + 1])
        

if __name__ == '__main__':
    shout()

Submission status: Runtime Error

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

#print slimes
count=0
for i in range(0,len(slimes)):
    if slime[ i ]==slimes[i+1]:
        count+=1
    else:
        continue
magic=count/2
print(magic)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N = int(input())
colors = int(input())
count = 0
for i in range(1,N)
if i % 2 == 0 :continue
elif color[i-1] == color[i] or color[i] == color[i+1]
    color[i] = color[i-1] + color[i+1]
    color[i] = color[i] % 10000
    count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
s = 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: Runtime Error

Solution code:
N = int(input())
colors = int(input())
count = 0
for i in range(1,N)
	if i % 2 == 0 :continue
    elif color[i-1] == color[i] or color[i] == color[i+1]
    color[i] = color[i-1] + color[i+1]
    color[i] = color[i] % 10000
    count = count + 1
	print(count)

Submission status: Runtime Error

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

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

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] = (data[i+1]+data[i+2])%10000
        count+=1
        
print(count)

Submission status: Runtime Error

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] = (data[i+1]+data[i+2])%10000

        count+=1
print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
li=[]
re=[]
for i in range(n):
	li.append(list(map(int,input().split())))
	if li[i][0] >= li[i][1] and li[i][1] <= li[i][3]:
		Lim=li[i][0]%li[i][1]
		if li[i][1] == li[i][3]:
			pass
		else:
			while Lim+li[i][3]-li[i][1]<li[i][1]:
				Lim=Lim+li[i][3]-li[i][1]
		if li[i][2] >= Lim:
			re.append("Yes")
		else:
			re.append("No")
	else:
		re.append("No")
for value in re:
 print(value)

Submission status: Runtime Error

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] = data[i+1]+data[i+2]+1
        else:
            data[i] = data[i+1]+1
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
#A = 初期値　B = 一日の購入　C = 乳化のボーダー　D =在庫の増やす数

#A > B
#D % B >= B - C

size = int(input())
data = []
flag = 0

for i in range(size):
    ip = input().split()
    data = []
    for j in ip:
        data.append(int(j))
    #定義
    buf = []
#    print(store,buy,bord,charge,buf)
    #最初の処理
    data[0] = data[0] % data[1]
    if data[0] > data[3]:
        flag = 1
    #定常処理
    while data[0] not in buf:
        buf.append(data[0])
        data[0] = (data[0] + data[3]) % data[1]
        if data[0] > data[3]:
            flag = 1
            break
 #   print(buf)
    if flag == 1:
        print("No")
        flag = 0
    else:
        print("Yes")

Submission status: Runtime Error

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

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

count = 0
i = 1
while i <= (N-1):
    if A[i] == A[i - 1]:
        j = i + 1
        if j <= (N-1):
            while True:
                if A[j] == A[j - 1]:
                    count += 1
                    j += 1
                else:
                    count += 2
                    i = j
                    break
        else:
            count += 2
            break
    else:
        i += 1

print(count // 2)

Submission status: Runtime Error

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

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()]
    check(a)
    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: Runtime Error

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] = a[i-2] if a[i-2] == 0 else a[i+2]

print(count)

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(1000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

Solution code:
from sys import stdin

t = stdin.readline()
t_i = int(t)
data = [stdin.readline().rstrip().split() for _ in range(t_i)]
#print(data)
for i in range(t_i) :
    a = int(data[i][0])
    b = int(data[i][1])
    c = int(data[i][2])
    d = int(data[i][3])
    #print(a, b, c, d)
    if a < b :
        print("No")
    elif b > d :
        print("No")
    elif a % b > c and a % b < b :
        print("No")
    else :
        #print("Yes")
    
        stock = a
        count = 0
        while True :
            stock = stock - b
            if stock < 0 :
                print("No")
                break
            if stock <= c :
                stock = stock + d
            count = count + 1
            if count > 10000 :
                print("Yes")
                break

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(1100):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(1200):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(1500):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(2000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(5000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(10000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

Solution code:
t = int(input())
for i in range(t):
    able = "Yes"
    a,b,c,d = map(int, input().split())
    if a - b < 0:
        able = "No"
    else:
        x = c+(a-c)%b
        if x <= c:
            x+=d
        for i in range(100000):
            x-=b
            if x >= 0:
                if x <= c:
                    x+=d
            else:
                able = "No"
                break
    print(able)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if N != 2:
    for i in range(1,N):
        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: Runtime Error

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

count=0
for i in range(len(l)-1):
    if i == len(l)-1:
        break
    if l[i] == l[i+1]:
        if l[i+1]+l[i+2]< 10000:
            l[i+1] = l[i]+l[i+2]
        else:
            l[i+1] = l[i]-l[i+2]
        count=count+1
print(count)

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
a=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 changeflag[i-1]==1:
            changeflag.append(0)
        else:
            ans+=1
            changeflag.append(1)
    else:
        changeflag.append(0)
print(ans)

Submission status: Runtime Error

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

left = a[0]

for i in range(1,N):
    if  a[i] == left:
        a[i] += 1
        if not i == N and a[i] == a[i + 1]:
            a[i] += 1
        cnt += 1
    left = a[i]

print(cnt)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
counteven = 0
countodd = 0
for i in range(N//2):
    if i == 0:
        if A[i] == A[2*i+2]:
            counteven += 1
    elif A[2*i-2] == A[2*i] or A[2*i] == A[2*i+2]:
        counteven += 1

for i in range(N//2):
    if i == 0:
        if A[2*i+1] == A[2*i+3]:
            countodd += 1
    elif A[2*i-1] == A[2*i+1] or A[2*i+1] == A[2*i+3]:
        countodd += 1

print(min(counteven,countodd))

Submission status: Runtime Error

Solution code:
n = int(input())
l = [[int(i) for i in input().split()] for i in range(n)]
prev = 0
flag = False
result = 0
for i in l:
    if flag == False and i == prev:
        flag = True
        result += 1
    elif flag == True:
        flag = False
    prev = i
print(result)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counte %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))