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):
import sys

def main(inp):
    S=next(inp)
    l=len(S)-1
    ns=int(S,2)
    
    wh=1
    bl=0
    for i in range(l-1):
        if(i%2==0): 
            wh = (wh << 1)
            bl = (bl << 1) + 1
        else: 
            wh = (wh << 1) +1
            bl = (bl << 1)
            
    return min(bin(ns^wh).count("1"),bin(ns^bl).count("1"))
    
print(main(sys.stdin))

Solution (Python):
s = input()

count_left = 0
count_right = 0
n = len(s)
i = 0
while i < n:
  if n % 2 == 0:
    if i % 2 == 0: 
      if s[i] == "0":
        count_left += 1
      if s[n-i-1] == "0":
        count_right += 1
    else: 
      if s[i] == "1":
        count_left +=1
      if s[n-i-1] == "1":
        count_right += 1
  else:
    if i % 2 == 0: 
      if s[i] == "0":
        count_left += 1
      if s[n-i-1] == "1":
        count_right += 1
    else: 
      if s[i] == "1":
        count_left +=1
      if s[n-i-1] == "0":
        count_right += 1
  i += 1
    
    
print(min(count_left, count_right))

Solution (Python):
*S,=map(int,input());f,g=S[::2],S[1::2];u=sum(f)-sum(g);print(min(len(g)+u,len(f)-u))

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

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

S2 = S.copy()

counter = 0
counter2 = 0

switch = True
for i in range(len(S)):
    if switch:
        if S[i] == '1':
            S[i] = '0'
            counter+=1
        
        if S2[i] == '0':
            S2[i] = '1'
            counter2+=1

    else:
        if S[i] == '0':
            S[i] = '1'
            counter+=1
        
        if S2[i] == '1':
            S2[i] = '0'
            counter2+=1

    if switch:
        switch = False
    else:
        switch = True

if counter < counter2:
    print(counter)
else:
    print(counter2)

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

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

Solution (Python):


num = str(input())
list = list(num)
list = [int(i) for i in list]

counter = 0
for ii in range(1, len(list)):
    if list[ii - 1] == list[ii]:
        list[ii] = (list[ii] + 1) % 2
        counter += 1

print(counter)

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

ans1=0
ans2=0

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

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

Solution (Python):
num = str(input())
list_num = list(num)
list_num = [int(s) for s in list_num]



count_0 = 0
count_1 = 0

def _return_next_val(cur_num):
  if cur_num == 0:
    return 1
  else:
    return 0

check_num = 0


for i in range(len(list_num)):
  if list_num[i] != check_num:
    count_0 += 1
  check_num=_return_next_val(check_num) 

check_num = 1

for i in range(len(list_num)):
  if list_num[i] != check_num:
    count_1 += 1
  check_num=_return_next_val(check_num) 

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

s = ns()
n = len(s)
if n % 2 == 0:
    s0 = "01" * int(n/2)
else:
    s0 = "01" * int(n/2) + "0"

c0 = 0
c1 = 0
for i in range(n):
    if s[i] == s0[i]:
        c0 += 1
    else:
        c1 += 1

if c0 < c1:
    print(c0)
else:
    print(c1)

Solution (Python):
a = [int(n) for n in input()]
counter=0
for n in range(1, len(a)):
  if a[n-1]==a[n]:
    if a[n-1]==1:
      a[n]=0
    else:
      a[n]=1
    counter+=1
print(counter)

Solution (Python):
S = str(input())
slist = []
for i in range(len(S)):
    slist.append(S[i])
ans = 0

for i in range(len(slist)-1):
    if slist[i]==slist[i+1] and slist[i+1]=='0':
        slist[i+1] = '1'
        ans += 1
    elif slist[i]==slist[i+1] and slist[i+1]=='1':
        slist[i+1] = '0'
        ans += 1
    else:
        pass
print(ans)

Solution (Python):
import math                                        

n = list(raw_input())
      
cnt = 0                                            
k = 0                                              
g = 0                                              
for i in n:
    i = int(i)                                     
    if cnt % 2 == 0 and i == 0:                    
        g += 1                                     
    elif cnt % 2 != 0 and i == 0:
        k += 1                                     
    cnt += 1                                       
   
