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):
S1_str = str(input())
S1 = list(S1_str)
S2 = list(S1_str)

num1 = 0

for i in range(len(S1) - 1):
    if S1[i] == S1[i + 1]:
        S1[i + 1] = str((int(S1[i]) + 1) % 2)
        num1 += 1

num2 = 1
S2[0] = str((int(S2[0]) + 1) % 2)
for i in range(len(S2) - 1):
    if S2[i] == S2[i + 1]:
        S2[i + 1] = str((int(S2[i]) + 1) % 2)
        num2 += 1

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

Solution (Python):
s = input()
print(s[0::2].count(str(1-int(s[0]))) + s[1::2].count(s[0]))

Solution (Python):
S=list(input())
print(len(S)-max(S[1::2].count('0')+S[0::2].count('1'),S[1::2].count('1')+S[0::2].count('0')))

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

Solution (Python):
s = input()


def get_change_nums(start,s):
    count = 0
    for p in enumerate(s):
        i,x = p
        if int(x) != (i + start) % 2:
            count += 1
    return count
    
s0 = get_change_nums(0,s)
s1 = get_change_nums(1,s)

print(min(s0,s1))

Solution (Python):
import numpy as np
S = input()

s_list = [int(s) for s in S]

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

s_list_array = np.array(s_list)
case_1_array = np.array(case_1)
case_2_array = np.array(case_2)
result_1_list = (s_list_array + case_1_array).tolist()
result_2_list = (s_list_array + case_2_array).tolist()
result_1 = result_1_list.count(1)
result_2 = result_2_list.count(1)

print(min(result_1, result_2))

Solution (Python):
s = input()
n = len(s)
ans = n
for j in range(2):
    cnt = 0
    for i in range(n):
        if((i%2==j and s[i]=="0") or (i%2!=j and s[i]=="1")):
            cnt += 1
    ans = min(ans,cnt)
print(ans)

Solution (Python):
s = input()

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

so[0] = (so[0] + 1) % 2

cnti = 0
cnto = 1
for i in range(1, len(s)):
  if si[i] == si[i-1]:
    si[i] = (si[i] + 1) % 2
    cnti += 1
  if so[i] == so[i-1]:
    so[i] = (so[i] + 1) % 2
    cnto += 1

print(min(cnti, cnto))

Solution (Python):
s = input()
set = [0, 1]
diff = 0

for i in range(len(s)):
    set.reverse()
    if set[1] == int(s[i]):
        diff += 1

print(min([diff, len(s)-diff]))

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

s1=s[0]
count_1=0

for i in range(1,n):
    if i%2==0:
        if s[i]!=s1:
            count_1+=1
    else:
        if s[i]==s1:
            count_1+=1

count_2=1
for i in range(1,n):
    if i%2==0:
        if s[i]==s1:
            count_2+=1
    else:
        if s[i]!=s1:
            count_2+=1

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

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

ans1 = 0
ans2 = 0
for idx, i in enumerate(sl):
    if idx % 2 == int(i):
        ans2 += 1
    else:
        ans1 += 1
        
print(min(ans1, ans2))

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())
x=0
y=0
for i in range(0,len(s)):
  if i%2==0:
    if s[i]=="0":
      x+=1
  else:
    if s[i]=="1":
      x+=1
      
for j in range(0,len(s)):
  if j%2==0:
    if s[j]=="1":
      y+=1
  else:
    if s[j]=="0":
      y+=1
      
print(min(x,y))

Solution (Python):
s = list(str(input()))
w_1 = 0  
b_1 = 0  

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


print(min(b_1, w_1))

Solution (Python):
s = input()
cnt = 0
for i in range(1,len(s)):
    if s[i-1] == s[i]:
        new = (int(s[i])+1)%2
        """
        s_li = list(s)
        s_li[i] = str(new)
        s = ''.join(s_li)
        """
        s = s[:i] + str(new) + s[i+1:]
        cnt += 1
        
print(cnt)

Solution (Python):

s = input()

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

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

print(min(tmp1,tmp2))

Solution (Python):
s=input()
s_1="1"
s_0="0"
count_1=0
count_0=0

