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

Solution (Python):
strS = input()
S0 = []
S1 = []
changeA = 0
changeB = 0
S = [int(s) for s in strS]
for i in range(len(strS)):
    if (i % 2 == 0):
        S0.append(0)
        S1.append(1)
    else:
        S0.append(1)
        S1.append(0)

for i in range(len(S)):
    if not S[i] == S0[i]:
        changeA += 1
    if not S[i] == S1[i]:
        changeB += 1
if changeA > changeB :
    print(changeB)
else :
    print(changeA)

Solution (Python):
def main(input_str):
    input_list = list(input_str)
    count = 0
    if input_list[0] == "0":
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("0")
            else:
                ans.append("1")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    else:
        ans = []
        for i, _ in enumerate(input_list):
            if i % 2 == 0:
                ans.append("1")
            else:
                ans.append("0")
        for i, _ in enumerate(input_list):
            if input_list[i] != ans[i]:
                count += 1

    return count


if __name__ == "__main__":
    input_str = input()
    print(main(input_str))

Solution (Python):
S = [i for i in input()]

def henkan(a):
    if a == "0":
        a = "1"
    else:
        a = "0"
    return a
    
ans = 0
a = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        a = henkan(S[i+1])
        ans += 1
        S[i+1] = a
print(ans)

Solution (Python):
S = [int(i) for i in input()]
result = 0

for i, b1 in enumerate(S):
    if i < len(S)-1:
        b2 = S[i+1]
    else:
        break
    
    if b1 == b2:
        result += 1
        if b2 == 1:
            S[i+1] -= 1
        else:
            S[i+1] += 1

print(result)

Solution (Python):
s = list(input())
ans = 0
for i in range(0,len(s)-1):
    if s[i] == s[i+1]:
        if s[i] == "0": s[i+1] = "1"
        else: s[i+1] = "0"
        ans += 1

print(ans)

Solution (Python):
a=str(input())
odd0,even0=0,0
odd1,even1=0,0
for i in range(len(a)):
  if i%2==0:
    if a[i]=="0":
      odd0+=1
  else:
    if a[i]=="0":
      even0+=1
odd1=len(a)-int(len(a)/2)-odd0
even1=int(len(a)/2)-even0
print(min(odd1+even0,odd0+even1))

Solution (Python):
tiles = list(map(int, input()))




def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        if tile == color:
            counts = counts + 1
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Solution (Python):
from sys import stdin
from collections import Counter
s = list(stdin.readline().rstrip())
odd = Counter(s[0::2])
even = Counter(s[1::2])
if odd['1'] > even['1']:
    print(odd['0']+even['1'])
elif odd['1'] < even['1']:
    print(odd['1']+even['0'])
