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()

cost1 = S[::2].count("1") + S[1::2].count("0")
cost2 = S[::2].count("0") + S[1::2].count("1")

print(min(cost1, cost2))

Solution (Python):
S=input()
n=len(S)
A=('01'*n)[:n]
B=('10'*n)[:n]
a=0
b=0
for i in range(n):
    if S[i]!=A[i]:
        a+=1
    else:
        b+=1
print(min(a,b))

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

expected = []

for i in range(len(s)):
    if (i % 2 == 0):
        expected.append(0)
    else:
        expected.append(1)

union = []

for i in range(len(s)):
    union.append((s[i] + expected[i]) % 2)

cnt_0 = union.count(0)
cnt_1 = union.count(1)

print(min(cnt_0, cnt_1))

Solution (Python):
import numpy as np

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

expected = []

for i in range(len(s)):
    if (i % 2 == 0):
        expected.append(0)
    else:
        expected.append(1)

expected = np.array(expected)

union = s + expected
union = union % 2
union = union.tolist()

cnt_0 = union.count(0)
cnt_1 = union.count(1)

print(min(cnt_0, cnt_1))

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

check = 0
for char in S:
    if int(char) != check:
        count1 += 1
    check = (check+1)%2
check = 1
for char in S:
    if int(char) != check:
        count2 += 1
    check = (check+1)%2

print(min([count1,count2]))

Solution (Python):
s=input()

ans=0
for i, x in enumerate(s):
  if i%2==0:
    if x!=s[0]:
      ans+=1
  else:
    if x==s[0]:
      ans+=1
print(ans)

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

a = 0
b = 0
for i in range(len(s)):
    if s[i] != comp[i]:
        a += 1
    else:
        b += 1

print(min(a, b))

Solution (Python):
s = input()

ans1 = 0
ans2 = 0

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

print(min(ans1,ans2))

Solution (Python):
from collections import Counter
n=input()
a=n[::2]
b=n[1::2]
aa=Counter(a)
bb=Counter(b)
a0=aa["0"]
a1=aa["1"]
b0=bb["0"]
b1=bb["1"]
print(min(a0+b1,a1+b0))

Solution (Python):
S = input()
S1 = S[::2]
S2 = S[1::2]
if len(S1) == len(S2):
    if S1.count('0') >= S2.count('0'):
        ans = S1.count('1') + S2.count('0')
    else:
        ans = S1.count('0') + S2.count('1')
else:
    if S1.count('0') < S1.count('1'):
        ans = S1.count('0') + S2.count('1')
    else:
        ans = S1.count('1') + S2.count('0')
print(ans)

Solution (Python):
import numpy as np
s = np.array([int(i) for i in input()])
a = np.array([i%2 for i in range(len(s))])
b = np.array([1]+[i%2 for i in range(len(s)-1)])

print(min(np.sum(np.abs(s-a)),np.sum(np.abs(s-b))))

Solution (Python):
s = input()



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

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

print(min(a,b))

Solution (Python):
S = input()

count = 0
black = 0 
white = 0
for i in list(S):
  if count % 2 == 0:
    black += 1 if i != '0' else 0
    white += 1 if i != '1' else 0
  else: 
    black += 1 if i != '1' else 0
    white += 1 if i != '0' else 0
  count += 1

print(min(black, white))

Solution (Python):
s = input()
ans1 = 0
ans2 = 0
ideal1 = []
ideal2 = []
for x in range(len(s)):
    if x % 2 == 0:
        ideal1.append('1')
        ideal2.append('0')
    else:
        ideal1.append('0')
        ideal2.append('1')
for inp,i1,i2 in zip(s,ideal1,ideal2):
    if inp == i1:
        pass
    else :
        ans1 += 1
    if inp == i2:
        pass
    else:
        ans2 += 1

print(min(ans1,ans2))

Solution (Python):
S = input()
print(min(S[::2].count('0')+S[1::2].count('1'),S[::2].count('1')+S[1::2].count('0')))

Solution (Python):
S = input()

can1 = 0
can2 = 0

for i in range(len(S)):
    if abs(int(S[i])-i%2) == 1:
        can1 += 1
    elif abs(int(S[i])-(i+1)%2) == 1:
        can2 += 1

if can1 > can2:
    print(can2)
