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 = input()
spl = ""
cnt1 = 0
cnt2 = 0

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

cnt2 = len(s) - cnt1

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

Solution (Python):
s=input()
hi=5
ans=0
for i in range(len(s)):
    if(hi==s[i]):
        ans+=1
        if(s[i]=='0'):
            s=s[:i]+'1'+s[i+1:]

        else:
            s=s[:i]+'0'+s[i+1:]
    hi=s[i]
print(str(ans))

Solution (Python):
a=input()
l=len(a)
x=[int(a[i:i+1]) for i in range(l)]
counta=0
for i in range(l):
  if i%2==1:
    if x[i]==0:
      counta +=1
  else:
    if x[i]==1:
      counta +=1
countb=0
for i in range(l):
  if i%2==1:
    if x[i]==1:
      countb +=1
  else:
    if x[i]==0:
      countb +=1
c=int(min(counta,countb))
print(c)

Solution (Python):
print((lambda a: min(sum([abs(int(a[i])-(i+1)%2) for i in range(len(a))]),sum([abs(int(a[i])-i%2) for i in range(len(a))])))(list(input())))

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


def get_diff(str_a, str_b):
    res = ''
    for i in range(len(str_a)):
        if str_a[i] == str_b[i]:
            res = res + '-'
        else:
            res = res + '+'
    return res


def get_mixed_a(ml):
    return ('01' * (1 + int(ml / 2)))[0:ml]


def get_mixed_b(ml):
    return ('10' * (1 + int(ml / 2)))[0:ml]


zba = get_mixed_a(len_s)
zbb = get_mixed_b(len_s)
res_a = get_diff(zba, S)
res_b = get_diff(zbb, S)
ma = res_a.count('+')
mb = res_b.count('+')
print(min(ma, mb))

Solution (Python):
import numpy as np

S = list(map(int,input()))
S_len = len(S)
Tmp_S =[]
First_S = S[0]
for _ in range(S_len):
    Tmp_S.append(First_S)
    First_S = First_S ^ 1

S_np = np.array(S)
Tmp_S_np = np.array(Tmp_S)

TF_S = np.array(S_np == Tmp_S_np)
print(np.sum(TF_S == False))

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

Solution (Python):
def even_bit_maker(number_length):
    bit = ['0'] * number_length
    for i in range(number_length):
        if i % 2 == 0:
            bit[i] = '1'
    return int(''.join(bit), 2)


def odd_bit_maker(number_length):
    bit = ['0'] * number_length
    for i in range(number_length):
        if i % 2 == 1:
            bit[i] = '1'
    return int(''.join(bit), 2)


if __name__ == '__main__':
    init_tile = input()
    init_tile_bit = int(init_tile, 2)
    tile_len = len(init_tile)
    even_bit = init_tile_bit ^ even_bit_maker(tile_len)
    odd_bit = init_tile_bit ^ odd_bit_maker(tile_len)
    even_change_count = bin(even_bit).count('1')
    odd_change_count = bin(odd_bit).count('1')
    print(min(even_change_count, odd_change_count))

Solution (Python):
s_str = input()
s = list(map(int,s_str))
a = 0
for i in range(len(s)):
    if s[i] == i % 2:
        a = a + 1
if a < len(s) - a:
    print(a)
else:
    print(len(s)-a)

Solution (Python):
s = str(input())
l = len(s)
first = "01"*(int(l/2))
result1 = 0
result2 = 0
if l%2!=0:
	first += "0"
for i in range(l):
	if first[i] == s[i]:
		result2+=1
	else:
		result1+=1
print(min(result1,result2))

Solution (Python):

"""
Created on Sat Apr 13 21:30:35 2019

@author: yuta
"""
from collections import Counter
S = input()

def main(s):
    moji = list(s)
    first = moji[0:len(moji):2]
    second = moji[1:len(moji):2]
    
    x = Counter(first)
    y = Counter(second)
    
    x_count0 = x['0']
    x_count1 = x['1']
    y_count0 = y['0']
    y_count1 = y['1']
    
    count = min(x_count0 + y_count1,x_count1 + y_count0)
    print(count)