else:
    if odd['0'] > even['0']:
        print(odd['1']+even['0'])
    elif odd['0'] < even['0']:
        print(odd['0']+even['1'])
    else:
        print(len(s)//2)

Solution (Python):


import re

a = input()

preans1 = 0
preans2 = 1000000
if(a[0] == "0"):
    for i in range(len(a)):
        if(i%2 == 0):
            if(a[i] != "0"):
                preans1 += 1
        elif(i%2 == 1):
            if(a[i] != "1"):
                preans1 += 1
    if(a[-1] == "1"):
        preans2 = 0
        for i in range(2,len(a)+1):
            if(i%2 == 0):
                if(a[-i] != "0"):
                    preans2 += 1
            elif(i%2 == 1):
                if(a[-i] != "1"):
                    preans2 += 1
elif(a[0] == "1"):
    for i in range(len(a)):
        if(i%2 == 1):
            if(a[i] != "0"):
                preans1 += 1
        elif(i%2 == 0):
            if(a[i] != "1"):
                preans1 += 1
    if(a[-1] == "0"):
        preans2 = 0
        for i in range(2,len(a)+1):
            if(i%2 == 0):
                if(a[-i] != "1"):
                    preans2 += 1
            elif(i%2 == 1):
                if(a[-i] != "0"):
                    preans2 += 1
print(min(preans1,preans2))

Solution (Python):
def main():
  S=input()
  char = list(S)
  char2= list(S)
  num =len(list(S))
  count=0
  
  
  if num ==1:
    print(0)
  
  else:
    for i in range(0,num,2):
      if(char[i]=='0'):
        char[i]='1'
        count=count+1
    for j in range(1,num,2):
      if(char[j]=='1'):
        char[j]='0'
        count=count+1
    count_even=count
  
    count=0
    for i in range(0,num,2):
      if(char2[i]=='1'):
        char2[i]='0'
        count=count+1
    for j in range(1,num,2):
      if(char2[j]=='0'):
        char2[j]='1'
        count=count+1
    count_odd=count

    print(min(count_even,count_odd))
  
main()

Solution (Python):
S=list(input())
N=len(S)
S_int_1=list(S)
S_int_2=list(S)
for i in range(N):
    S_int_1[i]=int(S[i])
    S_int_2[i]=int(S[i])
cnt_1=0
cnt_2=0
for i in range(N):
    if i%2==0 and S_int_1[i]==0:
        S_int_1[i]=1
        cnt_1+=1
    elif i%2==1 and S_int_1[i]==1:
        S_int_1[i]=0
        cnt_1+=1
for i in range(N):
    if i%2==0 and S_int_2[i]==1:
        S_int_2[i]=0
        cnt_2+=1
    elif i%2==1 and S_int_2[i]==0:
        S_int_2[i]=1
        cnt_2+=1
print(min(cnt_1,cnt_2))

Solution (Python):
S = input()
count = 0
smae = ""

for i in range(len(S)) :
    if i == 0 :
        smae = S[i]
    elif smae == S[i] :
        smae = ("1" if S[i] == "0" else "0")
        count += 1
        continue
    smae = S[i]
    
print(count)

Solution (Python):
import numpy as np
tmp = str(input())

H = []
for i in range(len(tmp)):
    H.append(int(tmp[i]))


H = np.array(H, int)


x = []
y = []
for i in range(len(H)):
    x.append(i%2)
    y.append((i+1)%2)


a = sum(H == np.array(x))
b = sum(H == np.array(y))

if(a>=b):
    print(len(H)-a)
else:
    print(len(H)-b)

Solution (Python):
s=input()
l=len(s)

suuti=[]
for _ in s:
    suuti.append(int(_))

rei=[]
for _ in range(l):
    rei.append(_%2)

c=0
for _ in range(l):
    if rei[_]==suuti[_]:
        c+=1

print(min(c,l-c))

Solution (Python):
import collections
import math
S = [int(i) for i in input()]
guusuu = S[1::2]
kisuu = S[0::2]
if len(S)==1:
    print(0)
else:
    if len(S)%2==0:
        if guusuu.count(1)>=kisuu.count(1):
            print(len(guusuu)-guusuu.count(1)+len(kisuu)-kisuu.count(0))
        else:
            print(len(guusuu)-guusuu.count(0)+len(kisuu)-kisuu.count(1))
    else:
        if guusuu.count(1)>=kisuu.count(1):
            print(len(guusuu)-guusuu.count(1)+len(kisuu)-kisuu.count(0))
        else:
            print(len(guusuu)-guusuu.count(0)+len(kisuu)-kisuu.count(1))

Solution (Python):
s = input()

l = len(s)
a, b = '0', '1' 
res_a = res_b = 0 
for i in range(l):
    if s[i] != a:
        res_a += 1                                                                                             
    if s[i] != b:
        res_b += 1
    a, b = b, a

print(min(res_a, res_b))

Solution (Python):


import sys
input = sys.stdin.readline




S = input()

l = len(S) - 1
leng = l // 2

check1 = "01" * leng
check2 = "10" * leng

if l % 2 != 0:
    check1 = "1" + check1
    check2 = "0" + check2

check1 = int(check1, 2)
check2 = int(check2, 2)
S = int(S, 2)

check1 ^= S
check2 ^= S

print(min(bin(check1).count('1'), bin(check2).count('1')))

Solution (Python):
S = raw_input()

value = int(S, 2)

eval = ''
length = len(S)
if length % 2 == 0: val = 1
else: val = 0
for i in xrange(length):
    if i % 2 == val: eval += '1'
    else: eval += '0'

count = bin(value ^ int(eval,2)).count('1')

if count <= 0.5 * length: print count
else: print (length - count)

Solution (Python):
s = str(input())

compare1 = "01"*int(len(s)/2)
compare2 = "10"*int(len(s)/2)
if len(compare1)!=len(s):
  compare1 = compare1 + "0"
  compare2 = compare2 + "1"

diff1=0
diff2=0
for i,j,k in zip(s,compare1,compare2):
  if i == j:
    diff1 = diff1 + 1
  if i == k:
    diff2 = diff2 + 1

print(min(diff1,diff2))

Solution (Python):
s = input()

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

e_c = int((len(s)+1)/2)
o_c = len(s)-e_c

e1 = e_c - even + odd
o1 = o_c - odd + even
if(e1 > o1):
    print(o1)
else:
    print(e1)

Solution (Python):
S=str(input())
a=0
b=0
c=0
d=0
for i in range(0,len(S),1):
  if i%2==1 and S[i]=="1": 
    a+=1
  if i%2==0 and S[i]=="1": 
    b+=1
  if i%2==1 and S[i]=="0": 
    c+=1
  if i%2==0 and S[i]=="0": 
    d+=1

A=a+d
C=b+c
if A>=C:
  print(len(S)-A)
elif A<C:
  print(len(S)-C)

Solution (Python):
s = [int(i) for i in input()]
n = len(s)

p1 = [i for i in map(lambda n: n%2, range(n))]
p2 = [i for i in map(lambda n: (n+1)%2, range(n))]

s1,s2 = 0,0

for i in range(n):
    if s[i] != p1[i]:
        s1 += 1
    if s[i] != p2[i]:
        s2 += 1

print(min(s1, s2))

Solution (Python):
S = [ i for i in input()]

if len(S) <= 1:
  print(0)
  exit()

zerone = ['0', '1']
a = 0
b = 0

def is_even(num):
  return 0  if num % 2 == 0 else 1

for i in range(len(S)):
  if S[i] != zerone[is_even(i)]:
    a += 1
  else:
    b += 1

print(a if a < b else b)

Solution (Python):
S = list(input())

a = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        a += 1
        if S[i] == "0":
            S[i] = "1"
        else:
            S[i] = "0"
    else:
        pass
print(a)

Solution (Python):

S = str(input())

S_list = list(S)

S_len  = len(S_list)


BWB_list = ["0"] * S_len
for i in range(S_len):
  if i % 2 != 0:
    BWB_list[i] = "1"



WBW_list = ["1"] * S_len
for i in range(S_len):
  if i % 2 != 0:
    WBW_list[i] = "0"


    


BWB_cost = 0
for (target, bwb) in zip(S_list, BWB_list):
  if target != bwb:
    BWB_cost += 1

WBW_cost = 0
for (target, wbw) in zip(S_list, WBW_list):
  if target != wbw:
    WBW_cost += 1
    


print(str( min(BWB_cost,WBW_cost) ) )

Solution (Python):
S = list(input())
count1 = 0
count2 = 0

for i in range(int(len(S)/2)):
    if S[2*i] == "0" and S[2*i+1] == "1":
        count1 += 2
    elif S[2*i] == "1" and S[2*i+1] == "0":
        count2 += 2
    else:
        count1 += 1
        count2 += 1

if len(S)%2 == 0:
    if count1 >= count2:
        print(count2)
    else:
        print(count1)
else:
    if S[-1] == "0":
        count1 += 1
    else:
        count2 += 1
    
    if count1 >= count2:
        print(count2)
    else:
        print(count1)

Solution (Python):
s = raw_input()

s_str = list(str(s))
list_0 = []
list_1 = []
count_0 = 0
count_1 = 0

for i in range(0,len(s_str)):
 if i%2 == 0:
  list_0.extend(s_str[i])
 else:
  list_1.extend(s_str[i])

v0 = list_0.count("1")
v1 = list_1.count("1")

if v0 > v1:
 v = v1 + list_0.count("0")
else:
 v = v0 + list_1.count("0")

print v

Solution (Python):
s = input()
l = len(s)
a = 0
for i in range(l):
  if i&1 == 0:
    a <<= 2
    a += 1
b = ((2**l)-1) ^ a

S = int(s, 2)
A = bin(S^a).count('1')
B = bin(S^b).count('1')
print(min(A, B))

Solution (Python):
string = str(input())
lis = []

for s in string:
  lis.append(int(s))
  
ans = 0
itr = 0
j = 0
for i in lis:
  if len(lis) == 1:
    break
    
  if itr == 0:
    itr += 1
    j = i
    continue
    
  if  j == i:
    ans += 1
    if i == 1:
      j = 0
    else:
      j = 1
  else:
    j = i
    continue

print(ans)

Solution (Python):
import  numpy as np

s = input()
x = [int(str) for str in list(s)]
a0 = [0]
a1 = [1]

for i, v in enumerate(x):
    if i == 0:
        continue
    else:
        if a0[i-1] == 0:
            a0.append(1)
        else:
            a0.append(0)

        if a1[i-1] == 0:
            a1.append(1)
        else:
            a1.append(0)

x = np.array(x)
a0 = np.array(a0)
a1 = np.array(a1)

num_a0 = np.sum(x != a0)
num_a1 = np.sum(x != a1)

print(min(num_a0, num_a1))

Solution (Python):
S = input()
n = len(S)
s0 = 0
s1 = 0

for i in range(n):
    if i % 2 == 0:
        if S[i] != "0":
            s0 += 1
        else :
            s1 += 1
    
    else:
        if S[i] != "1":
            s0 += 1
        else:
            s1 += 1

if s0 > s1:
    print(s1)
else:
    print(s0)

Solution (Python):

"""
Created on Sat Apr 13 21:15:41 2019

@author: screamLab
"""

s = input()

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

Solution (Python):
S = input()

a = int("".join(["0" if i%2 == 0 else "1" for i in range(len(S))]), 2)
b = int("".join(["0" if i%2 == 1 else "1" for i in range(len(S))]), 2)


a_ = int(S, 2) ^ a
b_ = int(S, 2) ^ b

cnt1 = 0
cnt2 = 0

for c1 in bin(a_)[2:]:
    if c1 == "1":
        cnt1 += 1

for c2 in bin(b_)[2:]:
    if c2 == "1":
        cnt2 += 1

if cnt1 > cnt2:
    print(cnt2)
else:
    print(cnt1)

Solution (Python):
s = input()
length=len(s)

count1=0
count2=0

for i in range(0,length):
	if i%2==0:
		if s[i]=='0':
			count1+=1
		else:
			count2+=1
	if i%2==1:
		if s[i]=='0':
			count2+=1
		else:
			count1+=1

if count1>=count2:
	print(count2)
else:
	print(count1)

Solution (Python):
Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit()
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    
    
    
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    

min_change = change


change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    
    
    
    if cur is Tiles[i]:
        change_first+=1
        if min_change <= change_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]
        
