Problem:
 Score : 300 points    Problem Statement N tiles are arranged in a row from left to right. The initial color of each tile is represented by a string S of length N .  The i -th tile from the left is painted black if the i -th character of S is 0 , and painted white if that character is 1 .  You want to repaint some of the tiles black or white, so that any two adjacent tiles have different colors.  At least how many tiles need to be repainted to satisfy the condition?      Constraints  1 \leq |S| \leq 10^5  S_i is 0 or 1 .         Input Input is given from Standard Input in the following format:  S       Output Print the minimum number of tiles that need to be repainted to satisfy the condition.        Sample Input 1 000      Sample Output 1 1  The condition can be satisfied by repainting the middle tile white.       Sample Input 2 10010010      Sample Output 2 3       Sample Input 3 0      Sample Output 3 0

Solution (Python):
s = input()
o1e0 = 0
o0e1 = 0

for n, i in enumerate(s):
    if n % 2 == 0:
        if i == "0":
            o1e0 += 1
        else:
            o0e1 += 1

    else:
        if i == "1":
            o1e0 += 1
        else:
            o0e1 += 1

print(min(len(s) - o1e0, len(s) - o0e1))

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

count=0
for i in s:
	if i!=str(tmp):
		count+=1
	tmp=1-tmp

tmp=1
ccount=0
for i in s:
	if i!=str(tmp):
		ccount+=1
	tmp=1-tmp

print(min(count,ccount))

Solution (Python):
S = input()
count = 0
for i, c in enumerate(S):
    if c == "0" and i % 2 == 0:
        count += 1
    if c == "1" and i % 2 == 1:
        count += 1
print(min(len(S)-count, count))

Solution (Python):
def solve(s):
    n = len(s)
    best = n
    for flip in range(2):
        cnt = 0
        for i in range(n):
            if (i+flip) % 2 == 0:
                if s[i] == '1':
                    cnt += 1
            else:
                if s[i] == '0':
                    cnt += 1
        best = min(best, cnt)
    return best

s = input()
print(solve(s))

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



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

difference=0
for i in range(len(S)):
    if S[i] != str(rightanswer[i]):
               difference+=1

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

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

ans1, ans2 = 0, 0


for i in range(length):
    if i % 2 == 0 and S[i] == '0':
        pass
    elif i % 2 == 1 and S[i] == '1':
        pass
    else:
        ans1 += 1

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

Solution (Python):
Sarr = tuple(map(int, list(input())))

x = 0
c = 0
for i in Sarr:
  c += (x ^ i)
  x = x ^ 1

print(min(len(Sarr) - c, c))

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

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

Solution (Python):
s = input()

even_s = ''
odd_s = ''
for i in range(len(s)):
    if i & 1:
        odd_s += s[i]
    else:
        even_s += s[i]

odd_0_count = odd_s.count('0')
odd_1_count = odd_s.count('1')

even_0_count = even_s.count('0')
even_1_count = even_s.count('1')

print(min(odd_1_count + even_0_count, odd_0_count + even_1_count))

Solution (Python):
s=list(map(int,list(str(input()))))
a=s[:: 2]
b=s[1:: 2]
c=a.count(1)+b.count(0)
d=a.count(0)+b.count(1)
print(min(c,d))

Solution (Python):
S = input()
S = list(S)
N = len(S)
change = ['1','0']

icchi0 = 0
count = 0
S0 = ['0'] * N
for i in range(N):
    if i%2 == 1:
        S0[i] = '1'
        
for i in range(N):
    if S[i] == S0[i]:
        icchi0 += 1
        
if icchi0 >= N/2:
    print(N-icchi0)
else:
    print(icchi0)

Solution (Python):
S = input()
S = list(S)
N = len(S)
change = ['1','0']

count = 0
for i in range(1,N):
    if S[i] == S[i-1]:
        count += 1
        idx = int(S[i])
        S[i] = change[idx]
        
print(count)

Solution (Python):
s = input()
ans = float('inf')
for j in range(2):
    c = 0
    val = j
    for i in s:
        if val == int(i):
            c += 1
        val = (val + 1) % 2
    ans = min([ans, c])
