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()
ans = ''
ans2 = ''
counter = 0
counter2 = 0
for i in range(int(len(S)/2)):
    ans += '10'
    ans2 += '01'
if len(S) % 2 == 1:
    ans += '1'
    ans2 += '0'

for i in range(len(S)):
    if S[i] != ans[i]:
        counter += 1
    if S[i] != ans2[i]:
        counter2 += 1
print(min(counter, counter2))

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

count0 = 0
count1 = 0

for i in range(0,n,2):
  if(l[i] == '0'):
    count0 += 1
  if(i<n-1 and l[i+1]=='1' ):
    count1 += 1

print(min(count0+count1,n-count0-count1))

Solution (Python):
import math
s=str(input())
b=''
c=0
d=math.ceil(len(s)/2)
if s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Solution (Python):
S = input()
tile_1 = str()
tile_2 = str()
flag = True
for ii in range(len(S)):
    if flag:
        tile_1 += '1'
        tile_2 += '0'
        flag = False
    else:
        tile_1 += '0'
        tile_2 += '1'
        flag = True
        
count_1, count_2 = 0, 0
for s in range(len(S)):
    if S[s] != tile_1[s]:
        count_1 += 1
    
    if S[s] != tile_2[s]:
        count_2 += 1
        
print(min(count_1, count_2))

Solution (Python):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

S = SI().strip()

N = len(S)

zero_start = 0
zero_start_counter = 0
for i in range(N):
    if not zero_start == int(S[i]):
        zero_start_counter += 1
    zero_start = (zero_start+1)%2

one_start_counter = N - zero_start_counter

print(min(zero_start_counter, one_start_counter))

Solution (Python):
s = input()
n = len(s)
s = int(s,2)
a,b=("","")
for i in range(n):
    if i%2==0:
        a+="0"
        b+="1"
    else:
        a+="1"
        b+="0"
a = int(a,2)
b = int(b,2)
k = s^a
l = s^b
f=0
y=0
for i in bin(k):
    if i=="1":
        f += 1
for j in bin(l):
    if j=="1":
        y+=1
print(min(f,y))

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

Solution (Python):



import sys

input = sys.stdin.readline

def main():
    s = input()

    mask1 = ""
    mask2 = ""

    for i in range(len(s)):
        mask1 += str(0 ^ i%2)
        mask2 += str(1 ^ i%2)

    cnt1 = 0
    cnt2 = 0
    for i in range(len(s)):
        if s[i] == mask1[i]:
            cnt1 += 1
        if s[i] == mask2[i]:
            cnt2 += 1
    print(min(cnt1, cnt2))

main()

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

for i, s in enumerate(string):
    if i%2==0:
        if(s=='0'): c1+=1
        if(s=='1'): c2+=1        
    else :
        if(s=='0'): c2+=1
        if(s=='1'): c1+=1        

print(min(c1,c2))

Solution (Python):



"""
文字列を01のリストに変換
010101 or 101010 の行列を作り、XORの演算
その結果1になった個数が、変更しなければいけない回数
"""
import numpy as np
S = np.array(list(map(int,list(input()))))  
N=len(S)

ans_even = np.zeros(N)
ans_odd = np.zeros(N)
for i in range(N):
    if i %2 == 0:
        ans_even[i] = 1
    if i %2 == 1:
        ans_odd[i] = 1

a = np.sum(np.logical_xor(S, ans_even).astype(int))

b = np.sum(np.logical_xor(S, ans_odd).astype(int))

print(min(a,b))

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

Solution (Python):
def sub():
    ss = [e for e in input()]
    if len(ss) == 1:
        print("0")
        return
    dp = {}
    if ss[0] == "0":
        dp[(0,0)] = 0
        dp[(0,1)] = 1
    else:
        dp[(0,0)] = 1 
        dp[(0,1)] = 0 
    N = len(ss)
    for i in range(1, N):
        cI = ss[i]
        if cI == "0":
            dp[(i,0)] = dp[(i-1,1)]
            dp[(i,1)] = dp[(i-1,0)] + 1
        else:
            dp[(i,0)] = dp[(i-1,1)] + 1
            dp[(i,1)] = dp[(i-1,0)]

    count = min(dp[(N-1,0)], dp[(N-1,1)])

    print("{}".format(count))

sub()

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

print(min(count1, count2))

