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 = [int(i) for i in list(input())]
n = len(s)

a,b = [],[]

for i in range(n):
    if i%2 == 0:
        a.append(0)
        b.append(1)
    else:
        a.append(1)
        b.append(0)

A,B = 0,0

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

print(min(A,B))

Solution (Python):
def main():
    s = input()

    ans1 = 0
    ans0 = 0

    s_len = len(s)

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

    print(min(ans0,ans1))

if __name__ == '__main__':
    main()

Solution (Python):
s = input()

ans1 = 0
ans2 = 0
for i, title in enumerate(s):
    if i % 2 == 0 and title != "0":
        ans1 += 1
    if i % 2 == 1 and title != "1":
        ans1 += 1
    if i % 2 == 1 and title != "0":
        ans2 += 1
    if i % 2 == 0 and title != "1":
        ans2 += 1

print(min(ans1, ans2))

Solution (Python):
s = input()

so=""
se=""
for i in range(1, len(s), 2):
  so += s[i]
for i in range(0, len(s), 2):
  se += s[i]

print(len(s) - max(so.count("1") + se.count("0"), so.count("0") + se.count("1")))

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

def check(x, y):
    count = 0
    for i in range(len(x)):
        if x[i] != y[i]:
            count += 1
    print(count)

if ls%2 == 0:
    if s[0] == '1':
        s1 = '10'*(ls//2)
        check(s, s1)
    if s[0] == '0':
        s2 = '01'*(ls//2)
        check(s, s2)
else:
    if s[0] == '1':
        s3 = '10'*(ls//2) + '1'
        check(s, s3)
    if s[0] == '0':
        s4 = '01'*(ls//2) + '0'
        check(s, s4)

Solution (Python):
import sys
s = list(sys.stdin.readline())
n = len(s)

ans = 0
for i in range(n-1):
    if s[i] != s[i+1]: continue
    if s[i] == '0': s[i+1] = '1'
    else: s[i+1] = '0'
    ans += 1
print(ans)

Solution (Python):
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
import itertools





read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

S = readline().decode('utf8').rstrip()

f0 = S[::2].count('0') + S[1::2].count('1')
f1 = S[::2].count('1') + S[1::2].count('0')
print(min(f0, f1))

Solution (Python):
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys
import itertools





read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

S = readline().decode('utf8').rstrip()
L = len(S)


def odd(M):
    while len(M) != L:
        if len(M) % 2 == 0:
            M += '1'
        else:
            M += '0'
    return M


def even(M):
    while len(M) != L:
        if len(M) % 2 == 0:
            M += '0'
        else:
            M += '1'
    return M


temp = ''
A = odd(temp)
B = even(temp)
na = sum(i == j for i, j in zip(S, A))
nb = sum(i == j for i, j in zip(S, B))
print(min(na, nb))

Solution (Python):
s = list(input())
even_s = s[0::2]
odd_s = s[1::2]
cnt = 0
for i in range(len(even_s)):
    if even_s[i] != '0':
        cnt += 1

for i in range(len(odd_s)):
    if odd_s[i] != '1':
        cnt += 1

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

Solution (Python):
import copy
s = list(input())
c = copy.copy(s)
n = len(s)
cnt1 = cnt2 = 0
for i in range(n-1):
    if c[i+1]==c[i]:
        cnt1 += 1
        c[i+1] = '0' if c[i+1]=='1' else '1'
s[0] = '0' if s[0]=='1' else '1'
cnt2+=1
for i in range(1,n):
    if s[i-1]==s[i]:
        cnt2 += 1
        s[i] = '0' if s[i]=='1' else '1'
print(min(cnt1,cnt2))

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

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

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

print(cnt)

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

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

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

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

print(cnt)

Solution (Python):
S = list(str(input()))
count = 0
if S[0] == "1":
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "0":
            count += 1
        elif i % 2 == 1 and j == "1":
            count += 1
else:
    for i, j in enumerate(S):
        if i % 2 == 0 and j == "1":
            count += 1
        elif i % 2 == 1 and j == "0":
            count += 1
print(count)

Solution (Python):
s=input()
cnt1=cnt2=0
m=["0","1"]
for i in range(len(s)):
    if s[i]!=m[0]:
        cnt1+=1
    else:
        cnt2+=1
    m[0],m[1]=m[1],m[0]
print(min(cnt1,cnt2))

Solution (Python):
s=input()
leng=len(s)
cnt1=cnt2=0
m=["0","1"]
for i in range(leng):
    if s[i]!=m[0]:
        cnt1+=1
    else:
        cnt2+=1
    t=m[0]
    m[0]=m[1]
    m[1]=t
print(min(cnt1,cnt2))

Solution (Python):
import sys

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

sys.setrecursionlimit(10 ** 9)


def main():
    S = INPUT()
    N = len(S)

    s = ["", ""]
    for i in range(N):
        for j in range(2):
            s[j] += str((i + j)%2)

    cnt = [0, 0]
    for i in range(N):
        for j in range(2):
            if s[j][i] != S[i]: cnt[j] += 1

    print(cnt[0] if cnt[0] < cnt[1] else cnt[1])


if __name__ == '__main__':
    main()

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

if n%2==0:
  m=n//2
  ans1=(4**m-1)//3
  ans2=2*ans1
else:
  m=(n-1)//2
  ans1=(4**(m+1)-1)//3
  ans2=2*(4**m-1)//3

  
s=int(s,2)
tmp1=bin(ans1^s).count('1')
tmp2=bin(ans2^s).count('1')
print(min(tmp1,tmp2))

Solution (Python):
S = input()
d = int(S[0])
T = []
U = []
for i in range(len(S)):
  T.append(d)
  d = (d + 1) % 2
  U.append(d)
count1 = 0
count2 = 0
for i in range(len(S)):
  if int(S[i]) != T[i]:
    count1 += 1
  if int(S[i]) != U[i]:
    count2 += 1
print(min(count1, count2))

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

evensum=0
oddsum=0
for i in range(n):
    evenflg=i%2
    if s[i]=="0":
        if evenflg==1:
            oddsum=oddsum+1
        else:
            evensum=evensum+1
    else:
        if evenflg==0:
            oddsum=oddsum+1
        else:
            evensum=evensum+1
if evensum<oddsum:
    print(evensum)
else:
    print(oddsum)

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

if (s[0] == '0'):
   x = '01' * int(m/2)
   if (m % 2 == 1):
      x += '0'
else:
   x = '10' * int(m/2)
   if (m % 2 == 1):
      x += '1'

ans = [0 if s[i] == x[i] else 1 for i in range(m)]
print(sum(ans))

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

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

print(min(ans1, ans2))

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

Solution (Python):
S = list(input())
S_con = []
ctr = 1

for i in range(len(S)-1):
    if (S[i] != S[i + 1]):
        ctr += 1
    else:
        S_con.append(ctr)
        ctr = 1

if (ctr > 1):
    S_con.append(ctr)
else:
    S_con.append(1)

even = sum(S_con[0::2])
odd=sum(S_con[1::2])
answer = min(even, odd)
print(answer)

Solution (Python):
s = input()

even_position_nums = s[::2]
len_even = len(even_position_nums)
odd_position_nums = s[1::2]
len_odd = len(odd_position_nums)



tmp = len_even - even_position_nums.count('1')
tmp1 = len_odd - odd_position_nums.count('0')
first = tmp + tmp1

tmp = len_even - even_position_nums.count('0')
tmp1 = len_odd - odd_position_nums.count('1')
second = tmp + tmp1
print(min(first, second))

Solution (Python):
s = [int(x) for x in list(map(str, input()))]

ans = 0

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

print(ans)

Solution (Python):
s = list(input())
cnt1 = 0
cnt2 = 0
val1 = 0
val2 = 1
for i in range(len(s)):
    if int(s[i]) == val1 % 2:
        cnt1 += 1
    val1 += 1
    if int(s[i]) == val2 % 2:
        cnt2 += 1
    val2 += 1
print(min(cnt1, cnt2))

Solution (Python):
def solve(s):
    l = len(s)
    even_0 = len([s[i] for i in range(l) if i % 2 == 0 and s[i] == '0'])
    even_1 = len([s[i] for i in range(l) if i % 2 == 0 and s[i] == '1'])
    odd_0 = len([s[i] for i in range(l) if i % 2 == 1 and s[i] == '0'])
    odd_1 = len([s[i] for i in range(l) if i % 2 == 1 and s[i] == '1'])

    return even_0 + odd_1 if even_0 + odd_1 < even_1 + odd_0 else even_1 + odd_0


if __name__ == '__main__':
    s = input()
    print(solve(s))

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

l01 = ["0" if i % 2 == 0 else "1" for i in range(len(s))]
l10 = ["1" if i % 2 == 0 else "0" for i in range(len(s))]

count01 = 0
count10 = 0
for i in range(len(s)):
    if s[i] != l01[i]:
        count01 += 1

for i in range(len(s)):
    if s[i] != l10[i]:
        count10 += 1

print(min(count01, count10))

Solution (Python):
S = list(input())
s1 = S[::2]
s2 = S[1::2]
res1 = s1.count("0") + s2.count("1")
res2 = s1.count("1") + s2.count("0")
print(min(res1, res2))

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

Solution (Python):
S = input()
cnt = 0
ch = S[0]
for i in range(1,len(S)):
	if S[i] == ch:
		cnt+=1
		if ch == "0":
			ch = "1"
		else:
			ch = "0"
	else:
		ch = S[i]
print(cnt)

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = tuple(map(int, tuple(input())))

    ans = 10 ** 5
    for i in range(2):
        v = i
        a = 0
        for s in S:
            if s != v:
                a += 1
            v = 1 if v == 0 else 0
        ans = min(ans, a)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools



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

S = readline().decode('utf8')
f0 = S[::2].count('1') + S[1::2].count('0')
f1 = S[::2].count('0') + S[1::2].count('1')

print(min(f1, f0))

Solution (Python):
s = input()
count_2 = 0
count_1 = 0
sum_2 = 0
sum_1 = 0
for i in range(0,len(s),2):
    sum_2 += 1
    if s[i] == "0":
        count_2 += 1
for i in range(1, len(s), 2):
    sum_1 += 1
    if s[i] == "0":
        count_1 += 1
p1 = sum_1 - count_1 + count_2
p2 = sum_2 - count_2 + count_1
if p1 <= p2:
    print(p1)
else:
    print(p2)

Solution (Python):
s = input()

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

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

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

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

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

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

print(count)

Solution (Python):
S = input()

c = int(S, 2)
a = int(''.join('0' if x % 2 == 0 else '1' for x in range(len(S))), 2) ^ c
b = int(''.join('1' if x % 2 == 0 else '0' for x in range(len(S))), 2) ^ c

ax = len([x for x in str(bin(a)) if x == '1'])
bx = len([x for x in str(bin(b)) if x == '1'])

print(min(ax, bx))

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

odd = even = 0
for i in range(len(S)):
    if i % 2 + S[i] == 1:
        even += 1
    if i % 2 + S[i] != 1:
        odd += 1
print(min(odd, even))

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

Solution (Python):
s=list(input())
n=len(s)
dic={"0":"1","1":"0"}

temp=[]
temp.append(s[0])
ans=0
for i in range(1,n):
    temp.append(dic[temp[i-1]])

for i in range(n):
    if temp[i]!=s[i]:
        ans+=1
print(ans)

Solution (Python):
s = input()
n = sum((i+int(c))%2 for i,c in enumerate(s))
print(min(n, len(s)-n))

Solution (Python):
S=list(input())
A=[]
B=[]
a=0
b=0
for i in range(len(S)):
    if i%2==0:
        A.append("0")
    else:
        A.append("1")
for i in range(len(S)):
    if A[i]!=S[i]:
        a+=1
for j in range(len(S)):
    if j%2==0:
        B.append("1")
    else:
        B.append("0")
for j in range(len(S)):
    if B[j]!=S[j]:
        b+=1
print(min(a, b))

Solution (Python):
s=input()
li=[]
ans = 0
for i in range(len(s)):
  if i == 0:
    li.append(s[i])
  else:
    if s[i] == li[-1] and s[i] == "0":
      li.append("1")
      ans += 1
    elif s[i] == li[-1] and s[i] == "1":
      li.append("0")
      ans += 1
    else:
      li.append(s[i])
print(ans)

Solution (Python):

import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x

def main():
    S = cin.string()
    m,n = 0,0
    for i,s in enumerate(S):
        if i % 2 == 0:
            if s == "0":
                m+=1
            else:
                n+=1
        else:
            if s == "0":
                n +=1
            else:
                m +=1
    print(min(n,m))
    return

if __name__ == "__main__":
    main()

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

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

print(min(ans1, ans2))

Solution (Python):
import sys

s = sys.stdin.readline().rstrip()

def main():
    s1 = s[::2]
    s2 = s[1::2]
    res1 = s1.count('1') + s2.count('0')
    res2 = s1.count('0') + s2.count('1')
    return min(res1, res2)

if __name__ == '__main__':
    ans = main()
    print(ans)

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

d = {0:{0:0, 1:0}, 1:{0:0, 1:0}}

for i, s in enumerate(S):
  d[i%2][S[i]] += 1


ans = min(d[0][0]+d[1][1], d[0][1]+d[1][0])
print(ans)

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

a = 0
b = 0
cnt = 0
for i in S:
  if cnt % 2 == 0:
    if i == 0:
      b += 1
    else:
      a += 1
  else:
    if i == 0:
      a += 1
    else:
      b += 1
  cnt += 1
print(min(a,b))

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

for i in range(len(S)):
    S[i] = int(S[i])

f = S[0]
ans = 0

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

print(ans)

Solution (Python):
S=input()
N=len(S)
a=[]
b=[]
c=[0,1]
for i in range(N):
    a.append(c[i%2])
    b.append(c[(i+1)%2])

ans_a=0
ans_b=0


for i in range(N):
    s=int(S[i])
    if a[i]!=s:
        ans_a+=1
    if b[i]!=s:
        ans_b+=1
        
print(min(ans_a,ans_b))

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

arr2 = np.zeros((len(S)), dtype='int')
arr2[::2] = 1
arr1 = np.ones((len(S)), dtype='int')
arr1[::2] = 0

ans = min(np.count_nonzero(S != arr1), np.count_nonzero(S != arr2))
print(ans)

Solution (Python):
s = input()
b = "10"*10**5
count1 = 0
count2 = 0
for i in range(len(s)):
    if s[i] == b[i]:
        count1 += 1
    else:
        count2 += 1
print(min(count1, count2))

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

E = [s for i, s in enumerate(S) if i % 2 == 0]
O = [s for i, s in enumerate(S) if i % 2 == 1]

E_1 = [e for e in E if e == '1']
O_1 = [o for o in O if o == '1']

diffs_e1_o0 = len(E) - len(E_1) + len(O_1)
diffs_e0_o1 = len(O) - len(O_1) + len(E_1)

print(min(diffs_e0_o1, diffs_e1_o0))

Solution (Python):
s = input()
n = len(s)
s1 = []
s2 = []
for i in range(n):
    if i % 2 == 0:
        s1.append("0")
    else: s1.append("1")
for i in range(n):
    if i % 2 != 0:
        s2.append("0")
    else: s2.append("1")
s1_switch = 0
s2_switch = 0
for i in range(n):
    if s[i] != s1[i]:
        s1_switch += 1
    elif s[i] != s2[i]:
        s2_switch += 1
print(min(s1_switch, s2_switch))

Solution (Python):
S = input()
g = []
k = []
for i in range(len(S)):
  if i%2 == 0:
    k.append(S[i]) 
  else:
    g.append(S[i]) 

print(min(k.count('0') + g.count('1'), g.count('0') + k.count('1')))

Solution (Python):
S = list(input())
a=0
b=0
for i in S[::2]:
    if i=="1":
        a+=1
for k in S[1::2]:
    if k=="0":
        a+=1

for i in S[::2]:
    if i=="0":
        b+=1
for k in S[1::2]:
    if k=="1":
        b+=1
print(min(a,b))

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

even = collections.Counter(s[0::2])
odd = collections.Counter(s[1::2])

print(min(len(s) - (even["0"] + odd["1"]), len(s) - (even["1"] + odd["0"])))

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):
import sys
 
def main():
    S = [int(i) for i in input()]
 
    N = len(S)
 
    ol = [0] * N
    lo = [0] * N
    for i in range(N):
        if i % 2 ==0:
            ol[i] = 0
            lo[i] = 1
        else:
            ol[i] = 1
            lo[i] = 0
 
    ol_cnt = 0
    lo_cnt = 0
    for j in range(N):
        if ol[j] == S[j]:
            ol_cnt += 1
        if lo[j] == S[j]:
            lo_cnt += 1
 
    print(min(ol_cnt, lo_cnt))
 
main()

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


S=input()

a=''
b=''

lenS=len(S)

for i in range(lenS):
    if i%2==0:
        a+='1'
        b+='0'
    else:
        a+='0'
        b+='1'
        
ca=0
cb=0
for i in range(lenS):
    if a[i]!=S[i]:
        ca+=1
    if b[i]!=S[i]:
        cb+=1
print(min(ca,cb))

Solution (Python):
def main():
    s = input()
    N = len(s)
    S = []
    for j in range(N):
        S.append(s[j])
    result = 0
    for i in range(N - 1):
        if S[i] == S[i + 1]:
            result += 1
            if S[i + 1] == "0":
                S[i + 1] = "1"
            else:
                S[i + 1] = "0"
    print(result)


if __name__ == '__main__':
    main()

Solution (Python):
a = list(input())
b = a[::2].count('0') + a[1::2].count('1')
c = min(b, len(a) - b)
print(c)

Solution (Python):
s=input()
sento1 = 0
sento0 = 0
for i in range(len(s)):

  if i % 2 == 0:
    
    if s[i] == '1':
      sento1 += 1
      
    elif s[i] == '0':
      sento0 += 1
      
  else:
    if s[i] == '0':
      sento1 += 1
    elif s[i] == '1':
      sento0 += 1
      
print(min(sento1,sento0))

Solution (Python):
s=input()
l="1"+"01"*(len(s)//2)
ans=0
for i in range(len(s)):
  if s[i]==l[i]:
    ans+=1
print(min(ans,len(s)-ans))

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

s1 = 0
s2 = 0

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

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

print(min(s1, s2))

Solution (Python):
s=input()
l=len(s)
sa=""
sb=""
for i in range(l):
    if i%2==0:
        sa+="0"
        sb+="1"
    else:
        sa+="1"
        sb+="0"
ca=0
cb=0
for i in range(l):
    if sa[i]!=s[i]:
        ca+=1
    if sb[i]!=s[i]:
        cb+=1


print(min(ca,cb))

Solution (Python):
s = input().strip()



count0 = 0
count1 = 0
for i, c in enumerate(s):
    if i % 2 == 0:
        if c == '0':
            count1 += 1
        else:
            count0 += 1
    else:
        if c == '0':
            count0 += 1
        else:
            count1 += 1

count = min(count0, count1)
print(count)

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

Solution (Python):
import sys

def main():
    S = [int(i) for i in input()]

    N = len(S)

    ol = [0] * N
    lo = [0] * N
    for i in range(N):
        if i % 2 ==0:
            ol[i] = 0
            lo[i] = 1
        else:
            ol[i] = 1
            lo[i] = 0

    ol_cnt = 0
    lo_cnt = 0
    for j in range(N):
        if ol[j] == S[j]:
            ol_cnt += 1
        if lo[j] == S[j]:
            lo_cnt += 1

    print(min(ol_cnt, lo_cnt))

main()

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

def paint(start):
    a = s[::]
    ret = 0
    if a[0] != start:
        ret += 1
        a[0] ^= 1
    for i in range(1, len(a)):
        if a[i] == a[i - 1]:
            ret += 1
            a[i] ^= 1
    return ret

print(min(paint(0), paint(1)))

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

Solution (Python):
s = input()
pattern01 = 0
pattern10 = 0
for i, v in enumerate(s):
	if i % 2 == int(v):
		pattern01 += 1
	else:
		pattern10 += 1
print(min(pattern01, pattern10))

Solution (Python):
import os, sys, re, math

S = input()

A = ('01' * 50000)[:len(S)]
B = ('10' * 50000)[:len(S)]

countA = 0
countB = 0
for i in range(len(S)):
    if A[i] != S[i]:
        countA += 1
    if B[i] != S[i]:
        countB += 1

print(min(countA, countB))

Solution (Python):
S = input()
l = len(S)
bw = '01' * (l // 2 + 1)
wb = '10' * (l // 2 + 1)
bw_count = len([ 1 for a, b in zip(S, bw) if a != b  ])
wb_count = len([ 1 for a, b in zip(S, wb) if a != b  ])
print(min(bw_count, wb_count))

Solution (Python):
s = input()

ans = int(1e5 + 1)
for i in range(2):
  b = i
  temp = 0
  for c in s:
    t = int(c)
    temp += (t != b)
    b = 0 if b else 1
  ans = min(ans, temp)
print(ans)

Solution (Python):
S = input()
p1 = 0
p2 = 1

d1 = 0
d2 = 0
for s in S:
    s = int(s)
    if p1 != s:
        d1 += 1
    if p2 != s:
        d2 += 1
    p1 ^= 1
    p2 ^= 1

print(min(d1, d2))

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

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"
    else:
      s[i] = "0"
    count += 1
    
print(count)

Solution (Python):
S = input()

def zero_start(S):
    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
    return cnt

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

paints = [zero_start(S), one_start(S)]

print(min(paints))

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

Solution (Python):
a = input()
x = 0
y = 0
for t in range(0,len(a)):
    if t%2 == 0 and a[t] == "1":
        x = x+1
    if a[t] == "0" and t%2 == 1:
        x = x+1
        
for t in range(0,len(a)):
    if t%2 == 0 and a[t] == "0":
        y = y+1
    if  t%2 == 1 and a[t] == "1":
        y= y+1
        
print (min(y,x))

Solution (Python):
s=str(input())
br1=0
s=list(s)
s2=s
br2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=='0':
            br1+=1
    else:
        if s[i]=='1':
            br1+=1

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

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

Solution (Python):
s = input()

count_a = 0
count_b = 0

for i in range(0, len(s)):
    if int(s[i])%2 == i%2:
        count_a += 1
    if int(s[i])%2 != i%2:
        count_b += 1

print(min(count_a, count_b))

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

Solution (Python):

import math
import heapq
import bisect
import numpy as np


S = input()

n1 = S[::2].count("0")+S[1::2].count("1")
n2 = S[::2].count("1")+S[1::2].count("0")

ans = len(S)-max(n1,n2)
print(ans)

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

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

Solution (Python):
S = input()

x = y = 0
for i, c in enumerate(S):
    if i % 2:
        a, b = 0, 1
    else:
        a, b = 1, 0
    if int(c) == a:
        x += 1
    if int(c) == b:
        y += 1
print(min(x, y))

Solution (Python):
s = input()
n = len(s)
a = "10" * (n // 2) + "1" * (n % 2)
b = "01" * (n // 2) + "0" * (n % 2)

print(min(bin(int(s,2) ^ int(a, 2)).count("1") , bin(int(s, 2) ^ int(b, 2)).count("1")))

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

Solution (Python):
s = input()

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

print(min(b,w))

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

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

l1 = [i % 2 for i in range(n)]
l2 = [(i+1) % 2 for i in range(n)]
c1 = ''.join(map(str, l1))
c2 = ''.join(map(str, l2))


def diff(s, c):
    count = 0
    for i in range(n):
        if s[i] != c[i]:
            count += 1
    return count


print(min(diff(s, c1), diff(s, c2)))

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

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

Solution (Python):
s=input()

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

Solution (Python):
s = input()

cnt1 = 0
cnt2 = 0

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

print(min(cnt1, cnt2))

Solution (Python):
S=list(input())
a,b=[],[]
for i in range(len(S)):
	if i%2==0:
		a.append(S[i])
	else:
		b.append(S[i])


zero_gu=a.count('0')

iti_gu=a.count('1')


zero_ki=b.count('0')

iti_ki=b.count('1')


ans1=iti_ki+zero_gu


ans2=iti_gu+zero_ki

print(min(ans1,ans2))

Solution (Python):
S = input()

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

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

Solution (Python):
import copy
a=list(input())
b=a.copy()
count1=0
count2=0
for i in range(len(a)-1):
    if a[i]==a[i+1]:
        count1+=1
        if a[i]=="0":
            a[i+1]="1"
        else:
            a[i+1]="0"

for i in range(len(b)-2,-1,-1):
    if b[i]==b[i+1]:
        count2+=1
        if b[i+1]=="0":
            b[i]="1"
        else:
            b[i]="0"
print(min(count1,count2))

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

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

Solution (Python):
s=list(map(int,input()))
bw=0 
for i in range(len(s)):
	if (i%2==0 and s[i]==1) or (i%2==1 and s[i]==0):
		bw+=1
wb=0
for i in range(len(s)):
	if (i%2==0 and s[i]==0) or (i%2==1 and s[i]==1):
		wb+=1
print(min(bw,wb))

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

s01 = []
s10 = []

for i in range(len(s)):
    if i % 2 == 0:
        s01.append('0')
        s10.append('1')
    else:
        s01.append('1')
        s10.append('0')

count01 = 0
count10 = 0

for i in range(len(s)):
    if s[i] != s01[i]:
        count01 += 1
    if s[i] != s10[i]:
        count10 += 1

print(min(count01, count10))

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

tmp = '0'
ans1 = 0
for iro in S:
    if iro != tmp:
        ans1 += 1
    tmp = str(int(tmp)^1)

tmp = '1'
ans2 = 0
for iro in S:
    if iro != tmp:
        ans2 += 1
    tmp = str(int(tmp)^1)

print(min(ans1,ans2))