if min_change > change_first:
    min_change = change_first

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    
    
    
    if cur is Tiles[i]:
        change_reverse+=1
        if min_change <= change_reverse:
            break


        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    
    
if min_change > change_reverse:
    min_change = change_reverse


change_reverse_first=1
if Tiles[N_len-1] == "0":
    cur = "1"
else:
    cur = "0"

for i in reversed(range(0, N_len-1)):
    
    
    
    if cur is Tiles[i]:
        change_reverse_first+=1
        if min_change <= change_reverse_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

if min_change > change_reverse_first:
    min_change = change_reverse_first

print(str(min_change))

Solution (Python):
s = input()
n = len(s)
k = 0
l = 0
for i in range(n):
  if (i+1) % 2 == 1:
    if s[i] == "1":
      k = k + 1
    else:
      l = l + 1 
  else:
    if s[i] == "0":
      k = k + 1
    else:
      l = l + 1
print(min(k,l))

Solution (Python):
S = input()

S0 = "0"
S1 = "1"

S00 = ""
SA = ""

for i in range(len(S)):

    S00 += str(abs(int(S0) - (i % 2)))

for i in range(len(S)):

    SA += str(int(S[i]) ^ int(S00[i]))

print(min(SA.count("0"), SA.count("1")))

Solution (Python):
S = input()