Solution (Python):
from sys import stdin

def solve(s):
    cnt = 0
    for i, color in enumerate(s):
        if i == 0:
            continue
        if s[i - 1] == color:
            s[i] = '0' if color == '1' else '1'
            cnt = cnt + 1
    return cnt


def main():
    s = list(stdin.readlines()[0])
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
S=input()
N=len(S)
list1=list(map(int,S))
ans1=0
for i in range(len(list1)):
    if i%2==0:
        if list1[i]==1:
            ans1+=1
    elif i%2==1:
        if list1[i]==0:
            ans1+=1
ans2=min(ans1,(N-ans1))
print(ans2)

Solution (Python):
def solve(string):
  diff = 0
  for k, v in enumerate(string):
    if (k % 2 == 1 and v == '1') or (k % 2 == 0 and v == '0'):
      diff += 1
  return min(diff, len(string) - diff)

def main():
  string = input()
  ans = solve(string)
  print(ans)
  
main()

Solution (Python):
string = input()
ans_01 = 0
ans_10 = 0

tile = 0
for s in string:
    if s != str(tile % 2):
        ans_01 += 1
    tile += 1

tile = 1
for s in string:
    if s != str(tile % 2):
        ans_10 += 1
    tile += 1

if ans_01 >= ans_10:
    print(ans_10)
else:
    print(ans_01)

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

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

for i in range(len(S)):
    if S[i] == s1[i]:
        c2 += 1
    else:
        c1 += 1

print(min(c1, c2))

Solution (Python):

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


count = [0, 0]


for i, s in enumerate(S):
    if i % 2 == 0: 
        if s != 0:
            count[0] += 1        
    elif i % 2 == 1: 
        if s != 1:
            count[0] += 1


for i, s in enumerate(S):
    if i % 2 == 0: 
        if s != 1:
            count[1] += 1        
    elif i % 2 == 1: 
        if s != 0:
            count[1] += 1

print(min(count))

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

