Problem:


Score : 300 points

Problem Statement

N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N.

The i-th tile from the left is painted black if the i-th character of S is 0, and painted white if that character is 1.

You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.

At least how many tiles need to be repainted to satisfy the condition?

Constraints

1 \leq |S| \leq 10^5

S_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the minimum number of tiles that need to be repainted to satisfy the condition.

Sample Input 1

000

Sample Output 1

1

The condition can be satisfied by repainting the middle tile white.

Sample Input 2

10010010

Sample Output 2

3

Sample Input 3

0

Sample Output 3

0



Sample input:
000


Sample output:
1

Submission status: Wrong Answer

Solution code:
S = str(input())
S = list(S)

result = 0

#変更すべきものだったら変更したあとの前のものもの
#変更するべきものではない場合は前のもの
tempChangedTile = S[0]

for index, tile in enumerate(S):
    #最初だけヌルポを防ぐ
    if index == 0:
        tempChangedTile = tile
        continue
    
    try:
        if tempChangedTile != S[index+1]:
            tempChangedTile = S[index+1]
        else:
            result += 1
            if S[index + 1] == "0":
                tempChangedTile = "1"
            else:
                tempChangedTile = "0"
    except:
        pass

print(result)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline

# bisect_left(lists, 3)
# bisect_right(lists, 3)

def main():
	S = input()
	S = list(S)

	if len(S) == 2:
		print(0)
		sys.exit()

	fst = []
	snd = []
	for i, val in enumerate(S):
		if i == len(S)-1:
			break
		if i % 2 == 0:
			fst.append(val)
		else:
			snd.append(val)

	fst1 = collections.Counter(fst)
	snd1 = collections.Counter(snd)

	ans = 0
	if fst1["0"] < snd1["0"]:
		ans = fst1["0"] + snd1["1"]
	else:
		ans = fst1["1"] + snd1["0"]
	

	print(ans)

	
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
S = input()
count = 0
for i in range(len(S)):
    if S[i: i+3] == '000':
        S = S[:i+1] + '1' + S[i+2:]
        count += 1
    elif S[i: i+3] == '001':
        if i >0:
            S = S[:i-1] + '1' + S[i+1:]
        else:
            S = '1' + S[i+1:]
        count += 1
    elif S[i: i+3] == '011':
        S = S[:i+2] + '0' + S[i+3:]
        count += 1
    elif S[i: i+3] == '100':
        S = S[:i+2] + '1' + S[i+3:]
        count += 1
    elif S[i: i+3] == '110':
        if i > 0:
            S = S[:i-1] + '0' + S[i+1:]
        else:
            S = '0' + S[i+1:]
        count += 1
    elif S[i: i+3] == '111':
        S = S[:i+1] + '0' + S[i+2:]
        count += 1
    else:
        pass
print(count)

Submission status: Wrong Answer

Solution code:
S = input()
bin_S = int(S, 2)
N = len(S)
cout = 0
b = 0
w = 1
#
bw = []
for i in range(int(N / 2)):
    bw.append(b)
    bw.append(w)
if len(bw) < N:
    bw.append(b)
bw = ''.join(map(str, bw))

bin_bw = int(bw, 2)

#
wb = []
for i in range(int(N / 2)):
    wb.append(w)
    wb.append(b)
if len(wb) < N:
    wb.append(w)
wb = ''.join(map(str, wb))

bin_wb = int(wb, 2)
#
bw_and_S = format(bin_bw ^ bin_S,'b')
wb_and_S = format(bin_wb ^ bin_S,'b')
bwcout = 0
wbcout = 0

for i in range(len(bw_and_S)):
    if bw_and_S[i] == '0':
        bwcout += 1

for i in range(len(wb_and_S)):
    if wb_and_S[i] == '0':
        wbcout += 1

print(min(bwcout,wbcout))

Submission status: Wrong Answer

Solution code:
import sys, math
input = sys.stdin.readline

S = list(input().replace('\n',''))
S = list(map(int, S))
prev = S[0]
ans = 0
for i in range(1, len(S)):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
    if i == 1:
      if cur ^ S[i+1] == 1:
        prev = cur
      else:
        prev = 2 + ~cur
    else:
      prev = 2 + ~cur
  else:
    prev = cur

print(ans)

Submission status: Wrong Answer

Solution code:
S = list(raw_input())

array=[]

if len(S) == 1:
    print 0