print(ans)

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

S = list(input())

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

Solution (Python):
def zeroOne(start=0):
    """Infinite sequence of alternating zero and one."""
    assert start == 0 or start == 1
    x = start
    while True:
        yield x
        x = 1 - x

def cost(S, zeroOne):
    """The number of different tiles between S and zeroOne sequence."""
    return sum(1 for c, z in zip(S, zeroOne) if int(c) == z)

S = input()

v = min(cost(S, zeroOne(0)), cost(S, zeroOne(1)))
print(v)

Solution (Python):
s = input()
li = [int(a) for a in s]
tem = []
cnt = 0
for i in range (len(li)):
    if i%2 == 1:
        tem.append(0)
    else:
        tem.append(1)
    if li[i] == tem[i]:
        cnt+= 1
if cnt <= (len(li) / 2):
    print(str(cnt))
else:
    print(str(len(li) - cnt))

Solution (Python):
a = input()
kazu = 0
a = [int(i) for i in a]
if a[0]==0:
    check = [ 0 if i%2==0 else 1 for i in range(len(a))]
else:
    check = [ 1 if i%2==0 else 0 for i in range(len(a))]
for i in range(len(a)):
    if a[i]!=check[i]:
        kazu+=1
print(kazu)

Solution (Python):
S = input()
oddblack, oddwhite = 0,0
evenblack, evenwhite = 0,0
for i,x in enumerate(S):
    if i % 2 == 1:
        if x == '0':
            oddblack += 1
        else:
            oddwhite += 1
    else:
        if x == '0':
            evenblack += 1
        else:
            evenwhite += 1

answer = min(oddblack + evenwhite , oddwhite + evenblack)
print(answer)

Solution (Python):
import sys
import math

mat = list(sys.stdin.readline().strip())

odd = 0
even = 0
for i, x in enumerate(mat):
    flg = i % 2
    if flg:
        if int(x) == 1:
            even += 1
        else:
            odd += 1
    else:
        if int(x) == 1:
            odd += 1
        else:
            even += 1

print(min(odd, even))

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