else:
    print(can1)

Solution (Python):
s = input()
n = len(s)
if n%2 == 0:
    s1 = '10'*(n//2)
else:
    s1 = '10'*(n//2) +'1'

s1cnt = 0

for i in range(n):
        if s1[i] == s[i]:
            s1cnt +=1
s2cnt = n - s1cnt
print(min(s1cnt,s2cnt))

Solution (Python):
s = input()
n = len(s)
ans = 0


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


print(min(ans,n-ans))

Solution (Python):
s = input()
n = len(s)
ans = 0


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


print(min(ans,n-ans))

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

Solution (Python):
s = input()
s_h = s[0]

for i in range(1, len(s)):
    if s_h[-1] == "0":
        s_h += "1"
    else:
        s_h += "0"

ans = 0
for i in range(len(s)):
    if s[i] != s_h[i]:
        ans += 1
    else:
        continue

print(ans)

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

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

print(min(ans1, ans2))

Solution (Python):
if __name__ == "__main__":
    tile = input()
    
    a = tile[0::2].count("1") + tile[1::2].count("0")
    b = tile[0::2].count("0") + tile[1::2].count("1")

    print(min(a, b))

Solution (Python):
*a,=input()
c=0
for i in range(len(a)-1):
    if a[i]=="0" and a[i+1]=="0":
        a[i+1]="1"
        c+=1
    elif a[i]=="1" and a[i+1]=="1":
        a[i+1]="0"
        c+=1
print(c)

Solution (Python):
s = list(input())
count = 0
n = len(s)
if n % 2 == 0:
    for i in range(0,int(n/2)):
        if s[(2*i)+1] == "0":
            count = count + 1
    for j in range(0,int(n/2)):
        if s[2*j] == "1":
            count = count + 1
else:
    for i in range(0,int((n-1)/2)+1):
        if s[2*i] == "0":
            count = count + 1
    for j in range(0,int(((n-1)/2))):
        if s[2*j + 1] == "1":
            count = count + 1
count2 = n - count
print(min(count,count2))

Solution (Python):
S = list(input())
R1 = [(1 + (-1)**i)/2 for i in range(len(S))]
R2 = [(1 + (-1)**(i+1))/2 for i in range(len(S))]
count1 = 0
count2 = 0
for i in range(len(S)):
    if int(S[i]) != R1[i]:
        count1 += 1
for i in range(len(S)):
    if int(S[i]) != R2[i]:
        count2 += 1
print(min(count1,count2))

Solution (Python):
S=input()
Aodd=0
Aeven=0
for i in range(len(S)):
    if int(S[i])==i%2:
        Aeven+=1
    else:
        Aodd+=1
print(min(Aeven,Aodd))

Solution (Python):
S = input()

cnd0 = 0
cnd1 = 0

target = '01' * (len(S) // 2)
if len(S) % 2 == 1:
    target = target + '0'
for idx, ch in enumerate(S):
    if ch != target[idx]:
        cnd0 += 1

target = '10' * (len(S) // 2)
if len(S) % 2 == 1:
    target = target + '1'
for idx, ch in enumerate(S):
    if ch != target[idx]:
        cnd1 += 1

print(min(cnd0, cnd1))

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

S0 = []
S1 = []

for i in range(len(S)):
    S0.append(str(i%2))
    S1.append(str(int(not i%2)))





S0_count = 0
S1_count = 0


for i in range(len(S)):
    if S[i] != S0[i]:
        S0_count += 1
    if S[i] != S1[i]:
        S1_count += 1

print(min(S0_count, S1_count))

Solution (Python):
s1 = input()

n1 = list(s1)
c1 = 0
c2 = 0
for i1 in range(len(n1)):
    if i1 % 2 == 0:
        if n1[i1] == "1":
            c1 += 1
    else:
        if n1[i1] == "0":
            c1 += 1

for i2 in range(len(n1)):
    if i2 % 2 == 0:
        if n1[i2] == "0":
            c2 += 1
    else:
        if n1[i2] == "1":
            c2 += 1
print(min(c1, c2))

Solution (Python):
s = input()
res = s[0::2].count('0')+s[1::2].count('1')
print(min(res, len(s)-res))

Solution (Python):

def reverse(str):
  if str == '0':
    str = '1'
  else:
    str = '0'
  return str


S = raw_input()
S = list(S)
N = len(S)
ans = 0

for i in xrange(N-1):
  if S[i] == S[i+1]:
    S[i+1] = reverse(S[i+1])
    ans += 1

print ans

Solution (Python):
S = input()
n = len(S)
SS = list(map(int, S))
A1 = [x&1 for x in range(n)]
A2 = [x&1 for x in range(1, n+1)]

cnt = [0, 0]
for i in range(n):
    cnt[0] += abs(SS[i] - A1[i])
    cnt[1] += abs(SS[i] - A2[i])

print(min(cnt))

Solution (Python):
s = input()
n = len(s)
count = 0
for i in range(n):
    if i%2 == 0:
        count += int(s[i])
    else:
        count += 1-int(s[i])
if count <= n//2:
    print(count)
else:
    print(n - count)

Solution (Python):

s = input()
b = []

for i in range(len(s)):
    if s[i] == '0':
        b.append(False)
    else:
        b.append(True)

switch = False
c1 = 0
for i in range(len(b)):
    if b[i] != switch:
        c1 += 1
    switch = not switch

switch = True
c2 = 0
for i in range(len(b)):
    if b[i] != switch:
        c2 += 1
    switch = not switch

print(min(c1, c2))

Solution (Python):
def resolve():
    S = input()
    comp = "".join([ str(i % 2) for i in range(len(S))])
    cnt = 0
    for i in range(len(S)):
        if S[i] == comp[i]:
            cnt = cnt + 1
    return min(cnt, len(S)-cnt)

if '__main__' == __name__:
    print(resolve())

Solution (Python):
s=input()
a=sum(s[i]!="0" for i in range(0,len(s),2))
b=sum(s[i]!="1" for i in range(1,len(s),2))
c=sum(s[i]!="1" for i in range(0,len(s),2))
d=sum(s[i]!="0" for i in range(1,len(s),2))
print(min(a+b,c+d))

Solution (Python):
S=input()

Length=len(S)
Counta=0
Countb=0

if Length%2==0:
    Sa="01"*(Length//2)
    Sb="10"*(Length//2)
else:
    Sa="01"*(Length//2)+"0"
    Sb="10"*(Length//2)+"1"
    
for i in range(Length):
    if S[i]!=Sa[i]:
        Counta+=1
    if S[i]!=Sb[i]:
        Countb+=1
        
print(min(Counta,Countb))

Solution (Python):
s = input()
tile_01 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
tile_10 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
tile_01 = ''.join(tile_01)
tile_10 = ''.join(tile_10)

s_01 = bin(int('0b' + s, 2) ^ int('0b' + tile_01, 2)).split('b')[1].zfill(len(s))
s_10 = bin(int('0b' + s, 2) ^ int('0b' + tile_10, 2)).split('b')[1].zfill(len(s))
short_01 = 0
short_10 = 0
for i in range(len(s_01)):
    if s_01[i] == '1':
        short_01 += 1
    elif s_10[i] == '1':
        short_10 += 1

print(min(short_01, short_10))

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

w=[i%2 for i in range(len(n))]
b=[(i+1)%2 for i in range(len(n))]
x,y=0,0
for i in range(len(n)):
  if n[i]!=w[i]:
    x+=1
  if n[i]!=b[i]:
    y+=1
if x<y:
  print(x)
else:
  print(y)

Solution (Python):
S = input()

def cd(S, R):
    return sum([1 for s, r in zip(S, R) if s != r])
print(min(cd(S, '01' * (len(S)+1//2)), cd(S, '10' * (len(S)+1//2))))

Solution (Python):
import sys

def main():
    sinputl = sys.stdin.readline

    input = sinputl().strip()
    length = len(input)
    string1 = "10" * (length // 2) + "1" * (length % 2)
    string2 = "01" * (length // 2) + "0" * (length % 2)
    count1 = 0
    count2 = 0

    for i in range(length):
        if input[i] != string1[i]:
            count1 += 1

    for i in range(length):
        if input[i] != string2[i]:
            count2 += 1

    print(min(count1, count2))


if __name__ == "__main__":
    main()

Solution (Python):
s = list(input())
n = len(s)
zero = 0
one = 0
for i in range(n):
    if i%2==0:
        if int(s[i])!=0:
            zero+=1
        else:
            one+=1
    elif i%2==1:
        if int(s[i])==0:
            zero+=1
        else:
            one+=1
print(min(zero,one))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

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

  c1=c2=0
  f=True
  for x in s:
    if f:
      if x=='0':
        c1+=1
      f=False
    else:
      if x=='1':
        c1+=1
      f=True

  f=False
  for x in s:
    if f:
      if x=='0':
        c2+=1
      f=False
    else:
      if x=='1':
        c2+=1
      f=True

  
  return min(c1,c2)

print(main())

Solution (Python):
n=list(input())
S=0
for i,l in zip(range(len(n)),n):
  if i%2==0 and int(l)==0:
    S=S
  elif i%2==0 and int(l)==1:
    S=S+1
  elif i%2==1 and int(l)==0:
    S=S+1
  else:
    S=S
M=0
for i,l in zip(range(len(n)),n):
  if i%2==0 and int(l)==0:
    M=M+1
  elif i%2==0 and int(l)==1:
    M=M
  elif i%2==1 and int(l)==0:
    M=M
  else:
    M=M+1
print(min(M,S))

Solution (Python):
def resolve():
	S=input()
	Slist=[int(i) for i in list(S)]
	N=len(S)
	
	if N%2==0:
		s1='10'*(N//2)
		s2='01'*(N//2)
	else:
		s1='10'*(N//2)+'1'
		s2='01'*(N//2)+'0'
	s1List=[int(i) for i in list(s1)]
	s2List=[int(i) for i in list(s2)]
	
	print(min(sum([1 for i in range(N) if Slist[i]!=s1List[i]]),sum([1 for i in range(N) if Slist[i]!=s2List[i]])))
resolve()

Solution (Python):
def resolve():
	S=input()
	Slist=[int(i) for i in list(S)]
	N=len(S)
	
	if N%2==0:
		s1='10'*(N//2)
		s2='01'*(N//2)
	else:
		s1='10'*(N//2)+'1'
		s2='01'*(N//2)+'0'
	s1List=[int(i) for i in list(s1)]
	s2List=[int(i) for i in list(s2)]
	
	print(min(sum([1 for i in range(N) if Slist[i]!=s1List[i]]),sum([1 for i in range(N) if Slist[i]!=s2List[i]])))

resolve()

Solution (Python):










import numpy as np
import math
import copy

c = input()
color_list = list(map(int, list(c)))

N= len(color_list)

f0_num = 0
filter_0 = [i % 2 for i in range(N)]
f1_num = 0
filter_1 = [i % 2 for i in range(1, N + 1)]

for c, f0, f1 in zip(color_list, filter_0, filter_1):
    if c != f0:
        f0_num += 1
    if c != f1:
        f1_num += 1

print(min(f0_num, f1_num))

Solution (Python):
from sys import stdin

S = stdin.readline().rstrip()
T1 = [k % 2 for k in range(len(S))]
T2 = [1 - k % 2 for k in range(len(S))]
c1 = 0
c2 = 0
for l in range(len(S)):
    if int(S[l]) == T1[l]:
        c1 += 1
    else:
        c2 += 1

print(min(c1, c2))

Solution (Python):
def solve(init, s):
    ideal = init  
    result = 0  
    for color in s:
        if color != ideal:
            result += 1
        ideal ^= 1  
    return result


s = input()
s = list(map(int, s))
print(min(solve(0, s), solve(1, s)))

Solution (Python):
S = list(input())
W = 0 
B = 0 

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

print (min(W, B))

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

ans1 = 0
ans2 = 0

for i in range(int((N+1)/2)):
    if orig[2*i] != '1':
        ans1 = ans1 + 1

for i in range(int(N/2)):
    if orig[2*i+1] != '0':
        ans1 = ans1 + 1

for i in range(int((N+1)/2)):
    if orig[2*i] != '0':
        ans2 = ans2 + 1

for i in range(int(N/2)):
    if orig[2*i+1] != '1':
        ans2 = ans2 + 1

if ans1 > ans2:
    print(ans2)
else:
    print(ans1)

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

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ (S[i] == '1'):
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))

Solution (Python):
S=input()
N=len(S)
A=len([i for i in range(N) if str(i%2)==S[i]])
print(min(A,N-A))

Solution (Python):
S=input()
N=len(S)
A="".join([str(i%2) for i in range(N)])
B="".join([str((i+1)%2) for i in range(N)])
print(min(sum([1 for i in range(N) if S[i]!=A[i]]),sum([1 for i in range(N) if S[i]!=B[i]])))

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

Solution (Python):
S = list(map(int, list(input())))
s0 = S[::2]
s1 = S[1::2]

count_0 = 0
count_1 = 0

for i in s0:
    if i == 0:
        count_0 += 1
    else:
        count_1 += 1

for i in s1:
    if i == 1:
        count_0 += 1
    else:
        count_1 += 1

if count_0 > count_1:
    print(count_1)
else:
    print(count_0)

Solution (Python):

def main():
    S = input()
    a = ["1" if i % 2 == 0 else "0" for i in range(len(S))]
    b = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
    if comparison(S, a) <= comparison(S, b):
        print(comparison(S, a))
    else:
        print(comparison(S, b))


def comparison(S, n):
    count = 0
    for i in range(len(S)):
        if not n[i] == S[i]:
            count += 1
    return count


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    S = input()
    a = ["1" if i % 2 == 0 else "0" for i in range(len(S))]
    b = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
    if comparison(S, a) <= comparison(S, b):
        print(comparison(S, a))
    else:
        print(comparison(S, b))


def comparison(S, n):
    count = 0
    for i in range(len(S)):
        if not n[i] == S[i]:
            count += 1
    return count


if __name__ == "__main__":
    main()

Solution (Python):
s = input()
x = 0
count0 = 0
count1 = 0
for i in s:
    count0 = count0+1 if i==str(x) else count0
    x = int(not(x))
x = 1
for i in s:
    count1 = count1 + 1 if i == str(x) else count1
    x = int(not(x))
print(min(count0, count1))

Solution (Python):
s = input()

x = 0
count0 = 0
count1 = 0

for i in s:
    
     
    count0 = count0+1 if i==str(x) else count0
    x = int(not(x))

x = 1
for i in s:
    
    
    count1 = count1 + 1 if i == str(x) else count1
    x = int(not(x))

print(min(count0, count1))

Solution (Python):
s = input()

x = 0
count0 = 0
count1 = 0

for i in s:
    if i == str(x):
        count0 += 1
    x = int(not(x))

x = 1
for i in s:
    if i == str(x):
        count1 += 1
    x = int(not(x))

print(min(count0, count1))

Solution (Python):
s = input()

x = 0
count0 = 0
count1 = 0

for i in s:
    if i == str(x):
        count0 += 1
    x = int(not(x))

x = 1
for i in s:
    if i == str(x):
        count1 += 1
    x = int(not(x))


print(min(count0, count1))

Solution (Python):
S = input()

B = [] * len(S)
ans = 0

for i in range(len(S)) :
    if not int(S[i]) == (i%2) :
        ans += 1

ans = min(ans , len(S) - ans)

print(ans)

Solution (Python):


s = input()
s1 = s0 = 0
for j in range(len(s)):
    if j % 2 == 0 and int(s[j]) == 0:
        pass
    elif j % 2 == 1 and int(s[j]) == 1:
        pass
    else:
        s0 += 1
    if j % 2 == 0 and int(s[j]) == 1:
        pass
    elif j % 2 == 1 and int(s[j]) == 0:
        pass
    else:
        s1 += 1
print(min(s1, s0))

Solution (Python):
s = input()
if len(s) % 2 == 0:
  s1 = "10" * int(len(s) / 2)
  s2 = "01" * int(len(s) / 2)
else:
  s1 = "10" * int(len(s) / 2) + "1"
  s2 = "01" * int(len(s) / 2) + "0"
a1 = int(s) + int(s1)
a2 = int(s) + int(s2)
a1 = str(a1).count("1")
a2 = str(a2).count("1")
print(min(a1,a2))

Solution (Python):

def problem():
    s = str(input())
    print(algorithm(s))

def algorithm(s: str):
  counter1 = 0
  counter2 = 0

  for index in range(len(s)):
    if index % 2 == 0:
      if s[index] == '0':
        counter1 += 1
    else:
      if s[index] == '1':
        counter1 += 1

  for index in range(len(s)):
    if index % 2 == 0:
      if s[index] == '1':
        counter2 += 1
    else:
      if s[index] == '0':
        counter2 += 1   

  return counter1 if counter1 < counter2 else counter2

problem()

Solution (Python):
arr=list(map(int,list(input())))
ans=[0,0]
for i in range(2):
    respect=i
    for j in range(len(arr)):
        if arr[j]!=respect:
            ans[i]+=1
        respect=(respect+1)%2
print(min(ans[0],ans[1]))

Solution (Python):

s = input()
input_len = len(s)


s = "1" + s


str1 = "1" + "01" * (input_len//2)
str2 = "1" + "10" * (input_len//2)

if(input_len%2 == 1):
	
	str1 = str1 + "0"
	str2 = str2 + "1"





input_num = int(s, 2)
num1 = int(str1, 2)
num2 = int(str2, 2)





ans1 = input_num ^ num1
ans2 = input_num ^ num2




ans_str1 = list(bin(ans1)[2:])
ans_list1 = list(filter(lambda x: x == "1", ans_str1)) 
a1 = len(ans_list1)

ans_str2 = list(bin(ans2)[2:])
ans_list2 = list(filter(lambda x: x == "1", ans_str2)) 
a2 = len(ans_list2)

if a1 < a2:
	print(a1)
else:
	print(a2)

Solution (Python):
S = input().strip()
if len(S) == 1:
  print(0)
else:
  n = 0
  for i, s_i in enumerate(S):
    if i%2 == 0:
      if s_i == '0':
        n += 1
    else:
      if s_i == '1':
        n += 1
  print(min(n, len(S)-n))

Solution (Python):

import sys
input = sys.stdin.readline

s = input().rstrip()
a = s[0]
ans = 0
for i, j in enumerate(s):
    if i % 2 == 0:
        if j != a:
            ans += 1
    else:
        if j == a:
            ans += 1
print(ans)

Solution (Python):

s = input()
a = s[0]
ans = 0
for i, j in enumerate(s):
    if i % 2 == 0:
        if j != a:
            ans += 1
    else:
        if j == a:
            ans += 1
print(ans)

Solution (Python):
s = input()
cnt = 0
if(s[:1] == '0'):
  for i in range(len(s) // 2):
    if(s[2*i+1:2*i+2] == '0'):
      cnt += 1
    if(s[2*i+2:2*i+3] == '1'):
      cnt += 1
else:
  for i in range(len(s) // 2):
    if(s[2*i+1:2*i+2] == '1'):
      cnt += 1
    if(s[2*i+2:2*i+3] == '0'):
      cnt += 1  
print(cnt)

Solution (Python):
s=input();sl=len(s)
t=['01'*(sl//2),'10'*(sl//2)]
a,b=0,0
if sl%2:
	t[0]+='0';t[1]+='1'
for i,j,k in zip(s,t[0],t[1]):
	if i==j: a+=1
	if i==k: b+=1
print(min(a,b))

Solution (Python):
s = [int(i) for i in list(input())]
a = []
b = []
for i in range(len(s)):
    if i % 2 == 0:
        a.append(0)
    else:
        a.append(1)
for i in range(len(s)):
    if i % 2 == 1:
        b.append(0)
    else:
        b.append(1)
count_a = 0
count_b = 0
for i, j in zip(s, a):
    if i != j:
        count_a += 1
for i, j in zip(s, b):
    if i != j:
        count_b += 1
print(min(count_a, count_b))

Solution (Python):
S = input()
count_0 = 0
count_1 = 0
for i, c in enumerate(S):
    if int(c) == i%2:
        count_1 += 1

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

Solution (Python):
S = input()
count_0 = 0
count_1 = 0
for i, c in enumerate(S):
    if int(c) == i%2:
        count_1 += 1
    else:
        count_0 += 1
print(min(count_1, count_0))

Solution (Python):
s = input()

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

print(min(wb, bw))

Solution (Python):
s = input()
n = len(s)
a = [] 
for i in range(n):
  if i%2 == 1:
    a.append(1)
  else:
    a.append(0)

k = 0
for i in range(n):
  if int(s[i]) != a[i]:
    k = k + 1
print(min(k, n-k))

Solution (Python):
S = input()

BW = '01' * (10**6)
WB = '10' * (10**6)

ans = 0
if S[0] == '0':
    for i in range(len(S)):
        if S[i] != BW[i]:
            ans += 1
else:
    for i in range(len(S)):
        if S[i] != WB[i]:
            ans += 1
            
print(ans)

Solution (Python):
import sys
import os


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

A=[i%2 for i in range(len(S))]
B=[(i+1)%2 for i in range(len(S))]

C=[(x+y)%2 for (x,y) in zip(A,S)]
D=[(x+y)%2 for (x,y) in zip(B,S)]

print(min(sum(C),sum(D)))

Solution (Python):
s=input()
s=list(s)
n=len(s)
acnt=1
bcnt=1
flag=False
for i in range(n):
    if i!=n-1 and s[i]==s[i+1]:
        flag=True
        a=s[:]
        if s[i]=='0':
            s[i]='1'
        else:
            s[i]='0'
        for j in range(n):
            if j!=n-1 and s[j]==s[j+1]:
                if s[j]=='0': 
                    s[j+1]='1'
                    acnt+=1
                else:
                    s[j+1]='0'
                    acnt+=1
                        
        if a[i]=='0':
            a[i+1]='1'
        else:
            a[i+1]='0'
        for k in range(n):
            if k!=n-1 and a[k]==a[k+1]:
                if a[k]=='0':
                    a[k+1]='1'
                    bcnt+=1
                else:
                    a[k+1]='0'
                    bcnt+=1
                    
        break
if n==1 or flag==False: print(0)
else: print(min(bcnt,acnt))

Solution (Python):
S = str(input())
N = len(S)
T1=[]
T2=[]
a=0
b=0
for i in range(N):
  if i%2==1:
  	T1.append('0')
  else:
  	T1.append('1')
for i in range(N):
  if i%2!=1:
  	T2.append('0')
  else:
  	T2.append('1')  
for i in range(N):
  if S[i]!=T1[i]:
    a=a+1
  else:
    a=a
    
for i in range(N):
  if S[i]!=T2[i]:
    b=b+1
  else:
    b=b

if a>b:
  print("%d"% b)
else:
  print("%d"% a)

Solution (Python):
s=input()
zerofirst="0"
onefirst="1"
for i in range(1,len(s)):
  if i%2!=0:
    zerofirst=zerofirst+"1"
    onefirst=onefirst+"0"
  else:
    zerofirst=zerofirst+"0"
    onefirst=onefirst+"1"
zerodif=0
onedif=0
for j in range(len(s)):
  if s[j]!=zerofirst[j]:
    zerodif+=1
  if s[j]!=onefirst[j]:
    onedif+=1
print(min(zerodif,onedif))

Solution (Python):
S=list(input())
N=len(S)
ans1=0
ans2=0
for i in range(N): 
    if i%2==0 and S[i]!='1':
        ans1+=1
    if i%2==1 and S[i]!='0':
        ans1+=1
for i in range(N): 
    if i%2==0 and S[i]!='0':
        ans2+=1
    if i%2==1 and S[i]!='1':
        ans2+=1
print(min(ans1,ans2))

Solution (Python):
s = input()

even_s = s[1::2]
odd_s = s[::2]

num_1 = even_s.count('1')+odd_s.count('0')
num_2 = even_s.count('0')+odd_s.count('1')

print(min(num_1 , num_2))

Solution (Python):
S = input()

cnt = [0,0]
ans = [0,1]

for i in range(len(S)):
    for j in range(2):
        if int(S[i]) != ans[j]:
            cnt[j] += 1
        
        ans[j] = 1 - ans[j]
            

print(min(cnt))

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



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


def solve(S, n):
    ans = 0

    for i in range(len(S)):
        if int(S[i]) == n:
            pass
        else:
            ans += 1

        n = 1 - n

    return ans


def main():
    S = input()

    print(min(solve(S, 0), solve(S, 1)))


if __name__ == '__main__':
    main()

Solution (Python):
s = list(map(int, input()))
odd = s[0]
even = abs(s[0] - 1)

ans = 0
for v in s[::2]:
    if v != odd:
        ans += 1
        
for v in s[1::2]:
    if v != even:
        ans += 1
    
print(ans)

Solution (Python):
s = input()

final_1 = []
final_2 = []

final_1_cnt = 0
final_2_cnt = 0

for i in range(len(s)):
    if i % 2 == 0:
        final_1.append('0')
        final_2.append('1')
    else:
        final_1.append('1')
        final_2.append('0')

    if final_1[i] == s[i]:
        final_2_cnt += 1
    else:
        final_1_cnt += 1

print(min(final_1_cnt, final_2_cnt))

Solution (Python):
s=input()

l_1=[0 if i%2==0 else 1 for i in range(len(s))]
l_2=[1 if j%2==0 else 0 for j in range(len(s))]

ans_1=0
ans_2=0
for k in range(len(s)):
    if int(s[k])!=l_1[k]:
        ans_1+=1
    if int(s[k])!=l_2[k]:
        ans_2+=1

print(min(ans_1,ans_2))

Solution (Python):
ans = 0
S =input()
for i,j in enumerate(S):
  j = int(j)
  if i%2 == j:
    ans += 1
print(min(ans,len(S)-ans))

Solution (Python):
S = input()

N = len(S)

A = "" 
B = "" 

for i in range(N):
    if i % 2 == 0:
        A += "0"
        B += "1"
    else:
        A += "1"
        B += "0"


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


print(min(difA,difB))

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

Solution (Python):
S=input()

l = len(S)
ans1 = 0
ans2 = 0

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

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

Solution (Python):

S = input()


ans = min(
    sum(S[i] == str(i % 2) for i in range(len(S))),
    sum(S[i] == str((i + 1) % 2) for i in range(len(S)))
)


print(ans)

Solution (Python):
s=input()

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

for i in range(len(s)):
	if i%2==1:
		if s[i]=='0':
			odd_0+=1
		else:
			odd_1+=1
	if i%2==0:
		if s[i]=='0':
			even_0+=1
		else:
			even_1+=1
print(min([even_1+odd_0,even_0+odd_1]))

Solution (Python):
mass = input()
mass = list(mass) 
mass = [int(n) for n in mass]
count = 0

for i in range(0, len(mass)):
        if(i == len(mass) - 1):
            break
        if(mass[i] == mass[i+1]): 
            mass[i+1] = (mass[i+1] + 1) % 2 
            count += 1

print(count)

Solution (Python):
mass = input()
mass = list(mass) 
mass = [int(n) for n in mass]
count = 0

for i in range(0, len(mass)):
    try:
        if(mass[i] == mass[i+1]): 
            mass[i+1] = (mass[i+1] + 1) % 2 
            count += 1
    except IndexError: 
        print(count)

Solution (Python):
mass = input()
mass = list(mass)
count = 0

for i in range(0, len(mass)):

    try:
        if(mass[i] == mass[i+1]):
            mass[i+1] = (int(mass[i+1]) + 1) % 2
            mass[i+1] = str(mass[i+1])
            count += 1
    except IndexError:
        print(count)

Solution (Python):
import numpy as np
import heapq




s = input()
l = len(s)

f1 = '10'*(l//2)
f2 = '01'*(l//2)

if l%2 == 1:
    f1 += '1'
    f2 += '0'

s = int(s, 2)    

print(min(format(s ^ int(f1, 2), 'b').count('1'), format(s ^ int(f2, 2), 'b').count('1')))

Solution (Python):
s = input()
c1 = ['0']*len(s)
c2 = ['0']*len(s)
for i in range(len(s)):
    if i%2 == 0:
        c2[i] = '1'
    else:
        c1[i] = '1'

a1 = 0
a2 = 0
for i in range(len(s)):
    if c1[i] == s[i]:
        a1 += 1
    if c2[i] == s[i]:
        a2 += 1
print(min(a1,a2))

Solution (Python):
st = input()
ans1 = 0
ans2 = 0
for i in range(len(st)):
  if i%2 == 0 and st[i] == '0':
    ans1 += 1
  if i%2 == 1 and st[i] == '1':
    ans1 += 1
  if i%2 == 0 and st[i] == '1':
    ans2 += 1
  if i%2 == 1 and st[i] == '0':
    ans2 += 1
    
print(min(ans1, ans2))