main(S)

Solution (Python):
s = list(input())
len = len(s)
a =["0"]*len
b =["0"]*len

for i in range(len):
    if i % 2 == 0:
        a[i] = "1"

for i in range(len):
    if i % 2 == 1:
        b[i] = "1"


len_a = 0
len_b = 0

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

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

ans = min(len_a,len_b)
print(ans)

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

X=0
Y=0
n=0
for i in N:
  if n %2==0:
    if i =="0":
      X+=1
    
  else:
    if i =="1":
      X+=1
  n+=1
n=0
for i in N:
  if n %2==0:
    if i =="1":
      Y+=1
    
  else:
    if i =="0":
      Y+=1
  n+=1


ans=min(X,Y)
print(ans)

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

now=S[0]
n=0
X=0
for i in S:

    if n==0:
        n+=1
        continue
    if now==i:
        if now=='1':
            S[n]='0'
        else:
            S[n]='1'
        X+=1
    now=S[n]
    n+=1

print(X)

Solution (Python):
s = input()

len_s = len(s)

cnt01_0 = 0
cnt01_1 = 0
cnt10_0 = 0
cnt10_1 = 0

for i in range(len_s):
    if (i%2 == 0)and(s[i]=='0'):
        cnt01_0 += 1
    elif(i%2 == 1)and(s[i]=='1'):
        cnt01_1 += 1

for i in range(len_s):
    if (i%2 == 0)and(s[i]=='1'):
        cnt10_0 += 1
    elif(i%2 == 1)and(s[i]=='0'):
        cnt10_1 += 1

out01 = len_s - cnt01_0 - cnt01_1
out10 = len_s - cnt10_0 - cnt10_1


print(min(out01,out10))

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

s1=[0 for __ in range(len(s))]
s2=[0 for __ in range(len(s))]

for i in range(len(s)):
    if i%2 == 0:
        s1[i]=1
    else:
        s2[i]=1

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

Solution (Python):
s = input()
s_g = list(map(int, (s[0::2])))
s_k = list(map(int, (s[1::2])))
ans = [len(s_g) - sum(s_g) + sum(s_k),len(s_k) - sum(s_k) + sum(s_g)]

print(min(ans))

Solution (Python):
S = str(input())
N = len(S)
c_K = 0
c_H = 0
for i in range(N):
  K = str(i%2)
  if(S[i]==K):
    c_K+=1
  else:
    c_H+=1
M = max(c_K,c_H)
G = N-M
print(G)

Solution (Python):
char_list = list(input())
count1 = 0
count2 = 0
if len(char_list) == 1:
    print(0)
else:
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "0":
                continue
            else:
                count1 += 1
        else:
            if char_list[i] is "1":
                continue
            else:
                count1 += 1
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "1":
                continue
            else:
                count2 += 1
        else:
            if char_list[i] is "0":
                continue
            else:
                count2 += 1
    print(min(count1,count2))

Solution (Python):
S = list(input())
answer = 0
for i in range(len(S)):
    if i == 0:
        continue
    elif S[i] == S[i-1]:
        if S[i] == '1':
            S[i] = '0'
        else:
            S[i] = '1'
        answer += 1

print(answer)

Solution (Python):
S = list(input())
g_list = S[0::2]
k_list = S[1::2]

print(
  min(
    g_list.count("0")+k_list.count("1"),
    g_list.count("1")+k_list.count("0")
  )
)

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

ac = 0
bc = 0

for idx, s in enumerate(n):
    if(idx % 2 == 0):
        if(s == '0'):
            ac += 1
        else:
            bc += 1
    else:
        if(s == '0'):
            bc += 1
        else:
            ac += 1

if(ac < bc):
    print(ac)
else:
    print(bc)

