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 = list(map(int,list(input())))
N = len(S)
A_list = []
B_list = []
for i in range(N):
  if i % 2 == 0:
    A_list.append(0)
    B_list.append(1)
  else:
    A_list.append(1)
    B_list.append(0)

A_count = 0
B_count = 0
for i in range(N):
  if S[i] == A_list[i]:
    A_count += 1
  if S[i] == B_list[i]:
    B_count += 1

print(min(A_count,B_count))

Solution (Python):
S = list(input())
l = len(S)
counter1 = 0
counter2 = 0
current1 = '0'
current2 = '1'
for i in range(l):
    if S[i] != current1:
        counter1 += 1
    else:
        counter2 += 1
    current1, current2 = current2, current1
print(min(counter1, counter2))

Solution (Python):
s = input()
l = []
for x in s:
    l.append(int(x))
o = 0
for i in range(len(l)-1):
    if l[i] == l[i+1]:
        o += 1
        l[i+1] = 0 if l[i+1] == 1 else 1
    
print(o)

Solution (Python):
import numpy as np

S = np.array([int(x) for x in input()])

n, m = divmod(len(S), 2)

c1 = np.array([0, 1] * n + ([] if m ==0 else [0]))
c2 = np.array([1, 0] * n + ([] if m ==0 else [1]))

a1 = sum(abs(S - c1))
a2 = sum(abs(S - c2))

print(min(a1, a2))

Solution (Python):
S =input()
ans1 = 0
ans2 = 0
t = 0
for i in range(len(S)):
    if int(S[i]) == t:
        ans1 += 1
    else:
        ans2 += 1
    t = not(t)

print(min(ans1,ans2))

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

odd = 0;
even = 0;

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

print(min(odd,even))

Solution (Python):
import numpy as np

s = np.array([int(x) for x in input()])
f = np.arange(len(s)) % 2
g = (f + 1) % 2

i = np.logical_xor(f, s).sum()
j = np.logical_xor(g, s).sum()
print(min(i, j))

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

def count(t,start):
     ans = 0
     for i in range(len(t)):
          if (i%2 == 0) and (t[i] != start):
               ans += 1
          if (i%2 == 1) and (t[i] == start):
               ans += 1
     return ans
     
ans = min(count(t,'0'), count(t,'1'))
print(ans)

Solution (Python):
from sys import stdin

