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())
Acnt=0
Bcnt=0
AList=[]
BList=[]
for i in range(len(S)):
    if i%2==0:
        AList.append(0)
    else:
        AList.append(1)

for j in range(len(S)):
    if j%2==0:
        BList.append(1)
    else:
        BList.append(0)
    


    
for k in range(len(S)):
    if int(S[k])!=AList[k]:
        Acnt+=1
    if int(S[k])!=BList[k]:
        Bcnt+=1
        
print(min(Acnt,Bcnt))

Solution (Python):
s = list(input())
n = len(s)
a = ['1']+['0']*(n-1)
b = ['0']+['1']*(n-1)

for i in range(1,n):
    if a[i-1] == '1':
        a[i] = '0'
    elif a[i-1] == '0':
        a[i] = '1'

    if b[i-1] == '1':
        b[i] = '0'
    elif b[i-1] == '0':
        b[i] = '1'

difA = 0
difB = 0

for j in range(n):
    if a[j] != s[j]:
        difA += 1

    if b[j] != s[j]:
        difB += 1

ans = min(difA,difB)

print(ans)

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

def sim(temp):
    ret = 0
    for i in range(length):
        if S[i] != str(temp):
            ret += 1
        if temp == 0:
            temp = 1
        else:
            temp = 0 
    return ret
    
res1 = sim(0)
res2 = sim(1)
ans = min(res1, res2)
print(ans)

Solution (Python):





def main():
    S=input()
    Z1=["1" if i%2==0 else "0" for i in range(len(S))]
    c1=0
    c2=0
    for i in range(len(S)):
        if S[i]!=Z1[i]:
            c1+=1
        else:
            c2+=1
    print(min(c1,c2))
    
if __name__=="__main__":
    main()

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    n = len(s)
    l = r = -1
    ans = 0
    for i in range(1, n):
        if s[i] == s[i - 1]:
            if l == -1:
                l = i
            else:
                r = i
        if r != -1:
            ans += r - l
            r = l = -1
    if l != -1:
        ans += n - l
    print(min(ans, n - ans))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Solution (Python):

s = list(input())
a1 = 0
a2 = 0
for i in range(len(s)):
    a1 += int(s[i]) == i % 2
    a2 += int(s[i]) != i % 2
print(min(a1, a2))

Solution (Python):
A=input()
S=[]
for i in A:
    S.append(int(i))

ans_1=0
ans_2=0
for i in range(1,len(S)+1):
    if i%2!=0:
        if S[i-1]!=0:
            ans_1+=1
    else:
        if S[i-1]==0:
            ans_1+=1
        

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

print(min(ans_1,ans_2))

