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 = str(input())
l = len(s)
a = 0

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

print(a)

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

if N % 2 == 0:
    s1 = "10"*int(N/2)
    s2 = "01"*int(N/2)
    c1 = 0
    c2 = 0
    for i,j,k in zip(S,s1,s2):
        if i != j:
            c1 += 1
        elif i != k:
            c2 += 1
        else:
            continue

    print(min(c1,c2)) 

else:
    s1 = "10"*int(N//2) + "1" 
    s2 = "01"*int(N//2) + "0"
    c1 = 0
    c2 = 0

    for i,j,k in zip(S,s1,s2):
        if i != j:
            c1 += 1
        elif i != k:
            c2 += 1
        else:
            continue

    print(min(c1,c2))

Solution (Python):
S = input()

counter = 0

sa = []
sb = []

for i in  range(len(S)):
  if i %2 ==0:
    sa.append(S[i])
  else:
    sb.append(S[i])

sa_0 = sa.count('0')
sa_1 = sa.count('1')
sb_0 = sb.count('0')
sb_1 = sb.count('1')
if sa_0 +sb_1 >= sa_1 +sb_0:
  counter = sa_1 +sb_0
else:
  counter = sa_0 + sb_1
  
print(counter)

Solution (Python):
def main():
    li = list(map(int, input()))
    option_0 = []
    option_1 = []
    count_0 = 0
    count_1 = 0

    
    for i in range(len(li)):
        if i%2 == 0:
            option_0.append(0)
            option_1.append(1)
        else:
            option_0.append(1)
            option_1.append(0)
    
    
    
    for i in range(len(li)):
        if option_0[i] != li[i]:
            count_0 += 1
        if option_1[i] != li[i]:
            count_1 += 1

    print(min(count_0, count_1))

if __name__ == '__main__':
    main()

Solution (Python):



n = str(input())
l1 = []
for c in n:
	l1.append(c)

z, o = '0', '1'

one, zero = [], []

for i in range(len(l1)):
	if i%2 == 0:
		one.append(o)
		zero.append(z)
	else:
		one.append(z)
		zero.append(o)

c1, c2 = 0,0
for i in range(len(l1)):
	if l1[i] == one[i]:
		c1 += 1
	if l1[i] == zero[i]:
		c2 += 1

ans = min(c1, c2)
print(ans)

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

o1 = "10" * (n // 2) + "1" * (n % 2 == 1)
o2 = "01" * (n // 2) + "0" * (n % 2 == 1)

count1 = 0
count2 = 0
for i in range(n):
	if s[i] != o1[i]:
		count1 += 1
	if s[i] != o2[i]:
		count2 += 1
		
print(min(count1,count2))

Solution (Python):
S=list(input())
count = 0
for i in range(len(S)-1):
    if len(set(S[i:i+2])) == 1:
        if S[i+1] == '1':
            S[i+1] = '0'
        else:
            S[i+1] = '1'
        count += 1
print(count)

Solution (Python):
s = input()
s_bin = bin(int(s, 2))

text_10 = ''
text_01 = ''

for i in range(len(s)):
    j = i % 2
    k = (i + 1) % 2
    text_10 += str(j)
    text_01 += str(k)

x = bin(int(s, 2) ^ int(text_10, 2)).count("1")
y = bin(int(s, 2) ^ int(text_01, 2)).count("1")

print(min(x, y))

Solution (Python):
T = input()
S = [int(x) for x in list(str(T))]

if len(S) == 1:
    print(0)
elif len(S) == 2:
    print(1 - (S[0] + S[1]) % 2)
else:
    n = len(S)
    S_1 = [0] + S
    S_2 = [1] + S
    num_1 = 0
    num_2 = 0

    for i in range(n):
        if int(S_1[i]) == int(S_1[i+1]) == 0:
            S_1[i+1] = 1
            num_1 += 1
        elif S_1[i] == S_1[i+1] == 1:
            S_1[i+1] = 0
            num_1 += 1
    
    for i in range(n):
        if S_2[i] == S_2[i+1] == 0:
            S_2[i+1] = 1
            num_2 += 1
        elif S_2[i] == S_2[i+1] == 1:
            S_2[i+1] = 0
            num_2 += 1       
    print(min(num_1, num_2))

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    ans0 = 0
    for i in range(len(S)):
        if i % 2 == 0 and S[i] != '0':
            ans0 += 1
        if i % 2 == 1 and S[i] != '1':
            ans0 += 1
    ans1 = 0
    for i in range(len(S)):
        if i % 2 == 0 and S[i] != '1':
            ans1 += 1
        if i % 2 == 1 and S[i] != '0':
            ans1 += 1
    return min(ans1, ans0)


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Solution (Python):
n = input()
answer = 0
if len(n)<=1:
    pass
else:
    for i in range(1,len(n)):
        if n[i]==n[i-1]:
            answer+=1
            if n[i]=='0':
                n = n[:i]+'1'+n[i+1:]
            else:
                n = n[:i]+'0'+n[i+1:]

print(answer)

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

if S_len % 2 :
	E = '1' + '01'*(S_len//2)
else :
	E = '10'*(S_len//2)

E = int(E, 2)
num = format(S ^ E, 'b').count('1')
ans = min(num, S_len - num)
print(ans)

Solution (Python):
S=list(input())
A=[]
B=[]
countA=0
countB=0
for i in range(0,len(S)):
  if i%2==0:
    A.append('1')
    B.append('0')
  else:
    A.append('0')
    B.append('1')
for i in range(0,len(S)):
  if S[i]!=A[i]:
    countA+=1
for i in range(0,len(S)):
  if S[i]!=B[i]:
    countB+=1
if countA>=countB:
  print(countB)
else:
  print(countA)

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

ans1 = 0
ans2 = 1

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

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

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

print(ans1 if ans1 <= ans2 else ans2)

Solution (Python):
import numpy as np
S = list(str(input()))
S = [int(s) for s in S]
S = np.array(S)
n = len(S)

N1 = np.zeros(n)
N2 = np.zeros(n)
N1[0::2] = 1
N2[1::2] = 1

a = N1 + S
a_num = np.sum(a[np.where(a == 1)])
b = N2 + S
b_num = np.sum(b[np.where(b == 1)])
print(int(min(a_num, b_num)))

Solution (Python):
S = input()

length_S = len(S)

S_check = []

count = 0

for i in range(length_S):
  if i % 2 == 0:
    S_check.append("0")
  else:
    S_check.append("1")

for i in range(length_S):
  if S[i] == S_check[i]:
    count += 1

print(min(count, length_S-count))

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

le=len(S)
counter=0

for i in range(0,le-1):
    if S[i]==S[i+1]:
        if S[i+1] =='0':
            S[i+1] ='1'
        else:
            S[i+1] ='0'
        counter=counter+1
print(counter)

Solution (Python):
pat = input()
if len(pat) == 1:
    print(0)            
else:
    
    pat1 = "0"
    pat2 = "1"

    for i in range(len(pat)-1):
        if pat1[-1:]=="0":
            pat1 = pat1+"1"
        else:
            pat1 = pat1+"0"
        
    for i in range(len(pat)-1):
        if pat2[-1:]=="0":
            pat2 = pat2+"1"
        else:
            pat2 = pat2+"0"

    count1 = 0
    count2 = 0
    for s in range(len(pat)):
        if pat[s] != pat1[s]:
            count1 = count1 + 1

        if pat[s] != pat2[s]:
            count2 = count2 + 1


    if count1 <= count2:
        print(count1)

    else:
        print(count2)

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

Solution (Python):
s = list(input())
pattern_a_count = 0
pattern_b_count = 0


for index, value in enumerate(s):
  if index % 2 == 0:
    if value == "0":
      pattern_a_count += 1
  if index % 2 == 1:
    if value == "1":
      pattern_a_count += 1


for index, value in enumerate(s):
  if index % 2 == 0:
    if value == "1":
      pattern_b_count += 1
  if index % 2 == 1:
    if value == "0":
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(res)

Solution (Python):
str=input()
n=len(str)
evenzero=0
evenone=0
oddzero=0
oddone=0
count=0
for x in range(n):
    if x%2==0:
        if str[x]=="0":
            evenzero +=1
        else:
            evenone +=1
    else:
        if str[x]=="0":
            oddzero +=1
        else:
            oddone +=1

t=max(evenzero+oddone,evenone+oddzero)

if t==evenzero+oddone:
    for x in range(n):
        if x % 2 == 0:
            if str[x] != "0":
                count += 1
        else:
            if str[x] != "1":
                count += 1
elif t==evenone+oddzero:
    for x in range(n):
        if x % 2 == 0:
            if str[x] != "1":
                count += 1
        else:
            if str[x] != "0":
                count += 1

print(count)

Solution (Python):
a = list(str(input()))
counter = 0
if len(a) == 1:
    counter = 0
else:
    for i in range(1,len(a)):
        if a[i] == a[i-1]:
            if a[i-1] == '0':
                a[i] = '1'
            else:
                a[i] = '0'     
            counter = counter + 1
print(counter)

Solution (Python):
s=input()
ans0=0
ans1=0

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

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


print(min(ans0,ans1))

Solution (Python):
ls=list(input())
ls1=['0','1']
ls2=['1','0']
a=int(len(ls)/2)
ls1=ls1*a
ls2=ls2*a

b=0
c=0
if len(ls)%2 == 1:
    ls1.append('0')
    ls2.append('1')


for i in range(len(ls)):
    if ls[i]==ls1[i]:
        b=b+1
    if ls[i] == ls2[i]:
        c=c+1
ans=min([b,c])
print(ans)

Solution (Python):


ss = input()


s = []
for i in range(len(ss)):
    s.append(int(ss[i]))


if len(s)%2 == 0:
    s0 = [0,1] *(len(s)//2)
    s1 = [1,0] *(len(s)//2)
else:
    s0 = [0,1] *(len(s)//2)
    s0.append(0)
    s1 = [1,0] *(len(s)//2)
    s1.append(1)




sum0 = 0
sum1 = 0
for i in range(len(s)):
    
    if s0[i] != s[i]:
        
        sum0 = sum0 +1

    if s1[i] != s[i]:
        
        sum1 = sum1 +1

ans = min(sum0, sum1)
print(ans)

Solution (Python):
N = "0b" + input()
M = "0b" + "1"*(len(N)-2)
a = int(N, 0)^int(M, 0)
if len(N) % 2 == 0:
    K = "0b"+"10"*((len(N)-2)//2) 
else:
    K = "0b"+"10"*((len(N)-2)//2)+"1" 
uK = bin(int(K, 0)^int(M, 0)) 
q = bin(int(N, 0)^int(K, 0))
w = bin(int(N, 0)^int(uK, 0))
q = q[2:]
w = w[2:]
print(min(w.count("1"), q.count("1")))

Solution (Python):
s = input()
l=len(s)
s1=0
s0=0
l0=[]
l1=[]
for i in range(l):
    l0.append(str(i%2))
    l1.append(str((i+1)%2))
l0="".join(l0)
l1="".join(l1)
for i in range(l):
    if(l1[i]!=s[i]):
        s1=s1+1
    if(l0[i]!=s[i]):
        s0=s0+1
print(min(s0,s1))

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

counter = 0

for num in range(len(S)-1):
  if num == len(S):
    break
  if S[num] == S[num+1]:
    counter += 1
    if S[num+1] == '0':
      S[num+1] = '1'
    else:
      S[num+1] = '0'

print(counter)

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

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

Solution (Python):
s = list(map(int,list(input())))
a = 0
b = 1
counta = 0
countb = 0
for binary in s:
    if binary != a:
        counta += 1
    a += 1
    if a == 2:
        a = 0
for binary in s:
    if binary != b:
        countb += 1
    b += 1
    if b == 2:
        b = 0
print(counta if counta < countb else countb)

Solution (Python):
s=input()
ls=[c for c in s]
ct=0
j=0
for i in range(len(ls)):
    if ls[i]==ls[j]:
        if (i-j)%2!=0 and i-j!=0 and i-j!=1 and i!=len(ls)-1:
            ct+=int((i-j-1)/2)+1
            ls[i]=ls[j+1]
            j=i
        elif (i-j)%2!=0 and i-j!=0 and i-j!=1 and i==len(ls)-1:
            
            ct+=int((i-j-1)/2-1)
        elif (i-j)%2==0 and i-j!=0 and i-j!=2:
            ct+=int((i-j)/2-1)
            j=i
            
        elif i-j==1:
            ct+=1
            if ls[i]=='0':
                ls[i]='1'
            else:
                ls[i]='0'
            j=i
        elif i-j==2:
            j=i
            
        else:pass
if j<len(ls)-2:
    if (len(ls)-1-j)%2==0:
        ct+=int((len(ls)-1-j)/2)
    else:
        ct+=int((len(ls)-2-j)/2)
print(ct)

Solution (Python):
def main():
	S = input()
	start0 = "0"
	ans0 = 0
	ans1 = 0
	for i, c in enumerate(S):
		if i % 2 == 0:
			if c != start0:
				ans1 += 1
			else:
				ans0 += 1
		else:
			if c != start0:
				ans0 += 1
			else:
				ans1 += 1
	print(min(ans0, ans1))

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
A =[int(c) for c in s]

a = 0
b = 0
for i in range(len(A)):
    if A[i] != i % 2:
        a += 1
    else:
        b += 1

if a < b:
    print(a)
else:
    print(b)

Solution (Python):
S = list(input())
N = len(S)
k = 0
l = 0

for i in range(N):
	if i % 2 == 0:
		if int(S[i]) == 0:
			k += 0
		else:
			k += 1
	else:
		if int(S[i]) == 1:
			k += 0
		else:
			k += 1

for i in range(N):
	if i % 2 == 0:
		if int(S[i]) == 1:
			l += 0
		else:
			l += 1
	else:
		if int(S[i]) == 0:
			l += 0
		else:
			l += 1
            
print(min(k,l))

Solution (Python):
import numpy as np

num = np.array([i=="1" for i in input()])
s_1 = np.array([i%2==0 for i in range(len(num))])
s_0 = np.array([i%2==1 for i in range(len(num))])







r_1 = np.sum(s_1 == num)
r_0 = np.sum(s_0 == num)
print(min(r_0, r_1))

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

Solution (Python):
S = list(input())
S2 = S[:]
now = S[0]
ans = 0
ans2 = 0
for i in range(len(S)-1):
  if now == "1":
    if S[i+1] == "0":
      now = "0"
    else:
      ans += 1
      now = "0"
      S[i+1] = "0"
  else:
    if S[i+1] == "1":
      now = "1"
    else:
      ans += 1
      now = "1"
      S[i+1] = "1"
S2.reverse()
now = S2[0]
for i in range(len(S2)-1):
  if now == "1":
    if S2[i+1] == "0":
      now = "0"
    else:
      ans2 += 1
      now = "0"
      S2[i+1] = "0"
  else:
    if S2[i+1] == "1":
      now = "1"
    else:
      ans2 += 1
      now = "1"
      S2[i+1] = "1"
print(min(ans, ans2))

Solution (Python):
s = input()
n = len(s)
if n % 2 == 1:
    n += 1
pattern = '01' * ((n + 10) // 2)

ans_a = 0
ans_b = 0
for i, (a, b, ss) in enumerate(zip(pattern[1:], pattern[:-1], s)):
    if ss != a:
        ans_a += 1
    if ss != b:
        ans_b += 1
print(min(ans_a, ans_b))

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

result = 0



tempChangedTile = S[0]

for index, tile in enumerate(S):
    
    try:
        if tempChangedTile != S[index+1]:
            tempChangedTile = S[index+1]
            
            
        else:
            
            
            result += 1
            if S[index + 1] == "0":
                tempChangedTile = "1"
            else:
                tempChangedTile = "0"
    except:
        pass

print(result)

Solution (Python):
s = input()
a,b = 0,0

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

print(min(a,b))

Solution (Python):
N = input()

length = len(N)

ans1 = ''
ans2 = ''

for i in range(length):
    if i % 2 == 0:
        ans1 = ans1 + "1"
        ans2 = ans2 + "0"
    else:
        ans1 = ans1 + "0"
        ans2 = ans2 + "1"

count1 = 0
count2 = 0



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

    if N[i] != ans2[i]:
        count2 = count2 + 1

print(min(count1,count2))

Solution (Python):
s = input()
s = [int(i) for i in s]
n = len(s)
start_one = []
start_zero = []
for i in range(n):
    if i % 2 == 0:
        start_one.append(1)
        start_zero.append(0)
    else:
        start_one.append(0)
        start_zero.append(1)
count_one = 0
count_zero = 0
for i in range(n):
    if s[i] != start_one[i]:
        count_one += 1
    elif s[i] != start_zero[i]:
        count_zero += 1
ans = min(count_one, count_zero)
print(ans)

Solution (Python):
s =list(input())
g_s = s[0::2]
k_s = s[1::2]
g_zero = g_s.count('0')
k_zero = k_s.count('0')
if g_zero > k_zero:
  print(k_zero + len(g_s)-g_zero) 
else:
  print(g_zero+ len(k_s)-k_zero)

Solution (Python):
import collections
S = list(input())
S_g = [S[i] for i in range(len(S)) if i%2 == 0]
S_k = [S[i] for i in range(len(S)) if i%2 != 0]

S_g_count = collections.Counter(S_g)
S_k_count = collections.Counter(S_k)

S_g_count = sorted(S_g_count.items(),key = lambda x:x[1],reverse=True)
S_k_count = sorted(S_k_count.items(),key = lambda x:x[1],reverse=True)

count = 0
if len(S_g_count) == 0 or len(S_k_count) == 0:
  print(0)
  exit()
if len(S_g_count) == 2 and len(S_k_count) == 2:
  if S_g_count[0][0] != S_k_count[0][0]:
    count = len(S_g)-S_g_count[0][1] + len(S_k)-S_k_count[0][1]
  else:
    if S_k_count[0][1] >= S_g_count[0][1]:
      count = len(S_k)-S_k_count[0][1] + len(S_g)-S_g_count[1][1]
    else:
      count = len(S_g)-S_g_count[0][1] + len(S_k)-S_k_count[1][1]
elif len(S_g_count) == 1 and len(S_k_count) == 1:
  if S_g_count[0][0] == S_k_count[0][0]:
    count = min(S_g_count[0][1],S_k_count[0][1])
  else:
    count = 0
else:
  if len(S_g_count) == 1:
    if S_g_count[0][0] == S_k_count[0][0]:
      count = len(S_k) - S_k_count[1][1]
    else:
      count = len(S_k) - S_k_count[0][1]
  else:
    if S_k_count[0][0] == S_g_count[0][0]:
      count = len(S_g) - S_g_count[1][1]
    else:
      count = len(S_g) - S_g_count[0][1]
print(count)

Solution (Python):



s = input().rstrip()

if s == "0" or s == "1":
    print("0")
    exit()

length = len(s)

shou = length // 2
amari = length % 2
a = "10"*shou
b = "01"*shou
if amari == 1:
    a = a + "1"
    b = b + "0"

bins = int(s,2)
bina = int(a,2)
binb = int(b,2)

saxor = bin(bina ^ bins)
sbxor = bin(binb ^ bins)

saxor_cnt1 = sum(map(int, str(saxor.lstrip("0b"))))
sbxor_cnt1 = sum(map(int, str(sbxor.lstrip("0b"))))

out = min (saxor_cnt1, sbxor_cnt1)

print(out)

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

len_val = len(list_input)
ans_a = []
ans_b = []

a_count = 0
b_count = 0

for i in range(len_val):

    ans_a.append(i%2)
    ans_b.append((i+1)%2)

for i in range(len_val):
    if ans_a[i] == list_input[i]:
        b_count += 1
    else:
        a_count += 1

if a_count >= b_count:
    print(b_count)
else:
    print(a_count)

Solution (Python):
S = [digit for digit in input()]
s_len = len(S)

pattern1 = [str(i % 2) for i in range(s_len)]
pattern2 = [str(1) if i % 2 == 0 else str(0) for i in range(s_len)]


def get_diff_num(pattern, compared):
    diff_num = 0
    for p, c in zip(pattern, compared):
        if not p == c:
            diff_num += 1
    return diff_num

p1_diff = get_diff_num(pattern1, S)
p2_diff = get_diff_num(pattern2, S)
print(min(p1_diff, p2_diff))

Solution (Python):
S = input()
N = len(S)
cnt_0 = 0
cnt_1 = 0

for i in range(N):
    if i%2 != int(S[i]):
        cnt_0 += 1
    else:
        cnt_1 += 1

print(min(cnt_0, cnt_1))

Solution (Python):
ta=list(input())
sz=len(ta)
ans0=0
ans1=0
ans=0
for i in range(sz):
    if(i%2==0):
        if(ta[i]=="0"):
            ans0=ans0+1
    else:
        if(ta[i]=="1"):
            ans0=ans0+1
for i in range(sz):
    if(i%2==0):
        if(ta[i]=="1"):
            ans1=ans1+1
    else:
        if(ta[i]=="0"):
            ans1=ans1+1
ans+=min(ans0,ans1)
print(ans)

Solution (Python):
def gene(n,leng):
    r = []
    for i in range(leng):
        r.append(n)
        n = 1 - n
    return r

def nuri(lis):
    zerone = gene(0,len(lis))
    zo = 0
    onezero = gene(1,len(lis))
    oz = 0

    for i in range(len(lis)):
        if zerone[i] != lis[i]:
            zo += 1
        if onezero[i] != lis[i]:
            oz += 1
    if zo < oz:
        ans = zo
    else:
        ans = oz
    return ans

        

tyle = list(input())
tyle = [int (i) for i in tyle]
print(nuri(tyle))

Solution (Python):
master = list(input())
change = 0
cn = 0
cn_r = 0
l = master.copy()
r = master.copy()
for i in range(len(l)-1):
    if l[i] == l[i+1]:
        if l[i] == "0":
            change = "1"
        else:
            change = "0"
        l[i+1] = change
        cn += 1
for i in reversed(range(1,len(l))):
    if r[i] == r[i-1]:
        if r[i] == "0":
            change = "1"
        else:
            change = "0"
        r[i-1] = change
        cn_r += 1

print(min(cn,cn_r))

Solution (Python):
import numpy

s = list(input())
N = len(s)
count_A = 0
count_B = 0

for i in range(N):
    s[i] = int(str(s[i]))

A = numpy.empty(N)
B = numpy.empty(N)

for j in range(N):
    if j % 2 == 0 :
        A[j] = 1
        B[j] = 0
    else:
        A[j] = 0
        B[j] = 1

for k in range(N):
    A[k]=s[k]-A[k]
    B[k]=s[k]-B[k]
    if A[k] != 0:
        count_A = count_A + 1
    if B[k] != 0:
        count_B = count_B + 1

if count_A > count_B :
    print(count_B)
else :
    print(count_A)

Solution (Python):
s = []
S = input()

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

sum = 0
for i in range(len(S)):
    s.append(S[i])

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

print(sum)

Solution (Python):
s = input()
lists = []
for i in s:
    lists.append(i)

preword = lists[0]
count = 0
for i in range(1,len(lists)):
    if lists[i] == preword:
        count += 1
        if lists[i] == "0":
            preword = "1"
        else:
            preword = "0"
    else:
        preword = lists[i]

print(count)

Solution (Python):



s = input()

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

n = len(s)
c = 0

base = s[0]

for i in range(1, n):

    if s[i] == base:
        c += 1
        if s[i] == '0':
            base = '1'
        else:
            base = '0'
        
        continue
    
    base = s[i]

print(c)

Solution (Python):
import numpy as np
S = input()
l = len(S)
n = list(map(int, str(S)))
a = np.arange(l) 
b = np.where(a%2==0, 0, 1) 
c = np.where(a%2==1, 0, 1) 
bool1 = np.logical_xor(n, b)
bool2 = np.logical_xor(n, c)

count1 = np.sum(bool1)
count2 = np.sum(bool2)

if count1 < count2:
    print(count1)
else:
    print(count2)

Solution (Python):
import sys

num=input()
L=len(num)
count=0

if L == 1 :
    print(0)
    sys.exit()

for i in range(L):
    flg=False
    if num[i] == num[i+1]:
        count+=1
        flg=True

    if i+1 == L-1 :
        break
    
    if flg == True:
        if num[i] == '0':
            num_CHG = num[:i+1] + '1'+ num[i+2:]
            num = num_CHG
        else:
            num_CHG = num[:i+1] + '0'+ num[i+2:]
            num = num_CHG
print(count)

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

t1 = [0,1]
t2 = [1,0]
num1 = num2 = 0
for i in range(n):
    tmp = i%2
    num1 += abs(int(s[i]) - t1[tmp])
    num2 += abs(int(s[i]) - t2[tmp])

if num1 >= num2:
    print(num2)
else:
    print(num1)

Solution (Python):


if __name__ == "__main__":
    S = input()
    N = len(S)
    if S[0] == "0":
        Sn = [int(S[n]) for n in range(N)]
    else:
        Sn = [(int(S[n])+1)%2 for n in range(N)]

    total0 = 0
    total1 = 0

    
    for n in range(N):
        
        if Sn[n] != n%2:
            total0 += 1
    
    for m in range(N):
        
        if Sn[m] != (m+1)%2:
            total1 += 1

    print(min(total0, total1))

Solution (Python):

m=input()
round = len(m)

n = 0

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

if n>round/2:
    print(round-n)
else:
    print(n)

Solution (Python):
from sys import stdin
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
import bisect
import heapq

rs = lambda: stdin.readline().strip()
ri = lambda: int(rs())
rsl = lambda: stdin.readline().split()
rim = lambda: map(int, rsl())
ril = lambda: list(rim())


s = rs()
one_even = []
one_odd = []
for i, char in enumerate(s):
    if i % 2 == 0 and char == '1':
        one_even.append(True)
    elif i % 2 == 1 and char == '0':
        one_even.append(True)
    else:
        one_even.append(False)

for i, char in enumerate(s):
    if i % 2 == 1 and char == '1':
        one_odd.append(True)
    elif i % 2 == 0 and char == '0':
        one_odd.append(True)
    else:
        one_odd.append(False)

one_even.sort()
one_odd.sort()
index1 = 0
for i, boolean in enumerate(one_even):
    if boolean:
        index1 = i
        break

index2 = 0
for i, boolean in enumerate(one_odd):
    if boolean:
        index2 = i
        break

print(min(index1, index2))

Solution (Python):
import sys


st = input()
fl = [ int(x) for x in st]

N = len(st)


sgn = 1


fl_sum = [0.0, 0.0]
len_sum = [0, 0]

for i in range(N):
  sgn = int(sgn - (-1)**float(i)) 
  fl_sum[sgn] += fl[i]
  len_sum[sgn] += 1




if fl_sum[0] <= fl_sum[1]:
  x = 0
  y = 1
else:
  x = 1
  y = 0

num = int(fl_sum[x] + (len_sum[y] - fl_sum[y]))
print(num)

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

s = S + ['\n']

sl = len(s)

count = 0
limit = sl // 2 + 1
for i in range(1, sl):
    if s[i-1] == s[i]:
        count += 1
        if s[i-1] == '0':
            s[i] = '1'
        else:
            s[i] = '0'
    if count > limit:
        break

if count > limit:
    count = 0
    s = ['\n'] + S
    for i in range(1, sl):
        ind = -1 * (i+1)
        if s[-1 * i] == s[ind]:
            count += 1
            if s[ind] == '0':
                s[ind] = '1'
            else:
                s[ind] = '0'

print(count)

Solution (Python):


a= input()
c=0
for i in range(len(a)):
    if i==0:
        if a[i]=='0':
            flag=True
        else:
            flag=False
    else:
        if a[i]=='0' and flag==True:
            c+=1
            flag=False
        elif a[i]=='0' and flag==False:
            pass
            flag=True
        elif a[i]=='1' and flag==True:
            pass
            flag=False
        elif a[i]=='1' and flag==False:
            c+=1
            flag=True
                
print(c)

Solution (Python):
s=input()
num_st=[0,0]
for i, c in enumerate(list(s)):
	if int(c) == i % 2:
		num_st[0]+=1
	else:
		num_st[1]+=1

ret = min(num_st)
print(int(ret))

Solution (Python):

S = list(input())
result = 0

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

print(result)

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

if len(S_) == 0: 
    ans = 0
    
elif S_[0] == 1:
    r, l = 0, 1 
    ans = 0
    while l < len(S_):
        
        if S_[r] > S_[l]:
            r += 1
            l += 1
        elif S_[r] == S_[l]:
            if S_[l-1] == 1:
                S_[l] = 0
                r += 1
                l += 1
                ans += 1
            else:
                S_[l] = 1
                r += 1
                l += 1
                ans += 1
        else:
            r += 1
            l += 1

elif S_[0] == 0:
    r, l = 0, 1 
    ans = 0
    while l < len(S_):
        if S_[r] < S_[l]:
            r += 1
            l += 1
        elif S_[r] == S_[l]:
            if S_[l-1] == 0:
                S_[l] = 1
                r += 1
                l += 1
                ans += 1
            else:
                S_[l] = 0
                r += 1
                l += 1
                ans += 1
        else:
            r += 1
            l += 1
            
print(ans)

Solution (Python):


import sys
import copy





S = input().rstrip()

cnt1 = 0
cnt2 = 0

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

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

print(min(cnt1, cnt2))

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

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

Solution (Python):
n = input()


tmp0 = []
tmp1 = []
for i in range(len(n)):
    if (i % 2 == 0):
        tmp0.append("0")
        tmp1.append("1")
    else:
        tmp0.append("1")
        tmp1.append("0")


ans0 = 0
ans1 = 0


for i in range(len(n)):
    if(tmp0[i] != n[i]):
        ans0 += 1
    else:
        ans1 += 1


print(min(ans0,ans1))

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

c=0
for i in range(len(l)-1):
  if l[i] == l[i+1]:
    if l[i+1] == "0":
      l[i+1] = "1"
    else:
      l[i+1] = "0"
    c += 1
print(c)

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

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

print(min(c,d))

Solution (Python):
import math

s = input()
half_len = math.ceil(len(s) / 2)

b_s = int(s, base=2)
b_10 = int(('10' * half_len)[:len(s)], base=2)
b_01 = int(('01' * half_len)[:len(s)], base=2)

print(min(["{0:b}".format(b_s ^ b_10).count('1'), "{0:b}".format(b_s ^ b_01).count('1')]))

Solution (Python):
from sys import stdin
S = list(map(int, list(stdin.readline().rstrip())))

n = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        if S[i+1]==1: S[i+1]=0
        elif S[i+1]==0: S[i+1]=1
        n += 1
print(n)

Solution (Python):
s=input()
n=len(s)
a=sum(i%2^int(s[i])for i in range(n))
print(min(a,n-a))

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
input = sys.stdin.readline




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

	if len(S) == 2:
		print(0)
		sys.exit()

	fst = []
	snd = []
	for i, val in enumerate(S):
		if i == len(S)-1:
			break
		if i % 2 == 0:
			fst.append(val)
		else:
			snd.append(val)

	fst1 = collections.Counter(fst)
	snd1 = collections.Counter(snd)

	
	

	ans = 0
	if fst1["0"] <= snd1["0"]:
		ans = fst1["0"] + snd1["1"]
	else:
		ans = fst1["1"] + snd1["0"]
	

	print(ans)

	
	
if __name__ == "__main__":
	main()