def main():
    S = input()

    case1 = '10' * (len(S) // 2)
    case2 = '01' * (len(S) // 2)
    if len(S) % 2:
        case1 += '1'
        case2 += '0'

    cnt1 = 0
    for s1, s2 in zip(S, case1):
        if s1 != s2:
            cnt1 += 1

    cnt2 = 0
    for s1, s2 in zip(S, case2):
        if s1 != s2:
            cnt2 += 1

    print(min(cnt1, cnt2))

input = lambda: stdin.readline().rstrip()
main()

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

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

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

prev = ''
count = 0

for i in range(len(li)):
    if 0 == i:
        prev = li[i]
    else:
        if '0' == prev and '0' == S[i]:
            count += 1
            li[i] = '1'
        elif '1' == prev and '1' == S[i]:
            count += 1
            li[i] = '0'
        prev = li[i]
print(count)

Solution (Python):
s = input()

a1 = s[::2].count("1") + s[1::2].count("0")
a2 = s[::2].count("0") + s[1::2].count("1")

print(min(a1, a2))

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

cnt1 = 0   
cnt2 = 0   

for i in range(n):
    if i % 2 == 0:
        if S[i] == '0':
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if S[i] == '1':
            cnt1 += 1
        else:
            cnt2 += 1
            
print(min(cnt1, cnt2))

Solution (Python):
s=input()


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

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

print(min(answ,ansb))

Solution (Python):
import numpy as np

S = input()
l = [int(s) for s in S]
t1 = [i % 2 for i in range(len(S))]
t2 = [(i+1) % 2 for i in range(len(S))]
l, t1, t2 = np.array(l), np.array(t1), np.array(t2)

d1 = ((t1 - l)**2).sum()
d2 = ((t2 - l)**2).sum()

print(int(min(d1, d2)))

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

Solution (Python):
str = input()

n = len(str)


str1 = "10"*(n//2) + "1"*(n%2)
str0 = "01"*(n//2) + "0"*(n%2)

v1 = 0
v0 = 0
for i in range(n):
	if str[i] == str1[i]: v1 += 1
	if str[i] == str0[i]: v0 += 1
	
print(min([v1,v0]))

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

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

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

c1=0
c2=0

for i in range(len(S)):
    if i%2==0:
        if S[i]=='0':
            c1+=1
        else:
            c2+=1
    else:
        if S[i]=='1':
            c1+=1
        else:
            c2+=1

print(min(c1,c2))

Solution (Python):


def main():
    s = input()
    one_start = 0
    zero_start = 0

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

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

    print(min(one_start,zero_start))

if __name__ == "__main__":
    main()

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

start_with0 = [0 if i % 2 else 1 for i in range(len(S))]
start_with1 = [1 if i % 2 else 0 for i in range(len(S))]

diff_0 = sum([i != j  for i, j in zip(S, start_with0)])
diff_1 = sum([i != j  for i, j in zip(S, start_with1)])
print(min(diff_0, diff_1))

Solution (Python):

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

T0 = sum([s%2 == 1 for s in S[::2]]) + sum([s%2 == 0 for s in S[1::2]])
T1 = sum([s%2 == 0 for s in S[::2]]) + sum([s%2 == 1 for s in S[1::2]])
print(min(T0, T1))

Solution (Python):
S = [n == "1" for n in input().strip()]
sum_odd = sum(S[::2])
sum_even = sum(S[1::2])

if sum_odd > sum_even:
  print((len(S[::2]) - sum_odd) + sum_even)
else:
  print((len(S[1::2]) - sum_even) + sum_odd)

Solution (Python):
str = list(input())  
last = str[0]
ans = 0

for i in range(1, len(str)):
    if last == str[i]:
        ans += 1
        if last == "0":
            last = '1'
        else:
            last = '0'
    else:
        last = str[i]


print(ans)

Solution (Python):


def bc(x):
    return bin(x).count("1")

S = input()
N = len(S)


B = "".join(["0" if i%2==0 else "1" for i in range(N)])
R = int(S, 2) ^ int(B, 2)
C = bc(R)
r = min(C, N-C)
print(r)

Solution (Python):
S = input()
S1 = S[0::2]
S2 = S[1::2]

S1white = S1.count("1")  
S2white = S2.count("1")

print(min(S1white + len(S2) - S2white, len(S1) - S1white + S2white))

Solution (Python):
s = input()

a1 = ''
a2 = ''

for i in range(len(s)):
	if (i % 2 == 0):
		a1 = a1 + '0'
		a2 = a1 + '1'
	else:
		a1 = a1 + '1'
		a2 = a2 + '0'
m1 = 0
m2 = 0

for i in range(len(s)):
	if(s[i] != a1[i]):
		m1 = m1 + 1
	else:
		m2 = m2 + 1

print(min(m1,m2))

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

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

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

Solution (Python):
s=input()
n,m=0,0
p,q=0,0
for i in range(len(s)):
    if i&1:
        if s[i]=='0':
            n+=1
        else:
            p+=1
    else:
        if s[i]=='0':
            m+=1
        else:
            q+=1
print(len(s)-max(n+q,m+p))

Solution (Python):
S = input()

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

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter

def j(q):
    if q==1: print("Yay!")
    else:print(":(")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)



a = input()                                  






n = len(a)
c = 0
add = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        add+=1
        add%=2
    if add:c+=1
print(min(n-c,c))

Solution (Python):
def int_raw():
    return int(input())


def ss_raw():
    return raw_input().split()


def ints_raw():
    return list(map(int, ss_raw()))


S = [int(s) for s in raw_input()]
current = 0
ans = 0
for s in S:
    if s != current:
        ans += 1
    current = 1 - current
print(min(ans, len(S) - ans))

Solution (Python):
S = list(input())
pattern = [[str(i % 2) for i in range(len(S))], [str((i+1) % 2) for i in range(len(S))]]
count = float('inf')
for pattern in pattern:
    c = 0
    for (s, p) in zip(S, pattern):
        if s != p:
            c += 1
    count = min(count, c)
print(count)

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

Solution (Python):
S = input()

s_1 = [S[i] for i in range(len(S)) if i % 2 == 0]
s_2 = [S[i] for i in range(len(S)) if i % 2 == 1]

ct_s1_0 = s_1.count('0')
ct_s1_1 = s_1.count('1')
ct_s2_0 = s_2.count('0')
ct_s2_1 = s_2.count('1')

count_1 = ct_s1_0 + ct_s2_1
count_2 = ct_s1_1 + ct_s2_0

print(min(count_1, count_2))

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

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

a = even.count(0) + odd.count(1)
b = even.count(1) + odd.count(0)

print(min(a, b))

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

n_white_even = sum(S_num[0::2])
n_black_even = len(S_num[0::2]) - n_white_even
n_white_odd = sum(S_num[1::2])
n_black_odd = len(S_num[1::2]) - n_white_odd


cand_1 = n_black_even + n_white_odd

cand_2 = n_white_even + n_black_odd

print(min(cand_1, cand_2))

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

S = input()
if S[0] == '0':
    res1 = S[::2].count('1')+S[1::2].count('0')
    res2 = S[1::2].count('1')+S[::2].count('0')
else:
    res1 = S[::2].count('1')+S[1::2].count('0')
    res2 = S[1::2].count('1')+S[::2].count('0')
print(min(res1,res2))

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

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

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

a = len(even) - even.count("0") + len(odd) - odd.count("1")
b = len(even) - even.count("1") + len(odd) - odd.count("0")

if a > b:
  print(b)
else:
  print(a)

Solution (Python):
def solve():
  s = input()
  n = len(s)
  odd = ""
  even = ""
  for i in range(n):
    if i%2 == 0:
      odd += s[i]
    else:
      even += s[i]
  
  oddzero = odd.count("0")
  oddone = odd.count("1")
  evenzero = even.count("0")
  evenone = even.count("1")
  ans = min(oddzero+evenone,oddone+evenzero)
  
  print(ans)
solve()

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

zeros = [0,0] 
flg = 0
for s in S:
    if s=='0':
        zeros[flg] += 1
    flg = (flg+1)%2

ones = [(N+1)//2-zeros[0], N//2-zeros[1]]
ans = min(zeros[0]+ones[1], zeros[1]+ones[0])
print(ans)

Solution (Python):
s = input()

list_s = [int(c) for c in s]

test_01 = []
test_10 = []

for i in range(len(s)):
    test_01.append(i % 2) 
    test_10.append((i+1) % 2)

cost01 = 0
cost10 = 0


for i in range(len(s)):
    cost01 += abs(test_01[i] - list_s[i])
    cost10 += abs(test_10[i] - list_s[i])

print(min(cost01,cost10))

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

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

print(min(count, n - count))

Solution (Python):
S = input()

cnt_1=0
cnt_0=0
for idx,s in enumerate(S):
  if (idx%2 == 0 and s == "0") or (idx%2 == 1 and s == "1"):
    cnt_0+=1
  if (idx%2 == 1 and s == "0") or (idx%2 == 0 and s == "1"):
    cnt_1+=1
print(min(cnt_0,cnt_1))

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

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

Solution (Python):


s = input()

p1 = 0
p2 = 0

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

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

print(min(p1,p2))

Solution (Python):
S = input()
cntA = 0
cntB = 0
for index,x in enumerate(S):
    if(index%2==0):
        if(x=='1'):
            cntA+=1
        else:
            cntB+=1
    else:
        if(x=='1'):
            cntB+=1
        else:
            cntA+=1
print(min(cntA,cntB))

Solution (Python):
S = input()
l = []
for s in S:
  l.append(s)

cnt = 0
for i in range(len(l)):
  if i != 0 and l[i - 1] == l[i]:
    if l[i] == "0":
      l[i] = "1"
    else:
      l[i] = "0"
    cnt += 1
print(cnt)

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

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

Solution (Python):
import numpy as np
words = lambda t : list(map(t, input().split()))

s = input()

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

print(min(bres,wres))

Solution (Python):
s = input()
zero = 0
one = 0
for i , j in enumerate(s):
    if i % 2 == 0:
        if j == '1':
            zero += 1
        if j == '0':
            one += 1
    if i % 2 == 1:
        if j == '1':
            one += 1
        if j == '0':
            zero += 1
print(min(zero, one))

Solution (Python):
S = [int(i) for i in input()]
p = [0]*len(S)
for i in range(len(S)):
    if i % 2 == 0:
        p[i] = 1
q = [0]*len(S)
for i in range(len(S)):
    if i % 2 == 1:
        q[i] = 1

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

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

print(min(pans, qans))

Solution (Python):
s=input()
cnt1=0
cnt2=0
for i in range(len(s)):
    if i%2==1 and s[i]=='0':
        cnt1+=1
    elif i%2==0 and s[i]=='1':
        cnt1+=1
    if i%2==0 and s[i]=='0':
        cnt2+=1
    elif i%2==1 and s[i]=='1':
        cnt2+=1
print(min(cnt1,cnt2))

Solution (Python):
s = input()

c01010c = 0
c10101c = 0
i = 0

for ss in s:
    if ss == '0' and i % 2 == 0:
        c10101c += 1
    elif ss == '0' and i % 2 == 1:
        c01010c += 1
    elif ss == '1' and i % 2 == 0:
        c01010c += 1
    elif ss == '1' and i % 2 == 1:
        c10101c += 1
    i += 1

print(min(c01010c, c10101c))

Solution (Python):
s=input()

now_black=True
count_a=0
for c in s:
    if now_black and c == "1":
        count_a += 1
    elif (not now_black) and c == "0":
        count_a += 1
    now_black = not now_black

now_black=False
count_b=0
for c in s:
    if now_black and c == "1":
        count_b += 1
    elif (not now_black) and c == "0":
        count_b += 1
    now_black = not now_black

print (min(count_a, count_b))

Solution (Python):
def solve(S):
    cnt0 = 0
    cnt1 = 0
    for i in range(len(S)):
        if i % 2 == 0:
            if S[i] == '1':
                cnt1 += 1
            else:
                cnt0 += 1
        else:
            if S[i] == '1':
                cnt0 += 1
            else:
                cnt1 += 1
    return min(cnt0, cnt1)


S = input()
print(solve(S))

Solution (Python):

import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        S = np.asarray(list(map(int,list(str(input())))))
    else:
        pass
    

    A = np.asarray(range(S.size))
    B = np.asarray([0]*S.size)
    B[A%2==0] = 0
    B[A%2==1] = 1
    
    C = np.asarray([0]*S.size)
    C[A%2==0] = 1
    C[A%2==1] = 0
    
    res1 = np.sum(np.bitwise_xor(S,B))
    res2 = np.sum(np.bitwise_xor(S,C))
    print(min(res1,res2))

if __name__ =='__main__':
    main()

Solution (Python):
S = input()

BLACK = '0'
WHITE = '1'

white_start = 0
black_start = 0

for i, s in enumerate(S):
    if i % 2 == 0:
        if s == BLACK:
            white_start += 1
        else:
            black_start += 1
    else:
        if s == BLACK:
            black_start += 1
        else:
            white_start += 1
print(min([white_start, black_start]))

Solution (Python):
S=[int(c) for c in input()]
T=[i%2 for i in range(len(S))]
q=0
for s,t in zip(S,T):
    q+= s!=t
print(min(q,len(S)-q))

Solution (Python):
S = raw_input()
count = [0,0]
oe = 0
n = 0
for c in S:
	if(c =='1'):
		count[oe] += 1
	else:
		count[(oe+1)%2] += 1
	oe = (oe+1)%2
	n += 1
print(n - max(count))

Solution (Python):
s = input()
n = len(s)
temp = len([i for i in range(n) if int(s[i]) == i % 2])
print(min(temp, n - temp))

Solution (Python):




def main():
    lc = list(map(int, list(input())))
    bc = lc[0]
    ret = 0
    for c in lc[1:]:
        if c == bc:
            bc = 1 - c
            ret += 1
        else:
            bc = c
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):


s = input()

ans0 = 0
ans1 = 0

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

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

print(min([ans0, ans1]))

Solution (Python):
S=input()

startzero=0
startone=0

for i in range(len(S)):
  if i%2==0:
    if S[i]=='0':
      startone+=1
    else:
      startzero+=1
  else:
    if S[i]=='0':
      startzero+=1
    else:
      startone+=1
  

print(min(startzero,startone))

Solution (Python):
S = input()

if len(S) == 1:
    print(0)
else:
    o = S[::2]
    e = S[1::2]
    to = o.count('1') + e.count('0')
    te = o.count('0') + e.count('1')
    print(min(to, te))

Solution (Python):
S=input()
ans=0
flag=0
for i in S:
  if int(i)==flag:
    ans+=1
  flag=abs(flag-1)
print(min(ans,len(S)-ans))

Solution (Python):
S = input()
if len(S) % 2 == 0:
    T = "10"*(len(S)//2)
    U = "01"*(len(S)//2)
else:
    T = "10"*(len(S)//2)+"1"
    U = "01"*(len(S)//2)+"0"

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

Solution (Python):
def main():
    S = input()
    L = []
    LL = []
    i = 0
    for _ in range(len(S)):
        L.append(str(1 ^ i))
        i ^= 1
    i = 0
    for _ in range(len(S)):
        LL.append(str(0 ^ i))
        i ^= 1
    L = ''.join(L)
    LL = ''.join(LL)
    lc = 0
    llc = 0
    for s, l, ll in zip(S, L, LL):
        if s != l:
            lc += 1
        if s != ll:
            llc += 1
    print(min(lc, llc))


main()

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

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

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

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

t1 = t2 = 0
for i in range(N):
    c = str(i % 2)
    if S[i] != c:
        t1 += 1
    else:
        t2 += 1
print(min(t1, t2))

Solution (Python):


S = input()

candidate1 = []
candidate2 = []
for i in range(len(S)):
    candidate1.append(str(i%2))
    candidate2.append(str((i+1)%2))

dif1 = dif2 = 0
for enu, i in enumerate(S):
    if i!= candidate1[enu]:
        dif1 += 1
    if i!= candidate2[enu]:
        dif2 += 1
    
print(min(dif1, dif2))

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a = list(input())

c = '0'
count1 = 0
count2 = 0
for i in a:
    if i != c:
        count1 += 1
    if c == '0':
        c = '1'
    else:
        c = '0'
c = '1'
for i in a:
    if i != c:
        count2 += 1
    if c == '0':
        c = '1'
    else:
        c = '0'
print(min(count1, count2))

Solution (Python):
s = input()
ans = float("inf")

for v in [1,2]:
  count = 0
  for i,c in enumerate(s):
    if (i+v) % 2 == 0:
      if c == "1":
        count += 1
    else:
      if c == "0":
        count += 1
  ans = min(count,ans)
print(ans)

Solution (Python):
S = input()
N = len(S)
ans1 = 0
ans2 = 0
for i in range(N):
  if i % 2 == 0 and S[i] == "0":
    ans1 += 1
  if i % 2 == 1 and S[i] == "1":
    ans1 += 1
for i in range(N):
  if i % 2 == 0 and S[i] == "1":
    ans2 += 1
  if i % 2 == 1 and S[i] == "0":
    ans2 += 1
print(min(ans1, ans2))

Solution (Python):
S = [int(i) for i in input()]
S1 = [i % 2 for i in range(len(S))]
S2 = [(i + 1) % 2  for i in range(len(S))]

s1 = 0
s2 = 0

for i in range(len(S)):
  if S[i] == S1[i]:
    s1 += 1
  if S[i] == S2[i]:
    s2 += 1
print(min(s1,s2))

Solution (Python):
s = input()
len = len(s)
min1,min2 = 0,0
moji1 = "10" * (len//2 +1)
moji2 = "01" * (len//2 +1)
for i in range(len) :
    if s[i] != moji1[i] :
        min1 += 1
    if s[i] != moji2[i] :
        min2 += 1
print(min(min1,min2))

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

k = len(S)
tmp = 0
ans1 = 0
ans2 = 0
for i in range(k):
    if tmp != S[i]:
        ans1 += 1
    tmp = (tmp + 1) % 2

tmp = 1
for i in range(k):
    if tmp != S[i]:
        ans2 += 1
    tmp = (tmp + 1) % 2

print(min(ans1, ans2))

Solution (Python):
s = input()
length = len(s)
black_s = ["0" if x %2 == 0 else "1" for x in range(length) ]
white_s = ["0" if x %2 == 1 else "1"for x in range(length)]

black = 0
white = 0
for index, x in enumerate(s):
    if x != black_s[index]:
        black += 1

    if x!= white_s[index]:
        white += 1
else:
    print(min(black, white))

Solution (Python):
S = input()
ans = 10 ** 6

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

temp = 0
for i in range(len(S)):
    if i & 1 :
        if S[i] != '0':
            temp += 1
    else:
        if S[i] == '0':
            temp += 1
ans = min(ans,temp)
print(ans)

Solution (Python):
import numpy as np

if __name__ == "__main__":
    S = input()
    N = len(S)
    ans1 = 0
    ans2 = 0
    for i in range(N):
        if((i % 2) == int(S[i])):
            ans1 += 1
        else:
            ans2 += 1
    print(min(ans1, ans2))

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

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

Solution (Python):



S = input()

r1 = 0
r2 = 0
for i in range(len(S)):
    if int(S[i]) == (i % 2):
        r1 += 1
    else:
        r2 += 1
print(min(r1, r2))

Solution (Python):
S = input()

length = len(S)
counter = 0

for i in range(length):
    if i % 2 == 0:
        if S[i] == '0':
            counter += 1

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

print(length - counter if length // 2 < counter else counter)

Solution (Python):

TL = input()
TL = list(TL)
cnt1 = 0
cnt2 = 0
fg = True

for lop in range(0,len(TL)):
    if fg == True:
        if TL[lop] == "0":
            cnt1 += 1
    else:
        if TL[lop] == "1":
            cnt1 += 1
    fg = fg ^ 1

fg = True
for lop in range(0,len(TL)):
    if fg == True:
        if TL[lop] == "1":
            cnt2 += 1
    else:
        if TL[lop] == "0":
            cnt2 += 1
    fg = fg ^ 1
 
print( min(cnt1,cnt2) )

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

kouho0 = [i % 2 == 0 for i in range(len(tiles))]
kouho1 = [i % 2 != 0 for i in range(len(tiles))]

kekka0 = 0
kekka1 = 0
for i in range(len(tiles)):
    if tiles[i] != kouho0[i]:
        kekka0 += 1
    if tiles[i] != kouho1[i]:
        kekka1 += 1

if kekka0 < kekka1:
    print(kekka0)
else:
    print(kekka1)

Solution (Python):
s = input()

x = s[0::2].count("0") + s[1::2].count("1")
y = s[0::2].count("1") + s[1::2].count("0")

print(min(x, y))

Solution (Python):





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

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

length=len(s)
target_1=[]
target_2=[]
for i in range(length):
    if i%2==0:
        target_1.append(1)
        target_2.append(0)
    else:
        target_1.append(0)
        target_2.append(1)
sum_1=0
sum_2=0
for i in range(length):
    if target_1[i]!=s[i]:
        sum_1=sum_1+1
    if target_2[i]!=s[i]:
        sum_2=sum_2+1

print(min(sum_1, sum_2))

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

SA="01"*(int(N))
SB="10"*(int(N))
ma=0
mb=0
for i in range(N):
    if SA[i]!=S[i]:
        ma+=1
    else:
        mb+=1
print(min(ma,mb))

Solution (Python):
s = input()

cnt_1 = 0
cnt_2 = 0

pattern = "01"

for i in range(len(s)):
    if s[i] != pattern[i % 2]:
        cnt_1 += 1
    
    if s[i] != pattern[(i + 1) % 2]:
        cnt_2 += 1

print(min(cnt_1, cnt_2))

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

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

Solution (Python):
S = input()
a = []
b = []
for i, s in enumerate(S):
  if i%2==0:
    a.append(s)
  else:
    b.append(s)
a0 = a.count('0')
a1 = a.count('1')
b0 = b.count('0')
b1 = b.count('1')
if a0+b1>=a1+b0:
  print(a1+b0)
else:
  print(a0+b1)

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

ans1 = 0
ans2 = 0

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


print(min(ans1,ans2))

Solution (Python):
S = input()

cnt = 0
prev = S[0]
for i in range(1, len(S)):
    if S[i] == prev:
        cnt += 1
        prev = str(abs(int(S[i])-1))
    else:
        prev = S[i]
    
print(cnt)

Solution (Python):


S = list(input())
N = len(S)
ans0 = 0
ans1 = 0

for i in range(N):
    if i % 2 == 0:
        if S[i] == '0':
            pass
        else:
            ans0 += 1
    else:
        if S[i] == '1':
            pass
        else:
            ans0 += 1


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

print(min(ans0, ans1))

Solution (Python):
def solve(s):
    side = 0
    count = [0,0]
    for c in s:
        if c != "0":
            count[side] += 1
        else:
            count[1-side] += 1
        side = 1 - side
    print(min(count))

s = input()
solve(s)

Solution (Python):
s = input()
zeroone = '01'* len(s)
onezero = '10' * len(s)
count_z = 0
count_o = 0
for i in range(len(s)):
    if s[i] == zeroone[i]:
        count_z += 1
    else:
        count_o += 1
print(min(count_o, count_z))

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

Solution (Python):
S = input()

res = 0
tmp = ""

for i in S:
    if tmp != i:
        tmp = i
        continue
    if i == "0":
        tmp = "1"
        res += 1
    else:
        tmp = "0"
        res += 1

print(res)

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):
s = input()

start_black = 0
start_white = 0
for i in range(len(s)):
	if i%2 == 0 and s[i] == "1":
		start_black += 1
	if i%2 == 1 and s[i] == "0":
		start_black += 1
	if i%2 == 0 and s[i] == "0":
		start_white += 1
	if i%2 == 1 and s[i] == "1":
		start_white += 1


print(min(start_white, start_black))