if len(s)%2:
  s_0+="10"*(len(s)//2)
  s_1+="01"*(len(s)//2)
else:
  s_0+="10"*(int(len(s)/2+1))
  s_1+="01"*(int(len(s)/2+1))

for i in range(len(s)):
  if s[i]==s_1[i]:
    count_1+=1
  if s[i]==s_0[i]:
    count_0+=1
print(min(len(s)-count_1,len(s)-count_0))

Solution (Python):
def main():
    S = list(map(int,input()))
    length = len(S)

    if length%2 == 0:
        array1 = [0,1]*int(length/2)
        array2 = [1,0]*int(length/2)
    else:
        array1 = [0,1]*int((length-1)/2)+[0]
        array2 = [1,0]*int((length-1)/2)+[1]

    count1 = 0
    count2 = 0
    for i in range(length):
        if S[i] != array1[i]:
            count1 += 1
        if S[i] != array2[i]:
            count2 += 1
    print(min(count1,count2))


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
a = "".join(str(i % 2) for i in range(len(s)))
b = "".join(str(i % 2) for i in range(1, len(s) + 1))
da = bin(int(a, 2) ^ int(s, 2)).count("1")
db = bin(int(b, 2) ^ int(s, 2)).count("1")
print(min(da, db))

Solution (Python):
from collections import Counter
S = list(input())
len_s = len(S)
a = Counter(S[::2])["1"] + Counter(S[1::2])["0"]
b = Counter(S[1::2])["1"] + Counter(S[::2])["0"]

print(a if a < b else b)

Solution (Python):
S=input()
ez=0
oz=0
eo=0
oo=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=="0":
      ez+=1
    else:
      eo+=1
  else:
    if S[i]=="0":
      oz+=1
    else:
      oo+=1
print(min(eo+oz,ez+oo))

Solution (Python):
s = list(input())
s_len = len(s)
ans_0 = 0
ans_1 = 0
for i in range(s_len):
  if i % 2 == 0 and s[i] == "0":
    ans_0+= 1
  elif i % 2 == 0 and s[i] == "1":
    ans_1+= 1
  elif i % 2 != 0 and s[i] == "0":
    ans_1+= 1
  else:
    ans_0 += 1
print(min(ans_0,ans_1))

Solution (Python):
s = input()


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

ans2 = s[::2].count('0') + s[1::2].count('1')
ans = min(ans1, ans2)

print(ans)

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

def convert(arr):
    H = []
    for value in arr:
        H.append(int(value))
    return H

def fix0(arr):
    count = 0
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            arr[i] = math.fabs(arr[i-1] - 1)
            count = count + 1
    return count

def fix1(arr):
    count = 0
    if arr[0] == arr[1]:
        count = count + 1

    if len(arr) > 2:
        for i in range(2,len(arr)):
            if arr[i] == arr[i-1]:
                arr[i] = math.fabs(arr[i-1] - 1)
                count = count + 1
    return count

def compare(x,y):
    if x < y:
        return x
    else:
        return y

def main(arr):
    if len(arr) > 1:
        
        
        count1 = fix0(arr.copy())
        count2 = fix1(arr.copy())
        return compare(count1,count2)
    else:
        return 0


print(main(convert(S)))

Solution (Python):
S = input()
bit = 0
c = ["0","1"]
count = 0
for s in S:
    if s == c[bit]:
        count += 1
    bit ^= 1
print(min(count,len(S)-count))

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

Solution (Python):
import math

S = input()
S_list = []
N = len(S)
for i in range(N):
    S_list.append(S[i])

even_0 = S_list[1::2].count('0')
odd_0 = S_list[::2].count('0')
print(max(min(even_0+math.ceil(N/2)-odd_0, odd_0+math.trunc(N/2)-even_0), 0))

Solution (Python):
S = input()

count = sum(int(s) != i%2 for i, s in enumerate(S))
print(min(count, len(S) - count))

Solution (Python):
hamming_distance = lambda S1,S2:sum(s1 != s2 for s1,s2 in zip(S1,S2))

S = input()
end_s_1 = ''.join([str(i%2) for i in range(len(S))])
end_s_2 = ''.join([str((i+1)%2) for i in range(len(S))])



ret = min(hamming_distance(S, end_s_1), hamming_distance(S, end_s_2))
print(ret)

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

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] != '0':
            count1 += 1
        else:
            count2 += 1
    else:
        if S[i] != '1':
            count1 += 1
        else:
            count2 += 1
print(min(count1,count2))

Solution (Python):
colormap = input('')
colormaplist = [int(i) for i in colormap]
changecounter = 0
for i in range(len(colormaplist)-1):
    if colormaplist[i+1] == colormaplist[i]:
        colormaplist[i+1] = 1-colormaplist[i+1]
        changecounter+=1
print(changecounter)

Solution (Python):
s = input()
option_1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option_2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 += 1
print(min(ans_1, ans_2))

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

idx_even = [s[x] for x in range(0, len(s), 2)]
idx_odd = [s[x] for x in range(1, len(s), 2)]



ans = min(
    idx_even.count("0") + idx_odd.count("1"), idx_even.count("1") + idx_odd.count("0")
)

print(ans)

Solution (Python):
s = input()
s1 = s[::2]
s2 = s[1::2]
count0 = s1.count("1") + s2.count("0")
count1 = s1.count("0") + s2.count("1")
print(min(count0, count1))

Solution (Python):
s=input()
S=list(s)
for i in range(len(S)):
    S[i]=int(S[i])
ans=0
count=0
count1=0
N=list(s)
if len(S)==1:
    ans=0
else:
    for j in range(1,len(N)-1):
        if N[j-1]==N[j]==N[j+1]:
            if N[j]!=0:
                N[j]=0
            else:
                N[j]=1
            count+=1
        elif N[j-1]==N[j] and N[j+1]!=N[j]:
            N[j-1]=N[j+1]
            count+=1
        elif N[j-1]!=N[j] and N[j+1]==N[j]:
            N[j+1]=N[j-1]
            count+=1
    for k in range(len(S)-2,0,-1):
        if S[k-1]==S[k]==S[k+1]:
            if S[k]!=0:
                S[k]=0
            else:
                S[k]=1
            count1+=1
        elif S[k-1]==S[k] and S[k+1]!=S[k]:
            S[k-1]=S[k+1]
            count1+=1
        elif S[k-1]!=S[k] and S[k+1]==S[k]:
            S[k-1]=S[k+1]
            count1+=1
    if count>count1:
        ans=count1
    else:
        ans=count
print(ans)

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

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

print(ans)

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()
point = 0

li = ["0","1"]

start = li.pop(li.index(s[0]))
last = li[-1]

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

print(point)

Solution (Python):
s = input()

ls = list(s)

ils = list(map(int, ls))


n = len(s)
cnt = 0
for i in range(1, n):
    if ils[i] == ils[i-1] and ils[i] == 0:
        cnt += 1
        ils[i] = 1
    elif ils[i] == ils[i-1] and ils[i] == 1:
        cnt += 1
        ils[i] = 0
print(cnt)

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

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

Solution (Python):
S=input()
if len(S)==1:
    print(0)
else:
    l=0
    r=0
    T=S[::-1]
    for i in range(1,len(S)):
        if S[i]==S[i-1]:
            if S[i]=='1':
                S=S[:i]+'0'+S[i+1:]
            else:
                S=S[:i]+'1'+S[i+1:]
            l+=1
    
    
    for i in range(1,len(T)):
        if T[i]==T[i-1]:
            if T[i]=='1':
                T=T[:i]+'0'+T[i+1:]
            else:
                T=T[:i]+'1'+T[i+1:]
            r+=1
    
    print(min(l,r))

Solution (Python):


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

print(S[::2].count(0) + S[1::2].count(1) if S[0]==1 else S[::2].count(1) + S[1::2].count(0))

Solution (Python):

si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()

ans_1 = 0
ans_2 = 0

cnt_1 = 0
cnt_2 = 0

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

for i,s in enumerate(S):
    if i%2 == 0:
        
        if s == '1':
            cnt_1 += 1
        
        if s == '0':
            cnt_2 += 1
    elif i%2 == 1:
        
        if s == '0':
            cnt_1 += 1
        
        if s == '1':
            cnt_2 += 1

print(min(cnt_1,cnt_2))

Solution (Python):
slis=list(map(int,input()))
e_slis=[]
o_slis=[]
for i in range(len(slis)):
	if i%2==0:
		o_slis.append(slis[i])
	else:
		e_slis.append(slis[i])
print(min(o_slis.count(0)+e_slis.count(1),o_slis.count(1)+e_slis.count(0)))

Solution (Python):
S = input()
p1 = ["1" if i%2==0 else "0" for i in range(len(S))]
p2 = ["0" if i%2==0 else "1" for i in range(len(S))]
print(min(bin((int(S,2)^int("".join(p1),2))).count("1"),bin((int(S,2)^int("".join(p2),2))).count("1")))

Solution (Python):
s = list(input())
a = [0]*len(s)
b = [0]*len(s)
dif1 = 0
dif2 = 0
for i in range(0,len(s)):
    if i%2 == 0:
        a[i] = 0
        b[i] = 1
    else:
        a[i] = 1
        b[i] = 0
for i in range(0,len(s)):
    if a[i] != int(s[i]):
        dif1 += 1
    if b[i] != int(s[i]):
        dif2 += 1
print(min(dif1,dif2))

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

Solution (Python):
S = input()

import math

even_s=[]
odd_s=[]

for i in range(len(S)):
        if i%2 == 0:
                even_s.append(int(S[i]))
        else:
                odd_s.append(int(S[i]))

e_1num = even_s.count(1)
e_0num = even_s.count(0)

o_1num = odd_s.count(1)
o_0num = odd_s.count(0)

res = min(e_1num+o_0num, e_0num+o_1num)

print(res)

Solution (Python):
S = str(input())
X=[]
ans = 0

for s in S:
    X.append(int(s))

for n in range(1,len(X)):
    if X[n-1] == X[n]:
        ans += 1
        if X[n] == 1:
            X[n] = 0
        else:
            X[n] = 1

print(ans)

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

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

if len(s)-a < a:
    print(len(s)-a)
else:
    print(a)

Solution (Python):
s=input()
n=len(s)
a0="01"*(n//2) + "0"*(n%2)
a1="10"*(n//2) + "1"*(n%2)
ans0=sum(s[i]!=a0[i] for i in range(n))
ans1=sum(s[i]!=a1[i] for i in range(n))
print(min(ans0,ans1))

Solution (Python):
S = input()
cnt = 0
for i, s in enumerate(S):
    cnt += (int(s)==(i%2))
print(min(cnt, len(S)-cnt))

Solution (Python):
s = input()

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

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

Solution (Python):
s = input()
tmp = ""
count = 0
for i in range(len(s)):
    if i % 2 == 0:
        tmp += "0"
    elif i % 2 == 1:
        tmp += "1"
    if s[i] != tmp[i]:
        count += 1
print(count if count*2 <= len(s) else len(s)-count)

Solution (Python):
s = input()
a = []
b = []
n = 0

for i in range(len(s)):
    if i % 2 == 0:
        a.append(s[i])
    else:
        b.append(s[i])
        
for i in range(len(a)):
    if a[i] == "0":
        n += 1
        
for i in range(len(b)):
    if b[i] == "1":
        n += 1
        
m = len(s) - n

if n > m:
    print(m)
else:
    print(n)

Solution (Python):
s = list(map(int, list(input())))
n = len(s)
cnt1 = 0
cnt2 = 0
for i in range(n):
    if i%2 == 0:
        if s[i] == 0:
            cnt1 += 1
    else:
        if s[i] == 1:
            cnt1 += 1

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

print(min(cnt1, cnt2))

Solution (Python):
S = input()

multi = len(S) // 2

if len(S) % 2 == 0:
	S1 = "10" * multi
	S2 = "01" * multi
	
else:
	S1 = "10" * multi + "1"
	S2 = "01" * multi + "0"
	
con1 = 0
con2 = 0	 
	
for i in range(0,len(S)):
	if S[i] != S1[i]:
		con1 += 1
	if S[i] != S2[i]:
		con2 += 1
		
print(min(con1,con2))

Solution (Python):
s_L = [str(val) for val in input()]
n = len(s_L)

p_1,p_2 = [],[]
for val in range(n):
    if val%2 ==0:
        p_1.append("0")
        p_2.append("1")
    else:
        p_1.append("1")
        p_2.append("0")
counter1,counter2 = 0,0

for val in range(n):
    if p_1[val] == s_L[val]:
        counter1 +=1
    else:
        counter2 +=1
print(min(counter1,counter2))

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

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

n = len(s)
 
ans_l = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    ans_l += 1
    if s[i] == 0:
      s[i+1] = 1
    else:
      s[i+1] = 0
print(ans_l)

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    s = str(input().rstrip('\n'))
    t1 = 0
    t2 = 0
    b = True
    for i in range(len(s)):
        if bool(int(s[i])) != b:
            t1 += 1
        if bool(int(s[i])) == b:
            t2 += 1
        b = not b
    print(min(t1, t2))


if __name__ == '__main__':
    slove()

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

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

print(min(ans))

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

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


main()

Solution (Python):
def repaint(S):
    return S[::2].count("0") + S[1::2].count("1")


def main():
    S = input()
    print(min(repaint(S), len(S) - repaint(S)))

    return


main()

Solution (Python):
def main():
    S = [int(i) for i in input()]
    x = - (-len(S) // 2) - sum(S[::2]) + sum(S[1::2])
    print(min(x, len(S) - x))

    return


main()

Solution (Python):
def main():
    S = [int(i) for i in input()]
    print(min(sum(S[::2]) + len(S) + (-len(S) // 2) - sum(S[1::2]),
              - (-len(S) // 2) - sum(S[::2]) + sum(S[1::2])))

    return


main()

Solution (Python):
s=list(input())
o0=o1=e0=e1=0
for i in range(len(s)//2):
    if s[i*2]=="0":
        o0+=1
    elif s[i*2]=="1":
        o1+=1
    if s[i*2+1]=="0":
        e0+=1
    elif s[i*2+1]=="1":
        e1+=1
if len(s)%2==1:
    if s[len(s)-1]=="0":
        o0+=1
    else:
        o1+=1
print(min( o1+e0,e1+o0 ))

Solution (Python):
S = input()

list = list(S)


ref = []
ref.append(list[0])
count = 0
for i in range(len(list)-1):
    if int(ref[i]) == int(list[i+1]):
        count += 1
        if int(list[i+1]) == 1:
            ref.append(0) 
        else:
            ref.append(1) 
    else:
        ref.append(list[i+1]) 

print(count)

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

Solution (Python):
S = input()
N = len(S)
if 2 == N:
    S_0 = "01" * (N // 2)
    S_1 = "10" * (N // 2)
else:
    S_0 = "01" * (N // 2) + "0"
    S_1 = "10" * (N // 2) + "1"

cnt_0 = 0
cnt_1 = 0
for i in range(N):
    if S[i] != S_0[i]:
        cnt_0 += 1
    if S[i] != S_1[i]:
        cnt_1 += 1

print(min(cnt_0, cnt_1))

Solution (Python):
S = list(input())
ans = 0
tmp = S[0]
for i in range(0,len(S)-1,2):
    if tmp != S[i]:
        ans += 1
        S[i] = tmp
    if S[i] == S[i+1]:
        ans += 1
if len(S)%2 == 1:
    if S[-1] != tmp:
        ans += 1
print(ans)

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

prev = "-1"
count = 0
for ss in s:
  if prev == ss:
    count+=1
    if ss == "0":
      prev="1"
    else:
      prev="0"
  else:
  	prev = ss
    
print(count)

Solution (Python):
s = input()
min = 9999999999999
for i in range(2):
    count = 0
    for j in range(len(s)):
        if int(s[j]) == (j + i) % 2:
            count += 1
    if min > count:
        min = count
print(min)

Solution (Python):
s=input()
s_od=s[0::2]
s_ev=s[1::2]
cnt_10 = s_od.count("0")+s_ev.count("1")
cnt_01 = s_od.count("1")+s_ev.count("0")
print(min(cnt_10,cnt_01))

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

lists=list(s)
n=len(lists)

ans1=0
ans2=0

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

print(min(ans1,ans2))

Solution (Python):
s = input();x = s[0::2];y = s[1::2]
print(min(x.count('0') + y.count('1'), x.count('1') + y.count('0')))

Solution (Python):


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

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

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

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

R_0 = [s for i, s in enumerate(S) if s != (i % 2)]
R_1 = [s for i, s in enumerate(S) if s == (i % 2)]

print(min(len(R_0), len(R_1)))

Solution (Python):
S = list(map(int , input()))
lst0 = []
lst1 = []
for i in range(len(S)):
    lst1.append(i % 2)
    lst0.append((i + 1) % 2)
cnt0 = 0
cnt1 = 0
for i in range(len(S)):
    if S[i] != lst0[i]:
        cnt0 += 1
    if S[i] != lst1[i]:
        cnt1 += 1
print(min(cnt0,cnt1))

Solution (Python):
S = input()
c = '0'
ans1 = 0
for i in range(len(S)):
    if S[i] != c:
        ans1 += 1
    if c == '0':
        c = '1'
    else:
        c = '0'

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

Solution (Python):
s=input()


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

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

Solution (Python):
s = input()

a=0 
for i in range(len(s)):
  if int(s[i])%2==i%2:
    a+=1
b=0
for i in range(len(s)):
  if int(s[i])%2!=i%2:
    b+=1
print(min(a,b))

Solution (Python):
s = input()
l = [int(i) for i in s[0::2]]
r = [int(i) for i in s[1::2]]

if len(s) == 1:
    print(0)
else:
    l_count1 = l.count(1)
    l_count0 = len(l)-l_count1
    r_count1 = r.count(1)
    r_count0 = len(r)-r_count1
    l_1 = l_count0+r_count1
    l_0 = l_count1+r_count0
    if (l_count1==len(l) and r_count0==len(r)) or (l_count0==len(l) and r_count1==len(r)):
        print(0)
    elif l_1 < l_0:
        print(l_1)
    else:
        print(l_0)

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


END1 = [0]
END2 = [1]

for _ in range(N-1):
    END1.append(END1[-1] ^ 1)
    END2.append(END2[-1] ^ 1)

for idx in range(N):
    END1[idx] = END1[idx] ^ S[idx]
    END2[idx] = END2[idx] ^ S[idx]

print(min(sum(END1),sum(END2)))

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

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

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

ans = min(cnt1, cnt2)
print(ans)

Solution (Python):
S = input()
N = len(S)
a = 0
b = 0
for i in range (0,N):
  if (i % 2 == 0) and (int(S[i]) == 1):
    a = a + 1
  elif (i % 2 == 1) and (int(S[i]) == 0):
    a = a + 1
 
for i in range (0,N):
  if (i % 2 == 0) and (int(S[i]) == 0):
    b = b + 1
  elif (i % 2 == 1) and (int(S[i]) == 1):
    b = b + 1
ans = min(a,b)
print(ans)

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

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

Solution (Python):
S = input()
n = len(S)
s1 = "".join([str(i%2) for i in range(n)])
s2 = "".join([str((i+1)%2) for i in range(n)])
S = int(S, 2)
ans1 = bin(int(s1, 2)^S).count('1')
ans2 = bin(int(s2, 2)^S).count('1')
print(min(ans1, ans2))

Solution (Python):
tiles = list(map(int, list(input())))
length = len(tiles)
reverse = {0: 1, 1: 0}
cnt = 0

for i in range(1, length):
    if tiles[i] == tiles[i - 1]:
        tiles[i] = reverse[tiles[i]]
        cnt += 1

print(cnt)

Solution (Python):
import copy
s = list(map(str,input()))
S=copy.copy(s)
cnt1=0
cnt2=0
for i in range(len(s)):
    
    if i%2==0 and s[i]=='1':
        s[i] = '0'
        cnt1+=1
    if i%2==1 and s[i]=='0':
        s[i] = '1'
        cnt1+=1
    if i%2==0 and S[i]=='0':
        S[i] = '1'
        cnt2+=1
    if i%2==1 and S[i]=='1':
        S[i] = '0'
        cnt2+=1
print(min(cnt1,cnt2))

Solution (Python):
s=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==0:
    b.append(1)
  else:
    b.append(0)

a_count=0
b_count=0

for i in range(len(s)):
  if s[i]!=str(a[i]):
    a_count+=1
for i in range(len(s)):
  if s[i]!=str(b[i]):
    b_count+=1
ans=[a_count,b_count]
print(min(ans))

Solution (Python):
s = input()
n = len(s)
p1 = [0 for _ in range(n)]
p2 = p1.copy()
for i in range(n):
    if i % 2 == 1: p1[i] = 1
    else: p2[i] = 1
ans1, ans2 = 0, 0
for i in range(n):
    if int(s[i]) != p1[i]: ans1 += 1
    else: ans2 += 1
print(ans1) if ans1 < ans2 else print(ans2)

Solution (Python):
s = input()

n = len(s)

req1 = '10'*10**5
req2 = '01'*10**5

diff = sum([1 for x, y in zip(s, req1) if x != y])

diff2 = sum([1 for x, y in zip(s, req2) if x != y])

print(min(diff, diff2))

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

Solution (Python):
s = input()

p1 = 0
p2 = 0

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

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

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

counter_1 = 0
for i in range(len(s)):
  
  if i%2==0:
    if s[i] == '0':counter_1 += 1
  
  if i%2!=0:
    if s[i] == '1':counter_1 += 1
      
counter_2 = 0
for i in range(len(s)):
  
  if i%2==0:
    if s[i] == '1':counter_2 += 1
  
  if i%2!=0:
    if s[i] == '0':counter_2 += 1
      
print(min(counter_1, counter_2))

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

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *

from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    S = input().rstrip()
    N = len(S)
    cnt_a = 0
    cnt_b = 0
    for i in range(N):
        if i%2 == 0 and S[i] == '0':
            cnt_a += 1
        elif i%2 == 1 and S[i] == '1':
            cnt_a += 1
        elif i%2 == 0 and S[i] == '1':
            cnt_b += 1
        elif i%2 == 1 and S[i] == '0':
            cnt_b += 1
    print(min(cnt_a,cnt_b))

if __name__ == '__main__':
    main()

Solution (Python):
odd_num_0 = 0
eve_num_0 = 0
S = input()
N = len(S)
for idx, s in enumerate(S):
  if s == '0':
    if idx%2 == 0: eve_num_0 += 1
    else: odd_num_0 += 1

if N%2 == 1:eve_num = N//2+1
else:eve_num = N//2
odd_num = N//2

print(min(eve_num-eve_num_0+odd_num_0,odd_num-odd_num_0+eve_num_0))

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

def main():
    S = input().strip()

    white = 0
    black = 0
    for i, v in enumerate(S):
        if i % 2 == 0:
            if v != '0':
                white += 1
            else:
                black += 1
        else:
            if v != '1':
                white += 1
            else:
                black += 1

    print(min(white, black))


if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()
N = len(S)
res1 = 0
sample = "0"
tmp = "1"
for i in range(N):
    if S[i] != sample:
        res1 += 1
    sample, tmp = tmp, sample

res2 = 0
sample = "1"
tmp = "0"
for i in range(N):
    if S[i] != sample:
        res2 += 1
    sample, tmp = tmp, sample


print(min(res1, res2))

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

gate1 = 0

cnt1 = 0
cnt2 = 1

for i in range(len(s)):
    if i == 0:
        gate1 = s[i]
        continue
    
    if s[i] != gate1:
        gate1 = s[i]
        cnt2 += 1
        continue
    else:
        if s[i] == 0:
            gate1 = 1
        else:
            gate1 = 0
        cnt1 += 1
        
print(min(cnt1,cnt2))

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

Solution (Python):

S = str(input())

ans_b_start = 0 
ans_w_start = 0 

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

Solution (Python):
s_list = list(map(int,(input())))
count_odd1 = 0
count_odd0 = 0
count_even1 = 0
count_even0 = 0
s_len = len(s_list)
for i in range(s_len):
    if i%2 == 0 and s_list[i] == 1:
        count_odd1 += 1
    if i%2 == 1 and s_list[i] == 1:
        count_even1 += 1

    if i%2 == 0 and s_list[i] == 0:
        count_odd0 += 1
    if i%2 == 1 and s_list[i] == 0:
        count_even0 += 1




print(min(s_len - count_even0 - count_odd1,s_len - count_even1 - count_odd0))