a=0
b=0
for i,s in enumerate(S):
    if  i% 2 == 0:
        if s =="0":
            a += 1
        else:
            b += 1
    else:
        if s=="0":
            b+=1
        else:
            a+=1
ans = min(a,b)
print(ans)

Solution (Python):
S = list(input())
loop = len(S)//2
if len(S)%2 == 1:
    odd = 1
else:
    odd = 0
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 odd == 1:
        if S[-1] == "0":
            A += 1 
        else:
            B += 1
if A < B:
    ans = A
else:
    ans = B
print(ans)

Solution (Python):
s = input()

num = len(s)
case1 = ''
case2 = ''
item1 = '1'
item2 = '0'
for item in range(len(s)):
    case1 += item1
    case2 += item2
    if item1 == '1':
        item1 = '0'
    else:
        item1 = '1'

    if item2 == '1':
        item2 = '0'
    else:
        item2 = '1'

count1 = 0
count2 = 0
for i in range(len(s)):
    if case1[i] != s[i]:
        count1 += 1
    if case2[i] != s[i]:
        count2 += 1
ret = min(count1, count2)
print(ret)

Solution (Python):
S = input()

N = len(S)

S = list(S)
count = 0
for i in range(1, N):
    if S[i] == S[i - 1]:
        S[i] = "1" if S[i - 1] == "0" else "0"
        count += 1