else:
    cnt = 0
    for i in range(len(S)):
        print "--", i
        if i == 0:
            cnt = 1
        else:
            if S[i-1] == S[i]:
                array.append(cnt)
                cnt = 1
            else:
                cnt += 1
    array.append(cnt)
    print "array:",array
    even = [n for i,n in enumerate(array) if i % 2 == 0]
    odd  = [n for i,n in enumerate(array) if i % 2 == 1]

    print even
    print odd
    
    if sum(even) > sum(odd):
        print sum(odd)
    else:
        print sum(even)

Submission status: Wrong Answer

Solution code:
S = list(input())
flag = 0
ans_1 = 0
ans_2 = 0
# 最初を変える
flag_a = 0
for i in range(1, len(S)):
    if (flag_a == 0):
        if (S[i] == "1"):
            ans_1 += 1
        flag_a = 1
    else:
        if (S[i] == "0"):
            ans_1 += 1
        flag_a = 0
if (len(S) != 1):
    if (S[0] != S[1]):
        ans_1 = 1000000

# 最初を変えない
S1 = S[0]
if (S1 == "1"):
    flag_b = 1
else:
    flag_b = 0
for i in range(1, len(S)):
    if (flag_b == 0):
        if (S[i] == "0"):
            ans_2 += 1
        flag_b = 1
    else:
        if (S[i] == "1"):
            ans_2 += 1
        flag_b = 0
if (len(S) != 1):
    if (S[0] == S[1]):
        ans_2 = 1000000

print(min(ans_1, ans_2))

Submission status: Wrong Answer

Solution code:
s=input()
a=[]
for i in range(len(s)):
  if i%2==0:
    a.append(0)
  else:
    a.append(1)
b=[]
for j in range(len(s)):
  if j%2==0:
    b.append(1)
  else:
    b.append(0)
cnt=0
for k in range(len(s)):
  if s[k]!=a[k]:
    cnt+=1
ans=0
for l in range(len(s)):
  if s[l]!=b[l]:
    ans+=1