k2 = int(math.floor((len(n)/2.0))-k)               
g2 = int(math.ceil((len(n)/2.0))-g)                

a1 = k2 + g                                        
a2 = k + g2                                        

print min(a1,a2)

Solution (Python):
S = list(str(input()))
pre = -1
now = -1
count = 0

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

print(count)

Solution (Python):
S = input().rstrip()
zero_zero = 0
one_zero = 0
zero_one = 0
one_one = 0
one = 0
zero = 0
for i in range(-(-len(S)//2)):
    tmp = S[i*2:i*2+2]
    if tmp == "00":
        zero_zero += 1
    elif tmp == "01":
        zero_one += 1
    elif tmp == "10":
        one_zero += 1
    elif tmp == "11":
        one_one += 1
    elif tmp == "1":
        one += 1
    else:
        zero += 1
counter = 0
if zero_one > one_zero:
    counter += one_zero*2 + zero_zero + one_one + one
elif zero_one < one_zero:
    counter += zero_one*2 + zero_zero + one_one + zero
else:
    counter += zero_one*2 + zero_zero + one_one
print(counter if len(S) != 1 else 0)

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

ans0 = ''
ans1 = ''

for i in range(N):
	if i%2 == 0:
		ans0 += '0'
		ans1 += '1'
	else:
		ans0 += '1'
		ans1 += '0'

leven0 = 0
leven1 = 0

for i in range(N):
	if S[i]!=ans0[i]:
		leven0 += 1
	if S[i]!=ans1[i]:
		leven1 += 1


if leven0>leven1:
	print(leven1)
else:
	print(leven0)

Solution (Python):
string = input()
list1 = []
for i in string:
  list1.append(int(i))
  
prev = list1[0]
sum = 0
for i, char in enumerate(list1):
  if (i > 0):
    if (char == prev):
      prev = 1 if char == 0 else 0
      sum += 1
    else:
      prev = char
print(sum)

Solution (Python):
def main():
    minu = 0
    S = input()
    N = len(S)
    S = int(S, 2)
    f01 = int('01' * (N//2) + '0' * (N%2), 2)
    f10 = int('10' * (N//2) + '1' * (N%2), 2)
    minu = min(str(bin(f01 ^ S)).count('1'), str(bin(f10 ^ S)).count('1'))
    print(minu)


main()

Solution (Python):


a = input()

L = len(a)

ans1 = 0
ans2 = 0

for i in range(L):
    if i%2 == 0:
        ans1 += 0 ^ int(a[i])
        ans2 += 1 ^ int(a[i])
    else:
        ans1 += 1 ^ int(a[i])
        ans2 += 0 ^ int(a[i])

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

Solution (Python):
S = input()
S = [int(S[i:i+1]) for i in range(len(S))]
n = len(S)
bc = 0
wc = 0
for i in range(n):
  if i % 2 == 0:
    if S[i] == 1:
        bc += 1
    else:
        wc += 1
  else:
    if S[i] == 0:
      	bc += 1
    else:
        wc += 1
if bc > wc:
    print(wc)
else:
    print(bc)

Solution (Python):
s = input()
x = 0
y = 0

check = "0"
for i in range(len(s)):
  if s[i] != check:
    x += 1
  if check == "0":
    check = "1"
  else:
    check = "0"
check = "1"
for j in range(len(s)):
  if s[j] != check:
    y += 1
  if check == "0":
    check = "1"
  else:
    check = "0"
  
if x<=y:
  ans = x
else:
  ans = y
print(ans)

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

n = len(s)
ans = n

num_0 = 0
for i in range(0, n, 2):
  if s[i] == "1":
    num_0 += 1
if n % 2 == 1:
  for i in range(1, n - 1, 2):
    if s[i] == "0":
      num_0 += 1
else:
  for i in range(1, n, 2):
    if s[i] == "0":
      num_0 += 1

num_1 = 0
for i in range(0, n, 2):
  if s[i] == "0":
    num_1 += 1
if n % 2 == 1:
  for i in range(1, n - 1, 2):
    if s[i] == "1":
      num_1 += 1
else:
  for i in range(1, n, 2):
    if s[i] == "1":
      num_1 += 1

print(min(ans, num_0, num_1))

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

Solution (Python):


tiles = input()
pattern0 = ''
pattern1 = ''
l = len(tiles)
sum0 = 0
sum1 = 0

for i in range(l):
  if i % 2 == 0:
    pattern0 += '0'
    pattern1 += '1'
  else:
    pattern0 += '1'
    pattern1 += '0'

for i in range(l):
  if tiles[i] != pattern0[i]:
    sum0 += 1
  if tiles[i] != pattern1[i]:
    sum1 += 1

if sum0 < sum1:
  print(sum0)
else:
  print(sum1)

Solution (Python):
def main():
    result = sub()
    print(result)


def sub():
    maskA = '10' * 10 ** 5
    maskB = '01' * 10 ** 5

    raw = input()
    length = len(raw)

    maskA = maskA[:length]
    maskB = maskB[:length]
    a = int(raw, 2) ^ int(maskA, 2)
    b = int(raw, 2) ^ int(maskB, 2)
    tmp = min(bin(a).count("1"), bin(b).count("1"))
    return min(tmp, length - tmp)


if __name__ == '__main__':
    main()

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

Solution (Python):
import numpy as np

S = input()
N = [0] * len(S)
for i in range(len(S)):
    N[i] = int(S[i])
arr = np.zeros((2,2))

for i in range(0, len(S), 2):
    if N[i] == 0:
        arr[0,0] += 1
    else:
        arr[0,1] += 1

for i in range(1, len(S), 2):
    if N[i] == 0:
        arr[1,0] += 1
    else:
        arr[1,1] += 1

ans = int(min(arr[0,0]+arr[1,1], arr[0,1]+arr[1,0]))

print(ans)

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

result = 0
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    s[i+1] = str(int(s[i+1]) ^ 1)
    result = result +1

print(result)

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

Solution (Python):






s = input()

s0 = s[0::2]
s1 = s[1::2]
cost1 = s0.count('0') + s1.count('1')
cost2 = s0.count('1') + s1.count('0')
ans = min(cost1, cost2)
print(ans)

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

s=''
for i in range(lenn):
  if i%2==0:
    s+='0'
  else:
    s+='1'

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

cnt1=0
for i in range(lenn):
  if n[i] != s[i]:
    cnt1+=1    
print(min(cnt,cnt1))

Solution (Python):
S = input()
S = list(S)
s1 = int(S[0])
count = 0
for i in S[1:]:
    i = int(i)
    if s1 == i:
        count += 1
        if i == 0:
            s1 = 1
        elif i == 1:
            s1 = 0
    else:
        s1 = i
print(count)

Solution (Python):
s=input()

hit = 0
for j in range(len(s)):
    if j%2 ==0:
        if s[j] == "0":
            hit = hit+1
        else:
            continue
    if j%2 ==1:
        if s[j] == "1":
            hit = hit+1
        else:
            continue
print(min(hit,len(s)-hit))

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    S = list(_ for _ in input())
    S = S[::-1]    
    S_num = 0
    temp_ans_0 = '0b'
    temp_ans_1 = '0b'
    num_temp_ans_0 = 0
    num_temp_ans_1 = 0
    for i in range(len(S)):
        if(i%2 ==0):
            temp_ans_0 += '0'
            temp_ans_1 += '1'
        else:
            temp_ans_0 += '1'
            temp_ans_1 += '0'
    
    
    
    
    
    
    
    
    
    
    S_str ='0b'+''.join(S)
    S_num = int(S_str,0)
    num_temp_ans_0 = int(temp_ans_0,0)
    num_temp_ans_1 = int(temp_ans_1,0) 
    c0 = bin(S_num ^ num_temp_ans_0).count('1')
    c1 = bin(S_num ^ num_temp_ans_1).count('1')
    
    print(min(c0,c1))
    
if __name__ == '__main__':
    main()

Solution (Python):
import sys

s = input()
ans = 0

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

print(ans)

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

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

Solution (Python):
s = input()
S = [int(s[i]) for i in range(len(s))]
N = len(S)
 
dis1 = 0
dis2 = 0
start = 0
for i in range(N):
    if (S[i]!=1-start):
        dis1 += 1
    if (S[i]!=start):
        dis2 += 1
    start = 1-start
res = min(dis1, dis2)
print (res)

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

Solution (Python):

S = str(input())
N = len(S)
b1 = ''
b2 = ''
for i in range(N):
    if i % 2 == 0:
        b1 = b1 + '1'
        b2 = b2 + '0'
    else:
        b1 = b1 + '0'
        b2 = b2 + '1'
bnum1 = int(b1, 2)
bnum2 = int(b2, 2)
bS = int(S, 2)
num1 = bnum1 ^ bS
num2 = bnum2 ^ bS
num1 = (bin(num1).replace('-','').replace('0b','').count('1'))
num2 = (bin(num2).replace('-','').replace('0b','').count('1'))
ans = min(num1, num2)
print(ans)

Solution (Python):
s = list(input())
l = len(s)
x = 0
y = 0
ans = 0

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

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

ans = min(x, y)
print(ans)

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

Solution (Python):
string=list(input())
if int(string[0])==1:
    c=0
else:
    c=1
a=0
for s in string:
    if int(s)==0 and c==1:
        c-=1
    elif int(s)==0 and c==0:
        c+=1
        a+=1
    elif int(s)==1 and c==0:
        c+=1
    elif int(s)==1 and c==1:
        c-=1
        a+=1
print(a)

Solution (Python):

S = str(input())

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


count_01 = 0 
for i in range(len(S)):
  s = int(S[i])
  if i % 2 == 0:
    if s != 0:
      count_01 += 1
  else:
    if s != 1:
      count_01 += 1
    
print(min(count_10,count_01))

Solution (Python):
S = input()
BW01 = '01' * (len(S) // 2)
if len(S) % 2 == 1:
    BW01 += '0'
WB10 = '10' * (len(S) // 2)
if len(S) % 2 == 1:
    WB10 += '1'

ans1 = ans2 = 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
    if i % 2 == 0 and S[i] == '0':
        ans2 += 1
    if i % 2 == 1 and S[i] == '1':
        ans2 += 1

print(min(ans1, ans2))

Solution (Python):
A = input()



LENGTH = len(A)
S = int(A)
S_LIST = []

for i in A:
    S_LIST.append(i)



LIST = list(map(int,S_LIST))


PATTERN_A = []
for i in range(LENGTH):
    if i % 2 == 0:
        PATTERN_A.append(0)
    else:
        PATTERN_A.append(1)




COUNT = 0
for i in range(LENGTH):
    if PATTERN_A[i] == LIST[i]:
        COUNT += 1

if LENGTH - COUNT < COUNT:
    COUNT = LENGTH - COUNT

print(COUNT)

Solution (Python):
S = str(input())
S_len = int(len(S))
zero_start = '01'*int(S_len/2)
one_start = '10'*int(S_len/2)
if S_len % 2 == 1:
    
    zero_start = int(zero_start + '0', 2)
    one_start = int(one_start + '1', 2)
else:
    zero_start = int(zero_start, 2)
    one_start = int(one_start, 2)



tmp_z = format(int(S, 2) ^ zero_start, 'b')
z_count = 0
for i in tmp_z:
    if i == '1':
        z_count += 1

tmp_o = format(int(S, 2) ^ one_start, 'b')
o_count = 0
for i in tmp_o:
    if i == '1':
        o_count += 1

if z_count > o_count:
    print(o_count)
else:
    print(z_count)

Solution (Python):
s=list(input())
o = len(s)
j = 0
k = 0

for i in range(o):
    if i%2 == 1:
        if s[i] == str(1):
           j = j + 1
        else: k = k + 1
    if i%2 == 0:
        if s[i] == str(0):
           j = j + 1
        else: k = k + 1

if k >= j:
    print(j)
else: print(k)

Solution (Python):
import numpy as np

S = input()

S = [int(i) for i in S]


count = 0

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

print(count)

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

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

v = 0


i = 1
while i<len(n):
    if(n[i-1] == n[i]):
        n[i] = (1-n[i])
        v+=1
    i+=1
print(v)

Solution (Python):
s = list(map(int, input()))
z = []
o = []
zj = 0
oj = 0
for i in range(len(s)):
    if i % 2 == 0:
        z.append(0)
        o.append(1)
        if s[i] == 0:
            oj += 1
        else:
            zj += 1
    else:
        z.append(1)
        o.append(0)
        if s[i] == 0:
            zj += 1
        else:
            oj += 1
print(min(zj, oj))

Solution (Python):
S = input()

len_S = len(S)
first = ("01" * (len_S//2+1))[:len_S]
second = ("10" * (len_S//2+1))[:len_S]

ans = min(bin(int(S,2) ^ int(first,2)).count('1'), bin(int(S,2) ^ int(second,2)).count('1'))
print(ans)

Solution (Python):
s = list(input())
first_zero = []
first_one = []
s_size = len(s)
for i in range(s_size):
    if i % 2 == 0:
        first_zero.append("0")
        first_one.append("1")
    else:
        first_zero.append("1")
        first_one.append("0")

count_zero = 0
count_one = 0

for index,number in enumerate(s):
    if number == first_zero[index]:
        pass
    else:
        count_zero += 1

    if number == first_one[index]:
        pass
    else:
        count_one += 1

if count_one > count_zero:
    print(count_zero)
else:
    print(count_one)

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

total_count = len(s)
odd_count = len(odd)
even_count = len(even)

odd_sum = sum(odd)
even_sum = sum(even)

rev = 0
rev += abs(odd_count-odd_sum)
rev += even_sum
rev = rev if (total_count // 2 >= rev) else total_count - rev

print(rev)

Solution (Python):
S = input()

white_counter = 0
tile_color = '1'
for tile in S:
    if tile_color == tile:
        pass
    else:
        white_counter += 1
    if tile_color == '1':
        tile_color = '0'
    else:
        tile_color = '1'

black_counter = 0
tile_color = '0'
for tile in S:
    if tile_color == tile:
        pass
    else:
        black_counter += 1
    if tile_color == '1':
        tile_color = '0'
    else:
        tile_color = '1'

print(min(white_counter, black_counter))

Solution (Python):
s = input()
len_s = len(s)
even_zero, even_one, odd_zero, odd_one = 0, 0, 0, 0

for i in range(len_s):

    if i % 2 == 0:
        if s[i] == "0":
            even_zero += 1
        else:
             even_one += 1
    else:
        if s[i] == "0":
            odd_zero += 1
        else:
             odd_one += 1

print(min(len_s - even_zero - odd_one, len_s - even_one - odd_zero))

Solution (Python):
n = input()
if len(n) == 1:
  print(0)
  exit()
cnt = 0
li = []
for i in n:
  li.append(int(i))

cnt = 0

for i in range(1, len(li)):
  if li[i] == li[i-1]:
    if li[i] == 1:
      li[i] = 0
    else:
      li[i] = 1
    cnt += 1
print(cnt)

Solution (Python):
data=[]

for i in input():
  data.append(int(i))

  
A=data.count(0)+data.count(1)

a=0
b=0
c=0
d=0
if A%2==0:
  for j in range(0,A//2):
    s=2*j
    if data[s]==1:
      a=a+1
    else:
      b=b+1
    if data[s+1]==1:
      c=c+1
    else:
      d=d+1
      
if A%2==1:
  for j in range(0,A//2+1):
    s=2*j
    if data[s]==1:
      a=a+1
    else:
      b=b+1
  for j in range(0,A//2):
    s=2*j
    if data[s+1]==1:
      c=c+1
    else:
      d=d+1
      
      
e=max(a+d,b+c)

print(A-e)

Solution (Python):


a = str(input())
lis_a = []
for i in a:
    lis_a.append(int(i))
    
sum = 0
for i in range(1,len(lis_a)):
    if lis_a[i-1] == lis_a[i]:
        sum += 1
        if lis_a[i] == 0:
            lis_a[i] = 1
        else:
            lis_a[i] = 0

print(sum)

Solution (Python):
s = list(input())
count1 = 0
s_copy = s.copy()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count1 += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
s = s_copy.copy()
s.reverse()
count2 = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count2 += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
print(min(count1,count2))

Solution (Python):
s = input()
s_00 = 0
s_01 = 0 
s_10 = 0
s_11 = 0
count = 0

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


for i in s:
    count += 1
    if i == "0" and count % 2 == 1:
        s_00 += 1
    elif i == "1" and count % 2 == 1:
        s_01 += 1
    elif i == "0" and count % 2 == 0:
        s_10 += 1
    elif i == "1" and count % 2 == 0:
        s_11 += 1

if s_00 + s_11 <= s_01 + s_10:
    print(s_00 + s_11)
else:
    print(s_01 + s_10)

Solution (Python):
s = input()

fc = s[0]
nc = ""

count = 0

if fc == "0":
    nc = "1"
else:
    nc = "0"

for i in range(1,len(s)):
    if s[i] != nc :
        count += 1
        nc = s[i]
    else:
        if nc == "0":
            nc = "1"
        else:
            nc = "0"

print(count)

Solution (Python):
s = input()

s_list = list(s)
s_len = len(s)

s_pattern1 = ""
is_zero = False
for _ in range(s_len):
    if is_zero:
        s_pattern1 += "0"
    else:
        s_pattern1 += "1"
    is_zero = not is_zero
    
s_pattern2 = ""
is_zero = True
for _ in range(s_len):
    if is_zero:
        s_pattern2 += "0"
    else:
        s_pattern2 += "1"
    is_zero = not is_zero

count1 = 0
count2 = 0
for i, c in enumerate(s_list):
    if c != s_pattern1[i]:
        count1 += 1
    if c != s_pattern2[i]:
        count2 += 1
        
print(min(count1,count2))

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

Solution (Python):
S = input()
listA = []
listB = []
ans1 = 0
ans2 = 0

for i in range(len(S)//2):
    listA.append(1)
    listA.append(0)
    listB.append(0)
    listB.append(1)

if len(S)%2 != 0:
    listA.append(1)
    listB.append(0)


for i in range(len(S)):
    if int(S[i]) != listA[i]:
        ans1 += 1
    if int(S[i]) != listB[i]:
        ans2 += 1

print(min(ans1,ans2))

Solution (Python):

S = str(input())
ans = 0

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

print(ans)

Solution (Python):
a = [i for i in input()]
target1 = []
target2 = []
for i, n in enumerate(a):
    if i % 2 == 0:
        target1.append('1')
        target2.append('0')
    else:
        target1.append('0')
        target2.append('1')

result1 = 0
result2 = 0
for i, el in enumerate(a):
    if target1[i] != el:
        result1 += 1
    if target2[i] != el:
        result2 += 1

print(min(result1, result2))

Solution (Python):
S=list(input())
count_0 = 0
count_1 = 0


for (i,item) in enumerate(S):
    if i%2 != 0 and item=="0":
        count_1 +=1


    elif i%2==0 and item=="1":
        count_1 +=1


for (i,item) in enumerate(S):
    if i%2 != 0 and item =="1" :
        count_0 +=1

    elif i%2==0 and item=="0":
        count_0 +=1

print(min(count_0,count_1))

Solution (Python):
import sys
import io
import math
import re

datalist = input().split()
num_summit = list(str(datalist[0]))

num_match = 0
flag = 0

for num in range(len(num_summit)):
    check_num = int(num_summit[num])
    if check_num == flag % 2:
        num_match += 1
    flag += 1

if num_match * 2 < len(num_summit):
    print(num_match)
else:
    print(len(num_summit)- num_match)

Solution (Python):

s = input()
strlen = len(s)
cnt = 0
for i in range(0, strlen, 2):
    if s[i] != '0':
        cnt += 1
for j in range(1, strlen, 2):
    if s[j] != '1':
        cnt += 1
print(min(cnt, strlen - cnt))

Solution (Python):



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

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

print(min(cnt1,cnt2))

Solution (Python):
a=raw_input()
x=sum([a[i]=="01"[i%2] for i in range(len(a))])
ans=min([x,len(a)-x])
print ans

Solution (Python):
a = list(map(int,list(input())))
r =[1,0]
n = 0
def change(n):
  if n == 0 :
    return 1
  else :
    return 0
if len(a) == 1 :
  print(0)
else :
  for i in range(1,len(a)):
    if a[i-1] == a[i] :
      n = change(n)
    r[n] +=1
  print(min(r))

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

dp = {}

for i in range(length):
  for j in range(2):
    if i == 0:
      dp[(i,j)] = 0 if S[0] == j else 1
      continue

    
    inverse = 0 if S[i] == 1 else 1

    if S[i] == j: 
      dp[(i, j)] = dp[(i-1, inverse)]
    else: 
      dp[(i, j)] = dp[(i-1, S[i])] + 1





print(min(dp[(length-1, 0)], dp[(length-1, 1)]))

Solution (Python):
ls = list(map(int, list(input().split()[0])))
N = len(ls)

cnt_0 = 0
cnt_1 = 0
ls_0 = ls.copy()
ls_1 = ls.copy()
for i in range(N):
    if i == 0:
        if ls_0[i] == 0:
            pass
        else:
            ls_0[i] = 0
            cnt_0 += 1
    else:
        if i % 2 == 0:
            if ls_0[i] == 0:
                pass
            else:
                ls_0[i] = 0
                cnt_0 += 1
        else:
            if ls_0[i] == 1:
                pass
            else:
                ls_0[i] = 1
                cnt_0 += 1

for i in range(N):
    if i == 0:
        if ls_1[i] == 1:
            pass
        else:
            ls_1[i] = 1
            cnt_1 += 1
    else:
        if i % 2 == 0:
            if ls_1[i] == 1:
                pass
            else:
                ls_1[i] = 1
                cnt_1 += 1
        else:
            if ls_1[i] == 0:
                pass
            else:
                ls_1[i] = 0
                cnt_1 += 1

print(min([cnt_0, cnt_1]))

Solution (Python):
s=input()
pre=bool(int(s[0]))
cnt=0
for i in range(1, len(s)):
    if pre == bool(int(s[i])):
        cnt+=1
        pre= not bool(int(s[i]))
    else:
        pre = bool(int(s[i]))
print(cnt)

Solution (Python):
S =input()
S_bin = int("0b"+S, 0)
if len(S)%2 == 0:
    a = int("0b"+"01"*int(len(S)/2),0)
    b = int("0b"+"10"*int(len(S)/2),0)
else:
    a = int("0b"+"1" + "01"*int(len(S)/2) ,0)
    b = int("0b"+"0" + "10"*int(len(S)/2) ,0)
print(min(bin(a^S_bin).count("1"),bin(b^S_bin).count("1")))

Solution (Python):
S = list(map(int, input()))
zero_one_cnt = 0
one_zero_cnt = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 0:
            zero_one_cnt += 0
            one_zero_cnt += 1
        else:
            zero_one_cnt += 1
            one_zero_cnt += 0
    else:
        if S[i] == 0:
            zero_one_cnt += 1
            one_zero_cnt += 0
        else:
            zero_one_cnt += 0
            one_zero_cnt += 1

print(min(zero_one_cnt, one_zero_cnt))

Solution (Python):
S = input()
S += '_'
a = 0
cnt = 0
if S[0] == "0":
    for i in range(0, len(S), 2):
        if S[i] == '1':
            cnt += 1
    for i in range(1, len(S), 2):
        if S[i] == '0':
            cnt += 1
if S[0] == "1":
    for i in range(0, len(S), 2):
        if S[i] == '0':
            cnt += 1
    for i in range(1, len(S), 2):
        if S[i] == '1':
            cnt += 1
print(cnt)

Solution (Python):
def revS(x):
    if x == '0':
        return '1'
    return '0'

S = list(input().rstrip())

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

print(count)

Solution (Python):
s = list(str(input()))
flag = 0
for i in range(len(s)-1):
  if s[i] == '1' and s[i+1] == '1':
    s[i+1] = '0'
    flag += 1
  elif s[i] == '0' and s[i+1] == '0':
    s[i+1] = '1'
    flag += 1
print(flag)

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

Solution (Python):
import numpy as np

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

answer_option_A = np.array([0 if i%2 == 0 else 1 for i in range(len(S))])
answer_option_B = np.array([1 if i%2 == 0 else 0 for i in range(len(S))])

answer_option_A = np.logical_xor(S, answer_option_A)
answer_option_B = np.logical_xor(S, answer_option_B)

print(min(answer_option_A.sum(),answer_option_B.sum()))

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

Solution (Python):
def tairu(a):
    hoge=None
    ii=0
    if len(a)==1:
        return 0
    for i in range(len(a)-1):
        hoge=a[i:i+2]
        if hoge[0]==hoge[1]:
            ii+=1
            if a[i+1]=="0":
                a[i+1]="1"
            else:
                a[i+1]="0"
    else:
        if a[-1]==a[-2]:
            ii+=1
    return ii
  
a=list(input())
print(tairu(a))