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()
n=len(s)
b_start = 0
w_start = 0
for i in range(n):
    if(i%2==0):
        b_start += (s[i]=='1')
        w_start += (s[i]=='0')
    else:
        b_start += (s[i]=='0')
        w_start += (s[i]=='1')

print(min(b_start,w_start))

Solution (Python):
S = list(input())
n = len(S)
for j in range(n):
	S[j] = int(S[j])
cnt = 0
for i in range(n-1):
	if S[i] == S[i+1]:
		S[i+1] = abs(S[i]-1)
		cnt += 1
print(cnt)

Solution (Python):
S = input()

if S[0]=="0":
  ans = ["0","1"]*(10**5//2)
    
else:
  ans = ["1","0"]*(10**5//2)

count = 0
for i in range(len(S)):
  if S[i]!=ans[i]:
    count+=1
print(count)

Solution (Python):
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


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

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





if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


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

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





if __name__ == "__main__":
    main()

Solution (Python):
s = input()
ans1 = 0 ; ans2 = 0
for i in range(len(s)) :
    
    if i % 2 == 0 :
        if s[i] != "0" :
            ans1 += 1
    else :
        if s[i] != "1" :
            ans1 += 1

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

Solution (Python):
S = input()
L = [i&1 for i in range(len(S))]
m = sum(int(S[i])!=L[i] for i in range(len(S)))
print(m if m<=len(S)//2 else len(S)-m)

Solution (Python):
S = input()
L = len(S)
SS = ""
cnt = 0

if S[0] == "0":
    while len(SS) < L:
        SS += "0"
        SS += "1"

else:
    while len(SS) < L:
        SS += "1"
        SS += "0"

for i in range(L):
    if S[i] != SS[i]:
        cnt += 1

print(cnt)

Solution (Python):
s = input()
l= len(s)
 
if l== 1:
    print(0)
    exit()
 
even = s[::2]
odd = s[1::2]

odd_zero = odd.count("0")
even_one = even.count("1")
 

odd_one = odd.count("1")
even_zero = even.count("0")
 
print(min(odd_zero + even_one, odd_one + even_zero))

Solution (Python):
s = input()
start0 = 0
start1 = 0
for i,j in enumerate(s):
    if ~i&1:
        start0 += (j=="1")
        start1 += (j=="0")
    else:
        start0 += (j=="0")
        start1 += (j=="1")
print(min(start0,start1))

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

def main():
    s = list(input())
    zero, one = 0, 0
    for i in range(len(s)):
        if i%2 == 0:
            if s[i] == '1':
                zero += 1
            else:
                one += 1
        else:
            if s[i] == '1':
                one += 1
            else:
                zero += 1
    print(min(zero, one))
        
if __name__ == '__main__':
    main()

Solution (Python):
s= input()


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


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

print(min(ans1,ans2))

Solution (Python):

s = input()
len = len(s)

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

even = s[::2]
odd = s[1::2]



odd_zero = odd.count("0")
even_one = even.count("1")




odd_one = odd.count("1")
even_zero = even.count("0")

print(min(odd_zero + even_one, odd_one + even_zero))

Solution (Python):
s = input()

ans0 = 0
ans1 = 0
for i, s_i in enumerate(s):
    if i % 2 == 0:
        if s_i == '0':
            ans1 += 1
        else:
            ans0 += 1
    else:
        if s_i == '0':
            ans0 += 1
        else:
            ans1 += 1
print(min(ans0, ans1))

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

s = input().rstrip()

li = ['0'] * len(s)
for i in range(len(s)):
    li[i] = s[i]

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

Solution (Python):
S = input()
a = 0
b = 0
for i, s in enumerate(S):
  if i % 2:
    if s == "1":
      a += 1
    else:
      b += 1
  else:
    if s == "1":
      b += 1
    else:
      a += 1
print(min(a, b))

Solution (Python):
from copy import deepcopy
s1 = list(input())
s2 = deepcopy(s1)
length = len(s1)

ans1 = 0
ans2 = 0


for a in range(length):
    if a % 2 == 0:
        if s1[a] == '1':
            s1[a] = '0'
            ans1 += 1
    else:
        if s1[a] == '0':
            s1[a] = '1'
            ans1 += 1


for a in range(length):
    if a % 2 == 0:
        if s2[a] == '0':
            s2[a] = '1'
            ans2 += 1
    else:
        if s2[a] == '1':
            s2[a] = '0'
            ans2 += 1

print(min(ans1, ans2))

Solution (Python):
s = open(0).read().rstrip()

from itertools import cycle

count1 = 0
for c,d in zip(s,cycle('10')):

    if c!= d:
        count1 += 1
        
count2 = 0
for c,d in zip(s,cycle('01')):

    if c!= d:
        count2 += 1

print(min(count1,count2))

Solution (Python):
S = list(map(int, input()))
a = [0 if (i+1)%2 == 0 else 1 for i in range(len(S))]
b = [0 if (i+1)%2 == 1 else 1 for i in range(len(S))]
ans0, ans1 = 0, 0
ans0 = [0 for i, j in zip(a, S) if i == j]
ans1 = [0 for i, j in zip(b, S) if i == j]
print(min(len(ans0), len(ans1)))

Solution (Python):

s = input()
n = len(s)
z = "01" * n
print(
    min(sum(s[i] != z[i] for i in range(n)),
        sum(s[i] != z[i + 1] for i in range(n))))

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

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

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

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

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

Solution (Python):
S = input()
White = '10'*(len(S)//2)+'1'*(len(S)%2)
Black = '01'*(len(S)//2)+'0'*(len(S)%2)
WD = len([X for X in map(set,zip(S,White)) if len(X)==2])
BD = len([X for X in map(set,zip(S,Black)) if len(X)==2])
print(min(WD,BD))

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

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

a = [i%2 for i in range(len(s))]
b = [(i+1)%2 for i in range(len(s))]

a_sum = sum(abs(x-y) for x, y in zip(s, a))
b_sum = sum(abs(x-y) for x, y in zip(s, b))
print(min(a_sum, b_sum))

Solution (Python):
s = input()
N = len(s)
f = s[0]
c = 0
for i in range(1,N):
  if i % 2 == 1:
    if f == s[i]:
      c+=1
  else:
    if f != s[i]:
      c+=1
print(c)

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

Solution (Python):
S = input()

if S[0] == '0':
    A = '01' * len(S)
else:
    A = '10' * len(S)

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

print(min(cnt, abs(len(S) - cnt)))

Solution (Python):
S = input()
counter = 0
for i in range(1, len(S)):
    previous_color = S[i - 1]
    checking_color = S[i]
    if previous_color == checking_color:
        counter += 1
        if previous_color == '0':
            S = S[:i] + '1' + S[i + 1:]
        else:
            S = S[:i] + '0' + S[i + 1:]
print(min(counter, abs(len(S) - counter)))

Solution (Python):
s = input()
N = len(s)
f = s[0]
c = 0
for i in range(1,N):
  if i % 2 == 1:
    if f == s[i]:
      c+=1
  else:
    if f != s[i]:
      c+=1
print(c)

Solution (Python):
S = input()

if S[0] == '0':
    A = '01' * len(S)
else:
    A = '10' * len(S)
    
cnt = 0
for i in range(len(S)):
    if S[i] != A[i]:
        cnt += 1
        
print(cnt)

Solution (Python):
import numpy as np
S=np.array(list(input()),dtype=np.int8)
L=len(S)
A=np.arange(L)&1
B=1-A
x1=(A!=S).sum()
x2=(B!=S).sum()
print(min(x1,x2))

Solution (Python):
S=input()
d0=0
d1=0
for i in range(len(S)):
    d0+=int(S[i])!=i%2
    d1+=int(S[i])!=(i+1)%2
print(min(d0,d1))

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

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

odd0, odd1 = 0, 0
even0, even1 = 0, 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s == "0":
            even0 += 1
        else:
            even1 += 1
    else:
        if s == "0":
            odd0 += 1
        else:
            odd1 += 1
print(min(even0+odd1, even1+odd0))

Solution (Python):
s=list(input())
n=len(s)
s1=["0"for i in range(n)]
s2=["1"for i in range(n)]
for i in range(0,n,2):
    s1[i]="1"
    s2[i]="0"
tmp1=0
tmp2=0
for i in range(n):
    if s[i]!=s1[i]:
        tmp1+=1
    if s[i]!=s2[i]:
        tmp2+=1
print(min(tmp1,tmp2))

Solution (Python):
s = list(input())
len_s = len(s)
half_len_s = len_s // 2 + 1
str_01 = "01" * half_len_s
str_10 = "10" * half_len_s
list_01 = list(str_01[:len_s])
list_10 = list(str_10[:len_s])
count1 = 0
count2 = 0
for v1, v2 in zip(s, list_01):
    if v1 == v2:
        count1 += 1
for v1, v2 in zip(s, list_10):
    if v1 == v2:
        count2 += 1
print(min(count1, count2))

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

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

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

X=0

Z=0
for s in S:
    if s!=Z:
        X+=1
    Z^=1
    
Y=0

Z=1
for s in S:
    if s!=Z:
        Y+=1
    Z^=1

print(min(X,Y))

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

Solution (Python):
s=list(input())
n=len(s)
p=[]
q=[]
cnt_p=0
cnt_q=0

if n%2!=0:
  m=(n-1)//2
  p.extend(['0','1']*m)
  p.append('0')
  q.extend(['1','0']*m)
  q.append('1')
else:
  m=n//2
  p.extend(['0','1']*m)
  q.extend(['1','0']*m)
for i in range(n):
  if s[i]==p[i]:
    cnt_p+=1
  else:
    cnt_q+=1
print(min(cnt_p,cnt_q))

Solution (Python):
s=input()
S=[s[i] for i in range(len(s))]
A=['0','1']
B=[A[i%2] for i in range(len(S))]
count=0
for i in range(len(S)):
  if S[i]!=B[i]:
    count=count+1
print(min(count,len(S)-count))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

s = [int(ch) for ch in input()]

ans = [0]*2

for t in range(2):
    tmp = s[:]
    if t == 0:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                pass
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
    if t == 1:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                tmp[i] ^= 1
                tmp[i+1] ^= 1
                ans[t] += 2
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1

print(min(ans))

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

s = [int(ch) for ch in input()]

ans = [0]*2

for t in range(2):
    tmp = s[:]
    if t == 0:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                pass
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
    if t == 1:
        for i in range(len(s)-1):
            if i == 0 and tmp[i] == tmp[i+1]:
                tmp[i] ^= 1
                ans[t] += 1
            elif i == 0 and tmp[i] != tmp[i+1]:
                tmp[i] ^= 1
                tmp[i+1] ^= 1
                ans[t] += 2
            elif tmp[i] == tmp[i+1]:
                tmp[i+1] ^= 1
                ans[t] += 1
s
print(min(ans))

Solution (Python):
S = input()
n = len(S)
dp = [[0] * 2 for _ in range(n)]
s = int(S[0])
dp[0][s] = 0
dp[0][1-s] = 1
for i, s in enumerate(S[1:], 1):
    s = int(s)
    dp[i][s] = dp[i-1][1-s]
    dp[i][1-s] = dp[i-1][s] + 1
print(min(dp[n-1]))

Solution (Python):
S=[0 if c =='0' else 1 for c in input()]
a = S[0::2]
b = S[1::2]
x = a.count(1)
y = b.count(1)
if x > y:
    ans = (len(a)-x) + (y)
else:
    ans = (len(b)-y) + (x)
print(ans)

Solution (Python):
n = input()
a,b = "",""
for i in range(len(n)//2):
    a += "01"
    b += "10"
if len(n) != len(a):
    a += "0"
    b += "1"

acount,bcount = 0,0
for i in range(len(n)):
    if n[i] != a[i]:
        acount += 1
    if n[i] != b[i]:
        bcount += 1
print(min(acount,bcount))

Solution (Python):









import sys
input = sys.stdin.readline

origin = list(map(int, input().rstrip('\n')))


t1 = []
t2 = []
for i in range(len(origin)):
    if i % 2 == 0:
        t1.append(0)
        t2.append(1)
    else:
        t1.append(1)
        t2.append(0)

n1 = 0
n2 = 0
for i in range(len(origin)):
    if t1[i] != origin[i]:
        n1 += 1
    if t2[i] != origin[i]:
        n2 += 1

print(min(n1, n2))

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

Solution (Python):
import numpy as np

S = np.array(list(input()))
S = S.astype('int32')
length = len(S)

if length == 1:
    print(0)
    exit()

check_array1 = np.zeros(length, int)
for i in range(1, length, 2):
    check_array1[i] = 1

check_array2 = np.append(check_array1[1:], check_array1[-2])


checked1_S = S + check_array1
checked2_S = S + check_array2

checked1_total = (checked1_S == 1).sum()
checked2_total = (checked2_S == 1).sum()

answer = min(checked1_total, checked2_total)

print(answer)

Solution (Python):
S = list(input())
ans1 = 0
ans2 = 0

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

Solution (Python):
s = input()

ans = 100100100100

for i in range(2):
    cnt = 0
    t = str(i)
    for i in s:
        if t != i:
            cnt += 1
            
        t = 1 - int(t)    
        t = str(t)
    
    ans = min(ans,cnt)
    
print(ans)

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()

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

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()

memo = s[0]
cnt = 0

for i in range(1,len(s)):
	if s[i] == memo:
		cnt += 1
		
		if memo == "0":
			memo = "1"
		else:
			memo = "0"
	else:
		memo = s[i]
	
print(cnt)

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

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

print(ans)

Solution (Python):
S = input()

first_0 = 0
first_1 = 0

for i, s in enumerate(S):
    if i % 2 == 0:
        if s == "0":
            first_1 += 1
        else:
            first_0 += 1
    else:
        if s == "0":
            first_0 += 1
        else:
            first_1 += 1

print(min(first_0, first_1))

Solution (Python):
def resolve():
    S = input()
    zero = 0
    one = 0
    for i in range(len(S)):
        if i%2 == 0 and S[i] != "0" or i%2 == 1 and S[i] != "1":
            zero += 1
        elif i%2 == 0 and S[i] != "1" or i%2 == 1 and S[i] != "0":
            one += 1
    print(min(one, zero))
resolve()

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

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

print(min(cnt1, cnt2))

Solution (Python):
s = input()
LEN = len(s)
if LEN == 1:
    print(0)
    exit()
    
even = s[::2]
odd = s[1::2]

ew = even.count('1')
eb = (LEN+1)//2 - ew
ow = odd.count('1')
ob = (LEN)//2 - ow

print(min(eb + ow, ew + ob))

Solution (Python):
s = input()
phase = 'Odd'
ptn10 = 0
ptn01 = 0
for i in s:
  if phase == 'Odd':
    if i == '1':
      ptn01 += 1
    else:
      ptn10 += 1
    phase = 'Even'
  else:
    if i == '0':
      ptn01 += 1
    else:
      ptn10 += 1
    phase = 'Odd'
print(min(ptn10, ptn01))

Solution (Python):
import numpy as np
S=list(input())
S=[True if i=="0" else False for i in S]
stripeA=[True]*len(S)
stripeB=[True]*len(S)
for i in range(len(S)):
    if i%2==0:
        stripeA[i]=False
    else:
        stripeB[i]=False
stripeA=list(np.logical_xor(S,stripeA))
stripeB=list(np.logical_xor(S,stripeB))
stripeA=stripeA.count(True)
stripeB=stripeB.count(True)
if stripeA>stripeB:
    print(stripeB)
else:
    print(stripeA)

Solution (Python):
S = input()
n = len(S)
counter2n0=0
counter2n1=0
counter1n0=0
counter1n1=0
for i in range(n):
    if i%2 ==0:
        if S[i] == '0':
            counter2n0 +=1
        else:
            counter2n1 +=1
    if i%2 == 1:
        if S[i] == '0':
            counter1n0 +=1
        else:
            counter1n1 +=1
print(min(counter2n0+counter1n1,counter2n1+counter1n0))

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


def read():
    S = input().strip()
    return S,


def solve(S):
    N = len(S)
    ans = [0, 0]  
    for i in range(N):
        if S[i] == "1":
            ans[i % 2] += 1
    return min(ans[0]+N//2-ans[1], N//2+N%2-ans[0]+ans[1])


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Solution (Python):
s = str(input())
n = len(s)
a = 0
b = 0
apple = ("10" * n)[:n]
orange = ("01" * n)[:n]
for i in range(n):
    if apple[i] != s[i]:
        a += 1
    if orange[i] != s[i]:
        b += 1
print(min(a, b))

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

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

tile1=('10'*N)[:N]
tile0=('01'*N)[:N]

ans1=0
ans0=0
for i in range(N):
    ans1+=S[i]!=tile1[i]
    ans0+=S[i]!=tile0[i]

print(min(ans1,ans0))

Solution (Python):
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()
 
s=input()
n=len(s)
s10=[]
for i in range(n):
  if i%2==0:
    s10.append(1)
    
  else:
    s10.append(0)
    
s01=[]
for i in range(n):
  if i%2==0:
    s01.append(0)
    
  else:
    s01.append(1)
cnt10=0
cnt01=0
for i in range(n):
  if int(s[i])!=s10[i]:
    cnt10+=1
    
  if int(s[i])!=s01[i]:
    cnt01+=1
   
    
print(min(cnt10,cnt01))

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

sirokuro =[i%2 for i in range(0,N,1)]
kurosiro =[(i+1)%2 for i in range(0,N,1)]

loss1 = 0
for i in range(0,N,1):
    if S[i]!=sirokuro[i]:
        loss1 +=1

loss2 = 0
for i in range(0,N,1):
    if S[i]!=kurosiro[i]:
        loss2+=1

print(min(loss1,loss2))

Solution (Python):
s = input()
ev = "10"*(10**5)
od = "01"*(10**5)
evcnt = 0
odcnt = 0
for cnt, i in enumerate(s):
	if i == ev[cnt]:
		evcnt += 1
	if i == od[cnt]:
		odcnt += 1
print(len(s)-max(evcnt, odcnt))

Solution (Python):
S = input()
count = 0
for i in range(len(S)):
    if i%2 == 0 and S[i] == '1':
        count +=1
    if i%2 == 1 and S[i] == '0':
        count +=1

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

Solution (Python):
from copy import deepcopy
s=list(map(int,input()))
t=deepcopy(s)
if t[0]==1:
    t[0]=0
else:
    t[0]=1

cnt=0
rev_cnt=1

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

for i in range(1,len(t)):
    if t[i-1]==t[i]:
        if t[i]==0:
            t[i]=1
        else:
            t[i]=0
        rev_cnt+=1

print(min(cnt, rev_cnt))

Solution (Python):
from copy import deepcopy
s=list(map(int,input()))
t=deepcopy(s)
if t[0]==1:
    t[0]=0
else:
    t[0]=1

cnt=0
rev_cnt=1

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

for i in range(1,len(t)):
    if t[i-1]==t[i]:
        if t[i]==0:
            t[i]=1
        else:
            t[i]=0
        rev_cnt+=1

print(min(cnt, rev_cnt))

Solution (Python):
s=[]
S=input()
for i in S:
    s+=[int(i)]

ans=0
if s[0]==0:
    for i in s[0::2]:
        if i!=0:
            ans+=1
            
    for i in s[1::2]:
        if i!=1:
            ans+=1
            

if s[0]==1:
    for i in s[0::2]:
        if i!=1:
            ans+=1
    for i in s[1::2]:
        if i!=0:
            ans+=1
print(ans)

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

s = input()

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

Solution (Python):
s = list(input())
n = len(s)
for j in range(n):
  s[j] = int(s[j])
a = 0
b = 0

for i in range(n):
  if i%2 == 0 and s[i] == 0:
    a += 1
  elif i%2 == 0 and s[i] == 1:
    b += 1
  elif i%2 == 1 and s[i] == 0:
    b += 1
  else:
    a += 1
print(min(a,b))

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

if N%2==0:
  S1="10"*(N//2)
  count=0
  for i in range(N):
    if S[i]==S1[i]:
      count+=1
  if count >= N//2:
    print(N-count)
  else:
    print(count)
else:
  S2="10"*((N-1)//2)+"1"
  count=0
  for i in range(N):
    if S[i]==S2[i]:
      count+=1
  if count >= (N+1)//2:
    print(N-count)
  else:
    print(count)

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

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

Solution (Python):
s = input()
s1 = s[0::2]
s2 = s[1::2]

t1 = s1.count('1') + s2.count('0')
t2 = s1.count('0') + s2.count('1')
print(min(t1, t2))

Solution (Python):
import copy
def change(k):
  if k==0:
    return int(1)
  else:
    return int(0)
t=0
m=0
S=list(map(int,list(input())))
M=copy.copy(S)
T=copy.copy(S)
N=len(S)
for i in range(N):
  if i==0:
    if T[i]==0:
      t+=1
      T[0]=1
    else:
      m+=1
      M[0]=0
  else:
    if T[i]==T[i-1]:
      T[i]=change(T[i])
      t+=1
    if M[i]==M[i-1]:
      M[i]=change(M[i])
      m+=1
print(min(t,m))

Solution (Python):
S = input()

ans = 0

def f(i):
  ans = 0
  for c in S:
    if int(c)==i: ans += 1
    i = (i+1)%2
  return ans

ans = min(f(0),f(1))

print(ans)

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

import numpy as np

S = np.array(S)

zeroichi = ["0","1"]*(len(S)//2)+["0"]*(len(S)%2)
ichizero = ["1","0"]*(len(S)//2)+["1"]*(len(S)%2)

zeroichi = np.array(zeroichi)
ichizero = np.array(ichizero)

print(min(list(S == ichizero).count(False),list(S == zeroichi).count(False)))

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

Solution (Python):
s = input()

c01 = 0
c02 = 0


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


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

if all(x == 0 for x in [c01, c02]):
    print(0)
else:
    print(min(c01,c02))

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

B = ['0' for i in range(N)]
W = ['1' for i in range(N)]
for i in range(0,N,2):
    B[i] = '1'
    W[i] = '0'

X = 0
Y = 0
for i in range(N):
    if S[i] != B[i]:
        X += 1
    if S[i] != W[i]:
        Y += 1

print(min(X,Y))

Solution (Python):
S = input()
s = []
for _ in S:
  s.append(int(_))
s1 = [1]
s2 = [0]
for i in range(1,len(s)):
  if s1[i-1] == 0:
    s1.append(1)
  else:
    s1.append(0)
  if s2[i-1] == 0:
    s2.append(1)
  else:
    s2.append(0)
    
a = 0
b = 0
for j in range(len(s)):
  if s[j] != s1[j]:
    a += 1
  if s[j] != s2[j]:
    b += 1
print(min(a,b))

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

length = len(s)
count = 0

for i in range(length-1):
    if i == length:
        break
    if s[i] == s[i+1]:
        if s[i] == '0':
            s[i+1] = '1'
            count += 1
        else:
            s[i+1] = '0'
            count += 1


print(count)

Solution (Python):
import collections

s = map(int,list(raw_input()))

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

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

if n%2==0:
    odd=even=n//2
else:
    even=n//2
    odd=even+1
    
odd_black=0
even_black=0

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

odd_white=odd-odd_black
even_white=even-even_black

if odd_black<=even_black:
    count=odd_black+even_white
else:
    count=odd_white+even_black

print(count)

Solution (Python):

 

 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 

 







 
S = input()

min1 = 0 
min2 = 0 


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

print(min(min1,min2))

Solution (Python):
s=input()
i=0
c=0
for m in s:
  if i % 2 ==0:
    if int(m) ==1:
      c+=1
  else:
    if int(m)==0:
      c+=1
  i+=1
print(min(c,len(s)-c))

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

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

a = ['1', '0']*10**5
b = ['0', '1']*10**5

A = a[:len(s)]
B = b[:len(s)]
cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] != A[i]:
        cnt += 1
    if s[i] != B[i]:
        ans += 1
print(min(cnt, ans))

Solution (Python):
S = input()
S_odd = S[1::2]
S_even = S[0::2]

oddlist = []
evenlist = []

for i in range(len(S_odd)):
    oddlist.append(int(S_odd[i]))
for i in range(len(S_even)):
    evenlist.append(int(S_even[i]))

EvenSum = sum(evenlist)
OddSum = sum(oddlist)


if EvenSum <= OddSum:
    ans = len(oddlist) - OddSum
    ans += EvenSum
else:
    ans = len(evenlist) - EvenSum
    ans += OddSum

print(ans)

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

Solution (Python):
s=input()
a=[]
for i in range(0,len(s)//2*2,2):
  a.append(s[i:i+2])
a10=a.count('10')
a01=a.count('01')

if len(s)%2:
  s1=int(s[-1])
else:s1=-1

if a10>a01:
  if s1==0:
    cnt=len(a)-a10+a01+1
  else:
    cnt=len(a)-a10+a01
elif a01>a10:
  if s1==1:
    cnt=len(a)-a01+a10+1
  else:
    cnt=len(a)-a01+a10
else:
  cnt=len(a)
print(cnt)

Solution (Python):
s = input()
a = ''
b = ''
for i in range(len(s)):
  if i % 2 == 0:
    a += '0'
    b += '1'
  else:
    a += '1'
    b += '0'
c = 0
for x, y in zip(s, a):
  if x != y:
    c += 1
d = 0
for x, y in zip(s, b):
  if x != y:
    d += 1
print(min(c, d))

Solution (Python):
s = list(input())
n = len(s)-1
a = [1]+[0]*n
b = [0]+[1]*n
difA = 0
difB = 0

for i in range(1,n+1):
    a[i] = 0 if a[i-1] == 1 else 1
    b[i] = 0 if b[i-1] == 1 else 1

for j in range(n+1):
    if a[j] != int(s[j]):
        difA += 1
    if b[j] != int(s[j]):
        difB += 1

ans = min(difA,difB)

print(ans)