print(count)

Solution (Python):
S = input()
S = list(S)
for i in range(len(S)):
    S[i] = int(S[i])
dic = {0:1,1:0}

S1 = S[:]
S2 = S[:]

S2[0] = dic[S2[0]]
cnt1 = 0
cnt2 = 1


for i in range(len(S1)-1):
    if S1[i] == S1[i+1]:
        S1[i+1] = dic[S1[i+1]]
        cnt1 += 1



for i in range(len(S2)-1):
    if S2[i] == S2[i+1]:
        S2[i+1] = dic[S2[i+1]]
        cnt2 += 1


print(min(cnt1,cnt2))

Solution (Python):
s = tuple(input())
n = len(s)
count_0start = 0
count_1start = 0

for i in range(n)[::2]:
    if s[i] == '0':
        count_0start += 1
    else:
        count_1start += 1
    
for i in range(n)[1::2]:
    if s[i] == '1':
        count_0start +=1
    else:
        count_1start += 1

print(count_0start if count_0start < count_1start else count_1start)

Solution (Python):
a = input()
inp = [int(i) for i in a]

cnt = 0



gu_0 = 0
gu_0_score = 0
gu_1 = 0
gu_1_score = 0
ki_0 = 0
ki_0_score = 0
ki_1 = 0
ki_1_score = 0

for index, i in enumerate(inp):
	if index % 2 == 0:
		if i == 0:
			gu_0 += 1
		else:
			gu_1 += 1
	else:
		if i == 0:
			gu_1 += 1
		else:
			gu_0 += 1

maxscore = max([gu_0,gu_1,ki_0,ki_1])
			
if gu_0 + ki_1 == len(inp) or gu_1 + ki_0 == len(inp):
	print(0)
else:
	for score in [gu_0,gu_1,ki_0,ki_1]:
		if maxscore > score and score != 0:
			maxscore = score
	print(maxscore)

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

if len(s) == 1:
  print(0)
  exit()

ans = 0

for i in range(1, len(s)):
  if s[i-1] == s[i]:
    ans += 1
    if s[i] == '0':
      s[i] = '1'
    else:
      s[i] = '0'
  else:
    prev = s[i]

print(ans)

Solution (Python):
A = input()
A = list(A)
A = list(map(int,A))
B = [0 for _ in range(len(A))]
C = [1 for _ in range(len(A))]
for i in range(len(A)):
    if i%2==0:
        B[i] = 1
        C[i] = 0
count1 = 0
count2 = 0
for i in range(len(A)):
    if A[i]!=B[i]:
        count1 +=1
    if A[i]!= C[i]:
        count2 += 1
print(min(count1,count2))

Solution (Python):



S = list(map(int, input()))

def reverse(i):
    return (i+1)%2

ans1 = 0
expect = S[0]
for s in S:
    if s != expect:
        ans1 += 1
    expect = reverse(expect)

ans2 = 0
expect = reverse(S[0])
for s in S:
    if s != expect:
        ans2 += 1
    expect = reverse(expect)


print(min(ans1, ans2))

Solution (Python):



from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

S = input()
N = len(S)


s1 = S[0::2]
b1 = s1.count('0')
w1 = len(s1) - b1
s2 = S[1::2]
b2 = s2.count('0')
w2 = len(s2) - b2

print(min(b1 + w2, w1 + b2))

Solution (Python):
S = str(input())
cnt = 0
ch_flag = 0 

for i in range(len(S)):
  if(i + 1) >= len(S): 
    break
  if(ch_flag == 1):
    if(S[i] == '0'):
      tmp = '1'
    else:
      tmp = '0'
    ch_flag = 0
  else:
    tmp = S[i]
  if (tmp == S[i + 1]):
    ch_flag = 1
    cnt += 1
print(cnt)

Solution (Python):


s = input()

S = []
for i in s:
    S.append(int(i))
    