print(min(cnt,ans))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
if len(a)%2==0:
  if a[0]==a[-1]:
    print(len(a)//2)
  else:
  	print(len(a)//2-1)
else:
  if a[0]==a[-1]:
    print(len(a)//2)
  else:
    print(len(a)//2-1)

Submission status: Wrong Answer

Solution code:
S = list(input())
N = len(S)
count=0
num=0
if (N%2)!=0:
    NS=N-1
    a=1
else:
    NS =N
    a=0
    
count=0
for i in range(0,NS,2):
    num=int(S[i]+S[i+1])
    if num!=1:
        count=count+1
        #print(num)

if a==1:
   if S[0]!=S[N-1]:
       count=count+1

print(count)

Submission status: Wrong Answer

Solution code:
ans=0
check=0
X=[int(i) for i in input()]
p=X.pop()

for i in X:
    if p!=i:
        check+=1
    p=1 if p==0 else 0

print(min(check+1,len(X)-check))

Submission status: Wrong Answer

Solution code:
S=[]
for char in input():
  S.append(char)

#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

#route 2
C2=0
for n in range(len(S)):
  if n%2==0:
    if S[n]==0:
      S[n]=1
      C2+=1
  else:
    if S[n]==1:
      S[n]=0
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Wrong Answer

Solution code:
def c_doloring_colorfully(S):
    if len(S) == 1:
        return 0
    if len(S) == 2:
        if S in ('11', '00'):
            return 1
        elif S in ('10', '01'):
            return 0
    ans = 0
    tmp = list(S)
    for i in range(len(S)):
        t = ''.join(tmp[i:i + 3])
        if not len(t) == 3:
            break
        if t == '000':
            tmp[i], tmp[i + 1], tmp[i + 2] = '010'
            ans += 1
        elif t == '001':
            tmp[i], tmp[i + 1], tmp[i + 2] = '101'
            ans += 1
        elif t == '010':
            pass
        elif t == '011':
            tmp[i], tmp[i + 1], tmp[i + 2] = '010'
            ans += 1
        elif t == '100':
            tmp[i], tmp[i + 1], tmp[i + 2] = '101'
            ans += 1
        elif t == '101':
            pass
        elif t == '110':
            tmp[i], tmp[i + 1], tmp[i + 2] = '010'
            ans += 1
        elif t == '111':
            tmp[i], tmp[i + 1], tmp[i + 2] = '101'
            ans += 1
    return ans

S = input()
print(c_doloring_colorfully(S))

Submission status: Wrong Answer

Solution code:
s = input()

last = s[0]

c = 1

ans = 0

for i in range(1, len(s)):
	if(last == s[i]):
		c += 1
		if(c == 2):
			ans += 1
	else:
		c = 1
	last = s[i]

if(s[0] != s[len(s)-1]):
	ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
odds = []
even = []

if N == 1:
    print(0)
#奇数番目と偶数番目で別にリスト化する
else:
    for i in range(N):
        if i % 2 == 1:
            odds.append(int(S[i]))
        else:
            even.append(int(S[i]))
#print(odds)
#print(even)
n1 = len(odds)
n2 = len(even)
ans1 = 0
ans2 = 0
for j in range(n1):
    if odds[j] == 1:
        ans1 += 1
for k in range(n2):
    if even[k] == 0:
        ans1 += 1

for n in range(n1):
    if odds[n] == 0:
        ans2 += 1
for m in range(n2):
    if even[m] == 1:
        ans2 +=1

print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
S = input()

a = "0b"
for i in range(len(S)):
    if i % 2 == 0:
        a += "0"
    else:
        a += "1"
a = int(a, 2)
b = "0b"
for i in range(len(S)):
    if i % 2 == 0:
        b += "1"
    else:
        b += "0"
b = int(b, 2)
S = int("0b"+S, 2)
S_a = S ^ a
S_b = S ^ b
print(bin(S_a).count("1") if bin(S_a).count("1") < bin(S_a).count("1") else bin(S_b).count("1"))

Submission status: Wrong Answer

Solution code:
print(1)

Submission status: Wrong Answer

Solution code:
S=[]
for char in input():
  S.append(char)

#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

#route 2
C2=0
for n in range(len(S)):
  if i%2==0:
    if S[i]==0:
      S[i]=0
      C2+=1
  else:
    if S[i]==1:
      S[i]=1
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Wrong Answer

Solution code:
S = list(input())
loop = len(S)//2
A = 0
B = 0
for x in range(loop):
    if S[x*2] == "0":
        A += 1
    if S[1+x*2] == "1":
        A += 1
for x in range(loop):
    if S[x*2] == "1":
        B += 1
    if S[1+x*2] == "0":
        B += 1
if A < B:
    ans = A
else:
    ans = B
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
S = [i for i in input()]
onecount = S.count("1")
zerocount = S.count("0")
print(onecount//2+zerocount//2)

Submission status: Wrong Answer

Solution code:
a =list(input())


def saisyo1(a):
    kisuu = a[1::2]
    guusuu = a[0::2]
    count = 0
    for i in kisuu:
        if i != 1:
            count += 1
    for i in guusuu:
        if i != 0:
            count += 1
    return count

def saisyo0(a):
    kisuu = a[1::2]
    guusuu = a[0::2]
    count = 0
    for i in kisuu:
        if i != 0:
            count += 1
    for i in guusuu:
        if i != 1:
            count += 1
    return count

def main():
   print(min(saisyo0(a),saisyo1(a)))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin
from collections import Counter
s = list(stdin.readline().rstrip())
odd = s[0::2]
even = s[1::2]
odd_zero = odd.count('0')
even_zero = even.count('0')
if len(set(odd)) == 1 and len(set(even)) == 1 and set(odd) != set(even):
    print(0)
elif odd_zero < even_zero:
    print(odd_zero+len(even)-even_zero)
elif odd_zero > even_zero:
    print(len(odd)-odd_zero+even_zero)
elif odd_zero == even_zero:
    if len(odd) > len(even):
        print(odd_zero+len(even)-even_zero)
    else:
        print(odd_zero+even_zero)

Submission status: Wrong Answer

Solution code:
s = input()
N = len(s)
if N == 1:
	print(0)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
if len(a)%2==0:
  if a[0]==a[-1]:
    print(len(a)//2)
  else:
  	print(len(a)//2-1)
else:
  print(len(a)//2)

Submission status: Wrong Answer

Solution code:
S=[]
for char in input():
  S.append(char)

#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

#route 2
C2=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==0:
      S[i]=0
      C2+=1
  else:
    if S[i]==1:
      S[i]=1
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Wrong Answer

Solution code:
S = list(input())
flag = 0
ans_1 = 0
ans_2 = 0
# 最初を変える
flag_a = 0
for i in range(1, len(S)):
    if (flag_a == 0):
        if (S[i] == "1"):
            ans_1 += 1
        flag_a = 1
    else:
        if (S[i] == "0"):
            ans_1 += 1
        flag_a = 0
if (len(S) != 1):
    if (S[0] != S[1]):
        ans_1 = 100000

# 最初を変えない
flag_b = 1
for i in range(1, len(S)):
    if (flag_b == 0):
        if (S[i] == "0"):
            ans_2 += 1
        flag_b = 1
    else:
        if (S[i] == "1"):
            ans_2 += 1
        flag_b = 0
if (len(S) != 1):
    if (S[0] == S[1]):
        ans_2 = 100000

print(min(ans_1, ans_2))

Submission status: Wrong Answer

Solution code:
li=list(input())
odd_0 = li[0::2].count("0")
even_0 = li[1::2].count("0")
odd_1 = li[0::2].count("1")
even_1 = li[1::2].count("1")


if odd_0 >= even_0:
    print(odd_1+even_0)
else:
    print(odd_0+even_1)

Submission status: Wrong Answer

Solution code:

paint = input();
white =0;
black = 0;

for i in range(len(paint)):
    if(paint[i]=='0'):black+=1
    elif (paint[i]=='1'): white+=1;
#print(white)
if(white==0 or black==0):
    print(int(len(paint)/2))
else:
    print(min(white,black))

Submission status: Wrong Answer

Solution code:
S = input()
word_01 = '01'
word_10 = '10'
q, mod = divmod(len(S), 2)
if mod == 0:
    word_01 = word_01 * q
    word_10 = word_10 * q
else:
    word_01 = word_01 * q + '0'
    word_10 = word_10 * q + '1'
print(word_01)
print(word_10)
S_list = list(S)
word_01_list = list(word_01)
word_10_list = list(word_10)
counter1 = 0
counter2 = 0
for num1, num2, num3 in zip(S_list, word_01_list, word_10_list):
    if num1 != num2:
        counter1 += 1
    if num1 != num3:
        counter2 += 1
result = min(counter1, counter2)
print(result)

Submission status: Wrong Answer

Solution code:
s=input()
ls=[c for c in s]
ct=0
j=0
for i in range(len(ls)):
    if ls[i]==ls[j]:
        if (i-j)%2!=0 and i-j!=0 and i-j!=1:
            ct+=2
            ls[i]=ls[j+1]
            j=i
            #print(i,j)
        elif (i-j)%2==0 and i-j!=0 and i-j!=2:
            ct+=1
            j=i
            #print(i,j)
        elif i-j==1:
            ct+=1
            if ls[i]=='0':
                ls[i]='1'
            else:
                ls[i]='0'
            j=i
            #print(i,j)
        elif i-j==2:
            j=i
if j<len(ls)-2:
    if (len(ls)-1-j)%2==0:
        ct+=int((len(ls)-1-j)/2)
    else:
        ct+=int((len(ls)-2-j)/2)
print(ct)

Submission status: Wrong Answer

Solution code:
S = str(input())
N = len(S)
K = []
H = []
for i in range(N):
  K.append(i%2)
  H.append((i+1)%2)
count_K=0
count_H=0
for i in range(N):
  if (K[i]!=S[i]):
    count_K=count_K+1
  elif (H[i]!=S[i]):
    count_H=count_H+1
  else:
    None
M = min(count_K,count_H)
print(M)

Submission status: Wrong Answer

Solution code:
s=input()
l=len(s)
a=int(("10"*1000)[:l],2)
b=int(("10"*1000)[1:l+1],2)
s=int(s,2)
print(min(str(bin(a^s)).count("1"),str(bin(b^s)).count("1")))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
if len(a)%2==0:
  print(len(a)//2-1)
else:
  print(len(a)//2)

Submission status: Wrong Answer

Solution code:
s=input()
l=len(s)
a=int(("10"*1000)[:l],2)
b=int(("10"*1000)[1:l+1],2)
s=int(s,2)
print(*map(bin,[a,b,s]))
print(min(str(bin(a^s)).count("1"),str(bin(b^s)).count("1")))

Submission status: Wrong Answer

Solution code:
import sys
#input=sys.stdin.readline

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

s=input()
l=list(s)
l=list(map(int, l))
ans=0
if len(l) == 2 and l[0] == l[1]:
    print(1)
    exit()
if len(l) > 2:
    if l[0] == l[1] and l[0] != l[2]:
        ans+=1
        if l[0] == 1: l[0] = 0 
        else: l[0] = 1    
for i in range(2, len(s)):
    if l[i] == l[i-1] and l[i] != l[i-2]:
        ans+=1
        if l[i] == 1: l[i] = 0 
        else: l[i] = 1
    elif l[i] == l[i-1] and l[i] == l[i-2]:
        ans+=1
        if l[i-1] == 1: l[i-1] = 0
        else: l[i-1] = 1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
cnt = 0
s = S[0]
for i in range(1, len(S)):
    si = int(S[i])
    #print(s, si)
    if s == si:
        #print("hit")
        s = 1 - si
        cnt += 1
    else:
        s = si
print(cnt)

Submission status: Wrong Answer

Solution code:
ans=0
check=0
X=[int(i) for i in input()]
p=X.pop()
for i in X:
    if p!=i:
        check+=1
    p=1 if p==0 else 0
print(min(check,len(X)-check))

Submission status: Wrong Answer

Solution code:
S = input()
word_01 = '01'
word_10 = '10'
q, mod = divmod(len(S), 2)
if mod == 0:
    word_01 = word_01 * q
    word_10 = word_10 * q
else:
    word_01 = word_01 * (q-1) + '0'
    word_10 = word_10 * (q-1) + '1'
S_list = list(S)
word_01_list = list(word_01)
word_10_list = list(word_10)
counter1 = 0
counter2 = 0
for num1, num2, num3 in zip(S_list, word_01_list, word_10_list):
    if num1 != num2:
        counter1 += 1
    if num1 != num3:
        counter2 += 1
result = min(counter1, counter2)
print(result)

Submission status: Wrong Answer

Solution code:
import math

s=input()
ans0=0
ans1=0
for i in range(math.ceil(len(s)/2)):
#    print(i)
    if s[2*i]!="0":
        ans0+=1
    if i>0:
        if s[2*i-1]!="1":
            ans0+=1

for i in range(math.ceil(len(s)/2)):
#    print(i)
    if s[2*i]!="1":
        ans1+=1
    if i>0:
        if s[2*i-1]!="0":
            ans1+=1

print(min(ans0,ans1))

Submission status: Wrong Answer

Solution code:
S = input()
p01 = 0
p10 = 0
p00 = 0
p11 = 0
for i in range(0, (len(S)//2 * 2), 2):
    if S[i:i+2] == '01':
        p01 += 1
    elif S[i:i+2] == '10':
        p10 += 1
    elif S[i:i+2] == '00':
        p00 += 1
    else:
        p11 += 1
#print(p01,p10,p00,p11)
c = 0
if (p01 == 0) and (p10 == 0):
    c = len(S) // 2
elif p01 >= p10:
    c = p10 * 2 + p00 + p11
    if len(S) & 1:
        if S[-1] == '0':
            c += 1
else:
    c = p01 * 2 + p00 + p11
    if len(S) & 1:
        if S[-1] == S[-2]:
            c += 1
print(c)

Submission status: Wrong Answer

Solution code:
S=[]
for char in str(input()):
  S.append(char)

#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

#route 2
C2=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==0:
      S[i]=0
      C2+=1
  else:
    if S[i]==1:
      S[i]=1
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Wrong Answer

Solution code:
import sys
#input=sys.stdin.readline

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

s=input()
l=list(s)
l=list(map(int, l))
ans=0
if len(l) > 2:
    if l[0] == l[1] and l[0] != l[2]:
        ans+=1
        if l[0] == 1: l[0] = 0 
        else: l[0] = 1    
for i in range(2, len(s)):
    if l[i] == l[i-1] and l[i] != l[i-2]:
        ans+=1
        if l[i] == 1: l[i] = 0 
        else: l[i] = 1
    elif l[i] == l[i-1] and l[i] == l[i-2]:
        ans+=1
        if l[i-1] == 1: l[i-1] = 0
        else: l[i-1] = 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, math
input = sys.stdin.readline

S = list(input().replace('\n',''))
S = list(map(int, S))
prev = S[0]
ans = 0
for i in range(1, len(S)-1):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
    prev = 2 + ~cur
  else:
    prev = cur

print(ans)

Submission status: Wrong Answer

Solution code:
a = [int(n) for n in input()]
counter=1
for n in range(1, len(a)):
  if a[n-1]==a[n]:
    if a[n-1]==1:
      a[n]=0
    else:
      a[n]=1
    counter+=1
print(counter)

Submission status: Wrong Answer

Solution code:
colors = input()
l = len(colors)
count1 = 0
for i in range(l):
	if int(colors[i]) == (i % 2):
		count1 += int(colors[i])
print(min(count1, l-count1))

Submission status: Wrong Answer

Solution code:
s=input()
l=len(s)
a=int(("10"*100)[:l],2)
b=int(("10"*100)[1:l+1],2)
s=int(s,2)
print(min(str(bin(a^s)).count("1"),str(bin(b^s)).count("1")))

Submission status: Wrong Answer

Solution code:
S = input()
p01 = 0
p10 = 0
p00 = 0
p11 = 0
for i in range(0, (len(S)//2 * 2), 2):
    if S[i:i+2] == '01':
        p01 += 1
    elif S[i:i+2] == '10':
        p10 += 1
    elif S[i:i+2] == '00':
        p00 += 1
    else:
        p11 += 1
#print(p01,p10,p00,p11)
c = 0
if (p01 == 0) and (p10 == 0):
    c = len(S) // 2
elif p01 >= p10:
    c = p10 * 2 + p00 + p11
    if len(S) & 1:
        if S[-1] == '0':
            c += 1
else:
    c = p01 * 2 + p00 + p11
    if len(S) & 1:
        if S[-1] == '1':
            c += 1
print(c)

Submission status: Wrong Answer

Solution code:
s = list(input().split())
print((len(s)-1)/2 if s.count('0') > 0 and s.count('1') > 0 else len(s)/2)

Submission status: Wrong Answer

Solution code:
S = input().rstrip()
zero_zero = 0
one_zero = 0
zero_one = 0
one_one = 0
one = 0
zero = 0
for i in range(-(-len(S)//2)):
    tmp = S[i*2:i*2+2]
    if tmp == "00":
        zero_zero += 1
    elif tmp == "01":
        zero_one += 1
    elif tmp == "10":
        one_zero += 1
    elif tmp == "11":
        one_one += 1
    elif tmp == "1":
        one += 1
    else:
        zero += 1
counter = 0
if zero_one > one_zero:
    counter += one_zero*2 + zero_zero + one_one + one
elif zero_one < one_zero:
    counter += zero_one*2 + zero_zero + one_one + zero
else:
    counter += zero_one*2 + zero_zero + one_one + zero + one
print(counter if len(S) != 1 else 0)

Submission status: Wrong Answer

Solution code:

line = raw_input()
odd_one = 0
even_one = 0
for i, val in enumerate(line):
    if val == '1':
        if (i + 1)% 2 == 0:
            even_one += 1
        else:
            odd_one += 1

odd_zero = len(line) / 2 + 1 - odd_one
even_zero = len(line) / 2 - even_one

result = 0
if odd_one + even_zero > even_one + odd_zero:
    result = even_one + odd_zero
else:
    result = odd_one + even_zero
print result

Submission status: Wrong Answer

Solution code:
n = list(input())
ex = 0
if len(n) <= 1:
    print(0)
elif len(n)==2:
    b = (int)(n[1 - 1])
    m = (int)(n[1])
    if b == 0 and m == 0:
        ex += 1
    if b == 1 and m == 1:
        ex += 1
else:
    for i, l in enumerate(n):
        if i >= 1:
            if len(n) - (i + 1) > 0:
                b = (int)(n[i - 1])
                m = (int)(n[i])
                f = (int)(n[i + 1])
                if b == 0 and m == 0 and f == 0:
                    n[i] = 1
                    ex += 1
                if b == 1 and m == 1 and f == 1:
                    n[i] = 0
                    ex += 1
                if b == 1 and m == 1 and f == 0:
                    n[i - 1] = 0
                    ex += 1
                if b == 0 and m == 0 and f == 1:
                    n[i - 1] = 1
                    ex += 1
                if b == 0 and m == 1 and f == 1:
                    n[i + 1] = 0
                    ex += 1
                if b == 1 and m == 0 and f == 0:
                    n[i + 1] = 1
                    ex += 1
print(ex)

Submission status: Wrong Answer

Solution code:
import sys
#input=sys.stdin.readline

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

s=input()
l=list(s)
l=list(map(int, l))
ans=0
for i in range(2, len(s)):
    if l[i] == l[i-1] and l[i] != l[i-2]:
        ans+=1
        if l[i] == 1: l[i] = 0 
        else: l[i] = 1
    elif l[i] == l[i-1] and l[i] == l[i-2]:
        ans+=1
        if l[i-1] == 1: l[i-1] = 0
        else: l[i-1] = 1
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
count1=0
count2=0
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    count1=count1+1
for i in range(1,len(s)-1):
  if s[i]==s[i+1]:
    count2=count2+1
if count1>=count2:
  print(count1)
else:
  print(count2)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
T = ['{}'.format(i % 2) for i in range(n)]
print(T)
tmp = 0
for i in range(n):
    if S[i] == T[i]:
        tmp += 1
if tmp >= n - tmp:
    ans = n - tmp
else:
    ans = tmp
print(ans)

Submission status: Wrong Answer

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

dis1 = 0
dis2 = 0
start = 0
for i in range(N):
    if (S[i]!=1-start):
        dis1 += 1
    if (S[i]!=start):
        dis2 += 1
    start = 1-start
res = min(dis1, dis2)
print (res)

Submission status: Wrong Answer

Solution code:
S = list(map(int, input()))
length = len(S)

dp = {}

for i in range(length):
  for j in range(2):
    if i == 0:
      dp[(i,j)] = 0 if S[0] == j else 1
      continue

    # print('i,j:', i, j)
    inverse = 0 if S[i] == 1 else 1

    if S[i] == j: # 最后 S[i] 不动
      dp[(i, j)] = dp[(i-1, inverse)]
    else: # 最后 S[i] 变成inverse
      dp[(i, j)] = dp[(i-1, S[i])] + 1




# print('dp', dp)
print(dp[(length-1, S[-1])])

Submission status: Wrong Answer

Solution code:
s = input()

fc = s[0]
nc = ""

count = 0

if fc == "0":
    nc = "1"
else:
    nc = "0"

for i in range(1,len(s)):
    if s[i] != nc :
        count += 1
        nc = s[i]

print(count)

Submission status: Wrong Answer

Solution code:
def main():
    result = sub()
    print(result)


def sub():
    maskA = '10' * 10 ** 5
    maskB = '01' * 10 ** 5

    raw = input()
    length = len(raw)
    maskA = maskA[:length]
    maskB = maskB[:length]
    a = int(raw, 2) | int(maskA, 2)
    b = int(raw, 2) | int(maskB, 2)
    tmp = min(bin(a).count("1"), bin(b).count("1"))
    return min(tmp, length - tmp)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S=list(input())
count_0 = 0
count_1 = 0

#101010
for (i,item) in enumerate(S):
    if i%2 != 0 and item=="0":
        count_1 +=1


    elif i%2==0 and item==1:
        count_1 +=1

#010101
for (i,item) in enumerate(S):
    if i%2 != 0 and item =="1" :
        count_0 +=1

    elif i%2==0 and item=="0":
        count_0 +=1

print(min(count_0,count_1))

Submission status: Wrong Answer

Solution code:

line = raw_input()
odd_one = 0
even_one = 0
for i, val in enumerate(line):
    if val == '1':
        if (i + 1)% 2 == 0:
            even_one += 1
        else:
            odd_one +1

odd_zero = len(line) / 2 + 1 - odd_one
even_zero = len(line) / 2 - even_one

result = 0
if odd_one + even_zero > even_one + odd_zero:
    result = even_one + odd_zero
else:
    result = odd_one + even_zero
print result

Submission status: Wrong Answer

Solution code:
s = input()
od = []
ev = []

if len(s)==1:
    print(0)
else:
    for i in range(len(s)):
        if i//2 == 0:
            od.append(int(s[i]))
        else:
            ev.append(int(s[i]))
    
    a = len(od)-sum(od)+sum(ev)
    b = len(ev)-sum(ev)+sum(od)

    print(min(a,b))

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

s = list(input())

cnt1=0
for i in range(len(s)):
        if s[i] is i%2:
                cnt1 += 1

cnt2=0
for i in range(len(s)):
        if s[i] is (i+1)%2:
                cnt2 += 1

print(min(cnt1,cnt2))

Submission status: Wrong Answer

Solution code:
S = list(input())
count = 0



if S[0] == "0":
    for i in range(1,len(S)):
        if i % 2 == 0:
            if S[i] == "0":
                count += 1
                S[i] = "1"
        else:
            if S[i] == "1":
                count += 1
                S[i] = "0"
else:
    for i in range(1,len(S)):
        if i % 2 == 1:
            if S[i] == "1":
                count += 1
                S[i] = "0"
        else:
            if S[i] == "0":
                count += 1
                S[i] = "1"
print(count)

Submission status: Wrong Answer

Solution code:
S = input()

cnt1=0
start=S[0]
for i in range(len(S)):
    if i%2!=0:
        if S[i]==start:
            cnt1+=1
    else:
        if S[i]==start:
            cnt1+=1
cnt2=0
start=S[-1]
for i in range(len(S)):
    if i%2==0:
        if S[i-1]!=start:
            cnt2+=1
    else:
        if S[i-1]==start:
            cnt2+=1
if cnt1 < cnt2:
    print(cnt1)
else:
    print(cnt2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
s = list(stdin.readline().rstrip())
odd = s[0::2]
even = s[1::2]
odd_zero = odd.count('0')
even_zero = even.count('0')
if len(set(odd)) == 1 and len(set(even)) == 1 and set(odd) != set(even):
    print(0)
elif odd_zero < even_zero:
    print(odd_zero+len(even)-even_zero)
elif odd_zero > even_zero:
    print(len(odd)-odd_zero+even_zero)
else:
    print(odd_zero+even_zero)

Submission status: Wrong Answer

Solution code:
from itertools import groupby

s = input()

ans = []
for i,j in groupby(s):
	a,b = i,list(j)
	# print(len(b))
	ans.append(len(b)//2)


tot = sum(ans)

if(tot%2==0):
	print(tot+1)

else:
	print(tot)

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc124
# -*- coding: utf-8 -*-

s = list(input())

cnt1=0
for i in range(len(s)):
        if s[i] is i%2:
                count1 += 1

cnt2=0
for i in range(len(s)):
        if s[i] is (i+1)%2:
                count1 += 1

print(min(cnt1,cnt2))

Submission status: Wrong Answer

Solution code:
tiles = input()
pair_tiles_list = [tiles[i: i + 2] for i in range(0, len(tiles), 2)]
base_pair = ""
count = 0
if pair_tiles_list.count("01") < pair_tiles_list.count("10"):
    base_pair = "10"
else:
    base_pair = "01"

for pair in pair_tiles_list:
    if pair != base_pair:
        if pair[0] != base_pair[0]:
            count += 1
        if pair.__len__() > 1:
            if pair[1] != base_pair[1]:
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
S = list(map(int, input()))
length = len(S)

dp = {}

for i in range(length):
  for j in range(2):
    if i == 0:
      dp[(i,j)] = 0 if S[0] == j else 1
      continue

    # print('i,j:', i, j)
    inverse = 0 if j == 1 else 1

    if S[i] == j:
      dp[(i, j)] = dp[(i-1, inverse)]
    else:
      dp[(i, j)] = dp[(i-1, S[i])] + 1




# print('dp', dp)
print(dp[(length-1, S[-1])])

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
i = n-1
B = ["0","1"]
n0,n1,b = 0,0,0
while i:
  if S[i]==B[b] : n0+=1
  else : n1+=1
  b = 1-b
  i -= 1
if n0>n1 : print(n1)
else : print(n0)

Submission status: Wrong Answer

Solution code:
S = input().rstrip()
zero_zero = 0
one_zero = 0
zero_one = 0
one_one = 0
one = 0
zero = 0
for i in range(len(S)//2-1):
    tmp = S[i*2:i*2+2]
    if tmp == "00":
        zero_zero += 1
    elif tmp == "01":
        zero_one += 1
    elif tmp == "10":
        one_zero += 1
    else:
        one_one += 1
index = len(S)//2-1 if len(S)//2-1 >= 0 else 0
tmp = S[index*2:]
if tmp == "00":
    zero_zero += 1
elif tmp == "01":
    zero_one += 1
elif tmp == "10":
    one_zero += 1
elif tmp == "11":
    one_one += 1
elif tmp == "1":
    one += 1
else:
    zero += 1
counter = 0
if zero_one > one_zero:
    counter += one_zero*2 + zero_zero + one_one + one
elif zero_one < one_zero:
    counter += zero_one*2 + zero_zero + one_one + zero
else:
    counter += zero_one*2 + zero_zero + one_one + zero + one
print(counter if len(S) != 1 else 0)

Submission status: Wrong Answer

Solution code:
S = input()
cnt = [[0,0],[0,0]]
for i, s in enumerate(S):
    x = int(i) % 2
    y = int(s)
    cnt[x][y] += 1
if cnt[0][0] >= cnt[1][0]:
    print(cnt[0][1] + cnt[1][0])
else:
    print(cnt[0][0] + cnt[1][1])