if len(s) % 2 == 0:
    a = [1,0] * (len(s) // 2)
    b = [0,1] * (len(s) // 2)
    aa = 0
    bb = 0
    for i in range(len(s)):
        if s[i] != a[i]:
            aa += 1
        if s[i] != b[i]:
            bb += 1
    c = min(aa,bb)
else:
    a = [1,0] * (len(s) // 2) + [1]
    b = [0,1] * (len(s) // 2) + [0]
    aa = 0
    bb = 0
    for i in range(len(s)):
        if s[i] != a[i]:
            aa += 1
        if s[i] != b[i]:
            bb += 1
    c = min(aa, bb)

print(c)

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

Solution (Python):
lst = [int(i) for x in input().split() for i in x]
length = len(lst)
idealLst1 =[ i&1 for i in range(1,length+1)]
idealLst2 = [i&1 for i in range(length)]
count1 = 0
count2 = 0

for i in range(length):
    if(lst[i] != idealLst1[i]):
        count1+=1    

for i in range(length):
    if(lst[i] != idealLst2[i]):
        count2+=1
print(min(count1,count2))

Solution (Python):
args = input()

black_result = 0
white_result = 0
c = 0
for s in args:
    if int(s) == c % 2:
        black_result += 1
    else:
        white_result += 1
    c += 1

print(min(black_result, white_result))

Solution (Python):


S = list(map(int, input()))
N=len(S)
count=0


def rev(x):
    if x==0:
        return 1
    else:
        return 0


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

for i in range(N-1):
    if S[i]==S[i+1]:
        S[i+1]=rev(S[i+1])
        count+=1
print(count)

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

n = len(s)
ans = 0

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

Solution (Python):
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import numpy as np
S = input()
l = len(S)
n = list(map(int, str(S)))
a = np.arange(l) 
b = np.where(a%2==0, 0, 1) 
c = np.where(a%2==1, 0, 1) 
bool1 = np.logical_xor(n, b)
bool2 = np.logical_xor(n, c)
 
count1 = np.sum(bool1)
count2 = np.sum(bool2)
 
if count1 < count2:
    print(count1)
else:
    print(count2)

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


e = [0, 1] * (int(len(s)/2) + 1)

h = [0, 0]
h[0] = sum([x == ei for x, ei in zip(s,e[0:len(s)])])
h[1] = sum([x == ei for x, ei in zip(s,e[1:len(s)+1])])

print(min(h))

Solution (Python):

def main():
    s = input()
    tmp = '0'
    ans = 0
    for i in range(len(s)):
        if tmp == '0':
            if s[i] != '0':
                ans += 1
            tmp = '1'
        else:
            if s[i] != '1':
                ans += 1
            tmp = '0'
    tmp = '1'
    ans2 = 0
    for i in range(len(s)):
        if tmp == '0':
            if s[i] != '0':
                ans2 += 1
            tmp = '1'
        else:
            if s[i] != '1':
                ans2 += 1
            tmp = '0'
    print(min(ans, ans2))


if __name__ == '__main__':
    main()

Solution (Python):
S = 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

ans = min([count, len(S)-count])
print(ans)

Solution (Python):
S = input()

correct = S[0]
answer = 0

for i in range(len(S)):
  if (correct != S[i]):
    answer += 1

  if (correct == "0"):
    correct = "1"
  else:
    correct = "0"
    
print(answer)

Solution (Python):
l = list(map(int, input()))
l_zero = [0]*len(l)
l_one = [0]*len(l)
    
for i in range(len(l)):
    if i%2 == 0 or i == 0:
        pass
    else:
        l_zero[i] = 1
    
for i in range(len(l)):
    if i%2 == 0 or i == 0:
        l_one[i] = 1
    else:
        pass
    



cnt_zero = 0
for n in range(len(l)):
    if l[n] == l_zero[n]:
        cnt_zero += 1
    else:
        pass
    
cnt_one = 0
for n in range(len(l)):
    if l[n] == l_one[n]:
        cnt_one += 1
    else:
        pass

rlt = 0
if cnt_zero < cnt_one:
    rlt = cnt_zero
elif cnt_one < cnt_zero:
    rlt = cnt_one
else:
    rlt = cnt_zero

print(rlt)

Solution (Python):
s = input()

sum1 = sum([(i % 2 == 0 and s[i] == '0') or (i % 2 == 1 and s[i] == '1') \
    for i in range(len(s))])
sum2 = sum([(i % 2 == 1 and s[i] == '0') or (i % 2 == 0 and s[i] == '1') \
    for i in range(len(s))])

print(min(sum1, sum2))

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

A = [abs(i%2-x) for i,x in enumerate(Ss) ]
B = [abs((i+1)%2-x) for i,x in enumerate(Ss) ]
print(min([sum(A), sum(B)]))

Solution (Python):
N = list(input())
A = []
B = []
for i in range(len(N)):
    if int(i) % 2 == 0:
        B.append(N[i])
    else:
        A.append(N[i])
C = A.count('0') + B.count('1')
D = B.count('0') + A.count('1')
print(min(C,D))

Solution (Python):
S = input()                                                                                                                                                  
N = len(S)                                                                                                                                                   
                                                                                                                                                             
C = 0                                                                                                                                                        
for i in range(0,N,2):                                                                                                                                       
    if S[i] != '0':                                                                                                                                          
        C = C+1                                                                                                                                              
                                                                                                                                                             
for i in range(1,N,2):                                                                                                                                       
    if S[i] != '1':                                                                                                                                          
        C = C+1                                                                                                                                              
                                                                                                                                                             
print(min(C,N-C))

Solution (Python):
a = input()
a = list(a)
k = 0
if a[0] == '1':
    for i in range(len(a)-1):
        if (i%2 == 0) & (a[i+1] == '1'):
            k += 1
        elif (i%2 == 1) & (a[i+1] == '0'):
            k += 1
else:
    for j in range(len(a)-1):
        if (j%2 == 0) & (a[j+1] == '0'):
            k += 1
        elif (j%2 == 1) & (a[j+1] == '1'):
            k += 1
print(k)

Solution (Python):
S = input()

ans = 0
numOperations = 0

for i in range(len(S)):
    if i%2 == 0 and S[i] == '0': numOperations += 1
    if i%2 == 1 and S[i] == '1': numOperations += 1
ans = numOperations    

numOperations = 0

for i in range(len(S)):
    if i%2 == 0 and S[i] == '1': numOperations += 1
    if i%2 == 1 and S[i] == '0': numOperations += 1
 
print( min(ans, numOperations) )

Solution (Python):
s = input()
a = ('01' * 10 ** 5)[:len(s)]
b = ('10' * 10 ** 5)[:len(s)]

n_a = 0
n_b = 0
for c, d in zip(s, a):
    n_a += 1 if c == d else 0

for c, d in zip(s, b):
    n_b += 1 if c == d else 0
print(min([n_a, n_b]))

Solution (Python):
S = input()

cnt = 0


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

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

print(min(cnt,cnt2))

Solution (Python):

def main():
    s = [int(x) for x in input()]
    cnt = 0
    if len(s) == 1:
        print("0")
        exit()
    for i in range(len(s)-1):
        if s[i] == 1:
            if s[i+1] == 1:
                s[i+1] = 0
                cnt+=1
        else:
            if s[i+1] == 0:
                s[i+1] = 1
                cnt+=1
    print(cnt)
main()

Solution (Python):

def main():
    s = [int(x) for x in input()]
    odd = s[::2]
    even = s[1::2]
    cnt = 0

    if odd[0]:
        cnt = odd.count(0) + even.count(1)    
    else:
        cnt = odd.count(1) + even.count(0)
    print(cnt)
main()

Solution (Python):

def main():
    s = [int(x) for x in input()]
    odd = s[::2]
    even = s[1::2]
    cnt = 0

    if odd[0]:
        cnt = odd.count(0) + even.count(1)    
    else:
        cnt = odd.count(1) + even.count(0)
    print(cnt)
main()

Solution (Python):

def main():
    s = [int(x) for x in input()]
    cnt = 0
    if len(s) == 1:
        print("0")
        exit()
    for i in range(len(s)-1):   
        if s[i] == 1:   
            if s[i+1] == 1: 
                s[i+1] = 0  
                cnt+=1  
        else:
            if s[i+1] == 0:
                s[i+1] = 1
                cnt+=1
    print(cnt)
main()

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

odd = S[::2]
cnt1 = odd.count("1")

even = S[1::2]
cnt2 = even.count("0")

sum_num = cnt1 + cnt2
sum_num2 = N - cnt1 - cnt2

print(min(sum_num,sum_num2))

Solution (Python):
s = input()

str_list = list(s)
count =0

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

print(count)

Solution (Python):
S = input()
size = len(S)
A = ""
B = ""
countA = 0
countB = 0
if size%2 == 0:
    cnt = int(size/2)
    for _ in range(cnt):
        A = A+"01"
        B = B+"10"
else:
    cnt = int((size-1)/2)
    for _ in range(cnt):
        A = A +"01"
        B = B + "10"
    A = A + "0"
    B = B + "1"
for i in range(size):
    if S[i] != A[i]:
        countA += 1
    if S[i] != B[i]:
        countB += 1
print(min(countA,countB))

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




odd = S[::2]
cnt1 = odd.count("1")

even = S[1::2]
cnt2 = even.count("0")

sum1 = N - cnt1 - cnt2
sum2 = cnt1 + cnt2
print(min(sum1,sum2))

Solution (Python):
m = map(int, list(raw_input()))
ans = 0
for i in range(len(m) - 1):
  if m[i] == m[i + 1]:
    m[i + 1] = 1 - m[i + 1]
    ans = ans + 1
print ans

Solution (Python):
S = input()
test = int(S[0])
count = 0

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

print(count)

Solution (Python):


''' 
------------------------
author : iiou16
------------------------
'''

def main():
    S = "0b" + input()
    
    
    
    """
    
    0000
    0b0000 0b0101
    0b101
    1
    """
    base = "0b"
    for i in range(len(S)-2):
        if i % 2 == 0:
            base += "1"
        else:
            base += "0"
    
    res = int(S, 0) ^ int(base, 0)

    b_format = "{:0" + str(len(S)-2) + "b}"
    bit = b_format.format(res)
    
    bit = list(map(int, list(bit)))
    count = sum(bit)
    
    if count >= len(bit) / 2:
        print(len(bit) - count)
    else:
        print(count)


if __name__ == '__main__':
    main()

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

c1 = S[1::2].count('0')
c2 = S[0::2].count('1')

sum1 = N-c1-c2
sum2 = c1+c2

print(min(sum1,sum2))

Solution (Python):
s = list(input())
sl = len(s)
sample1 = ['0' if e % 2 == 0 else '1' for e in range(sl)]
c1, c2 = 0, 0
for i in range(sl):
    if sample1[i] != s[i]:
        c1 += 1
    else:
        c2 += 1
print(min(c1, c2))

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

t1 = ('01' * (len(s) // 2 + 1))[:len(s)]
t2 = ('10' * (len(s) // 2 + 1))[:len(s)]

d1, d2 = 0, 0
for i in range(len(s)):
    cs, ct1, ct2 = s[i], t1[i], t2[i]
    if cs != ct1:
        d1 += 1
    else:
        d2 += 1

print(min(d1, d2))

Solution (Python):
S=list(input())
if len(S)%2==0:
    A=['0','1']*(len(S)//2)
    B=['1','0']*(len(S)//2)
else:
    A=['0','1']*(len(S)//2)+['0']
    B=['1','0']*(len(S)//2)+['1']

a,b=0,0
for i in range(len(S)):
    if A[i]!=S[i]:
        a+=1
        continue
for k in range(len(S)):
    if B[k]!=S[k]:
        b+=1
        continue
print(min(a,b))

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

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

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

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

n = len(a)
o_odd = 0
o_even = 0
for i in range(n):
    if i % 2 == 0 and a[i] == 1:
        o_odd += 1
    elif i % 2 == 1 and a[i] == 1:
        o_even += 1

z_even = int(n / 2 - o_even)
z_odd = round(n / 2 - o_odd + 0.1)

f_o = z_odd + o_even
f_z = z_even + o_odd

print(min(f_o, f_z))

Solution (Python):
def make01mask(start, len):
    mask = start
    for i in range(0, len - 1):
        if mask[i] == "0":
            mask += "1"
        else:
            mask += "0"
    return mask



def maskxor(bit, mask, digits):
    type = '0' + str(digits) + 'b'
    
    

    return (format(int(bit, 2) ^ int(mask, 2), type)).count("1")



bin_str = str(input())
bitdigits = len(bin_str)





start0 = maskxor(bin_str, make01mask("0", bitdigits), bitdigits)
start1 = maskxor(bin_str, make01mask("1", bitdigits), bitdigits)

if start0 > start1:
    print(start1)
else:
    print(start0)

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

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

Solution (Python):

"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
if k == '1':
    e = '0'
else :
    e = '1'

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))

Solution (Python):
S = input()
N = len(S)
even = S[0::2]
odd = S[1::2]
ptn0 = N - (even.count('0') + odd.count('1'))
ptn1 = N - (even.count('1') + odd.count('0'))
print(min(ptn0, ptn1))

Solution (Python):
a = input()
t1 = ""
t2 = ""

for i in range(len(a)):
  if (i % 2 == 0):
    t1 = t1 + "1"
    t2 = t2 + "0"
  else :
    t1 = t1 + "0"
    t2 = t2 + "1"
    
b1 = int(t1, 2) ^ int(a, 2)
b2 = int(t2, 2) ^ int(a, 2)
c1 = bin(b1).count("1")
c2 = bin(b2).count("1")

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

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

left_b = 0
if N%2 == 0:
    for i in range(N//2):
        if S[2*i] == str(1): 
            left_b = left_b + 1
        if S[2*i+1] == str(0):
            left_b = left_b + 1
    mini = min(left_b,N - left_b)
        
else:
    for i in range(N//2):
        if S[2*i] == str(1): 
            left_b = left_b + 1
        if S[2*i+1] == str(0):
            left_b = left_b + 1
    if S[N-1] == str(1):
            left_b = left_b + 1
    mini = min(left_b,N - left_b)

print(mini)

Solution (Python):
s = input()

cnt_0 = 0
cnt_1 = 0
for i in range(0, len(s), 2):
  if s[i] == '0':
    cnt_0 += 1
  else:
    cnt_1 += 1

if cnt_0 > cnt_1:
  first = '0'
  second = '1'
elif cnt_0 == cnt_1:
  if s[len(s)-1] == '1':
    first = '0'
    second = '1'
  else:
    first = '1'
    second = '0'
else:
  first = '1'
  second = '0'

cnt = 0
for i in range(0, len(s)):
  if not i%2:
    if s[i] != first:
      cnt += 1
  else:
    if s[i] != second:
      cnt += 1
print(cnt)

Solution (Python):

"""
C - Coloring Colorfully
https://atcoder.jp/contests/abc124/tasks/abc124_c

"""
import sys


from itertools import cycle

def solve(S):
    c1 = cycle('10')
    ans1 = 0
    for s in S:
        if s != next(c1):
            ans1 += 1

    c2 = cycle('01')
    ans2 = 0
    for s in S:
        if s != next(c2):
            ans2 += 1
    return min(ans1, ans2)


def main(args):
    S = input()
    ans = solve(S)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
from sys import stdin


def main():
    S = stdin.readline().rstrip()
    count = [0, 0]
    x = ['01', '10']
    for j in range(2):
        for i, c in enumerate(S):
            if c == x[j][i % 2]:
                count[j] += 1
    print(min(count))


if __name__ == "__main__":
    main()

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

bw = ''
wb = ''
for n in range(N):
    bw += str(n % 2)
    wb += str((n+1) % 2)

diff_bw = 0
diff_wb = 0
for n in range(N):
    if S[n] != bw[n]:
        diff_bw += 1
    if S[n] != wb[n]:
        diff_wb += 1

print(min(diff_bw, diff_wb))

Solution (Python):
S = input()

BW = "01" * (10**5)
WB = "10" * (10**5)

ans = 0
if S[0] == "0":
    for i in range(len(S)):
        if S[i] != BW[i]:
            ans += 1
else:
    for i in range(len(S)):
        if S[i] != WB[i]:
            ans += 1
            
print(ans)

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

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

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

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

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

Solution (Python):
S = input()

ans = len(S)
tmp = 0
for i in range(len(S)):
    if int(S[i]) == i%2:
        tmp += 1
ans = min(ans,tmp)

tmp=0
for i in range(len(S)):
    if int(S[i]) == (i+1)%2:
        tmp += 1
ans = min(ans,tmp)

print(ans)

Solution (Python):

L = list(map(int, input()))
L0 = 0
L1 = 0
for i, n in enumerate(L):
    if i % 2 == 0:
        if n == 1:
            L1 += 1
        else:
            L0 += 1
    else:
        if n == 0:
            L1 += 1
        else:
            L0 += 1
print(min(L1, L0))

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

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

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

Solution (Python):
S = input()
tmp1,tmp2 = 0,0
c1,c2 = 0,1
ans = 0
length = len(S)

for i in range(length):
	tmp1 += 1 if int(S[i]) == c1 else 0
	tmp2 += 1 if int(S[i]) == c2 else 0
	c1 = abs(c1 - 1)
	c2 = abs(c2 - 1)

ans = min(tmp1,tmp2)
print(ans)

Solution (Python):
'''input
0
'''

S=input()

da, db=0,0
A=[]
B=[]


for i in range(len(S)):
	A.append(i%2)
	B.append((i+1)%2)
	
	da+=abs(A[i]-int(S[i]))
	db+=abs(B[i]-int(S[i]))


print(min(da, db))

Solution (Python):
S_array = [int(c) for c in list(input())]
count = 0

if len(S_array) == 1:
  print(count)
  exit()

for i in range(len(S_array) - 1):
  if S_array[i] != S_array[i + 1]:
    continue
  elif S_array[i] == 0:
    S_array[i + 1] = 1
  else:
    S_array[i + 1] = 0
  count = count + 1

print(count)

Solution (Python):
S = input()
N = len(S)
num = float('inf')
tmp = 0
for k in range(N):
    if k % 2 == 0 and S[k] == '0':
        tmp += 1
    if k % 2 != 0 and S[k] == '1':
        tmp += 1

num = min(tmp, num)

tmp = 0
for k in range(N):
    if k % 2 == 1 and S[k] == '0':
        tmp += 1
    if k % 2 != 1 and S[k] == '1':
        tmp += 1

num = min(tmp, num)

print(num)

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




count_0 = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s!= 0:
            count_0 += 1
    else:
        if s!= 1:
            count_0 += 1




count_1 = 0
for i, s in enumerate(S):
    if i % 2 == 0:
        if s!= 1:
            count_1 += 1
    else:
        if s!= 0:
            count_1 += 1

print(min(count_0, count_1))

Solution (Python):
import copy

S = [int(x) for x in input()]
N = len(S)

com = [0] * N
com_01 = copy.deepcopy(com)
com_10 = copy.deepcopy(com)

dif_01 = 0
dif_10 = 0
for n in range(N):
    
    if n % 2 == 0:
        com_10[n] = 1
    else:
        com_01[n] = 1

    dif_01 += abs(S[n] - com_01[n])
    dif_10 += abs(S[n] - com_10[n])

print(min(dif_01, dif_10))

Solution (Python):

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

lnS = len(S)
pt1 = [0,1] * (lnS // 2)
if lnS % 2==1:
    pt1.append(0)

dif_S_pt1 = sum(list(map(lambda x,y:abs(x-y),S,pt1)))
print(min([dif_S_pt1,lnS - dif_S_pt1]))

Solution (Python):
S = input()
N = len(S)
Sw = '01' * (N // 2)
if (N % 2):
  Sw += '0'
Sb = '10' * (N // 2)
if (N % 2):
  Sb += '1'
diffw = 0
for i in range(N):
  if (S[i] != Sw[i]):
    diffw += 1
diffb = 0
for i in range(N):
  if (S[i] != Sb[i]):
    diffb += 1
print(min(diffw, diffb))

Solution (Python):

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

Solution (Python):
color = input().rstrip("\n")

l1 = [str(i % 2) for i in range(len(color))]
l2 = [str((i + 1) % 2) for i in range(len(color))]

s1 = s2 = 0
for c, n1, n2 in zip(color, l1, l2):
    s1 += (c != n1)
    s2 += (c != n2)

print(min(s1, s2))

Solution (Python):
def solve():
    S = raw_input()
    even0 = 0
    even1 = 0
    odd0 = 0
    odd1 = 0
    for i in range(len(S)):
        if i % 2 == 0:
            if S[i] == '0':
                even0 += 1
            else:
                even1 += 1
        else:
            if S[i] == '0':
                odd0 += 1
            else:
                odd1 += 1
    ret = min(even0 + odd1, even1 + odd0)
    print str(ret)

if __name__ == '__main__':
    solve()

Solution (Python):
S = input()


def eq(x, y):
    if x == y:
        return 1
    return 0


A = "01" * len(S)
B = "10" * len(S)

a = sum(map(eq, S, A))
b = sum(map(eq, S, B))

print(min(a, b))

Solution (Python):
s = input()
c = 0
 
for x in range(len(s)):
    c += s[x] != ('0' if x%2 else '1')
 
print(c if c < x+1-c else x+1-c)

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

for x in range(len(s)):
    c += 1 if s[x] != str(x%2) else 0

print(c if c < x+1-c else x+1-c)

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

for x in range(len(s)):
    c += 1 if s[x] != ('0' if x%2 else '1') else 0

print(c if c < x+1-c else x+1-c)

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

Solution (Python):
S = input()
c = S[::2].count('1')
c += S[1::2].count('0')
if c > len(S)/2:
    c = len(S)-c

print(c)

Solution (Python):
s = input()
c1,c2 = 0, 0

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

print(min(c1,c2))

Solution (Python):
s = input()
a = list(s)
n = len(s)
ansa = 0
ansb = 0
for i in range(n):
    if i%2 == 0 and int(a[i]) == 0:
      ansa = ansa + 1

    if i%2 == 1 and int(a[i]) == 1:
      ansa = ansa + 1    
    
    if i%2 == 0 and int(a[i]) == 1:
      ansb = ansb + 1
        
    if i%2 == 1 and int(a[i]) == 0:
      ansb = ansb + 1
     
        
if ansa > ansb:
  print(ansb)
else :
  print(ansa)

Solution (Python):
n=list(map(int,list(input())))
a=[1 if i%2==0 else 0 for i in range(len(n))]
b=[1 if i%2==1 else 0 for i in range(len(n))]
num_a=0
num_b=0
for i in range(len(n)):
	if n[i] is a[i]:
		num_a+=1
	if n[i] is b[i]:
		num_b+=1

if num_a>=num_b:
	print(len(n)-num_a)
else:
	print(len(n)-num_b)

Solution (Python):
s = input()
ans1, ans2 = 0, 0
for i, e in enumerate(s):
  if i%2:
    if e=="0":
      ans1 += 1
    if e=="1":
      ans2 += 1
  else:
    if e=="1":
      ans1 += 1
    if e=="0":
      ans2 += 1
print(min(ans1, ans2))