if len(S) % 2 == 0: 
    ans = 0
    num1 = 0
    num2 = 0
    
    
    for i, Si in enumerate(S): 
        if i % 2 == 0:
            if S[i] != 0:
                num1 += 1
        if i % 2 != 0:
            if S[i] != 1:
                num1 += 1
    
    for i, Si in enumerate(S): 
        if i % 2 == 0:
            if S[i] != 1:
                num2 += 1
        if i % 2 != 0:
            if S[i] != 0:
                num2 += 1
    
    ans = min([num1, num2])
    print(ans)

if len(S) % 2 != 0: 
    ans = 0
    num1 = 0
    num2 = 0
    
    
    for i, Si in enumerate(S): 
        if i % 2 == 0:
            if S[i] != 1:
                num1 += 1
        if i % 2 != 0:
            if S[i] != 0:
                num1 += 1
    
    for i, Si in enumerate(S): 
        if i % 2 == 0:
            if S[i] != 0:
                num2 += 1
        if i % 2 != 0:
            if S[i] != 1:
                num2 += 1
    
    ans = min([num1, num2])
    print(ans)

Solution (Python):
s = input()
type_A = 0
type_B = 0
for i in range(len(s)):
  if i%2 == 0:
    if int(s[i])!=0:
      type_A += 1
  else:
    if int(s[i])!=1:
      type_A += 1

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

if type_A > type_B:
  print(type_B)
else:
  print(type_A)

Solution (Python):
def c_coloring_colorfully(S):
    s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '')
    s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '')
    ans1, ans2 = 0, 0
    for k, s in enumerate(S):
        if s != s1[k]:
            ans1 += 1
        if s != s2[k]:
            ans2 += 1
    return min(ans1, ans2)

S = input()
print(c_coloring_colorfully(S))

Solution (Python):
s = input();l = [];h=[]
n=len(s)
for i in range(n):
    l += s[i] 
    
h += l 
cnt1=0;cnt2=0

if l[0]=='1':
    l[0]='0'
    cnt1 += 1
for i in range(n-1):
    if l[i]==l[i+1]:
        if l[i]=='0':
            l[i+1]='1'
        else:
            l[i+1]='0'
        cnt1 += 1

if h[0] == '0':
    h[0] = '1'
    cnt2 += 1
for j in range(n-1):
    if h[j]==h[j+1]:
        if h[j]=='0':
            h[j+1]='1'
        else:
            h[j+1]='0'
        cnt2 += 1
print(min(cnt1,cnt2))

Solution (Python):


S = str(input())
ans = 0
if len(S)==1:
    print(0)
    exit()
elif S=="00" or S=="11":
    print(1)
    exit()

flg = True
if S[0]=="0":
    for i in range(len(S)):
        if i == 0:
            continue
        if i%2 == 0:
            if S[i]!="0":
                ans+=1
                continue
        else:
            if S[i]!="1":
                ans+=1
                continue
else:
    for i in range(len(S)):
        if i == 0:
            continue
        if i%2 == 0:
            if S[i]!="1":
                ans+=1
                continue
        else:
            if S[i]!="0":
                ans+=1
                continue
print(ans)

Solution (Python):
l = list(map(int,list(input())))
sum = 0

if l[0] == 0:
	for i in range(len(l)):
		if i%2 == 0:
			if l[i] == 0:
				continue
			else:
				sum += 1
		else:
			if l[i] == 0:
				sum += 1
				
if l[0] == 1:
	for i in range(len(l)):
		if i%2 == 0:
			if l[i] == 1:
				continue
			else:
				sum += 1
		else:
			if l[i] == 1:
				sum += 1

print(sum)