if N%2 == 0:
    S_1 = "01"*(N//2)
    S_2 = "10"*(N//2)
else:
    S_1 = "01"*(N//2) + "0"
    S_2 = "10"*(N//2) + "1"
    
    
def distance(S,T,N):
    cnt = 0
    for i in range(N):
        if S[i] != T[i]:
            cnt += 1
    return cnt

print(min(distance(S,S_1,N),distance(S,S_2,N)))

Solution (Python):
import numpy as np
s = [int(i) for i in input()]

n = len(s)

list01 = [int(i%2) for i in range(n)]
list10 = [int((i+1)%2) for i in range(n)]

        
list_a = np.array(s) - np.array(list01)
list_b = np.array(s) - np.array(list10)

count0 = np.sum(list_a == 0)
count1 = np.sum(list_b == 0)
countmin = min((n-count0),(n-count1))
print(countmin)

Solution (Python):
S = input()
even_0 = 0
even_1 = 0
odd_0 = 0
odd_1 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            even_0 = even_0 + 1
        else:
            even_1 = even_1 + 1
    else:
        if S[i] == "0":
            odd_0 = odd_0 + 1
        else:
            odd_1 = odd_1 + 1
print(min(even_0 + odd_1, even_1 + odd_0))

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

p = [S[i] for i in range(0,s) if i%2 == 0]
q = [S[i] for i in range(1,s) if i%2 == 1]

p_1 = p.count('1')
p_0 = len(p)-p_1

q_1 = q.count('1')
q_0 = len(q)-q_1

if p_1 > p_0:
    if q_0 > q_1:
        ans = p_0 + q_1

    else:
        if p_1-p_0 > q_1-q_0:
            ans = p_0+q_1
        else:
            ans = p_1+q_0

else:
    if q_1 > q_0:
        ans = p_1 + q_0

    else:
        if p_0-p_1 > q_0-q_1:
            ans = p_1+q_0
        else:
            ans = p_0+q_1

print(ans)

Solution (Python):
number = input()
tile = [int(i) for i in number]
even = sum(tile[0::2])
odd = sum(tile) - even
ex1 = ((len(tile) // 2) - odd) + even
ex2 = ((len(tile) - (len(tile) // 2)) - even) + odd
print(min(ex1,ex2))

Solution (Python):
S = [int(i) for i in input()]
A = sum([int(i % 2 == 0) == v for i, v in enumerate(S)])
B = sum([int(i % 2 != 0) == v for i, v in enumerate(S)])
print(min(A, B))

Solution (Python):
s = input()
s = [int(x) for x in s]
length = len(s)
a,b=[],[]
counter = 0
countera = 0
counterb =0
for index,val in enumerate(s):
  if counter == 0:
    if val == 0:
      counterb += 1
    else:
      countera += 1
  else:
    if val == 0:
      countera += 1
    else:
      counterb += 1
  counter ^= 1
print(min(countera,counterb))

Solution (Python):
s = list(input())
n = len(s)
tempa = []
tempb = []
for i in range(n):
    if i%2 == 0:
        tempa.append("0")
        tempb.append("1")
    else:
        tempa.append("1")
        tempb.append("0")
    
countera = 0
counterb = 0
for i in range(n):
    if s[i] != tempa[i]:
        countera += 1
    if s[i] != tempb[i]:
        counterb += 1
print(min(countera,counterb))

Solution (Python):
c = 0
for i, n in enumerate(input()):
  c += i%2 ^ int(n)
print(min(c, i-c+1))

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

Solution (Python):
import sys

a = input()
S = [int(c) for c in a]

ans = 0

if S[0] == 0:
	nxt = 1
else:
	nxt = 0

for i, tar in enumerate(S):
	if tar == 0:
		nxt = 1
	else:
		nxt = 0

	if i!=len(S)-1 and S[i] == S[i+1]:
		S[i+1] = nxt
		ans += 1
	

print(ans)

Solution (Python):
s = input()

mod = 0
temp = 0
for c in s:
    if int(c) == mod:
        temp += 1
    mod = (mod + 1) % 2

ans = temp

mod = 1
temp = 0
for c in s:
    if int(c) == mod:
        temp += 1
    mod = (mod + 1) % 2

ans = min(ans, temp)

print(ans)

Solution (Python):
S = input()
N = len(S)
if N%2==0:
    pattern_A = "01"*(N//2)
    pattern_B = "10"*(N//2)
else:
    pattern_A = "01"*(N//2)+"0"
    pattern_B = "10"*(N//2)+"1"
error_A, error_B = 0, 0
for i in range(N):
    if pattern_A[i] != S[i]:
        error_A += 1
    if pattern_B[i] != S[i]:
        error_B += 1
ans = error_A if error_A<error_B else error_B
print(ans)

Solution (Python):
S = input()
correct_case1 = "".join(["0" if i%2 == 0 else "1" for i in range(len(S))])
correct_case2 = "".join(["0" if i%2 == 1 else "1" for i in range(len(S))])
c1 = 0
c2 = 0
for i in range(len(S)):
  if correct_case1[i] != S[i]:
    c1 += 1
  if correct_case2[i] != S[i]:
    c2 += 1
print(min([c1, c2]))

Solution (Python):
str = input()
S = list(str)
N = len(S)
count = 0
for x in range(N):
    if x % 2 == 0 and S[x] == "0":
        count += 1
    elif x % 2 == 1 and S[x] == "1":
        count += 1
if count > N / 2:
    print(N - count)
else:
    print(count)

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

if len(tile) == 1:
  print(0)
else:
  tile_odd = tile[0::2]
  tile_odd_0 = tile_odd.count("0")
  tile_odd_1 = tile_odd.count("1")
  tile_even = tile[1::2]
  tile_even_0 = tile_even.count("0")
  tile_even_1 = tile_even.count("1")
  ans = min(tile_odd_0 + tile_even_1, tile_odd_1 + tile_even_0)
  print(ans)

Solution (Python):
s=[int(i) for i in input()]
a=s[1::2]
b=s[::2]
print(min(a.count(0)+sum(b),sum(a)+b.count(0)))

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

even = l[0::2]
odd = l[1::2]

l = sum(map(lambda x:abs(1-x), even)) + sum(odd)
r = sum(map(lambda x:abs(1-x), odd)) + sum(even)

print(min(l, r))

Solution (Python):

s=input()
n=len(s)
ch=['0','1']
ans=[0,0]
x,y=0,1
for i in range(n):
    if s[i]==ch[x]:
        ans[0]+=1
    if s[i]==ch[y]:
        ans[1]+=1
    x=1-x
    y=1-y
    
print(min(ans))

Solution (Python):
n = input()
c1 = c2 = 0
l = len(n)
c1 = l - len([i for i in n[0::2] if i == "0"]) - len([i for i in n[1::2] if i == "1"])
c2 = l - len([i for i in n[0::2] if i == "1"]) - len([i for i in n[1::2] if i == "0"])

print(min(c1,c2))

Solution (Python):
S = input()
c1 = c2 = 0
 
N = len(S)
c1 = N - len([s for s in S[0::2] if s == "0"]) - len([s for s in S[1::2] if s == "1"])
c2 = N - len([s for s in S[0::2] if s == "1"]) - len([s for s in S[1::2] if s == "0"])
 
print(min(c1, c2))

Solution (Python):
S = input()
c1 = c2 = 0

N = len(S)
c1 = N - (len([s for s in S[0::2] if s == "0"]) + len([s for s in S[1::2] if s == "1"]))
c2 = N - (len([s for s in S[0::2] if s == "1"]) + len([s for s in S[1::2] if s == "0"]))

print(min(c1, c2))

Solution (Python):
S=input()
N=len(S)
comp1=""
comp2=""
count1=0
count2=0
for i in range(N):
    if i%2==0:
        comp1+="1"
        comp2+="0"
    else:
        comp1+="0"
        comp2+="1"
for i in range(N):
    if comp1[i]!=S[i]:
        count1+=1
    else:
        count2+=1
print(min(count1,count2))

Solution (Python):
s = input()

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

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


wrong1, wrong2 = 0, 0
for i in range(len(s)):
    if s[i] != answer1[i]:
        wrong1 += 1
    if s[i] != answer2[i]:
        wrong2 += 1

print(min([wrong1, wrong2]))

Solution (Python):
import sys

if __name__ == '__main__':
    S = list(map(lambda x: int(x), sys.stdin.readline().rstrip()))
    M1 = [0 if i % 2 == 0 else 1 for i in range(len(S))]
    M2 = [0 if i % 2 == 1 else 1 for i in range(len(S))]
    d1 = sum([1 if S[i] != M1[i] else 0 for i in range(len(S))])
    d2 = sum([1 if S[i] != M2[i] else 0 for i in range(len(S))])
    if d1 < d2:
        print(d1)
    else:
        print(d2)

Solution (Python):
S = input()

length_S = len(S)

wrong_10 = 0
wrong_01 = 0

for i in range(length_S):
	if i%2 == 0:
		if S[i] == '1':
			wrong_01 += 1
		else:
			wrong_10 += 1
	else:
		if S[i] == '1':
			wrong_10 += 1
		else:
			wrong_01 += 1
			
print(min(wrong_01, wrong_10))

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

t = "01"*(-((-1)*len(s)//2))

cnt_1 = 0
cnt_2 = 0

for i in range(len(s)):
    if s[i] == t[i]:
        cnt_1 += 1

    else:
        cnt_2 += 1

print(min(cnt_1,cnt_2))

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

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

print(min(cnt,len(s)-cnt))

Solution (Python):
tile = input()

cor_list = ["10"*50000, "01"*50000]

diff_1 = int("0b"+tile, 2) ^ int("0b"+cor_list[0][:len(tile)], 2)  
diff_2 = int("0b"+tile, 2) ^ int("0b"+cor_list[1][:len(tile)], 2)

score = [0, 0]
score[0] = sum([int(s) for s in bin(diff_1)[2:]])
score[1] = sum([int(s) for s in bin(diff_2)[2:]])

print(min(score))

Solution (Python):
S = input().rstrip()
s = list(S)
N = len(S)
c = 0
v = [None] * N
v[0] = s[0]
if N == 1:
  print(c)
else:
  for i in range(1,N):
    
    if s[i]=='0' and v[i-1] =='0':
      v[i] = '1'
      c +=1
    elif s[i] =='1' and v[i-1] == '1':
      v[i] = '0'
      c +=1
    elif s[i] =='1' and v[i-1] == '0':
      v[i] = '1'
    elif s[i] =='0' and v[i-1] == '1':
      v[i] = '0'
    

  print(c)

Solution (Python):
S = list(map(str, input()))
listA = ["0"]
listB = ["1"]
countA = 0
countB = 0

for i in range(len(S)):
  listA.append(str((i+1)%2))
  listB.append(str(i%2))
  if listA[i] != S[i]:
    countA = countA + 1
  if listB[i] != S[i]:
    countB = countB + 1

if countA <= countB:
  print(countA)
else:
  print(countB)

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

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

w = []
for i in range(n):
    w.append(int(s[i]))

counta = 0
for i in range(n):
    if i % 2 == 0:
        if w[i] != 0:
            counta = counta + 1
    else:
        if w[i] != 1:
            counta = counta + 1

countb = 0
for i in range(n):
    if i % 2 == 0:
        if w[i] != 1:
            countb = countb + 1
    else:
        if w[i] != 0:
            countb = countb + 1

print(min(counta, countb))

Solution (Python):
s = input()

s_val = int(s, 2)


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

num = min(str(bin(s_val^int(s1,2))).count('1'), str(bin(s_val^int(s2,2))).count('1'))
print(num)

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

input_array = list(s)


correct_data = []
patarn0 = 0
for i in range(len(input_array)):
  if (i % 2) == 0:
    correct_data.append("0")
  else:
    correct_data.append("1")

for i in range(len(input_array)):
  if correct_data[i] != input_array[i]:
    patarn0 += 1



correct_data = []
patarn1 = 0
for i in range(len(input_array)):
  if (i % 2) == 0:
    correct_data.append("1")
  else:
    correct_data.append("0")


for i in range(len(input_array)):
  if correct_data[i] != input_array[i]:
    patarn1 += 1


if patarn1 > patarn0:
  print(patarn0)
else:
  print(patarn1)

Solution (Python):
import numpy as np

S = np.array(list(map(int, list(input()))))
q, r = len(S) // 2, len(S) % 2
a1 = np.array([1, 0] * q + [1] * r)  
a2 = np.array([0, 1] * q + [0] * r)  

print(min(sum(abs(a1 - S)), sum(abs(a2 - S))))

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

b,w=0,0
for i in range(N):
    if i%2==0:
        if s[i]=="1": b+=1
        else: w+=1

    
    else:
        if s[i]=="1": w+=1
        else: b+=1

print(min(b,w))

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

Solution (Python):
S = input()

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

n = len(S) // 2
S1 = '01' * n
S2 = '10' * n
if n % 2 == 1:
    S1 += '0'
    S2 += '1'
ret1 = 0
ret2 = 0
for idx, s in enumerate(S):
    if S1[idx] != s:
        ret1 += 1
    if S2[idx] != s:
        ret2 += 1


print(min(ret1, ret2))

Solution (Python):
color = [int(x) for x in list(input())]

cnt1 = 0
cnt2 = 0

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

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

Solution (Python):
*s,=map(int,input())
n=len(s)
a=sum(s[::2])+n//2-sum(s[1::2])
print(min(a,n-a))

Solution (Python):
S = input()

size = len(S)



swaps = 0

for i, s in enumerate(S):
    
    if (i % 2 == 0 and s == '1') or (i % 2 == 1 and s == '0'):
        swaps += 1

print(min(swaps, size - swaps))

Solution (Python):



def main():
    s = list(map(int, input()))
    n = len(s)

    case1 = [0] * n
    case2 = [0] * n

    for i in range(n):
        if i % 2 == 0:
            case1[i] = 1
        else:
            case2[i] = 1

    count1 = 0
    count2 = 0

    for one, si in zip(case1, s):
        if one != si:
            count1 += 1

    for two, si in zip(case2, s):
        if two != si:
            count2 += 1

    print(min(count1, count2))


if __name__ == '__main__':
    main()

Solution (Python):
inp = input()
w = 0
list0 = []
list1 = []
for i in inp:
  if w == 0:
    list0.append(int(i))
    w = 1
  else:
    list1.append(int(i))
    w = 0

sum0 = sum(list0)
sum1 = sum(list1)
pat0 = sum(list0) + len(list1) - sum(list1)
pat1 = sum(list1) + len(list0) - sum(list0) 


print (min(pat0, pat1))

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

C = []
for i in range(len(S)):
    if i%2 == 0:
        C.append('0')
    if i%2 == 1:
        C.append('1')

a = 0
for s,c in zip(S, C):
    if s == c:
        a += 1

print(min([a, len(S)-a]))

Solution (Python):
import numpy as np
tile=str(input())
a=['01','10'][int(tile[0])]*(10**5//2)
print(sum(np.array(list(tile),dtype=int)^np.array(list(a[:len(tile)]),dtype=int)))

Solution (Python):
str = input()

count = 0
for i, s in enumerate(str):
    if (i + int(s)) % 2 == 0:
        count += 1

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

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

X1 = "10" * ((S_len // 2)+1)
X2 = "01" * ((S_len // 2)+1)

ans = 0
if S[0] == "0":
    for i in range(S_len):
        if X2[i] != S[i]:
            ans += 1
elif S[0] == "1":
    for i in range(S_len):
        if X1[i] != S[i]:
            ans += 1
    
print(ans)

Solution (Python):
from copy import *
s = str(input())
n = len(s)
ans = 0
S = s
for i in range(n):
    if i % 2 == 0:
        if s[i] == "1":
            ans += 1

    else:
        if s[i] == "0":
            ans += 1

aans = 0
for i in range(n):
    if i % 2 == 0:
        if S[i] == "0":
            aans += 1

    else:
        if S[i] == "1":
            aans += 1

print(min(ans,aans))

Solution (Python):
import sys
 
def main():
    input = sys.stdin.readline
    S = str(input().strip())
 
    cnt_01 = 0
    cnt_10 = 0
    for i in range(len(S)):
        s = S[i]
 
        if i % 2 == 0:
            if s != '0':
                cnt_01 += 1
            else:
                cnt_10 += 1
        else:
            if s != '0':
                cnt_10 += 1
            else:
                cnt_01 += 1
 
    return min(cnt_01, cnt_10)
 
 
if __name__ == '__main__':
    print(main())

Solution (Python):
s = str(input())
n = len(s)
s1 = ""
s2 = ""
for i in range(n):
    if(i&1):
        s1 += "0"
        s2 += "1"
    else:
        s1 += "1"
        s2 += "0"
ans1 = 0 ; ans2 = 0
for i in range(n):
    if(s[i] != s1[i]):
        ans1 += 1
    if(s[i] != s2[i]):
        ans2 += 1
print(min(ans1 , ans2))

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

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

Solution (Python):


S = input()

s0 = 0
s1 = 0
flag = False

for i in S:
    if (i == "1") ^ flag:
        s0 += 1
    if (i == "0") ^ flag:
        s1 += 1
    flag = not(flag)
    
print(min(s0, s1))

Solution (Python):
import numpy as np

S = input()

tile_color = []
for i in S:
    tile_color.append(int(i))

candidate = np.zeros((2,len(S)))
candidate[0, 0::2] = 1
candidate[1, 1::2] = 1

distance = [np.sum(np.abs(candidate[0,:] - tile_color)), np.sum(np.abs(candidate[1,:] - tile_color))]

print(int(min(distance)))

Solution (Python):
s=input()
s1='01'*(len(s)//2)+'0'*(len(s)%2)
s2='10'*(len(s)//2)+'1'*(len(s)%2)
ans1=0
ans2=0
for i,j,k in zip(s,s1,s2):
    if i!=j:ans1+=1
    if i!=k:ans2+=1
print(min(ans1,ans2))

Solution (Python):
a = list(input())
a = [int(x) for x in a]

cou = 0
cou2 = 0
b = [0]
c = [1]

if a[0] == 0:
    cou2 += 1
else:
    cou += 1
    
for i in range(len(a)-1):
    if b[i] == a[i+1]:
        cou += 1
        if b[i] == 1:
            x = 0
            b.append(x)
        else:
            x = 1
            b.append(x)
    else:
        b.append(a[i+1])
        
for i in range(len(a)-1):
    if c[i] == a[i+1]:
        cou2 += 1
        if c[i] == 1:
            x = 0
            c.append(x)
        else:
            x = 1
            c.append(x)
    else:
        c.append(a[i+1])
        
print(cou if cou < cou2 else cou2)

Solution (Python):
g = True
a=[0,0]
for i in map(int,list(input())):
  if g == bool(i):
    a[0]+=1
  else:
    a[1]+=1
  g = not g
print(min(a))

Solution (Python):
S = list(input())
odds = [S[i] for i in range(len(S)) if i % 2 == 0]
evens = [S[i] for i in range(len(S)) if i % 2 != 0]
ans = []
ans.append(odds.count("0")+evens.count("1"))
ans.append(odds.count("1")+evens.count("0"))
print(min(ans))

Solution (Python):
from collections import Counter

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
N = len(S)
if len(S) != 1:
    C1 = Counter(S[::2])
    C2 = Counter(S[1::2])

    odd = C1['0']+C2['1']
    even = C1['1']+C2['0']
    print(N-max(odd, even))
else:
    print(0)

Solution (Python):
if __name__ == "__main__":
    l = str(input())
    l = [int(x) for x in list(str(l))]
    length = len(l)
    temp1 = []
    temp2 = []
    for i in range(length):
        temp1.append(i % 2)
        temp2.append((i + 1) % 2)
    t1 = 0
    t2 = 0
    for n in range(length):
        if temp1[n] != l[n]:
            t1 += 1
        if temp2[n] != l[n]:
            t2 += 1
    print(min(t1, t2))

Solution (Python):
s=input()

a=[]
b=[]

for i in range(len(s)):
  if i%2==0:
    a.append(0)
    b.append(1)
  else:
    a.append(1)
    b.append(0)
ans1=0
ans2=0
for i in range(len(s)):
  if a[i]==int(s[i]):
    ans1+=1

for i in range(len(s)):
  if b[i]==int(s[i]):
    ans2+=1    
    

print(min(ans1,ans2))

Solution (Python):
S = input()
alt = '0'
n = 0
for c in S:
  if c == alt:
    n += 1
  if alt == '0':
    alt = '1'
  else:
    alt = '0'

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

Solution (Python):
a= input()

ans, res = 0,0

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

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

print(min(ans,res))

Solution (Python):
s = str(input())
odd = s[1::2]
even = s[0::2]
a = odd.count("0") + even.count("1")
b = odd.count("1") + even.count("0")
print(min(a,b))

Solution (Python):
S=input()
l,len01,len10=2,0,0
for i in range(len(S)):
	if (l%2==0)&(S[i]=='1'):
		len10+=1
	elif (l%2==0)&(S[i]=='0'):
		len01+=1
	if (l%2==1)&(S[i]=='1'):
		len01+=1
	elif (l%2==1)&(S[i]=='0'):
		len10+=1
	l+=1
print(min(len01,len10))

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

Solution (Python):
def subtract_lst (lst1, lst2):
    ans = 0
    for i in range(len(lst1)):
        e1 = lst1[i]
        e2 = lst2[i]
        if e1 != e2:
            ans += 1
    return ans

if __name__ == '__main__':
    s = input()
    lenS = len(s)
    a = ""
    b = ""
    for i in range(lenS // 2):
      a = a + "10"
      b = b + "01"
    if lenS % 2 == 1:
        a = a + "1"
        b = b + "0"
    aAns = subtract_lst (a, s)
    bAns = subtract_lst (b, s)
    print (min(aAns, bAns))

Solution (Python):
s=list(input())
odd,even=s[1::2],s[0::2]
print(min(even.count('0') + odd.count('1'), even.count('1') + odd.count('0')))

Solution (Python):
s = input()

a = "01"*int(len(s)/2) + "0"*int(len(s)%2)
b = "10"*int(len(s)/2) + "1"*int(len(s)%2)

a_count = 0
b_count = 0
for i, j, k in zip(a, b, s):
    if i != k:
        a_count += 1
    if j != k:
        b_count += 1

print(min(a_count, b_count))

Solution (Python):

S = list(input())

N = len(S)
count_1010 = 0
count_0101 = 0


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


for j in range(N):
    
    if j % 2 == 0:
        if S[j] != "0":
            count_0101 += 1
    
    else:
        if S[j] != "1":
            count_0101 += 1


print(min(count_0101, count_1010))

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

Solution (Python):


s=[int(s) for s in raw_input()]
s0=[x%2 for x in xrange(len(s))]
s1=[(x^1)%2 for x in xrange(len(s))]
t0,t1=[],[]
for i in xrange(len(s)):
 t0.append(s[i]^s0[i])
 t1.append(s[i]^s1[i])
print min(sum(t0),sum(t1))

Solution (Python):

import sys


def solve(S: int):
    first0 = 0
    first1 = 0
    for i in range(len(S)):
        c = S[i]
        if i % 2 == 0:
            if c == '0':
                first0 += 1
            else:
                first1 += 1
        else:
            if c == '0':
                first1 += 1
            else:
                first0 += 1
    print(min(first0, first1))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
s=input()
count =0
isSuccession = True 
for i in range(len(s) -1):
    if s[i] != s[i+1]:
        if isSuccession == False:
            count +=1
    else:
        isSuccession = (isSuccession+1)%2
        if isSuccession == False:
            count +=1
print(min(count, len(s) - count))

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

ans1 = 0
ans2 = 0

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

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):
N = str(input())
N_list = [int(x) for x in list(N)]
counter = 0
mae = N_list[0]
for i in range(len(N_list)-1):
    if N_list[i+1]==mae:
        counter +=1
        if mae == 0:
            N_list[i+1]=1
        else:
            N_list[i+1]=0

    mae=N_list[i+1]

print(counter)

Solution (Python):
s = input()
count_0 = 0
count_1 = 0
for i, si in enumerate(s):
    if i % 2 == 0 and si == '1':
        count_0 += 1
    elif i % 2 == 1 and si == '0':
        count_0 += 1

for i, si in enumerate(s):
    if i % 2 == 0 and si == '0':
        count_1 += 1
    elif i % 2 == 1 and si == '1':
        count_1 += 1

print(min(count_0, count_1))

Solution (Python):
S = input()

ans1 = 0
ans0 = 0

for s in S:
    if s == "0":
        ans1 += 1
    elif s == "1":
        ans0 += 1
    ans1, ans0 = ans0, ans1

print(min(ans1, ans0))

Solution (Python):
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  
def LF(): return [float(x) for x in sys.stdin.readline().split()]  
def LS(): return sys.stdin.readline().split()  
def MI(): return map(int, sys.stdin.readline().split())  
def II(): return int(sys.stdin.readline())  
def IS(): return input()  
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


s = IS()
P(min(s[::2].count('1')+s[1::2].count('0'), s[::2].count('0')+s[1::2].count('1')))

Solution (Python):
S=input()
a,b=list(map(int,S[::2])),list(map(int,S[1::2]))
p,q=sum(a),sum(b)
r,s=len(a)-sum(a),len(b)-sum(b)
print(min(p+s,q+r))

Solution (Python):
S = input()
S = list(S)
b_num =0
w_num = 0
for i in range(0,len(S),2):
    if S[i] == '0':
        b_num +=1
    else:
        w_num += 1
for i in range(1,len(S),2):
    if S[i] == '0':
        w_num +=1
    else:
        b_num += 1

ans = min([b_num , w_num])
print(ans)