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

Solution code:
S = input()

result = 0

t = S[0]
for s in S:
    if s != t:
        result +=1
    t = '1' if t == '0' else '0'

print(result)

Submission status: Accepted

Solution code:
s=list(str(raw_input()))

n=len(s)

if n%2==0:
	list1=[str(0),str(1)]*(n//2)
	list2=[str(1),str(0)]*(n//2)
else:
	list1=[str(0),str(1)]*(n//2)
	list1.append(str(0))
	list2=[str(1),str(0)]*(n//2)
	list2.append(str(1))

ctr1=0
ctr2=0

for i in range(n):
	if s[i]!=list1[i]:
		ctr1+=1
	if s[i]!=list2[i]:
		ctr2+=1

print min(ctr1,ctr2)

Submission status: Accepted

Solution code:
"""
python3 c.py < input.txt
"""
import math
import itertools as it
import heapq

S=input()
N=len(S)
a=0
for i in range(N):
    if i%2==0 and S[i] == "1":
        a=a+1
    elif i%2 ==1 and S[i]=="0":
        a=a+1

b=0
for i in range(N):
    if i%2==0 and S[i] == "0":
        b=b+1
    elif i%2 ==1 and S[i]=="1":
        b=b+1
print(min([a,b]))

Submission status: Accepted

Solution code:
from sys import stdin
N=(stdin.readline().rstrip())
A=0
B=0
for ind,i in enumerate(list(N)):
    if ind%2==0 and i != "0":
        A+=1
    elif ind%2!=0 and i != "1":
        A+=1

for ind,i in enumerate(list(N)):
    if ind%2==0 and i != "1":
        B+=1
    elif ind%2!=0 and i != "0":
        B+=1
print(min(A,B))

Submission status: Accepted

Solution code:
s = input()
s = list(s)


s = [int(x) for x in s]


leng = len(s)

# print(leng)
count = 0
if s[0]==0:
    for i in range(leng):
        if i%2==1 and s[i]==0:
            count +=1
        elif i%2==0 and s[i]==1:
            count +=1
else:#1スタート
    for i in range(leng):
        if i%2==1 and s[i]==1:
            count +=1
        elif i%2==0 and s[i]==0:
            count +=1

print(count)

Submission status: Accepted

Solution code:
s=input()
l=len(s)
word=''
for i in range(l):
    if i%2==0:
        word+='0'
    else:
        word+='1'
ans=0
for i in range(l):
    if s[i]!=word[i]:
        ans+=1
print(min(ans,l-ans))

Submission status: Accepted

Solution code:
s = input()
if len(s) == 0:
    print("0")
    exit()

s_10 = "10" * (len(s) // 2)
if len(s) % 2 != 0:
    s_10 += "1"

s_01 = "01" * (len(s) // 2)
if len(s) % 2 != 0:
    s_01 += "0"

a = len([i for i in range(len(s)) if s[i] != s_01[i]])
b = len([i for i in range(len(s)) if s[i] != s_10[i]])
ans = min(a, b)
print(ans)

Submission status: Accepted

Solution code:
s=input()
ls=len(s)
if ls%2:
    s1="10"*(ls//2)+"1"
    s2="01"*(ls//2)+"0"
else:
    s1="10"*(ls//2)
    s2="01"*(ls//2)
d=int(s,2)
d1=int(s1,2)
d2=int(s2,2)
h1=format(d^d1,"b").count("1")
h2=format(d^d2,"b").count("1")
print(min(h1,h2))

Submission status: Accepted

Solution code:
s = input()

ans1 = ""
ans2 = ""

for i in range(len(s)):
    if i%2 == 0:
        ans1 += "1"
        ans2 += "0"
    else:
        ans1 += "0"
        ans2 += "1"

ans11 = 0
ans22 = 0
for i in range(len(s)):
    if s[i:i+1] != ans1[i:i+1]:
        ans11 += 1
    if s[i:i+1] != ans2[i:i+1]:
        ans22 += 1
print(min(ans11,ans22))

Submission status: Accepted

Solution code:
s=input()
size=len(s)
even=s[0::2]
odd=s[1::2]
e_0=even.count("0")
e_1=even.count("1")
o_0=odd.count("0")
o_1=odd.count("1")
print(min(size-e_0-o_1,size-e_1-o_0))

Submission status: Accepted

Solution code:
s = input()
c = [int(s[i]) for i in range(len(s))]
count = 0
for i in range(1,len(s)):
  if c[i-1] == c[i]:
    if c[i] == 0:
      c[i] = 1
    else:
      c[i] = 0
    count += 1
print(count)

Submission status: Accepted

Solution code:
S = str(input())
check1 = 0
for i in range(len(S)):
    if i % 2 == 0 and S[i] != "0":
#         print(i,'yes')
        check1 += 1
    if i % 2 != 0 and S[i] == "0":
#         print(i,"no")
        check1 += 1
# print(check1)

check2 = 0
for i in range(len(S)):
    if i % 2 == 0 and S[i] != "1":
#         print(i,'yes')
        check2 += 1
    if i % 2 != 0 and S[i] == "1":
#         print(i,"no")
        check2 += 1
# print(check2)

print(min(check1,check2))

Submission status: Accepted

Solution code:
s=list(map(int,list(str(input()))))
l = len(s)
bs = [0 for i in range(l)]
ws = [0 for i in range(l)]
for i in range(l):
    if i%2==0:
        bs[i]=1
    else:
        ws[i]=1
b=0
w=0
for i in range(l):
    if s[i] != bs[i]:
        b += 1
    if s[i] != ws[i]:
        w += 1
print(min(b,w))

Submission status: Accepted

Solution code:
S = [int(x) for x in input()] # < 10**5

#print(S)
#print(odd)
#print(even)

odd =  [1 if i % 2 == 0 else 0 for i in range(len(S))]
even = [0 if i % 2 == 0 else 1 for i in range(len(S))]
print(min([
    sum(1 if i != j else 0 for i, j in zip(S, odd)),
    sum(1 if i != j else 0 for i, j in zip(S, even))
    ]))

Submission status: Accepted

Solution code:
def hanntenn(n):
    if n=="0":
        return "1"
    else:
        return "0"
    
s = input()
lists = list(s)
ans1 = 0
ans2 = 0
flag = "1"
for ob in lists:
    if ob == flag:
        flag = hanntenn(flag)
        continue
    else:
        flag = hanntenn(flag)
        ans1 += 1
flag = "0"
for ob in lists:
    if ob == flag:
        flag = hanntenn(flag)
        continue
    else:
        flag = hanntenn(flag)
        ans2 += 1
print(min(ans1,ans2))

Submission status: Accepted

Solution code:
s = input()

even = s[1::2]
odd = s[::2]
e1 = len(even) - even.count("1")
e0 = len(even) - even.count("0")
o1 = len(odd) - odd.count("1")
o0 = len(odd) - odd.count("0")


print(min(e1+o0, e0+o1))

Submission status: Accepted

Solution code:
S=input()
w=0
b=0
for i,s in enumerate(S):
  if i%2==0:
    if s=='0':
      w+=1
    else:
      b+=1
  else:
    if s=='0':
      b+=1
    else:
      w+=1
print(min(w,b))

Submission status: Accepted

Solution code:
S = list(map(int,list(input())))
N = len(S)
A_list = []
B_list = []
for i in range(N):
  if i % 2 == 0:
    A_list.append(0)
    B_list.append(1)
  else:
    A_list.append(1)
    B_list.append(0)

A_count = 0
B_count = 0
for i in range(N):
  if S[i] == A_list[i]:
    A_count += 1
  if S[i] == B_list[i]:
    B_count += 1

print(min(A_count,B_count))

Submission status: Accepted

Solution code:
S = list(input())
l = len(S)
counter1 = 0
counter2 = 0
current1 = '0'
current2 = '1'
for i in range(l):
    if S[i] != current1:
        counter1 += 1
    else:
        counter2 += 1
    current1, current2 = current2, current1
print(min(counter1, counter2))

Submission status: Accepted

Solution code:
s = input()
l = []
for x in s:
    l.append(int(x))
o = 0
for i in range(len(l)-1):
    if l[i] == l[i+1]:
        o += 1
        l[i+1] = 0 if l[i+1] == 1 else 1
    
print(o)

Submission status: Accepted

Solution code:
import numpy as np

S = np.array([int(x) for x in input()])

n, m = divmod(len(S), 2)

c1 = np.array([0, 1] * n + ([] if m ==0 else [0]))
c2 = np.array([1, 0] * n + ([] if m ==0 else [1]))

a1 = sum(abs(S - c1))
a2 = sum(abs(S - c2))

print(min(a1, a2))

Submission status: Accepted

Solution code:
S =input()
ans1 = 0
ans2 = 0
t = 0
for i in range(len(S)):
    if int(S[i]) == t:
        ans1 += 1
    else:
        ans2 += 1
    t = not(t)

print(min(ans1,ans2))

Submission status: Accepted

Solution code:
s=list(input())

odd = 0;
even = 0;

for i in range(len(s)):
    if i%2==0:
        if s[i] == "0":
            odd += 1
        else:
            even += 1
    else:
        if s[i] == "0":
            even += 1
        else:
            odd += 1

print(min(odd,even))

Submission status: Accepted

Solution code:
import numpy as np

s = np.array([int(x) for x in input()])
f = np.arange(len(s)) % 2
g = (f + 1) % 2

i = np.logical_xor(f, s).sum()
j = np.logical_xor(g, s).sum()
print(min(i, j))

Submission status: Accepted

Solution code:
t = list(input())

def count(t,start):
     ans = 0
     for i in range(len(t)):
          if (i%2 == 0) and (t[i] != start):
               ans += 1
          if (i%2 == 1) and (t[i] == start):
               ans += 1
     return ans
     
ans = min(count(t,'0'), count(t,'1'))
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    S = input()

    case1 = '10' * (len(S) // 2)
    case2 = '01' * (len(S) // 2)
    if len(S) % 2:
        case1 += '1'
        case2 += '0'

    cnt1 = 0
    for s1, s2 in zip(S, case1):
        if s1 != s2:
            cnt1 += 1

    cnt2 = 0
    for s1, s2 in zip(S, case2):
        if s1 != s2:
            cnt2 += 1

    print(min(cnt1, cnt2))

input = lambda: stdin.readline().rstrip()
main()

Submission status: Accepted

Solution code:
s = list(input())

ans = 0
for i in range(len(s)-1):
    if int(s[i]) == int(s[i+1]) == 0:
        s[i+1] = 1
        ans += 1
    elif int(s[i]) == int(s[i+1]) == 1:
        s[i+1] = 0
        ans += 1
print(ans)

Submission status: Accepted

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

prev = ''
count = 0

for i in range(len(li)):
    if 0 == i:
        prev = li[i]
    else:
        if '0' == prev and '0' == S[i]:
            count += 1
            li[i] = '1'
        elif '1' == prev and '1' == S[i]:
            count += 1
            li[i] = '0'
        prev = li[i]
print(count)

Submission status: Accepted

Solution code:
s = input()

a1 = s[::2].count("1") + s[1::2].count("0")
a2 = s[::2].count("0") + s[1::2].count("1")

print(min(a1, a2))

Submission status: Accepted

Solution code:
S = input()
n = len(S)

cnt1 = 0   #10101010...に必要な回数
cnt2 = 0   #01010101...
#min(cnt1, cnt2)
for i in range(n):
    if i % 2 == 0:
        if S[i] == '0':
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if S[i] == '1':
            cnt1 += 1
        else:
            cnt2 += 1
            
print(min(cnt1, cnt2))

Submission status: Accepted

Solution code:
s=input()

#最初が0
ansb=0
for i in range(len(s)):
  if i % 2==0:
    if s[i]=="1":
      ansb+=1
  else:
    if s[i]=="0":
      ansb+=1
#最初が1
answ=0
for i in range(len(s)):
  if i % 2==0:
    if s[i]=="0":
      answ+=1
  else:
    if s[i]=="1":
      answ+=1

print(min(answ,ansb))

Submission status: Accepted

Solution code:
import numpy as np

S = input()
l = [int(s) for s in S]
t1 = [i % 2 for i in range(len(S))]
t2 = [(i+1) % 2 for i in range(len(S))]
l, t1, t2 = np.array(l), np.array(t1), np.array(t2)

d1 = ((t1 - l)**2).sum()
d2 = ((t2 - l)**2).sum()

print(int(min(d1, d2)))

Submission status: Accepted

Solution code:
S = input()
startblack, startwhite = 0, 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":startwhite += 1
        else: startblack += 1
    else:
        if S[i] == "0": startblack += 1
        else: startwhite += 1
print(min(startblack, startwhite))

Submission status: Accepted

Solution code:
str = input()

n = len(str)
# 先頭を1で固定する場合と、0で固定する場合の2パターン

str1 = "10"*(n//2) + "1"*(n%2)
str0 = "01"*(n//2) + "0"*(n%2)

v1 = 0
v0 = 0
for i in range(n):
	if str[i] == str1[i]: v1 += 1
	if str[i] == str0[i]: v0 += 1
	
print(min([v1,v0]))

Submission status: Accepted

Solution code:
s = list(input())
c = 0
for i in range(len(s)):
    if (i != 0):
        if (s[i] == s[i - 1]):
            c += 1
            if (s[i] == "0"):
                s[i] = "1"
            else:
                s[i] = "0"
print(c)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
count_0 = 0
count_1 = 0
for i in range(n):
    if i % 2== 0:
        if int(s[i]) != 1:
            count_1 += 1
        else:
            count_0 += 1
    else:
        if int(s[i]) == 1:
            count_1 += 1
        else:
            count_0 += 1
print(min(count_0,count_1))

Submission status: Accepted

Solution code:
S=list(input())

c1=0
c2=0

for i in range(len(S)):
    if i%2==0:
        if S[i]=='0':
            c1+=1
        else:
            c2+=1
    else:
        if S[i]=='1':
            c1+=1
        else:
            c2+=1

print(min(c1,c2))

Submission status: Accepted

Solution code:
# coding:utf-8

def main():
    s = input()
    one_start = 0
    zero_start = 0

    for i in range(len(s)):
        if i%2 == 0:
            if s[i] != "0":
                one_start += 1
        else:
            if s[i] != "1":
                one_start += 1

    for i in range(len(s)):
        if i%2 == 0:
            if s[i] != "1":
                zero_start += 1
        else:
            if s[i] != "0":
                zero_start += 1

    print(min(one_start,zero_start))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = [int(s) for s in input()]

start_with0 = [0 if i % 2 else 1 for i in range(len(S))]
start_with1 = [1 if i % 2 else 0 for i in range(len(S))]

diff_0 = sum([i != j  for i, j in zip(S, start_with0)])
diff_1 = sum([i != j  for i, j in zip(S, start_with1)])
print(min(diff_0, diff_1))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = list(map(int, str(input())))

T0 = sum([s%2 == 1 for s in S[::2]]) + sum([s%2 == 0 for s in S[1::2]])
T1 = sum([s%2 == 0 for s in S[::2]]) + sum([s%2 == 1 for s in S[1::2]])
print(min(T0, T1))

Submission status: Accepted

Solution code:
S = [n == "1" for n in input().strip()]
sum_odd = sum(S[::2])
sum_even = sum(S[1::2])

if sum_odd > sum_even:
  print((len(S[::2]) - sum_odd) + sum_even)
else:
  print((len(S[1::2]) - sum_even) + sum_odd)

Submission status: Accepted

Solution code:
str = list(input())  # 一文字ずつ格納
last = str[0]
ans = 0

for i in range(1, len(str)):
    if last == str[i]:
        ans += 1
        if last == "0":
            last = '1'
        else:
            last = '0'
    else:
        last = str[i]


print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def bc(x):
    return bin(x).count("1")

S = input()
N = len(S)

# 0101...か1010...に変更するときの塗り替え数を見ればいい=XOR
B = "".join(["0" if i%2==0 else "1" for i in range(N)])
R = int(S, 2) ^ int(B, 2)
C = bc(R)
r = min(C, N-C)
print(r)

Submission status: Accepted

Solution code:
S = input()
S1 = S[0::2]
S2 = S[1::2]

S1white = S1.count("1")  # 黒にしなければいけない個数
S2white = S2.count("1")

print(min(S1white + len(S2) - S2white, len(S1) - S1white + S2white))

Submission status: Accepted

Solution code:
s = input()

a1 = ''
a2 = ''

for i in range(len(s)):
	if (i % 2 == 0):
		a1 = a1 + '0'
		a2 = a1 + '1'
	else:
		a1 = a1 + '1'
		a2 = a2 + '0'
m1 = 0
m2 = 0

for i in range(len(s)):
	if(s[i] != a1[i]):
		m1 = m1 + 1
	else:
		m2 = m2 + 1

print(min(m1,m2))

Submission status: Accepted

Solution code:
s = input()
ans = 0

for i in range(len(s)):
    if i == 0:
        pre = s[i]
    else:
        if s[i] == pre:
            ans += 1
            if s[i] == "0":
                pre = "1"
            else:
                pre = "0"
        else:
            pre = s[i]
            
print(ans)

Submission status: Accepted

Solution code:
_s = input()
c=0
for i in range(len(_s)):
    if _s[i]==('1' if i%2==0 else '0'):
        c+=1
ans=min(c,len(_s)-c)
print(ans)

Submission status: Accepted

Solution code:
s=input()
n,m=0,0
p,q=0,0
for i in range(len(s)):
    if i&1:
        if s[i]=='0':
            n+=1
        else:
            p+=1
    else:
        if s[i]=='0':
            m+=1
        else:
            q+=1
print(len(s)-max(n+q,m+p))

Submission status: Accepted

Solution code:
S = input()

n = S[::2].count('0') + S[1::2].count('1')
print(min(n, len(S) - n))

Submission status: Accepted

Solution code:
s = input()
a = 0
b = 0
for i in range(len(s)):
    if i %2==0:
        if s[i] == "0":
            continue
        else:
            a += 1
    else:
        if s[i] == "1":
            continue
        else:
            a += 1
for i in range(len(s)):
    if i %2==0:
        if s[i] == "1":
            continue
        else:
            b += 1
    else:
        if s[i] == "0":
            continue
        else:
            b += 1
print(min(a, b))

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yay!")
    else:print(":(")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
#n = ip()                                     #入力整数1つ
#a,b= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
n = len(a)
c = 0
add = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        add+=1
        add%=2
    if add:c+=1
print(min(n-c,c))

Submission status: Accepted

Solution code:
def int_raw():
    return int(input())


def ss_raw():
    return raw_input().split()


def ints_raw():
    return list(map(int, ss_raw()))


S = [int(s) for s in raw_input()]
current = 0
ans = 0
for s in S:
    if s != current:
        ans += 1
    current = 1 - current
print(min(ans, len(S) - ans))

Submission status: Accepted

Solution code:
S = list(input())
pattern = [[str(i % 2) for i in range(len(S))], [str((i+1) % 2) for i in range(len(S))]]
count = float('inf')
for pattern in pattern:
    c = 0
    for (s, p) in zip(S, pattern):
        if s != p:
            c += 1
    count = min(count, c)
print(count)

Submission status: Accepted

Solution code:
s = input()
res = 0
n = len(s)
cnt = 0
for i in range(n):
    if i % 2 == 0:
        if s[i] == "0":
            cnt += 1
    else:
        if s[i] == "1":
            cnt += 1
res = n - cnt
cnt = 0
for i in range(n):
    if i % 2:
        if s[i] == "0":
            cnt += 1
    else:
        if s[i] == "1":
            cnt += 1
res = min(res, n - cnt)
print(res)

Submission status: Accepted

Solution code:
S = input()

s_1 = [S[i] for i in range(len(S)) if i % 2 == 0]
s_2 = [S[i] for i in range(len(S)) if i % 2 == 1]

ct_s1_0 = s_1.count('0')
ct_s1_1 = s_1.count('1')
ct_s2_0 = s_2.count('0')
ct_s2_1 = s_2.count('1')

count_1 = ct_s1_0 + ct_s2_1
count_2 = ct_s1_1 + ct_s2_0

print(min(count_1, count_2))

Submission status: Accepted

Solution code:
s = list(map(int, input()))

even = s[::2]
odd = s[1::2]

a = even.count(0) + odd.count(1)
b = even.count(1) + odd.count(0)

print(min(a, b))

Submission status: Accepted

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

n_white_even = sum(S_num[0::2])
n_black_even = len(S_num[0::2]) - n_white_even
n_white_odd = sum(S_num[1::2])
n_black_odd = len(S_num[1::2]) - n_white_odd

# even: white, odd: black
cand_1 = n_black_even + n_white_odd
# even: black, odd: white
cand_2 = n_white_even + n_black_odd

print(min(cand_1, cand_2))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

S = input()
if S[0] == '0':
    res1 = S[::2].count('1')+S[1::2].count('0')
    res2 = S[1::2].count('1')+S[::2].count('0')
else:
    res1 = S[::2].count('1')+S[1::2].count('0')
    res2 = S[1::2].count('1')+S[::2].count('0')
print(min(res1,res2))

Submission status: Accepted

Solution code:
s=list(input())
a=[]
b=[]
for i in range(len(s)):
    if i%2==0:
        a.append("1")
        b.append("0")
    else:
        a.append("0")
        b.append("1")
a_count=0
b_count=0
for i in range(len(s)):
    if a[i]!=s[i]:a_count+=1
    if b[i]!=s[i]:b_count+=1
print(min(a_count,b_count))

Submission status: Accepted

Solution code:
s=list(input())

even=s[::2]
odd =s[1::2]

a = len(even) - even.count("0") + len(odd) - odd.count("1")
b = len(even) - even.count("1") + len(odd) - odd.count("0")

if a > b:
  print(b)
else:
  print(a)

Submission status: Accepted

Solution code:
def solve():
  s = input()
  n = len(s)
  odd = ""
  even = ""
  for i in range(n):
    if i%2 == 0:
      odd += s[i]
    else:
      even += s[i]
  
  oddzero = odd.count("0")
  oddone = odd.count("1")
  evenzero = even.count("0")
  evenone = even.count("1")
  ans = min(oddzero+evenone,oddone+evenzero)
  
  print(ans)
solve()

Submission status: Accepted

Solution code:
S = input()
N = len(S)

zeros = [0,0] # even, odd
flg = 0
for s in S:
    if s=='0':
        zeros[flg] += 1
    flg = (flg+1)%2

ones = [(N+1)//2-zeros[0], N//2-zeros[1]]
ans = min(zeros[0]+ones[1], zeros[1]+ones[0])
print(ans)

Submission status: Accepted

Solution code:
s = input()

list_s = [int(c) for c in s]

test_01 = []
test_10 = []

for i in range(len(s)):
    test_01.append(i % 2) 
    test_10.append((i+1) % 2)

cost01 = 0
cost10 = 0


for i in range(len(s)):
    cost01 += abs(test_01[i] - list_s[i])
    cost10 += abs(test_10[i] - list_s[i])

print(min(cost01,cost10))

Submission status: Accepted

Solution code:
s = list(map(int, list(input())))
n = len(s)

count = 0
for i in range(n):
    if i % 2 == s[i]:
        count = count + 1

print(min(count, n - count))

Submission status: Accepted

Solution code:
S = input()

cnt_1=0
cnt_0=0
for idx,s in enumerate(S):
  if (idx%2 == 0 and s == "0") or (idx%2 == 1 and s == "1"):
    cnt_0+=1
  if (idx%2 == 1 and s == "0") or (idx%2 == 0 and s == "1"):
    cnt_1+=1
print(min(cnt_0,cnt_1))

Submission status: Accepted

Solution code:
S = str(input())

ans1 = S[0::2].count('1') + S[1::2].count('0')
ans2 = S[0::2].count('0') + S[1::2].count('1')
print(min(ans1, ans2))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

s = input()

p1 = 0
p2 = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "1":
            p1 += 1
    else:
        if s[i] == "0":
            p1 += 1

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            p2 += 1
    else:
        if s[i] == "1":
            p2 += 1

print(min(p1,p2))

Submission status: Accepted

Solution code:
S = input()
cntA = 0
cntB = 0
for index,x in enumerate(S):
    if(index%2==0):
        if(x=='1'):
            cntA+=1
        else:
            cntB+=1
    else:
        if(x=='1'):
            cntB+=1
        else:
            cntA+=1
print(min(cntA,cntB))

Submission status: Accepted

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

cnt = 0
for i in range(len(l)):
  if i != 0 and l[i - 1] == l[i]:
    if l[i] == "0":
      l[i] = "1"
    else:
      l[i] = "0"
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
p=input()
f=p[0]
if f=="0":s="1"
if f=="1":s="0"
c=0
for i in range(len(p)):
    if i%2==0:t=f
    else:t=s
    if p[i]!=t:c+=1
print(c)

Submission status: Accepted

Solution code:
t=input()
s=[]
for i in t:
  s.append(int(i))
a,b=[0,0]
for i in range(len(s)):
  if (s[i] + i)%2==0:
    a+=1
  else:
    b+=1
print(min(a,b))

Submission status: Accepted

Solution code:
import numpy as np
words = lambda t : list(map(t, input().split()))

s = input()

bres = 0
wres = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            bres += 1
        else:
            wres += 1
    else:
        if s[i] == '0':
            wres += 1
        else:
            bres += 1

print(min(bres,wres))

Submission status: Accepted

Solution code:
s = input()
zero = 0
one = 0
for i , j in enumerate(s):
    if i % 2 == 0:
        if j == '1':
            zero += 1
        if j == '0':
            one += 1
    if i % 2 == 1:
        if j == '1':
            one += 1
        if j == '0':
            zero += 1
print(min(zero, one))

Submission status: Accepted

Solution code:
S = [int(i) for i in input()]
p = [0]*len(S)
for i in range(len(S)):
    if i % 2 == 0:
        p[i] = 1
q = [0]*len(S)
for i in range(len(S)):
    if i % 2 == 1:
        q[i] = 1

pans = 0
for i in range(len(S)):
    if S[i] != p[i]:
        pans += 1

qans = 0
for i in range(len(S)):
    if S[i] != q[i]:
        qans += 1

print(min(pans, qans))

Submission status: Accepted

Solution code:
s=input()
cnt1=0
cnt2=0
for i in range(len(s)):
    if i%2==1 and s[i]=='0':
        cnt1+=1
    elif i%2==0 and s[i]=='1':
        cnt1+=1
    if i%2==0 and s[i]=='0':
        cnt2+=1
    elif i%2==1 and s[i]=='1':
        cnt2+=1
print(min(cnt1,cnt2))

Submission status: Accepted

Solution code:
s = input()

c01010c = 0
c10101c = 0
i = 0

for ss in s:
    if ss == '0' and i % 2 == 0:
        c10101c += 1
    elif ss == '0' and i % 2 == 1:
        c01010c += 1
    elif ss == '1' and i % 2 == 0:
        c01010c += 1
    elif ss == '1' and i % 2 == 1:
        c10101c += 1
    i += 1

print(min(c01010c, c10101c))

Submission status: Accepted

Solution code:
s=input()

now_black=True
count_a=0
for c in s:
    if now_black and c == "1":
        count_a += 1
    elif (not now_black) and c == "0":
        count_a += 1
    now_black = not now_black

now_black=False
count_b=0
for c in s:
    if now_black and c == "1":
        count_b += 1
    elif (not now_black) and c == "0":
        count_b += 1
    now_black = not now_black

print (min(count_a, count_b))

Submission status: Accepted

Solution code:
def solve(S):
    cnt0 = 0
    cnt1 = 0
    for i in range(len(S)):
        if i % 2 == 0:
            if S[i] == '1':
                cnt1 += 1
            else:
                cnt0 += 1
        else:
            if S[i] == '1':
                cnt0 += 1
            else:
                cnt1 += 1
    return min(cnt0, cnt1)


S = input()
print(solve(S))

Submission status: Accepted

Solution code:
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        S = np.asarray(list(map(int,list(str(input())))))
    else:
        pass
    #print(S)

    A = np.asarray(range(S.size))
    B = np.asarray([0]*S.size)
    B[A%2==0] = 0
    B[A%2==1] = 1
    
    C = np.asarray([0]*S.size)
    C[A%2==0] = 1
    C[A%2==1] = 0
    
    res1 = np.sum(np.bitwise_xor(S,B))
    res2 = np.sum(np.bitwise_xor(S,C))
    print(min(res1,res2))

if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

BLACK = '0'
WHITE = '1'

white_start = 0
black_start = 0

for i, s in enumerate(S):
    if i % 2 == 0:
        if s == BLACK:
            white_start += 1
        else:
            black_start += 1
    else:
        if s == BLACK:
            black_start += 1
        else:
            white_start += 1
print(min([white_start, black_start]))

Submission status: Accepted

Solution code:
S=[int(c) for c in input()]
T=[i%2 for i in range(len(S))]
q=0
for s,t in zip(S,T):
    q+= s!=t
print(min(q,len(S)-q))

Submission status: Accepted

Solution code:
S = raw_input()
count = [0,0]
oe = 0
n = 0
for c in S:
	if(c =='1'):
		count[oe] += 1
	else:
		count[(oe+1)%2] += 1
	oe = (oe+1)%2
	n += 1
print(n - max(count))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
temp = len([i for i in range(n) if int(s[i]) == i % 2])
print(min(temp, n - temp))

Submission status: Accepted

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


def main():
    lc = list(map(int, list(input())))
    bc = lc[0]
    ret = 0
    for c in lc[1:]:
        if c == bc:
            bc = 1 - c
            ret += 1
        else:
            bc = c
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8

s = input()

ans0 = 0
ans1 = 0

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == "0":
            ans0 += 1
    else:
        if s[i] == "1":
            ans0 += 1

for i in range(len(s)):
    if i % 2 == 1:
        if s[i] == "0":
            ans1 += 1
    else:
        if s[i] == "1":
            ans1 += 1

print(min([ans0, ans1]))

Submission status: Accepted

Solution code:
S=input()

startzero=0
startone=0

for i in range(len(S)):
  if i%2==0:
    if S[i]=='0':
      startone+=1
    else:
      startzero+=1
  else:
    if S[i]=='0':
      startzero+=1
    else:
      startone+=1
  #print(i,S[i],startzero,startone)

print(min(startzero,startone))

Submission status: Accepted

Solution code:
S = input()

if len(S) == 1:
    print(0)
else:
    o = S[::2]
    e = S[1::2]
    to = o.count('1') + e.count('0')
    te = o.count('0') + e.count('1')
    print(min(to, te))

Submission status: Accepted

Solution code:
S=input()
ans=0
flag=0
for i in S:
  if int(i)==flag:
    ans+=1
  flag=abs(flag-1)
print(min(ans,len(S)-ans))

Submission status: Accepted

Solution code:
S = input()
if len(S) % 2 == 0:
    T = "10"*(len(S)//2)
    U = "01"*(len(S)//2)
else:
    T = "10"*(len(S)//2)+"1"
    U = "01"*(len(S)//2)+"0"

ans1,ans2 = 0,0
for i in range(len(S)):
    if S[i] != T[i]:
        ans1 += 1
    if S[i] != U[i]:
        ans2 += 1
print(min(ans1,ans2))

Submission status: Accepted

Solution code:
def main():
    S = input()
    L = []
    LL = []
    i = 0
    for _ in range(len(S)):
        L.append(str(1 ^ i))
        i ^= 1
    i = 0
    for _ in range(len(S)):
        LL.append(str(0 ^ i))
        i ^= 1
    L = ''.join(L)
    LL = ''.join(LL)
    lc = 0
    llc = 0
    for s, l, ll in zip(S, L, LL):
        if s != l:
            lc += 1
        if s != ll:
            llc += 1
    print(min(lc, llc))


main()

Submission status: Accepted

Solution code:
S=list(input())
#print(S)
count=0
for i in range(len(S)):
    if i%2==0:
        if S[i]=="0":
            count+=1
    else:
        if S[i]=="1":
            count+=1

print(min(count,len(S)-count))

Submission status: Accepted

Solution code:
S = input()
N = len(S)

t1 = t2 = 0
for i in range(N):
    c = str(i % 2)
    if S[i] != c:
        t1 += 1
    else:
        t2 += 1
print(min(t1, t2))

Submission status: Accepted

Solution code:
#coding:utf-8

S = input()

candidate1 = []
candidate2 = []
for i in range(len(S)):
    candidate1.append(str(i%2))
    candidate2.append(str((i+1)%2))

dif1 = dif2 = 0
for enu, i in enumerate(S):
    if i!= candidate1[enu]:
        dif1 += 1
    if i!= candidate2[enu]:
        dif2 += 1
    
print(min(dif1, dif2))

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a = list(input())

c = '0'
count1 = 0
count2 = 0
for i in a:
    if i != c:
        count1 += 1
    if c == '0':
        c = '1'
    else:
        c = '0'
c = '1'
for i in a:
    if i != c:
        count2 += 1
    if c == '0':
        c = '1'
    else:
        c = '0'
print(min(count1, count2))

Submission status: Accepted

Solution code:
s = input()
ans = float("inf")

for v in [1,2]:
  count = 0
  for i,c in enumerate(s):
    if (i+v) % 2 == 0:
      if c == "1":
        count += 1
    else:
      if c == "0":
        count += 1
  ans = min(count,ans)
print(ans)