Solution (Python):
def actual(s):
    N = len(s)
    num_repeat = (N // 2)

    if N % 2 == 0:
        
        valid_pattern1 = '10' * num_repeat
        valid_pattern2 = '01' * num_repeat
    else:
        
        valid_pattern1 = '1' + '01' * num_repeat
        valid_pattern2 = '0' + '10' * num_repeat

    flip_step1 = 0
    flip_step2 = 0

    for bit, v1, v2 in zip(s, valid_pattern1, valid_pattern2):
        flip_step1 += int(bit != v1)
        flip_step2 += int(bit != v2)

    return min(flip_step1, flip_step2)


s = input()
print(actual(s))

Solution (Python):
s = list(input())
n = len(s)
S = list(int(s[i]) for i in range(n))
if n %2 == 0:
  A = [0,1] * (n//2)
  B = [1,0] * (n//2)
else:
  A = [0,1] * (n//2) + [0]
  B = [1,0] * (n//2) + [1]

ansA = 0
ansB = 0
for i in range(n):
  ansA += abs(S[i]-A[i])
  ansB += abs(S[i]-B[i])
  
print(min(ansA,ansB))

Solution (Python):
s = input()
n = len(s)
x1, x2 = 0, 0
for i in range(n):
    if s[i] != str(i%2):
        x1 += 1
    if s[i] != str((i+1)%2):
        x2 += 1
print(min(x1, x2))

Solution (Python):
import sys


read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline

S = list(map(int, s_readline().rstrip()))
N = len(S)


def solve():

    ans = 0
    for i in range(N - 1):
        if S[i + 1] == S[i]:
            S[i + 1] = not S[i + 1]
            ans += 1

    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):












S= str(input())




one=[1,0]*10**5
zero=[0,1]*10**5

o=0
z=0
for i in range(len(S)):
    if one[i] != int(S[i]):
        o+=1
    if zero[i] != int(S[i]):
        z+=1

print(min(o,z))

Solution (Python):
s = input()
be = s[::2].count('0')
bo = s[1::2].count('0')
we = s[::2].count('1')
wo = s[1::2].count('1')
print(min(be + wo, bo + we))

Solution (Python):
import numpy as np
S = list(input())
S_np = np.array(list(map(int, S)))

standard1 = np.array([i%2 for i in range(len(S))])
standard2 = np.array([(i+1)%2 for i in range(len(S))])

diff_standard1 = sum((S_np - standard1) != 0)
diff_standard2 = sum((S_np - standard2) != 0)

print(min(diff_standard1, diff_standard2))

Solution (Python):
S = input()

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

print(min(result, result2))

Solution (Python):
def resolve():
    S = str(input())
    ans = 0
    for i in range(len(S)):
        if (S[0] == '0'):
            if i % 2 == 1 and S[i] != '1':
                ans += 1
            elif i % 2 == 0 and S[i] != '0':
                ans += 1
            else:
                pass
        if S[0] == '1':
            if i % 2 == 1 and S[i] != '0':
                ans += 1
            elif i % 2 == 0 and S[i] != '1':
                ans += 1
            else:
                pass
    print(ans)
    return

resolve()

Solution (Python):


import sys
sys.setrecursionlimit(10**6)

def operation(s,f):
    c = 0
    for i in range(len(s)):
        if (s[i] == f and i % 2 == 1) or (s[i] != f and i % 2 == 0):
            c += 1
    return c

def solve(s):
    return min(operation(s,"0"),operation(s,"1"))

def main():
    S = input()
    print(solve(S))


if __name__ == '__main__':
    main()

Solution (Python):

s = input()
cnt1 = 0
cnt2 = 0

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

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

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

Solution (Python):
def main():
    ss = list(input())
    n = len(ss)

    ans1 = 0
    ans2 = 0
    for i in range(n):
        if i % 2 == 0 and ss[i] == "1":
            ans1 += 1
        if i % 2 != 0 and ss[i] == "0":
            ans1 += 1

    for i in range(n):
        if i % 2 == 0 and ss[i] == "0":
            ans2 += 1
        if i % 2 != 0 and ss[i] == "1":
            ans2 += 1
    ans = min(ans1, ans2)
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

import sys

def main():
    S = sys.stdin.readline().rstrip()
    N = len(S)

    ans = float("inf")
    tmp1 = 0
    tmp2 = 0
    for i in range(N):
        if i % 2 == 0:
            s1 = "1"
            s2 = "0"
            if S[i] != s1:
                tmp1 += 1
            elif S[i] != s2:
                tmp2 += 1
        elif i % 2 == 1:
            s1 = "0"
            s2 = "1"
            if S[i] != s1:
                tmp1 += 1
            elif S[i] != s2:
                tmp2 += 1
    print(min(tmp1, tmp2))

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
N = len(S)
cnt1, cnt2 = 0, 0
for i in range(N):
    if i % 2 == 0:
        if S[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if S[i] == "0":
            cnt2 += 1
        else:
            cnt1 += 1

print(min(cnt1, cnt2))

Solution (Python):
def main():
    S = input()
    ans = 0
    ans01 = 0
    ans10 = 0
    
    S_01 = '0'
    for i in range(1,len(S)):
        if i % 2 == 1:
            S_01 += '1'
        else:
            S_01 += '0'
    
    S_10 = '1'
    for j in range(1,len(S)):
        if j % 2 == 1:
            S_10 += '0'
        else:
            S_10 += '1'
    
    for h in range(len(S)):
        if S_01[h] == S[h]:
            continue
        else:
            ans01 += 1
    
    for k in range(len(S)):
        if S_10[k] == S[k]:
            continue
        else:
            ans10 += 1

    if ans01 >= ans10:
        ans = ans10
    else:
        ans = ans01

    return ans

print(main())

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

cnt = 0

if len(S) == 1 or (S[0] != S[1] and len(S) == 2):
  print(0)
  exit()
elif len(S) == 2 and S[0] == S[1]:
  print(1)
  exit()

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


print(cnt)

Solution (Python):
s = input()

ki = s[1::2]
gu = s[::2]


cnt_1 = 0
cnt_2 = 0


for i in ki:
    if i == '0':
        i = 1
        cnt_1 += 1
for i in gu:
    if i == '1':
        i = 0
        cnt_1 += 1


for i in ki:
    if i == '1':
        i = 0
        cnt_2 += 1
for i in gu:
    if i == '0':
        i = 1
        cnt_2 += 1
ans = [cnt_1,cnt_2]
print(min(ans))

Solution (Python):
import sys

rr = lambda: sys.stdin.readline().rstrip()

s = list(rr())
cnt = 0
for i in range(len(s)-1):
  si = s[i]
  si1 = s[i+1]
  if si == si1:
    if si == '0':
      s[i+1] = '1'
    else:
      s[i+1] = '0'
    cnt += 1
print(cnt)

Solution (Python):
s=list(map(int,list(input())))
ans0=0
ans1=0
pre=s[0]
for si in s[1:]:
  if si==pre:
    ans0+=1
    pre=not si
  else:
    pre=si

pre=s[-1]
for si in s[:-1][::-1]:
  if si==pre:
    ans1+=1
    pre=not si
  else:
    pre=si
print(min(ans0,ans1))

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

ansa = 0
ansb = 0

a = 0 
b = 1 

for i in s:

  if i != a:
    ansa += 1
  
  if i != b:
    ansb += 1

  a = (a+1)%2
  b = (b+1)%2

print(min(ansa,ansb))

Solution (Python):
S = input()
L = len(S)
a, b = 0, 0

if L % 2 == 0:
  A = "01" * (L//2)
  B = "10" * (L//2)
else:
  A = "01" * (L//2) + "0"
  B = "10" * (L//2) + "1"
for i in range(L):
  if A[i] != S[i]:
    a += 1
  if B[i] != S[i]:
    b += 1
  
print(min(a, b))

Solution (Python):
s = input()

tmp = s[0]
cnt = 0


for i in range(1, len(s)):
    if tmp == s[i]:
        cnt += 1
        if tmp == "1":
            tmp = "0"
        else:
            tmp = "1"
    else:
        tmp = s[i]
            
print(cnt)

Solution (Python):
arr=list(map(int,input()))
N=int(len(arr)//2)
count_ichi=0
count_zero=0

if len(arr)%2==0:
    zero=[0,1]*N
    ichi=[1,0]*N
else:
    zero=[0,1]*N+[0]
    ichi=[1,0]*N+[1]

for i in range(len(arr)):
    if zero[i]!=arr[i]:
        count_zero+=1
    if ichi[i]!=arr[i]:
        count_ichi+=1

print(min(count_zero,count_ichi))

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

for x in ['0','1']:
  bef=x
  ret=0
  for c in s: 
 
    if bef==c:

      if bef=='1':

        bef="0"
      elif bef=='0':

        bef="1"
      ret+=1
    else:
      bef=c

  if ret<mn:
    mn=ret

print(mn)

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

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

Solution (Python):
import math
from collections import deque
from collections import defaultdict


def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	
	ans = data[:]
	return ans

s = readChar()

color = [[0,0],[0,0]]

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

print(min(color[0][0]+color[1][1],color[0][1]+color[1][0]))

Solution (Python):
S = list(input())
count = 0
for i in range(len(S) - 1):
    if S[i] == "0" and S[i+1] == "0":
        S[i+1] = "1"
        count += 1
    if S[i] == "1" and S[i+1] == "1":
        S[i+1] = "0"
        count += 1
print(count)

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

Solution (Python):
s = list(input())
s1 = [0]*len(s)
s0 = [1]*len(s)
for i in range(1,len(s), 2):
  s1[i] += 1
  s0[i] -= 1
n1 = 0
n0 = 0
for i in range(len(s)):
  if s1[i] != int(s[i]):
    n1 += 1
  elif s0[i] != int(s[i]):
    n0 += 1
print(min(n1, n0))

Solution (Python):
S = input()
N = len(S)
A, B = "01" * N, "10" * N
print(min(sum(s != a for s, a in zip(S, A)),
          sum(s != b for s, b in zip(S, B))))

Solution (Python):
def main():
    S = list(input())
    lenS = len(S)
    pt1 = ['0', '1'] * (lenS//2) + ['0']*(lenS%2==1)
    pt2 = ['1', '0'] * (lenS//2) + ['1']*(lenS%2==1)
    cnt1 = 0; cnt2 = 0
    for i in range(lenS):
        cnt1 += (pt1[i]!=S[i])
        cnt2 += (pt2[i]!=S[i])
    print(min(cnt1, cnt2))

if __name__ == "__main__":
    main()

Solution (Python):
S=input()

nagasa=len(S)

countA=0
countB=0
for i in range(nagasa):
    if i%2==0:
        if S[i]=="0":
            countA+=1
    else:    
        if S[i]=="1":
            countA+=1
    if i%2==0:
        if S[i]=="1":
            countB+=1
    else:    
        if S[i]=="0":
            countB+=1
print(min(countA,countB))

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

print(ans)

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

before_tile = S[0]

ans = 0
for i in range(1, len(S)):
    if S[i] == before_tile:
        ans += 1
        if S[i] == "0":
            S[i] = "1"
        else:
            S[i] = "0"
    before_tile = S[i]

print(ans)

Solution (Python):
S = input()

init0 = 0
init1 = 0
for i in range(len(S)):
    if i % 2 != int(S[i]):
        init0 += 1
    if i % 2 == int(S[i]):
        init1 += 1


print(min(init0, init1))

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

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

print(count)

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

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

print(count)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = readline().decode().rstrip()

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

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

print(min(p1,p2))

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

cnt0 = 0
cnt1 = 0
for e in S[::2]:
    if e == '1':
        cnt0 += 1
    else:
        cnt1 += 1
for e in S[1::2]:
    if e == '0':
        cnt0 += 1
    else:
        cnt1 += 1
print(min(cnt0, cnt1))

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

cnt0 = 0
cnt1 = 0
for e in S[::2]:
    if e == '1':
        cnt0 += 1
for e in S[1::2]:
    if e == '0':
        cnt0 += 1
for e in S[::2]:
    if e == '0':
        cnt1 += 1
for e in S[1::2]:
    if e == '1':
        cnt1 += 1
print(min(cnt0, cnt1))

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

Solution (Python):
S = str(input())
N = len(S)
a = N//2
b = N%2
N_base1 = "01"*a
N_base2 = "10"*a
N1 = N_base1 + "0"*b
N2 = N_base2 + "1"*b

n1,n2 = 0,0
for i, j, k in zip(S, N1, N2):
    if i != j:
        n1 += 1
    if i != k:
        n2 += 1

print(min(n1,n2))

Solution (Python):
S = input()
T = ''.join(['0' if i % 2 == 0 else '1' for i in range(len(S))])
x = str(int(S) + int(T)).count('1')
print(min(x, len(S) - x))

Solution (Python):
S_str=input()
S=int(S_str,2)

test_str=""
for i in range(len(S_str)):
  if i%2==0:
    test_str=test_str+"1"
  elif i%2==1:
    test_str=test_str+"0"

test_bin=int(test_str,2)
result_bin=bin(S ^ test_bin)

print(min(result_bin.count("1"),len(S_str)-result_bin.count("1")))

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

BW = 0
WB = 0

for i in range(len(N)):
  if int(N[i]) == i % 2:
    BW += 1
  else:
    WB += 1

print(min(BW, WB))

Solution (Python):

s = input()


bw = 0
wb = 0


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


print(min(bw, wb))

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

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

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

Solution (Python):
s=list(input())
cnt=0
for i in range(len(s)-1):
    if int(s[i])==int(s[i+1])==0:
        s[i+1]="1"
        cnt+=1
    elif int(s[i])==int(s[i+1])==1:
        s[i+1]="0"
        cnt+=1
print(cnt)

Solution (Python):
s=input()

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

Solution (Python):
S=input()
count=0
c=""
for s in S:
    if s!=c:
        c=s
    else:
        count+=1
        if s=="0":c="1"
        else:c="0"
print(count)

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

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

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

    print(ans)


resolve()

Solution (Python):
s=list(input())
n=len(s)
ans1=0
for i in range(n):
    if i%2==0 and s[i]=='0':
        ans1+=1
    elif i%2 == 1 and s[i]=='1':
        ans1+=1
ans2=0
for i in range(n):
    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):
S=list(input())
def zeroone(X,st,nx):
  out=0
  for i in range(len(X)):
    if i%2==0:
      if X[i]!=st:
        out+=1
    else:
      if X[i]!=nx:
        out+=1
        
  return out

ans1=zeroone(S,"1","0")
ans2=zeroone(S,"0","1")
ans=min(ans1, ans2)
print(ans)

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:
		if S[i]!='1':
			ans1+=1
for i in range(len(S)):
	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()
oi = 0
io = 0
for i in range(len(s)):
    if s[i]=='1':
        oi += i%2
        io += (i+1)%2
    else:
        io += i%2
        oi += (i+1)%2
print(min(oi,io))

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

p = ["0", "1"]
f = 1
ans = [0, 0]

for i in s:
    if (p[f] != i):
        ans[0] += 1
    else:
        ans[1] += 1
    f ^= 1

print(min(ans))

Solution (Python):
s=[int(i) for i in input()]
ans=0
for i in range(1,len(s)):
	ans+=s[~-i]==s[i]
	s[i]=not s[~-i]
print(ans)

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

Solution (Python):
S = input()
C = ["0","1"] 
count1=count2=0

for i in range(len(S)):
  
  if S[i] == C[i%2]:
    count1+=1
  
  if S[i] == C[(i+1)%2]:
    count2+=1

print(min([count1, count2]))

Solution (Python):
s=input()
a=[]
b=[]
for i in range(len(s)):
    if i%2==0:
        a.append('0')
    else:
        a.append('1')
for j in range(len(s)):
    if j%2==1:
        b.append('0')
    else:
        b.append('1')
ans1=0
ans2=0
for k in range(len(a)):
    if a[k]!=s[k]:
        ans1+=1
for z in range(len(b)):
    if b[z]!=s[z]:
        ans2+=1
print(min(ans1,ans2))

Solution (Python):
import copy

s = list(input())

s2 = s.copy()

cnt1 = 0
cnt2 = 0

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



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


print(min(cnt1, cnt2))

Solution (Python):
s = input()
even = []
odd = []
for i in range(len(s)):
    if i % 2 == 0:
        even.append(s[i])
    else:
        odd.append(s[i])
a,b = even.count('0'),even.count('1')
c,d = odd.count('0'),odd.count('1')
print(min(a+d,b+c))

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

if len(S) == 1:
    print(0)
else:
    s = list(S_int)
    def reverse_count(s, initial):
        count = 0
        c = initial
        for i in range(len(s)):
            if s[i] != c:
                count += 1
            c = (c + 1) % 2
        return count
        
    
    print(min(reverse_count(s, 0), reverse_count(s, 1)))

Solution (Python):
def main():
    s = list(map(int, input()))
    
    
    ans_0 = 0
    
    ans_1 = 0
    
    for i in range(len(s)):
        if i % 2 == 0 and s[i] != 0:
            ans_0 += 1
        elif i % 2 == 1 and s[i] != 1:
            ans_0 += 1
        if i % 2 == 0 and s[i] != 1:
            ans_1 += 1
        elif i % 2 == 1 and s[i] != 0:
            ans_1 += 1
    print(min(ans_0, ans_1))
        
   
    
if __name__ == '__main__':
    main()

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

Solution (Python):
s = input()
ls = len(s)
o0 = s[::2].count('0')
e0 = s[1::2].count('0')
if e0>=o0:
    print(ls//2-e0 + o0)
elif ls%2!=0:
    print(ls//2+1-o0 + e0)
else:
    print(ls//2-o0 + e0)

Solution (Python):
s=input()
a=int('0b'+s, 0)
b=int('0b'+''.join(['0' if i%2==0 else '1' for i in range(len(s))]), 0)
c=b^int('0b'+'1'*len(s), 0)
print(min(bin(a^b).count('1'),bin(a^c).count('1')))

Solution (Python):
S=input()
total1=0
total2=0
for i in range(len(S)):
    if i%2==0:
        if S[i]=="1":
            total1+=1
    elif i%2==1:
        if S[i]=="0":
            total1+=1
for i in range(len(S)):
    if i%2==0:
        if S[i]=="0":
            total2+=1
    elif i%2==1:
        if S[i]=="1":
            total2+=1
print(min(total1,total2))

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


count_1 = 0
count_2 = 0
for i in range(len(S)):
  
  if i % 2 == 0:
    if S[i] == '1':
      count_1 += 1
  elif S[i] == '0':
    count_1 += 1
  
  
  if i % 2 == 0:
    if S[i] == '0':
      count_2 += 1
  elif S[i] == '1':
    count_2 += 1
    
print(min(count_1, count_2))

Solution (Python):
s=input()
INF=10**5
ans=INF
for i in range(2):
	tmp=0
	c=i
	for j in range(len(s)):
		if s[j]!=str(c):
			tmp+=1
		c^=1
	ans=min(ans,tmp)
print(ans)

Solution (Python):
zero_first = 0
one_first = 0
for i, c in enumerate(input()):
    if i % 2 == 0 and c == '0' or i % 2 == 1 and c == '1':
        zero_first += 1
    else:
        one_first += 1
print(min(zero_first, one_first))

Solution (Python):
s = input()
o1 = s[::2].count('1')
o0 = s[::2].count('0')
e1 = s[1::2].count('1')
e0 = s[1::2].count('0')
print(min(o0 + e1, o1 + e0))

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

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

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

case1 =""
case2 =""

for i in range(len(S)):
    if i%2==0:
        case1 += "0"
        case2 += "1"
    else:
        case1 += "1"
        case2 += "0"
    
    
c1 = 0
c2 = 0
    
for i in range(len(S)):
    
    if S[i] != case1[i]:
        c1 +=1
    
    if S[i] != case2[i]:
        c2+=1
    
print(min(c1,c2))

Solution (Python):
import numpy as np
s=np.array(list(map(int,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))]

a=np.array(a)
b=np.array(b)

c=s-a
d=s-b

print(min(np.count_nonzero(c!=0),np.count_nonzero(d!=0)))

Solution (Python):
S = input()

a,b = 0,0
for i,c in enumerate(S):
  if i % 2 == 0:
    if c == '1':
      a += 1
    else:
      b += 1
  else:
    if c == '0':
      a += 1
    else:
      b += 1

print(min(a,b))

Solution (Python):
S=input()
c=S[::2].count("0")+S[1::2].count("1")
print(min(c,len(S)-c))

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

cnt = 0
a = S[0]

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

Solution (Python):
def resolve():
    S = input()
    Si = int(S, base=2)
    pt1 = int("".join([str(i % 2) for i in range(len(S))]), base=2)
    pt2 = int("".join([str(i % 2) for i in range(1, len(S) + 1)]), base=2)
    print(min(bin(Si ^ pt1)[2:].count("1"), bin(Si ^ pt2)[2:].count("1")))


resolve()

Solution (Python):
S = '0b' + input()
s1 = '0b' + '10' * (len(S) // 2 - 1) + '1' * (len(S) % 2)
s2 = '0b' + '01' * (len(S) // 2 - 1) + '0' * (len(S) % 2)
Ss1 = bin(int(S, 2) ^ int(s1, 2))[2:]
Ss2 = bin(int(S, 2) ^ int(s2, 2))[2:]
print(min(sum([1 for x in Ss1 if int(x)]), sum([1 for x in Ss2 if int(x)])))

Solution (Python):
import copy
s_l = list(input())
s_r = copy.copy(s_l)
s_r.reverse()
left = 0
right = 0

if len(s_l) == 1:
    print(0)
elif len(s_l) == 2:
    if s_l[0] == s_l[1]:
        print(0)
    else:
        print(1)
else:
    for i in range(len(s_l)-1):
        if s_l[i] == "0":
            if s_l[i+1] == "0":
                s_l[i+1] = "1"
                left += 1
        else:
            if s_l[i+1] == "1":
                s_l[i+1] = "0"
                left += 1
        if s_r[i] == "0":
            if s_r[i+1] == "0":
                s_r[i+1] = "1"
                right += 1
        else:
            if s_r[i+1] == "1":
                s_r[i+1] = "0"
                right += 1
    print(min(left,right))

Solution (Python):
s = input()
check = True
count = 0
for i in s:
    if check:
        if i != "0":
            count += 1
    else:
        if i != "1":
            count += 1
    check = not check
check = False
count2 = 0
for i in s:
    if check:
        if i != "0":
            count2 += 1
    else:
        if i != "1":
            count2 += 1
    check = not check
print(min(count, count2))

Solution (Python):

from copy import copy
import sys
input = sys.stdin.readline
S =[int(i) for i in input().strip()]
S2 =S.copy()
count =0
for i in range(len(S) -1):
    if S[i] ==S[i+1]:
        S[i+1] =(S[i+1] +1)%2
        count +=1

count2 =0
for i in range(len(S2)-1,0, -1):
    if S2[i] ==S2[i-1]:
        S2[i-1] =(S2[i-1] +1)%2
        count2 +=1
print(min(count,count2))

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

Solution (Python):
S = input()
C = ["0","1"] 
count1=count2=0

for i in range(len(S)):
  
  if S[i] == C[i%2]:
    count1+=1
  
  if S[i] == C[(i+1)%2]:
    count2+=1

print(min([count1, count2]))

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

Solution (Python):
s = input()
n = len(s)
count1 = 0
count2 = 0
for i in range(n):
    if i%2 == 0:
        if s[i] == "1":
            count2 += 1
        elif s[i] == "0":
            count1 += 1
    if i%2 != 0:
        if s[i] == "0":
            count2 += 1
        elif s[i] == "1":
            count1 += 1
print(min(count1, count2))