Solution (Python):
N = input()
before_number = N[0:1]
ans = 0
for i in range(len(N)-1):
    if before_number == N[i+1:i+2]:
        ans += 1
        if before_number == "1":
            before_number = "0"
        else:
            before_number = "1"
    else:
        before_number = N[i+1:i+2]
print(ans)

Solution (Python):
color_list = [int(_) for _ in input()]

zero_start = 0
one_start = 0

for i in range(len(color_list)):
    if i % 2 == 0: 
        if color_list[i] == 0:
            one_start += 1
        else:
            zero_start += 1
    else: 
        if color_list[i] == 0:
            zero_start += 1
        else:
            one_start += 1

if zero_start < one_start:
    print(zero_start)
else:
    print(one_start)

Solution (Python):
S = input()

H = []
M = []
for i in range(len(S)):
    if i % 2 == 0:
        H.append('0')
        M.append('1')
    else:
        H.append('1')
        M.append('0')

count1 = 0
for i in range(len(S)):
    if S[i] != H[i]:
        count1 += 1
count2 = 0
for i in range(len(S)):
    if S[i] != M[i]:
        count2 += 1

ans = min(count1,count2)
print(ans)

Solution (Python):
s = input()

cnt0 = 0                 
for i in range(len(s)):
    if s[i] != str(i%2):
        cnt0 = cnt0 + 1


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


if cnt0 < cnt1:
    print(cnt0)
else:
    print(cnt1)

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

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

fill_1_g = int(len(S)/2) - g
fill_1_k = int(len(S)/2) - k
if len(S) % 2 == 1:
  fill_1_g += 1

print(min([fill_1_g + k, fill_1_k + g]))

Solution (Python):
s=input()
even=s[1::2]
odd=s[::2]
ez=eo=oz=oo=cnt1=cnt2=0


for i in range(len(odd)):
  if odd[i]!='1':
    cnt1+=1
for i in range(len(even)):
  if even[i]!='0':
    cnt1+=1
for i in range(len(odd)):
  if odd[i]!='0':
    cnt2+=1
for i in range(len(even)):
  if even[i]!='1':
    cnt2+=1
print(min(cnt1,cnt2))

Solution (Python):
s = input()
m = len(s)
sl = [0]*m
for i in range(m):
    sl[i] = s[i]
pre = sl[0]
ans = 0

for i in range(m-1):
    if sl[i+1] == pre:
        ans += 1

        if sl[i+1] == "0":
            sl[i+1] = "1"
        else:
            sl[i+1] = "0"
            
        pre = sl[i+1]

    else:
        pre = sl[i+1]
    
print(ans)

Solution (Python):
s=input()
l=len(s)
odd=s[::2]
even=s[1::2]
o0=odd.count("0")
o1=odd.count("1")
e0=even.count("0")
e1=even.count("1")
if o0+e1>o1+e0:
    print(o1+e0)
else:
    print(o0+e1)

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

res = 0
for i in range(n):
    if i%2 == 0 and s[i] == '0':
        res += 1
    elif i%2 == 1 and s[i] == '1':
        res += 1

res2 = 0
for i in range(n):
    if i%2 == 0 and s[i] == '1':
        res2 += 1
    elif i%2 == 1 and s[i] == '0':
        res2 += 1
print(min(res,res2))

Solution (Python):
def hanten(tairu):
    if tairu == 0:
        return 1
    else:
        return 0

def main():
    l = list(map(int, list(input())))
    
    if len(l) <= 1:
        print(0)
    else:
        cnt = 0
        move_cnt = 1
        if l[0] == l[move_cnt]:
            l[move_cnt] = hanten(l[move_cnt])
            cnt = 1
        
        while move_cnt + 1 <= len(l) - 1:
            if l[move_cnt] == l[move_cnt + 1]:
                l[move_cnt + 1] = hanten(l[move_cnt + 1])
                cnt += 1
                
            move_cnt += 1
    
        print(cnt)


if __name__ == "__main__":
    main()

Solution (Python):
s=list(map(int,input()))
o=s[0::2]
e=s[1::2]
a=o.count(0)+e.count(1)
b=o.count(1)+e.count(0)
print(min(a,b))

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


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