Solution (Python):
S = input()
if len(S) % 2 == 0:
    N1 = "01" * (len(S)//2)
    N2 = "10" * (len(S)//2)
else:
    N1 = "01" * (len(S)//2) + "0"
    N2 = "10" * (len(S)//2) + "1"
n1 = 0
n2 = 0 
for i in range(len(S)):
    if S[i] != N1[i]:
        n1 = n1+1
    elif S[i] != N2[i]:
        n2 = n2+1
print(min(n1, n2))

Solution (Python):
S = list(input())

even_0 = 0
even_1 = 0
odd_0 = 0
odd_1 = 0

for i, value in enumerate(S):
    
    if i % 2 == 0:
        if value == "0":
            even_0 += 1
        else:
            even_1 += 1

    
    else:
        if value == "0":
            odd_0 += 1
        else:
            odd_1 += 1

print(min(even_0 + odd_1, even_1 + odd_0))

Solution (Python):
def color(s):
    k = 0
    for i in range(len(s)-1):
        if s[i+1]==s[i]:
            if s[i]=='0':
                s[i+1]='1'
            if s[i]=='1':
                s[i+1]='0'
            k = k+1
    return k
    
s=list(input())
print(color(s))

Solution (Python):
S = list(input())
len(S)
ans1 = 0
ans2 = 1
cnt1 = 0
cnt2 = 0
for i in range(len(S)):
  if not ans1 == int(S[i]):
    cnt1 = cnt1 + 1
  if ans1 == 0:
    ans1 = 1
  else:
    ans1 = 0

for i in range(len(S)):
  if not ans2 == int(S[i]):
    cnt2 = cnt2 + 1
  if ans2 == 0:
    ans2 = 1
  else:
    ans2 = 0

if cnt1 > cnt2:
  cnt1 = cnt2
  
print(cnt1)

Solution (Python):
def subtract_lst (lst1, lst2):
    ans = 0
    for i in range(len(lst1)):
        e1 = lst1[i]
        e2 = lst2[i]
        if e1 != e2:
            ans += 1
    return ans

if __name__ == '__main__':
    s = input()
    lenS = len(s)
    a = ""
    b = ""
    for i in range(lenS // 2):
      a = a + "10"
      b = b + "01"
    if lenS % 2 == 1:
        a = a + "1"
        b = b + "0"
    aAns = subtract_lst (a, s)
    bAns = subtract_lst (b, s)
    print (min(aAns, bAns))

Solution (Python):
data = [int(s) for s in input()]
count1 = 0
if data[0] == 0:
  
  
  for s in range(1,len(data)):
    
    
    
    if s % 2 == 0:
        if data[s] != 0:
            count1 += 1
    else :
        if data[s] != 1:
            count1 += 1
            
else:
  
  
  for s in range(1,len(data)):
    
    if s % 2 == 0:
      if data[s] != 1:
        count1 += 1
        
    else:
      if data[s] != 0:
        count1 += 1
          


print(count1)

Solution (Python):
s=input()
a="01"
b=x=y=0
for i in s:
  if i==a[b]: x+=1
  if i==a[~b]:y+=1
  b=~b
print(len(s)-max(x,y))

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

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


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

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

Solution (Python):
s = input()
size = len(s)

def poe(b):
  res = 0
  for i in range(size):
    if b:
      a = '1' if i % 2 == 0 else '0'
    else:
      a = '0' if i % 2 == 0 else '1'
 
    if a != s[i]:
      res+=1

  return res

print(min(poe(True), poe(False)))

Solution (Python):
import sys
 
s=list(input())
count=0
for i in range(len(s)):
  if i>=1:
    if s[i]==s[i-1]:
      if s[i-1]=='0':
        s[i]='1'
      else:
        s[i]='0'
      count+=1
print(count)

Solution (Python):
S = input()
ans1 = ans2 = 0
for i, s in enumerate(S):
    if i % 2 == 0 and s == '0':
        ans1 += 1
    if i % 2 == 1 and s == '1':
        ans1 += 1
    if i % 2 == 0 and s == '1':
        ans2 += 1
    if i % 2 == 1 and s == '0':
        ans2 += 1
print(min(ans1, ans2))

Solution (Python):
s=list(str(input()))
c=0
for x in range(len(s)-1):
    if s[x+1]==s[x]:
        if s[x]=="0":
            s[x+1]="1"
        else:
            s[x+1]="0"
        c+=1
print(c)

Solution (Python):
s = input()
l = len(s)

a=0
b=0
a=sum(int(s[i]) for i in range(0,l,2))
b=sum(int(s[i]) for i in range(1,l,2)) 

print(int(min(abs(l/2+0.5-a)+b,abs(l/2-b)+a)))

Solution (Python):
tiles=list(map(int,input()))
def create(x,y):
    sample=[]
    for i in range(0,len(tiles)):
        if i%2==0:
            sample.append(x)
        else:
            sample.append(y)
    return sample

sample1=create(1,0)
sample2=create(0,1)

def dif_count(list):
    count=0
    for i in range(0,len(list)):
        if list[i]!=tiles[i]:
            count+=1
    return count
print(min(dif_count(sample1),dif_count(sample2)))

Solution (Python):
n = input()
n_split = list(n)
count = 0

for i in range(len(n_split)):
    if i != 0:
        if n_split[i] == n_split[i-1]:
            if n_split[i] == "0":
                n_split[i] = "1"
            else:
                n_split[i] = "0"
            count += 1

print(count)

Solution (Python):
st=list(input())
n=list(map(int,st))
a=0
b=0
N=len(st)
retu10=[1,0]*(N//2  +1)
retu01=[0,1]*(N//2 +1)
r1=retu10[:N]
r0=retu01[:N]
for i in range(N):
  if r1[i]!=n[i]:
    a=a+1
  else:
    pass
for i in range(N):
  if r0[i]!=n[i]:
    b=b+1
  else:
    pass
print(min(a,b))

Solution (Python):
S = input()
l = len(S) // 2
s1 = [S[i*2] for i in range(l+(len(S) % 2))]
s2 = [S[i*2+1] for i in range(l)]
c = s1.count('1') + s2.count('0')
ret = c if c <= l else len(S) - c
print(ret)

Solution (Python):
S=list(input())
S=[int(i) for i in S]
sum_0=0
sum_1=0
if len(S)%2==1:
    S.append(2)
for i in range(0,len(S),2):
    if S[i]==1:
        sum_0+=1
    elif S[i]==0:
        sum_1+=1
    if S[i+1]==0:
        sum_0+=1
    elif S[i+1]==1:
        sum_1+=1
if sum_0>sum_1:
    print(sum_1)
else:
    print(sum_0)

Solution (Python):
S = input()
S2 = ""
S3 = ""
co1 = 0
co2 = 0
f = 1
for i in range(len(S)):
 if f == 1:
  S2 += "1"
  S3 += "0";f=0
 else:
  S2 += "0";S3 += "1";f=1
for i in range(0,len(S)):
  if S[i] != S2[i]:
   co1 += 1;print
for i in range(0,len(S)):
  if S[i] != S3[i]:
   co2 += 1
if co1 > co2:
 print(co2)
else:
 print(co1)

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

counter = 0
if len(s) == 1:
    print(0)
else:
    for i in range(1,len(s)):
        if s[i] == s[i-1]:
            s[i] = int(int(s[i-1]) ==  0)
            counter += 1
    print(counter)

Solution (Python):
S = list(input())
S = [int(i) for i in S]
sum1,sum2 = 0,0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            sum1 += 1
    else:
        if S[i] == 1:
            sum1 += 1

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 1:
            sum2 += 1
    else:
        if S[i] == 0:
            sum2 += 1
if sum1 <= sum2:
    print(sum1)
else:
    print(sum2)

Solution (Python):
S = input()
H = len(S) 
a = '0'
b = '1'
A = 0
B = 0
while len(a) < H:
    a = a + '1'
    if len(a) < H:
        a = a + '0'

        
while len(b) < H:
    b = b + '0'
    if len(b) < H:
        b = b + '1'

        
for i in range(H):
    if a[i] == S[i]:
        A = A + 1

for i in range(H):
    if b[i] == S[i]:
        B = B + 1

print(H - max(A,B))

Solution (Python):
s=input()
kuro=""
for i in range(len(s)):
    if i%2==0:
        kuro+="1"
    else:
        kuro+="0"
ans=0
for i in range(len(s)):
    if s[i]==kuro[i]:
        ans+=1
print(min(ans,len(s)-ans))

Solution (Python):
s = input()


a1 = 0
for i, item in enumerate(s):
    
    if i % 2 == 0 and item != "0":
        a1 += 1

    if i % 2 == 1 and item != "1":
        a1 += 1


a2 = 0
for i, item in enumerate(s):
    
    if i % 2 == 0 and item != "1":
        a2 += 1

    if i % 2 == 1 and item != "0":
        a2 += 1
print(min(a1, a2))

Solution (Python):
S = list(map(str, input()))

cnt = 0

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        cnt += 1

        if S[i+1] == "1":
            S[i+1] = "0"
        else:
            S[i+1] = "1"

print(cnt)

Solution (Python):
S=input()
Slist =list(S)
Sg=Slist[0::2]
Sk=Slist[1::2]
SG = ''.join(Sg)
SK = ''.join(Sk)
a=SG.count("0")
b=SG.count("1")
x=SK.count("0")
y=SK.count("1")
	
print(min(a+y,b+x))