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):
s = list(input())
a = []
b = []

for i in range(1, len(s)+1):
  a.append(i%2)     
  b.append((i+1)%2) 

c = 0
d = 0

s = list(map(int, s))

for i in range(len(s)):
  if a[i] != s[i]:
    c += 1
  if b[i] != s[i]:
    d += 1

if c > d:
  print(d)
else:
  print(c)

Solution (Python):
zero = "01" * 10**5
one = "10" * 10**5
s = str(input())
ans1 = 0
ans2 = 0
for i, j in zip(s, zero):
    if i != j:
        ans1 += 1
for i, j in zip(s, one):
    if i != j:
        ans2 += 1
print(min(ans1, ans2))

Solution (Python):
S = str(input())
N = len(S)

A = '01' * (N//2) + '01'[(N-1)%2]
B = '10' * (N//2) + '10'[(N-1)%2]
ans_A = 0
for i in range(N):
    if S[i] != A[i]:
        ans_A += 1

ans_B = 0
for i in range(N):
    if S[i] != B[i]:
        ans_B += 1

print(min(ans_A, ans_B))

Solution (Python):
S = str(input())
N = len(S)

A = '01' * (N//2) + '01'[(N-1)%2]
B = '10' * (N//2) + '10'[(N-1)%2]
ans_A = 0
for i in range(N):
    if S[i] != A[i]:
        ans_A += 1

ans_B = 0
for i in range(N):
    if S[i] != B[i]:
        ans_B += 1

print(min(ans_A, ans_B))

Solution (Python):
S = input()
lenS = len(S)
firstis0 = 0
firstis1 = 0

for i in range(len(S)):
    if i % 2 == 0 and S[i] == "1":
        firstis0 += 1
    elif i % 2 == 0 and S[i] == "0":
        firstis1 += 1
    elif i % 2 == 1 and S[i] == "0":
        firstis0 += 1
    else:
        firstis1 += 1
print(str(min(firstis0, firstis1)))

Solution (Python):
S = list(str(input()))
count = 0
for i in range(1,len(S)):
    if S [i - 1] == S[i]:
        count += 1
        S[i] = str(int(not int(S[i])))
print(count)

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

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

Solution (Python):

s = input().strip()
n = len(s)
cnt = 0

odd, even = 1, 0
flag = 0  

for i in range(1, n):
    if s[i] == s[i-1]:
        flag = 1 - flag

    if flag == 0:
         odd += 1
    else:
        even += 1

print(min(odd, even))

Solution (Python):
s = input().strip()
c1,c2 = 0,0
for i in range(len(s)):
  if i % 2 == 0 and s[i] != '0':
    c1 +=1
  if i%2 != 0 and s[i] != '1':
    c1 += 1
for i in range(len(s)):
  if i % 2 != 0 and s[i] != '0':
    c2 +=1
  if i%2 == 0 and s[i] != '1':
    c2 += 1
print(min(c1,c2))

Solution (Python):
S = input()
li = []
for s in S:
    li.append(int(s))

count = 0
first = li[0]
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] != first:
            count += 1
    else:
        if li[i] == first:
            count += 1

count2 = 1
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] == first:
            count2 += 1
    else:
        if li[i] != first:
            count2 += 1

print(min(count, count2))

Solution (Python):
s=list(input())
rei=0
iti=0
for i in range(len(s)):
  if i%2==0:
    if s[i]=='1':
      rei+=1
    else:
      iti+=1
  else:
    if s[i]=='0':
      rei+=1
    else:
      iti+=1
print(min(rei,iti))

Solution (Python):
import sys
input = sys.stdin.readline

s = input()
l = []
l.append(s[0])
count = 0
for i in range(1, len(s)):
    if l[i-1] == s[i]:
        count += 1
        if s[i] == "0":
            l.append("1")
        else:
            l.append("0")
    else:
        l.append(s[i])
print(count)

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

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

print(min(ans1, ans2))

Solution (Python):
from sys import stdin
s = list(map(int, list(stdin.readline().rstrip())))
ans_list = [0, 1] * (len(s) // 2)
if len(s) % 2 == 1: ans_list.append(0)
count = 0
for i, ans in zip(s, ans_list):
    if i != ans:
        count += 1
print("{}".format(min(count, len(s) - count)))

Solution (Python):
def calc_replace_n(str, start) :
    n = 0
    for i in range(len(str)) :
        if i%2==0 :
            if str[i] == start :
                n = n+1
        else :
            if str[i] != start :
                n = n+1
    return n

s = input()

replace_n_zero = calc_replace_n(s,"0")
replace_n_one = calc_replace_n(s,"1")

out = replace_n_zero if replace_n_zero < replace_n_one else replace_n_one
print(out)

Solution (Python):
n=input()
n1=n[::2]
n2=n[1::2]
nc=n1.count("0")+n2.count("1")
print(min(nc,len(n)-nc))

Solution (Python):
import copy


def count_num_flip(S):
    num_flip = 0
    S_prev = S[0]
    for S_next in S[1:]:
        if S_prev == S_next:
            num_flip += 1
            S_prev = not S_next
        else:
            S_prev = S_next
    return num_flip


if __name__ == '__main__':
    S = [bool(int(x)) for x in input()]
    S_prime = copy.copy(S)
    S_prime[0] = not S_prime[0]
    print(min(count_num_flip(S), count_num_flip(S_prime) + 1))

Solution (Python):
S = str(input())
count = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] != S[0]:
            count += 1
    else:
        if S[i] == S[0]:
            count += 1
print(count)

Solution (Python):
def Main():
    S = input()
    a, b = 0, 0
    for s in S:
        a += (s == '0')
        b += (s == '1')
        a, b = b, a
        
    print(min(a, b))

if __name__ == "__main__":
    Main()

Solution (Python):
s=list(input())
a=[]
b=[]
for i in range(1,len(s)+1):
    a.append(i%2)
    b.append((i+1)%2)
c=0
d=0
s=list(map(int,s))
for i in range(len(s)):
    if a[i] != s[i]:
        c+=1
    if b[i] != s[i]:
        d+=1
if c>d:
    print(d)
else:
    print(c)

Solution (Python):
n = str(input())
n_arr = list(str(n))
arr = list(map(int, n_arr))
zero = []
one = []
for i in range(len(arr)):
    if i % 2 == 0:
        zero.append(0)
        one.append(1)
    else:
        zero.append(1)
        one.append(0)
zero_diff = 0
one_diff = 0
for i in range(len(arr)):
    if arr[i] != zero[i]:
        zero_diff += 1
for i in range(len(arr)):
    if arr[i] != one[i]:
        one_diff += 1
print(min([one_diff,zero_diff]))

Solution (Python):
S = input()
a = b = 0

for i in range(len(S)):
    if S[i] == str(i%2):
        a += 1
    else:
        b += 1

print(min(a, b))

Solution (Python):
s=input()
ce=co=0
for i in range(len(s)):
    if i%2==0 and s[i]=='0':
        ce+=1 
    elif i%2==1 and s[i]=='1':
        ce+=1 
for i in range(len(s)):
    if i%2==1 and s[i]=='0':
        co+=1 
    elif i%2==0 and s[i]=='1':
        co+=1
if ce<co:
    print(ce)
else:
    print(co)

Solution (Python):

"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_b -d test-b
oj test -d test-c -c "python abc116c.py"
oj test -d test-b -c "python abc116b.py" test-b/sample-3.in
"""

from collections import defaultdict
import sys
import math
import time
import itertools


def deco(func):
    def wrapper(*args, **kwargs):
        s = time.time()
        
        ret = func(*args, **kwargs)
        logging.debug('--end in %f --' % (time.time() - s) )
        return ret
    return wrapper


@deco
def sol(S):
    zeroFirst= 0
    oneFirst = 0
    for i, s in enumerate(S):
        expected = '0' if i % 2 else '1'
        
        logging.debug("expected {} and s {} zeroFirst {}, oneFirst {}".format(
            expected, s, zeroFirst, oneFirst
        ))
        if s == expected:
            oneFirst+=1
        else:
            zeroFirst+=1

    logging.debug("zeroFirst {}, oneFirst {}".format(zeroFirst, oneFirst))
    return min(oneFirst, zeroFirst)






import logging

do_submit = False
do_submit = True

if do_submit:
    logging.basicConfig(level=logging.ERROR, format="%(message)s")
else:
    logging.basicConfig(level=logging.DEBUG, format="%(message)s")
def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(line.split()) for line in lines]
    (S) = parsed_lines[0][0]
    return (S)



if not do_submit:
    (S) = input_parse("""
    10010010
    """)
    print (sol(S))

    (S) = input_parse("""
    000
    """)
    print (sol(S))

else:
    str = ""
    str = input().strip()
    (S) = input_parse(str)
    print (sol(S))

Solution (Python):
s = input()

lgh = len(s)
s = int(s,2)

result = [0,0]

counter = 0

for i in range(lgh):
    result[0] = result[0] + (((s>>i)&1) ^ counter)
    counter = 1 - counter
    result[1] = result[1] + (((s>>i)&1) ^ counter)

print(min(result))

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

ans1 = 0
ans2 = 1

for i in range(1, len(s)):
    if (s[i-1] + s[i]) % 2 == 0:
        s[i] = abs(s[i]-1)
        ans1 += 1

if s2[0] == 0:
    s2[0] = 1
else:
    s2[0] = 0

for i in range(1, len(s)):
    if (s2[i-1] + s2[i]) % 2 == 0:
        s2[i] = abs(s2[i]-1)
        ans2 += 1

print(ans1 if ans1 <= ans2 else ans2)

Solution (Python):
S = input()


count01 = 0
pattern = False
for i in list(S):
  if bool(int(i)) is pattern:
    count01 += 1
  pattern = not(pattern)

count10 = 0
pattern = True
for i in list(S):
  if bool(int(i)) is pattern:
    count10 += 1
  pattern = not(pattern)

print(min(count01, count10))

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

A1 = '0'
A2 = '1'
for i in range(1, N):
  if i % 2 == 0:
    A1 = A1 + '0'
    A2 = A2 + '1'
  else:
    A1 = A1 + '1'
    A2 = A2 + '0'
S = int(S, 2)
A1 = int(A1, 2)
A2 = int(A2, 2)
n1 = bin(S ^ A1).count('1')
n2 = bin(S ^ A2).count('1')
print(min(n1, n2))

Solution (Python):



S = raw_input()

num0 = 0
num1 = 0
beg0 = '0'
beg1 = '1'

for s in S:
    if s != beg0:
        num0 += 1
    else:
        num1 += 1
    beg0 = '0' if beg0 == '1' else '1'
    beg1 = '0' if beg1 == '1' else '1'

print '{}'.format(min(num0, num1))

Solution (Python):
from sys import stdin
S = list(str(stdin.readline().rstrip()))
ans = 0
for i in range(1,len(S)):
    if S[i-1] == S[i]:
        ans+=1
        if S[i-1] == "0":
            S[i] = "1"
        if S[i-1] == "1":
            S[i] = "0"
print(ans)

Solution (Python):

S = list(input())
a = []
b = []
aans = 0
bans = 0

for i in range(len(S)):
    if i%2 == 0:
        a.append('0')
        b.append('1')
    else:
        a.append('1')
        b.append('0')
        
for i in range(len(S)):
    if S[i] != a[i]:
        aans += 1
    if S[i] != b[i]:
        bans += 1
if aans >= bans:
    print(bans)
else:
    print(aans)

Solution (Python):
s = input()
i = a = b = 0
for j in s:
    a += int(j) == i
    i = 1 - i
i = 1
for j in s:
    b += int(j) == i
    i = 1 - i
print(len(s) - max(a, b))

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

i=0
c=0
count=0

while len(li) > i :
    if int(li[i]) == c :
        count = count + 1
    c = c + 1
    c = c % 2
    i = i + 1
    
if len(li) / 2 < count : 
    ans = len(li) - count
else :
    ans = count

print(ans)

Solution (Python):



s = list(input())

N = len(s)

for i in range(N) : 
    s[i] = int(s[i])
    
s0 = []
s1 = []
    
for i in range(N) : 
    if i%2 == 0 : 
        s0.append(0)
    else : 
        s0.append(1)
        
for i in range(N) : 
    if i%2 == 1 : 
        s1.append(0)
    else : 
        s1.append(1)





cnt0 = 0
cnt1 = 0

for i in range(N) : 
    if s[i] != s0[i] : 
        cnt0 += 1
    if s[i] != s1[i] : 
        cnt1 += 1
        



print(min(cnt0, cnt1))

Solution (Python):
S = list(input())
N = len(S)
ans = float('inf')

cnt = 0
T = ["0"]*N
for i in range(N):
    if i%2==0: T[i] = "1"

for si,ti in zip(S, T):
    if si != ti:
        cnt += 1
ans = min(cnt, ans)


cnt = 0
T = ["0"]*N
for i in range(N):
    if i%2==1: T[i] = "1"

for si,ti in zip(S, T):
    if si != ti:
        cnt += 1
ans = min(cnt, ans)
print(ans)

Solution (Python):
c2,c3 = 0,0
def ret(a,b,c):
  global c2,c3
  if a == b:
    if c == 2:
      c2 += 1
    else:
      c3 += 1
    if b == "0":
      return "1"
    else:
      return "0"
  else:
    return b
S = input()
S2,S3 = list(S),list(S)
default = S2[0]
for j,k in enumerate(S2):
  if j == 0:
    continue
  S2[j] = ret(S2[j-1],k,2)
for j,k in enumerate(S3):
  if j == 0:
    S3[0] = ret(default,S3[0],3)
  S3[j] = ret(S3[j-1],k,3)
print(c2 if c2 <= c3 else c3)

Solution (Python):
tile = list(int(x) for x in input())

tile1 = []
tile2 = []
for i in range(len(tile)):
    if i%2 == 1:
        tile1.append(1)
        tile2.append(0)
    else:
        tile1.append(0)
        tile2.append(1)


import numpy as np
tile = np.array(tile)
tile1 = np.array(tile1)
tile2 = np.array(tile2)
sum1 = sum(abs(tile-tile1))
sum2 = sum(abs(tile-tile2))
print(min(sum1,sum2))

Solution (Python):
S = str(input())
S_list = [i for i in S]
target = ["0", "1"]

an1 = []
an2 = []

an1_suu = 0
an2_suu = 0

for j in range(len(S_list)):
    if j % 2 == 0:
        an1.append(target[0])
        an2.append(target[1])
    else:
        an1.append(target[1])
        an2.append(target[0])
    if S_list[j] == an1[j]:
        an1_suu += 1
    elif S_list[j] == an2[j]:
        an2_suu += 1
        
print(min(an1_suu, an2_suu))

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

s1 = [ ((-1)**i + 1)//2 for i in range(l)]
s2 = [ ((-1)**(i+1) + 1)//2 for i in range(l)]

m = 0
n = 0
for i in range(l):
  m += (int(s[i]) - s1[i])**2
  n += (int(s[i]) - s2[i])**2

print(min([m,n]))

Solution (Python):
s = input()
a = 0
b = 0
for index, i in enumerate(s):
  if int(i) == index%2:
    a+=1
  else:
    b+=1
    
print(min(a, b))

Solution (Python):



s = str(input())


colors = list(s)

prev = int(colors[0])
changeCnt = 0

for i in range(1,len(colors)):

    if prev == int(colors[i]):
        colors[i] = abs(int(colors[i])-1)
        changeCnt += 1
    
    prev = int(colors[i])


print(str(changeCnt))

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

convertor = {'1': '0', '0': '1'}

prev = s[0]
ans = 0

for i in range(1, n):
    if s[i] == prev:
        s[i] = convertor[s[i]]
        ans += 1
    prev = s[i]

print(ans)

Solution (Python):
from itertools import cycle
S = input()
cnt = sum(x if s=='0' else 1-x for s,x in zip(S, cycle((0,1))))

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

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



cnt1 = sum([1 for i in range(N) if i%2==0 and S[i]=="0"])
cnt2 = sum([1 for i in range(N) if i%2!=0 and S[i]=="1"])
cnt_S01 = cnt1 + cnt2

cnt3 = sum([1 for i in range(N) if i%2==0 and S[i]=="1"])
cnt4 = sum([1 for i in range(N) if i%2!=0 and S[i]=="0"])
cnt_S10 = cnt3 + cnt4

ans = min(cnt_S01, cnt_S10)
print(ans)

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

cnt1 = sum([1 for i in range(N) if i%2==0 and S[i]=="0"])
cnt2 = sum([1 for i in range(N) if i%2!=0 and S[i]=="1"])

cnt3 = sum([1 for i in range(N) if i%2==0 and S[i]=="1"])
cnt4 = sum([1 for i in range(N) if i%2!=0 and S[i]=="0"])

ans = min(cnt1 + cnt2, cnt3 + cnt4)
print(ans)

Solution (Python):
a = list(str(input()))

empty = []

empty.append([i for i in a[0::2]])
empty.append([i for i in a[1::2]])

aa = empty[0].count('0') + empty[1].count('1')
bb = empty[0].count('1') + empty[1].count('0')

if aa >= bb:
    print(bb)
else:
    print(aa)

Solution (Python):
S = input()
len_S = len(S)
diff_A ,diff_B = 0, 0
for i in range(len_S):
    if i % 2 == 0:
        if S[i] == "0":
            diff_A +=1
        else:
            diff_B += 1
    else:
        if S[i] == "0":
            diff_B +=1
        else:
            diff_A += 1
print(min(diff_A, diff_B))

Solution (Python):
s=input()
n=len(s)
s = int(s, 2)
s_10 = '1' * (n % 2) + '01' * (n // 2)
s_01 = '0' * (n % 2) + '10' * (n // 2)
s_10 = int(s_10, 2)
s_01 = int(s_01, 2)
r = bin(s ^ s_01)
l = bin(s ^ s_10)
print(min(r.count('1'), l.count('1')))

Solution (Python):
S = input()
ans = []
for i in range(2):
    pre_ans = 0
    _S = [s for s in S]
    if _S[0] == '0':
        if i == 1:
            _S[0] = '1'
            pre_ans += 1
    else:
        if i == 0:
            _S[0] = '0'
            pre_ans += 1
    for j in range(1,len(S)):
        if _S[j-1] == '0':
            if _S[j-1] == _S[j]:
                _S[j] = '1'
                pre_ans += 1
        else:
            if _S[j-1] == _S[j]:
                _S[j] = '0'
                pre_ans += 1
    ans.append(pre_ans)
print(min(ans))

Solution (Python):


S = input()
Se, So = S[0::2], S[1::2]

Se0, Se1, So0, So1 = Se.count('0'), Se.count('1'), So.count('0'), So.count('1')

print(min(Se0 + So1, Se1 + So0))

Solution (Python):
S = list(input())
N = len(S)
sub = 0
(pop) = 0

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

        elif S[i-1] == "1":
            S[i] = "0"
            sub += 1

    elif S[i] == "0":
        if S[i-1] == "1":
            (pop) += 1

        elif S[i-1] == "0":
            S[i] = "1"
            sub += 1

print(sub)

Solution (Python):
s=input()
count_1=0
count_2=0
p=0
for i in range(0,len(s)):
    if (s[i]=='0' and p==0) or (s[i]=='1' and p==1):
        if(p==0):
            p=1
        elif(p==1):
            p=0
        continue
    else:
        if(p==0):
            p=1
        elif(p==1):
            p=0
        count_1=count_1+1
p=1
for i in range(0,len(s)):
    if (s[i]=='0' and p==0) or (s[i]=='1' and p==1):
        if(p==0):
            p=1
        elif(p==1):
            p=0
        continue
    else:
        if(p==0):
            p=1
        elif(p==1):
            p=0
        count_2=count_2+1
print(min(count_1,count_2))

Solution (Python):
s=input()
count_1=0
count_2=0
for i in range(len(s)):
  if i%2 == 0 and s[i] == '0':
    count_1+=1
  if i%2 == 1 and s[i] == '1':
    count_1+=1
for i in range(len(s)):
  if i%2 == 0 and s[i] == '1':
    count_2+=1
  if i%2 == 1 and s[i] == '0':
    count_2+=1
if count_1 < count_2:
  print(count_1)
else:
  print(count_2)

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

cnt = 0
new = s[0]
for idx in range(len(s[1:])):
    idx += 1
    if new[idx-1]==s[idx]:
        if s[idx] == '0':
            new+='1'
        else:
            new+='0'
        cnt += 1
    else:
        new+=s[idx]
print(cnt)

Solution (Python):
tiles = list(input())
dic = {'0':'1', '1':'0'}
cnt = 0
for i in range(1,len(tiles)):
    if tiles[i] == tiles[i-1]:
        tiles[i] = dic[tiles[i]]
        cnt += 1
    else:
        continue
print(cnt)

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

s = S[::2].count('1') + S[1::2].count('0')
u = S[::2].count('0') + S[1::2].count('1')

print(min(s, u))

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

c = 0
if S[0] == '0':
    for i in S[::2]:
        if i == '1':
            c += 1
    for j in S[1::2]:
        if j == '0':
            c += 1
        
d = 0
if S[0] == '1':
    for i in S[::2]:
        if i == '0':
            d += 1
    for j in S[1::2]:
        if j == '1':
            d += 1
            
print(max(c,d))

Solution (Python):
import copy
S = [s for s in input()]
A, B = copy.deepcopy(S), copy.deepcopy(S)
li = [A, B]
count = [0, 1]

if S[0] == '0':
    B[0] = '1'
else:
    B[0] = '0'

for C in range(2):
    for i in range(1, len(li[C])):
        if li[C][i - 1] == li[C][i]:
            if li[C][i] == '0':
                li[C][i] = '1'
            else:
                li[C][i] = '0'
            count[C] += 1

print(min(count))

Solution (Python):
s = [int(x) for x in input()]
s1 = s[::2]
s0 = s[1::2]
print(min(len(s1)-sum(s1)+sum(s0) , len(s0)-sum(s0)+sum(s1)))

Solution (Python):
s = input()

count = 0
try:
    for i in range(0,len(s),2):
        if s[i] == '0':
            count += 1 
        if s[i+1] == '1':
            count +=1
except :
    pass
if count <= int(len(s)/2):
    print(count)
else:
    print(len(s)-count)

Solution (Python):
s = input()
last = int(s[0])
count = 0

for c in s[1:]:
	c = int(c)
	if(last == c):
		count += 1
		last = (c+1)%2
	else:
		last = c

s = s[::-1]
last = int(s[0])
count2 = 0

for c in s[1:]:
	c = int(c)
	if(last == c):
		count2 += 1
		last = (c+1)%2
	else:
		last = c


print(min(count,count2))

Solution (Python):
s=list(input())
b=[]
w=[]
n=len(s)
for i in range(n):
    if i%2==0:
        b+=s[i]
    else:
        w+=s[i]
bc=b.count('1')
wc=w.count('0')
print(min(bc+wc,n-bc-wc))

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

wb = ''
bw = ''
for i in range(0,length):
  if i % 2 == 0:
    wb += '0'
    bw += '1'
  else:
    wb += '1'
    bw += '0'

pat1 = 0
pat2 = 0
for i in range(0, length):
  if s[i] != wb[i]:
    pat1 += 1
  elif s[i] != bw[i]:
    pat2 += 1

if pat1 > pat2:
  print(pat2)
else:
  print(pat1)

Solution (Python):
S=input()
a=1
b=0
ct1,ct0=0,0

for i in range(len(S)):
    a=a^1
    b=b^1
    
    if(a!=int(S[i])):
        ct1+=1
    if(b!=int(S[i])):
        ct0+=1
print(min(ct1,ct0))

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

l =[0,1] * (len(S)//2) + ([0] if len(S)%2 == 1 else [])

l = [x + y for (x,y) in zip(S,l)]

print(min(l.count(1),(l.count(0)+l.count(2))))

Solution (Python):
S = input()

l = "01" * (len(S)//2) + ("0" if len(S)%2 == 1 else "")

l = [int(x) + int(y) for (x,y) in zip(S,l)]

print(min(l.count(1),(l.count(0)+l.count(2))))

Solution (Python):
s = input()
last = int(s[0])
count = 0

for c in s[1:]:
	c = int(c)
	if(last == c):
		count += 1
		last = (c+1)%2
	else:
		last = c
print(count)

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

l =[0,1] * (len(S)//2) + ([0] if len(S)%2 == 1 else [])

l = [x + y for (x,y) in zip(S,l)]

print(min(l.count(1),(l.count(0)+l.count(2))))

Solution (Python):
s = input()

n = len(s)
a = "10" * (n // 2) + "1" * (n % 2)
b = "01" * (n // 2) + "0" * (n % 2)

print(min(bin(int(s, 2) ^ int(a, 2)).count("1"), bin(int(s, 2) ^ int(b, 2)).count("1")))

Solution (Python):
S=list(str(input()))
odd=0
even=0
N=len(S)
for i in range(N):
    if S[i] != str(i%2):
        odd +=1
    else:
        even +=1
print(min(odd,even))

Solution (Python):
s = input()
head = s[0:1]
tail = ''.join(['10' for _ in range(len(s))])
ss = (head + tail if head == '0' else tail)[0:len(s)]
print(bin(int(s, 2) ^ int(ss, 2)).count("1"))

Solution (Python):
s = input()
n = len(s)
s1 = '01' * 50000
s2 = '10' * 50000

ans1 = 0
ans2 = 0

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

print(min(ans1,ans2))

Solution (Python):


import math, itertools, operator
from math import *
from math import factorial as fact
from functools import reduce
from statistics import mean, median, median_low, median_high, mode

from fractions import gcd





inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))



S = input()

cnt1 = 0  
cnt2 = 0  
BLACK = '0'
WHITE = '1'
for i in range(len(S)):
    if i & 1:
        if S[i] != WHITE:
            cnt1 += 1
        if S[i] != BLACK:
            cnt2 += 1
    else:
        if S[i] != BLACK:
            cnt1 += 1
        if S[i] != WHITE:
            cnt2 += 1
print(min(cnt1, cnt2))

Solution (Python):

S = input()
bf = '01' * (len(S) // 2) + '0' * (len(S) & 1)
wf = '10' * (len(S) // 2) + '1' * (len(S) & 1)
ans = 10**5
ans = min(ans, [x != y for x, y in zip(S, bf)].count(True))
ans = min(ans, [x != y for x, y in zip(S, wf)].count(True))
print(ans)

Solution (Python):


S = input()
lis = []
for t in range(len(S)):
    lis.append(S[t])
evencount0 = 0
unevencount0 = 0
evencount1 = 0
unevencount1 = 0
if len(S)%2 == 0:
    for t in range(int(len(S)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int(len(S)/2) - evencount0
    for t in range(int(len(S)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int(len(S)/2) - unevencount0

else:
    for t in range(int((len(S) - 1)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int((len(S) - 1)/2) - evencount0        

    for t in range(int((len(S)+1)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int((len(S)+1)/2) - unevencount0

elist = [evencount0 , evencount1 , unevencount0 , unevencount1 ]
if evencount1 + unevencount0 > evencount0 + unevencount1:
    k = evencount0 + unevencount1
else:
    k =evencount1 + unevencount0
print(k)

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

ans = 0
last_str = ''
for s in S:
  if (last_str == s) and s == '0':
    ans += 1
    last_str = '1'
  elif (last_str == s) and s == '1':
    ans += 1
    last_str = '0'
  else:
    last_str = s
print(ans)

Solution (Python):
S = input()
def func():
    from collections import Counter as c
    ev,od = [],[]
    for i in range(len(S)):
        ev.append(S[i]) if i%2 == 0 else 0
        od.append(S[i]) if i%2 == 1 else 0
    ev = c(ev).most_common()
    od = c(od).most_common()
    if len(od) == 0:
        return 0
    if ev[0][0] != od[0][0]:
        return len(S)-ev[0][1]-od[0][1]
    else:
        if len(ev) == len(od) == 1:
            return len(S)//2
        else:
            return min(len(S)-ev[0][1]-od[-1][1],len(S)-ev[-1][1]-od[0][1])
print(func())

Solution (Python):
tile = input()
total_0 = 0
total_1 = 0

for i in range(len(tile)):
    if i % 2 == 0:
        if int(tile[i]) == 0:
            total_1 += 1
        else:
            total_0 += 1
    else:
        if int(tile[i]) == 0:
            total_0 += 1
        else:
            total_1 += 1
print(total_0 if total_0 <= total_1 else total_1)

Solution (Python):
s = input()
a = ''
b = ''
for i in range(len(s)):
  if i%2 == 0:
    a += '0'
    b += '1'
  else:
    a += '1'
    b += '0'
def distance(s, a):
  return format(int(s, 2) ^ int(a, 2), 'b').count('1')
print(min(distance(s, a),distance(s, b)))

Solution (Python):
def countStr(x,S):
    c = 0
    for i, s in enumerate(S):
        if i % 2 == x:
            if s == "0":
                c += 1
        else:
            if s == "1":
                c += 1
    return c

S = input()
print(min(countStr(0,S),countStr(1,S)))

Solution (Python):
S = input()

cntA, cntB = 0, 0

for i, t in enumerate(S):
    if i%2 == 0:
        if t == '0': 
            cntA += 1
        else:
            cntB += 1
    else:
        if t == '1':
            cntA += 1
        else:
            cntB += 1
print (min(cntA, cntB))

Solution (Python):
t = input()
c1, c2 = 0, 0
for i, s in enumerate(t):
  if i % 2 == 0:
    if s == '0':
      c1 += 1
    else:
      c2 += 1
  else:
    if s == '1':
      c1 += 1
    else:
      c2 += 1
print(min(c1, c2))

Solution (Python):
S = input()
A = []
ans = 0
for i in range(len(S)):
    if i % 2 == 0:
        A.append(1)
    else:
        A.append(0)
for i in range(len(S)):
    if int(S[i]) != int(A[i]):
        ans += 1
print(min(ans, len(S) - ans))

Solution (Python):
s = list(str(input()))
S = []
for i in range(len(s)):
  S.append(int(s[i]))
ans1 = 100000
ans2 = 100000
ans = 0
t = 0
s = 0

if S[0]==0:
  for i in range(1,len(S),2):
    if S[i] != 1:
      t += 1
  for i in range(0,len(S),2):
    if S[i] != 0:
      s += 1
  ans1 = min(t+s,len(S)-t-s)
else:
  for i in range(1,len(S),2):
    if S[i] != 0:
      t += 1
  for i in range(0,len(S),2):
    if S[i] != 1:
      s += 1
  ans2 = min(t+s,len(S)-t-s) 
ans=min(ans1,ans2)
print(ans)

Solution (Python):
s=input()
p=int(''.join(map(str,[i%2 for i in range(1,len(s)+1)])),2)
print(min(bin(int(s,2)^n).count('1')for n in[p,p>>1]))

Solution (Python):
s = input()
p = int(''.join(map(str, [i % 2 for i in range(1, len(s) + 1)])), 2)
print(min(bin(int(s, 2) ^ n).count('1') for n in [p, p >> 1]))

Solution (Python):
s = input()
n = len(s)
t = int(s, 2)

l = [i % 2 for i in range(1, n + 1)]
b = ''.join(map(str, l))

p = int(b, 2)
q = p >> 1

a = bin(t ^ p).count('1')
b = bin(t ^ q).count('1')

print(min(a, b))

Solution (Python):
s = input()
b = ''.join(map(str, [i % 2 for i in range(1, len(s) + 1)]))
p = int(b, 2)
q = p >> 1
print(min(bin(int(s, 2) ^ n).count('1') for n in [p, q]))

Solution (Python):
s = input()
t = int(s, 2)
b = ''.join(map(str, [i % 2 for i in range(1, len(s) + 1)]))
p = int(b, 2)
q = p >> 1
print(min(bin(t ^ n).count('1') for n in [p, q]))

Solution (Python):
S = input()
n = len(S)
s = int(S, 2)
b = ''.join(map(str, [i % 2 for i in range(1, n + 1)]))
p = int(b, 2)
q = p >> 1
print(min(bin(s ^ n).count('1') for n in [p, q]))

Solution (Python):
S = input()
n = len(S)
s = int(S, 2)
b = ''.join(map(str, [i % 2 for i in range(n)]))
p = int(b, 2)
q = int(b[1:] + str(int(b[-1]) ^ 1), 2)
print(min(bin(s ^ n).count('1') for n in [p, q]))

Solution (Python):
s = input()
print(min(sum(1 if ord(s[i])==i%2+48 else 0 for i in range(len(s))),sum(0 if ord(s[i])==i%2+48 else 1 for i in range(len(s)))))

Solution (Python):
s = input()
s1, s2 = s[::2], s[1::2]
bwr1, bwr2 = (s1.count('0'), s1.count('1')), (s2.count('0'), s2.count('1'))
print(min(bwr1[1] + bwr2[0], bwr1[0] + bwr2[1]))

Solution (Python):
s=input()
even=list(s[::2])
odd=list(s[1::2])
ans1=sum(i!='0' for i in even)+sum(i!='1' for i in odd)
ans2=sum(i!='1' for i in even)+sum(i!='0' for i in odd)
print(min(ans1,ans2))

Solution (Python):
S = input()
S_list = list(S)
S_length = len(S)
Count = 0

for i in range(S_length-1):
    if S_list[i] == S_list[i+1]:
        Count += 1
        if S_list[i+1] == "0":
            S_list[i+1] = "1"
        else:
            S_list[i+1] = "0"
    else:
        continue

print(Count)

Solution (Python):
S = input()
count = 0
m = S[0]
for s in S[1:]:
    if s == m:
        count += 1
        m = "1" if s == "0" else "0"
    else:
        m = s
print(count)

Solution (Python):


S = input()

ans1 = 0
ans2 = 0




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



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

Solution (Python):
S = input()

cnt1 = cnt2 = 0
for i in range(len(S)):
    if i%2==0 and S[i]=='1':
        cnt1 += 1
    if i%2==1 and S[i]=='0':
        cnt1 += 1

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

print(min(cnt1,cnt2))

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

cnt = 0

for i in range(l):
	if i % 2 == 0 :
		if s[i] == "0" :
			cnt += 1

	else:
		if s[i] == "1" :
			cnt += 1

cnt_r = 0

for j in range(l):
	if j % 2 == 0 :
		if s[j] == "1" :
			cnt_r += 1

	else:
		if s[j] == "0" :
			cnt_r += 1

print(min(cnt, cnt_r))

Solution (Python):
S = input()
A = []
ans =0
for i in range(len(S)) :
    if i%2 == 0 :
        A.append(1)
    else :
        A.append(0)
for i in range(len(S)) :
    if int(S[i]) != int(A[i]) :
        ans +=1
print(min(ans, len(S)-ans))

Solution (Python):
s = list(map(int, list(input())))
s0 = s[::2]
s1 = s[1::2]
x0 = sum(s0)
x1 = sum(s1)
print(min(x0 + len(s1) - x1, x1 + len(s0) - x0))