print(min(cnt, cnt2))

Solution (Python):
import numpy as np
S=input()
ans=np.zeros(len(S))
s=np.zeros(len(S))
if S[0]=='1':
    ans[0]=1
    s[0]=1
else:
    ans[0]=0
    s[0]=0
    
for i in range(1,len(S)):
    ans[i]=(ans[i-1]+1)%2
    s[i]=int(S[i])
    
print(sum(ans!=s))

Solution (Python):
s_bin = input()
n = len(s_bin)

def make_target(n):
    target1_bin = '01' * (n//2)
    target2_bin = '10' * (n//2)
    if (n%2 == 1):
        target1_bin += '0'
        target2_bin += '1'
    return([target1_bin, target2_bin])

s = int(s_bin, 2)
target1, target2 = [int(i, 2) for i in make_target(n)]

diff1 = bin(s ^ target1)
diff2 = bin(s ^ target2)

cost1 = diff1.count('1')
cost2 = diff2.count('1')

print(min([cost1, cost2]))

Solution (Python):
S = [int(c) for c in input()]
S2 = S
beside_color = (S[0]+1)%2
count1 =0
for i in range(len(S)):
    if beside_color == S[i]:
        count1 +=1
        S[i] = (S[i]+1)%2
    beside_color = S[i]
count2 = 0
beside_color = S2[0]
for i in range(len(S)):
    if beside_color == S2[i]:
        count2 +=1
        S2[i] = (S2[i]+1)%2
    beside_color = S2[i]
if count2 < count1:
    ans = count2
else:
    ans = count1
print(ans)

Solution (Python):
def flip(c):
    if c == '0':
        return '1'
    else:
        return '0'

def main():
    S = input()

    
    count1 = 0
    target = '0'
    for s in S:
        if s != target:
            count1 += 1
        target = flip(target)

    
    count2 = 0
    target = '1'
    for s in S:
        if s != target:
            count2 += 1
        target = flip(target)

    print(min(count1, count2))

main()

Solution (Python):
S = input()

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

Solution (Python):
s = input()
ret = [0, 0]
for i in range(len(s)):
    ret[(int(s[i]) + i) % 2] += 1
print(min(ret))

Solution (Python):
N = input()
cnt = 0
for i in range(len(N)):
    if i % 2 == 0:
        cnt += (abs(int(N[i])-1))
    else:
        cnt += (abs(int(N[i])))
print(min(cnt, len(N)-cnt))

Solution (Python):
s = input()
t = int(s, 2)
N = len(s)
if N%2==0:
    a = '10'*(N//2)
    b = '01'*(N//2)
else:
    a = '10'*(N//2)+'1'
    b = '01'*(N//2)+'0'
a = int(a, 2)
b = int(b, 2)
print(min(str(bin(t^a))[2:].count('1'), str(bin(t^b))[2:].count('1')))

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

Solution (Python):


"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

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

Solution (Python):
S = input()
ct_a = 0
ct_b = 0
for i in range(S.__len__()):
    if i % 2 == 0:
        if S[i] == "0":
            ct_a += 1
        else:
            ct_b += 1
    else:
        if S[i] == "0":
            ct_b += 1
        else:
            ct_a += 1

print(min(ct_a,ct_b))

Solution (Python):
t = input()
t = str(t)
t = list(t)
t = [int(s) for s in t]
n = len(t)
c_a = 0
c_b = 0
for i in range(n):
    if i%2==0:
        if t[i] != 0:
            c_a += 1
    else:
        if t[i] != 1:
            c_a += 1

for i in range(n):
    if i%2==0:
        if t[i] != 1:
            c_b += 1
    else:
        if t[i] != 0:
            c_b += 1
    
if c_a >= c_b:
    print(c_b)
else:
    print(c_a)

Solution (Python):
A = input()
x = 0
lens = len(A)
C = list(A)

for i in range(1, lens):
  if C[i-1] == C[i]:
    x += 1
    
    if C[i] == '0':  
      C[i] = '1'
    else:
      C[i] = '0'
  else:
    continue

print(x)

Solution (Python):
S = input()

SSize = len(S)

bws = "".join([str(i%2) for i in range(SSize)])
wbs = "".join([str((i+1)%2) for i in range(SSize)])




diffCountBws = 0
diffCountWbs = 0

for i in range(SSize):
	if S[i] != bws[i]:
		diffCountBws += 1
	
	if S[i] != wbs[i]:
		diffCountWbs += 1
		
print(min(diffCountBws,diffCountWbs))

Solution (Python):
S = input()
s_list = [int(s) for s in S]
n = len(s_list)
s_first = s_list[0]
cnt1 = 0
cnt2 = 1
if s_first == 0:
    for i in range(1, n):
        if (i % 2 == 1) & (s_list[i] == 0):
            cnt1 += 1
        if (i % 2 == 0) & (s_list[i] == 1):
            cnt1 += 1
        if (i % 2 == 1) & (s_list[i] == 1):
            cnt2 += 1
        if (i % 2 == 0) & (s_list[i] == 0):
            cnt2 += 1
    print(min(cnt1, cnt2))
else:
    for i in range(1, n):
        if (i % 2 == 1) & (s_list[i] == 1):
            cnt1 += 1
        if (i % 2 == 0) & (s_list[i] == 0):
            cnt1 += 1
        if (i % 2 == 1) & (s_list[i] == 0):
            cnt2 += 1
        if (i % 2 == 0) & (s_list[i] == 1):
            cnt2 += 1
    print(min(cnt1, cnt2))

Solution (Python):
S = input()
oddnumlist = []
evennumlist = []
sepnum = 0

for index in S:
    if sepnum % 2 == 0:
        evennumlist.append(index)
    else:
        oddnumlist.append(index)
    sepnum += 1

if evennumlist.count("1") + oddnumlist.count("0") <= evennumlist.count("0") + oddnumlist.count("1"):
    print(evennumlist.count("1") + oddnumlist.count("0"))
else:
    print(evennumlist.count("0") + oddnumlist.count("1"))

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

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

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

Solution (Python):
import math
s = input()

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

ans1 = 0
ss = '01'*math.ceil(len(s)/2)
ss = ss[:len(s)]
for i in range(len(s)):
    if not ss[i] == s[i]:
        ans1 += 1

ans2 = 0
ss = '10'*math.ceil(len(s)/2)
ss = ss[:len(s)]
for i in range(len(s)):
    if not ss[i] == s[i]:
        ans2 += 1
print(min(ans1, ans2))

Solution (Python):
import numpy as np

N = np.array(list(map(int, list(input()))))

m = len(N)

A = np.array([i%2 for i in range(m)])
B = np.array([1 if i == 0 else 0 for i in A])

AA = np.count_nonzero((A-N) == 0)
BB = np.count_nonzero((B-N) == 0)

if AA > BB:
  print(m - AA)
else:
  print(m - BB)

Solution (Python):
import numpy as np
S = np.array(list(input()))
l1 = np.array([str(i%2) for i in range(S.size)])
l2 = np.array([str((i+1)%2) for i in range(len(S))])
a1 = np.array(S == l1)
a2 = np.array(S == l2)
b1 = np.sum(a1)
b2 = np.sum(a2)

if b1 < b2:
    print(b1)
else :
    print(b2)

Solution (Python):
S = input()

def get_dif(length, str1, str2):
    c = 0
    for i in range(length):
        if str1[i] != str2[i]:
            c += 1
    return c

l = len(S)
if l % 2 == 0:
    S1 = "01" * (l // 2)
    S2 = "10" * (l // 2)
else:
    S1 = "01" * ((l - 1) // 2) + "0"
    S2 = "10" * ((l - 1) // 2) + "1"

c1 = get_dif(l, S, S1)
c2 = get_dif(l, S, S2)

if c1 <= c2:
    print(c1)
else:
    print(c2)

Solution (Python):
def diffStr(a, b):
    i = 0
    diff = 0
    lenA = len(a)
    lenB = len(b) 
    while True:
        if i == lenA:
            break
        if i == lenB:
            break
        if a[i] != b[i]:
            diff += 1
        i += 1
    diff += abs(lenA - lenB)
    return diff

s = input()
n = len(s)
a = b = ''
c = False
for i in range(n):
    a += '1' if c else '0'
    b += '0' if c else '1'
    c = not c

diffA = diffStr(s, a)
diffB = diffStr(s, b)
print(min(diffA, diffB))

Solution (Python):
S = input()
p01 = 0
p10 = 0
p00 = 0
p11 = 0
for i in range(0, (len(S)//2 * 2), 2):
    if S[i:i+2] == '01':
        p01 += 1
    elif S[i:i+2] == '10':
        p10 += 1
    elif S[i:i+2] == '00':
        p00 += 1
    else:
        p11 += 1

c = 0
if (p01 == 0) and (p10 == 0):
    c = len(S) // 2
elif p01 >= p10:
    c = p10 * 2 + p00 + p11
    if len(S) & 1:
        if S[-1] == S[-2]:
            c += 1
else:
    c = p01 * 2 + p00 + p11
    if len(S) & 1:
        if S[-1] == S[-2]:
            c += 1
print(c)

Solution (Python):
s = input()
n = len(s)
count = 0
f = 0

test1 = ['0'] * n 
test2 = ['0'] * n


for i in range(n):
    if i % 2 == 0:
        test1[i] = '0'
        test2[i] = '1'
    else:
        test1[i] = '1'
        test2[i] = '0'



if len(s) == 1:
    print(count)
    f = 1
else:
    c0 = 0
    c1 = 0
    for i in range(n):
        if s[i] == '0':
            c0 += 1
        else:
            c1 += 1
    
    if c0 >= c1:
        if s[0] == '1' and s[-1] == '0':
            
            if n % 2 == 0:
                for i in range(n):
                    if test2[i] != s[i]:
                        count += 1
            else:
                for i in range(n):
                    if test1[i] != s[i]:
                        count += 1
        else:
            
            if s[0] == '0':
                for i in range(n):
                    if test1[i] != s[i]:
                        count += 1
                        
            else:
                for i in range(n):
                    if test2[i] != s[i]:
                        count += 1
    else:
        if s[0] == '0' and s[-1] == '1':
            
            if n % 2 == 0:
                for i in range(n):
                    if test1[i] != s[i]:
                        count += 1
            else:
                for i in range(n):
                    if test2[i] != s[i]:
                        count += 1
        else:
            if s[0] == '1':
                for i in range(n):
                    if test2[i] != s[i]:
                        count += 1
            else:
                for i in range(n):
                    if test1[i] != s[i]:
                        count += 1


if f == 0:
    print(count)

Solution (Python):


N = input()

N_list = list(N)
num = []

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


for a in range(len(N_list)):
    if a % 2 == 0: 
        if N_list[a] == "0":
            odd_0 += 1
        elif N_list[a] == "1":
            odd_1 += 1

    elif a % 2 == 1: 
        if N_list[a] == "0":
            even_0 += 1
        elif N_list[a] == "1":
            even_1 += 1

if max(even_0,even_1,odd_0,odd_1) == even_0:
    print(even_1 + odd_0 )

elif max(even_0,even_1,odd_0,odd_1) == even_1:
    print(even_0 + odd_1 )

elif max(even_0,even_1,odd_0,odd_1) == odd_0:
    print(even_0 + odd_1 )

elif max(even_0,even_1,odd_0,odd_1) == odd_1:
    print(even_1 + odd_0 )

Solution (Python):
import numpy as np
s = np.array([int(i) for i in list(input())])
if len(s)%2==0:
  t1 = np.array([int(i) for i in list("10"*int(len(s)/2))])
  t2 = np.array([int(i) for i in list("01"*int(len(s)/2))])
else:
  t1 = np.array([int(i) for i in list("10"*int((len(s)-1)/2)+"1")])
  t2 = np.array([int(i) for i in list("01"*int((len(s)-1)/2)+"0")])
ans = min(len(np.where((t1+s) == 1)[0]), len(np.where((t2+s) == 1)[0]))
print(ans)

Solution (Python):
ls = input()
count = 0
if len(ls) == 0:
  print('0')
else:
  temp = ls[0] 
  ls = ls[1:]
  for i in ls:
    if i == temp:
      count += 1
      if i == '0':
        temp = '1'
      else:
        temp = '0'
    else:
      temp = i
print(count)

Solution (Python):
s = list(input())
r = ''
if s[0] == '0':
  r = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
elif s[0] == '1':
  r = ['1' if i % 2 == 0 else '0' for i in range(len(s))]

mul = [str(int(s[i]) + int(r[i])) for i in range(len(s))]

print(mul.count('1'))

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

print(c)

Solution (Python):
c = list(input())
ans = [0, 0]
for i in range(len(c)):
    if i % 2 == 0 and c[i] == '0' or i % 2 == 1 and c[i] == '1':
        ans[0] += 1
    if i % 2 == 0 and c[i] == '1' or i % 2 == 1 and c[i] == '0':
        ans[1] += 1
print(min(ans))

Solution (Python):
s = input()
print(min(sum(s[i] != '0' if i & 1 else s[i] != '1' for i in range(len(s))),
    sum(s[i] != '1' if i & 1 else s[i] != '0' for i in range(len(s)))))

Solution (Python):

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

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

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

print result

Solution (Python):
import sys
import random
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
s = input().rstrip()
n = len(s)
ans2 = 0
ans = 0
for i in range(n):
    if i%2 == 0 and s[i] != "0":
        ans +=1
    if i%2 == 1 and s[i] != "1":
        ans += 1
for i in range(n):
    if i%2 == 0 and s[i] != "1":
        ans2 +=1
    if i%2 == 1 and s[i] != "0":
        ans2 += 1
print(min(ans2,ans))

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

a = []
b = []

if s[0] == '1':
    c = '0'
else:
    c = '1'

if len(s) % 2 == 1:
    s = s + c
    

for i in range(int(len(s)/2)):
    a.append(s[i * 2])
    b.append(s[i * 2 -1])

print(a.count(c) + b.count(s[0]))

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

adder = 0
ans_1=""
ans_2=""


for a in range(length):
  adder = (adder + 1)%2 
  ans_1 = ans_1 +str(adder)
  


counter = 0
for b in range(length):
  if state[b] == ans_1[b]:
    counter += 1

if counter >= length/2:
  counter = length - counter


print(counter)

Solution (Python):
S = input()

start1count = 0
start0count = 0

nextisblack = False

for tile in S:
    if nextisblack:
        nextisblack = False
        if tile == "1":
            start1count += 1
    else:
        nextisblack = True
        if tile == "0":
            start1count += 1

nextisblack = True

for tile in S:
    if nextisblack:
        nextisblack = False
        if tile == "1":
            start0count += 1
    else:
        nextisblack = True
        if tile == "0":
            start0count += 1

print(min(start1count,start0count))

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


A = str()
B = str()
if N%2 == 0:
  for i in range(int(N/2)):
    A += '10'
    B += '01'
else:
  for i in range(int((N-1)/2)):
    A += '01'
    B += '10'
  A += '0'
  B += '1'


a = 0
b = 0
for i in range(N):
  a += abs(int(S[i])-int(A[i]))
  b += abs(int(S[i])-int(B[i]))

num = min(a, b)
print(num)

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

temp_0 = "0"
temp_1 = "1"
count_0 = 0
count_1 = 0
for x in S:
    if x == temp_0:
        count_0 += 1
        if temp_0 == "1":
            temp_0 = "0"
        else:
            temp_0 = "1"
    else:
        if temp_0 == "1":
            temp_0 = "0"
        else:
            temp_0 = "1"
            
for x in S:
    if x == temp_1:
        count_1 += 1
        if temp_1 == "1":
            temp_1 = "0"
        else:
            temp_1 = "1"
    else:
        if temp_1 == "1":
            temp_1 = "0"
        else:
            temp_1 = "1"

print(min(count_0,count_1))

Solution (Python):
s = input()
n = len(s)
ans1 = sum(a != b for a, b in zip(('01'*10**5)[:n], s))
ans2 = sum(a != b for a, b in zip(('10'*10**5)[:n], s))
print(min(ans1, ans2))

Solution (Python):
s = raw_input();
n = len(s);

p1 = "";
p2 = "";

ap1 = 0;
ap2 = 0;

for i in range(n):
	if (i % 2 == 0):
		p1 += "0";
		p2 += "1";
	else:
		p1 += "1";
		p2 += "0";

for i in range(n):
	if s[i] != p1[i]:
		ap1 += 1;

	if s[i] != p2[i]:
		ap2 += 1;

if ap1 < ap2:
	print(ap1);

else:
	print(ap2);

Solution (Python):
def replace(a):
    if a == "0":
        a = "1"
    else:
        a = "0"
    return a

n = str(input())
l = [str(x) for x in list(str(n))]

count = 0
for i in range(1,len(l)):
    if l[i] == l[i-1]:
        l[i] = replace(l[i])
        count += 1
        
print(count)

Solution (Python):
from sys import stdin
from collections import deque

def paint(n):
    if n == 1:
        return 0
    else:
        return 1

S = stdin.readline().rstrip()
data = deque([int(x) for x in S])

before = data.popleft()
cnt = 0

while data:
    if data[0] == before:
        cnt += 1
        before = paint(data.popleft())
    else:
        before = data.popleft()

print(cnt)

Solution (Python):
yama=input()
kisuu=yama[0::2]      
guusuu=yama[1::2]
iti=kisuu.count("0")
ni=guusuu.count("1")
kari=iti+ni
zentai=len(yama)

if kari*2>zentai:
  kari=zentai-kari
print(kari)

Solution (Python):
import sys

def solve(tile):
    count = 0
    prev = ""
    for i in xrange(len(tile)):
       if tile[i] == prev:
           count += 1
           if tile[i] == "0":
               prev = "1"
           else:
               prev = "0"
       else:
           prev = tile[i]

    return count

if __name__ == '__main__':

    tile = sys.stdin.readline().strip()
    ans = solve(tile)
    print ans

Solution (Python):

S=input()

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

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

print(min(count1,count2))

Solution (Python):
S = str(input())
tmp1 = "01" *100000
tmp2 = "10" *100000
count = 0
if S[0] == "0":
    for i in range(len(S)):
        if tmp1[i] != S[i]:
            count += 1
else:
    for i in range(len(S)):
        if tmp2[i] != S[i]:
            count += 1
print(count)

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

SCheckA = []
SCheckB = []
for i in range(len(S)):
  if i % 2 == 0:
    SCheckA.append("1")
    SCheckB.append("0")
  else:
    SCheckA.append("0")
    SCheckB.append("1")
countA = 0
countB = 0
for j in range(len(S)):
  if SCheckA[j] != S[j]:
    countA += 1
  if SCheckB[j] != S[j]:
    countB += 1
    
if countA >= countB:
  print(countB)
else:
  print(countA)

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

print(counter)

Solution (Python):
List=list(input())
result = []
if List[0] == "0":
    result.append("0")
    for i in range(1,len(List)):
        if(i%2==0):
            result.append("0")
        else:
            result.append("1")
elif List[0] == "1":
    result.append("1")
    for i in range(1,len(List)):
        if(i%2==0):
            result.append("1")
        else:
            result.append("0")
count = 0
for i in range(len(List)):
    if(List[i]!=result[i]):
        count = count + 1
print(count)