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):
import sys
import math
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def change_color(t):
    if t == '0':
        return '1'
    return '0'


def solve(inputs):
    tiles = list(inputs[0])
    tiles = [x == "1" for x in tiles]

    diff_num_1 = 0
    diff_num_2 = 0
    state_1 = True
    state_2 = False

    for t in tiles:
        if t != state_1:
            diff_num_1 += 1
        if t != state_2:
            diff_num_2 += 1

        state_1 = not state_1
        state_2 = not state_2
    return min(diff_num_1, diff_num_2)


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

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

    odd_tile_dict = {"0": 0, "1": 0}
    even_tile_dict = {"0": 0, "1": 0}
    for s in S[1::2]:
        odd_tile_dict[s] += 1

    for s in S[::2]:
        even_tile_dict[s] += 1

    res = min(odd_tile_dict["0"] + even_tile_dict["1"], odd_tile_dict["1"] + even_tile_dict["0"])
    print(res)

if __name__ == '__main__':
    main()

Solution (Python):
s = list(map(int, input()))
a = 0
b = 0
for i, v in enumerate(s):
    a += v ^ (i & 1)
    b += v ^ ((i + 1) & 1)

print(min(a, b))

Solution (Python):
s = list(map(int, input()))
a = 0
b = 0
for i in range(len(s)):
    a += s[i] ^ (i % 2)
    b += s[i] ^ ((i + 1) % 2)

print(min(a, b))

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

last = S[0]
n_change = 0
for idx, current in enumerate(S):
    if idx == 0:
        continue
    if current == last:
        current = 0 if current == 1 else 1
        S[idx] = current
        n_change += 1
    last = current

print(n_change)

Solution (Python):
def smaller(x, y):
	if x < y:
		return x
	return y

S = input()
dp0 = []
dp1 = []
if S[0] == '0':
	dp0.append(0)
	dp1.append(1)
else:
	dp0.append(1)
	dp1.append(0)
for i in range(1, len(S)):
	newdp0 = dp1[-1]
	newdp1 = dp0[-1] + 1
	if S[i] == '1':
		newdp0 = dp1[-1] + 1
		newdp1 = dp0[-1]
	dp0.append(newdp0)
	dp1.append(newdp1)
print(smaller(dp0[-1], dp1[-1]))

Solution (Python):



s = list(input())
s_len = len(s)
ctr = 0

for i in range(s_len - 1):
    if s[i] == s[i + 1]:
        if s[i] == '0':
            s[i + 1] = '1'
        else:
            s[i + 1] = '0'
        ctr += 1
print(ctr)

Solution (Python):
s = input()
ans = 0
if len(s) > 1:
    k = s[1]
    if s[0] == '0' and s[1] == '0':
        k ='1'
    elif s[0] == '1' and s[1] == '1':
        k = '0'
for i in range(1,len(s)):
    if i%2 == 0 and s[i] != s[0]:
        ans+=1
    elif i%2 != 0 and s[i] != k:
        ans+=1

print (ans)

Solution (Python):
s = list(input())
even = s[1::2]
odd = s[::2]
a = even.count('0')
b = even.count('1')
c = odd.count('0')
d = odd.count('1')
if a+d <= b+c:
	print(a+d)
else:
	print(b+c)

Solution (Python):
count1 = 0
count2 = 0
num = input()
le = len(num)

for n in range(le):
    if n%2 == 0:
        if num[n] == "0":
            count1 += 1
    else:
        if num[n] == "1":
            count1 += 1
for n in range(le):
    if n%2 == 0:
        if num[n] == "1":
            count2 += 1
    else:
        if num[n] == "0":
            count2 += 1
print(min(count1,count2))

Solution (Python):
S = input()

len_s = len(S)
if len_s == 1:
  print(0)
else:
  temp = len_s//2

  a = '10' * (temp)
  b = '01' * (temp)

  if len_s%2 != 0:
    a = a + '1'
    b = b + '0'

  cnt_a = 0
  cnt_b = 0
  for i in range(len_s):
    if a[i] != S[i]:
      cnt_a += 1
    if b[i] != S[i]:
      cnt_b += 1
  print(min(cnt_a, cnt_b))

Solution (Python):
s = input()
l = len(s)
left = ""
right = ""
l_ans = 0
r_ans = 0
if l % 2 == 0:
    left = "10" * (l // 2)
    right = "01" * (l // 2)
else:
    left = "10" * (l // 2) + "1"
    right = "01" * (l // 2) + "0"
for i in range(l):
        if s[i] != left[i]:
            l_ans += 1
        if s[i] != right[i]:
            r_ans += 1
print(min(l_ans, r_ans))

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

Solution (Python):
S = input()


def solve(color):
    ret = 0

    for s in S:
        if s != color:
            ret += 1
        color = '0' if color == '1' else '1'

    return ret


print(min(solve('0'), solve('1')))

Solution (Python):
s=list(input())
s1=[]
s2=[]

for i in range(len(s)):
    if i%2==0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
    
count1=0
count2=0
for i in range(len(s)):
    if s[i]!=s1[i]:
        count1+=1
    if s[i]!=s2[i]:
        count2+=1
        
print(min(count1,count2))

Solution (Python):
import sys
from collections import deque  
from collections import defaultdict  
from heapq import heapify, heappush, heappop, heappushpop  
from bisect import bisect_left, bisect_right  



s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    S = i2s()
    a = 0
    b = 0
    t = ['0', '1']
    for i, s in enumerate(S):
        if s == t[i & 1]:
            a += 1
        else:
            b += 1
    n = min(a, b)
    print(n)

main()

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

Solution (Python):


s = input()
ls = len(s)
zero_one = "01" * (ls//2) + "0" * (ls%2)
one_zero = "10" * (ls//2) + "1" * (ls%2)


a, b = 0, 0
for i in range(ls):
    if s[i] != zero_one[i]:
        a += 1
    if s[i] != one_zero[i]:
        b += 1

print(min(a,b))

Solution (Python):


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

length = len(S)
diff = [abs(s - i % 2) for (i, s) in enumerate(S)]
diff_sum = sum(diff)
ans = min(diff_sum, length - diff_sum)

print(ans)

Solution (Python):



""" convenient functions




"""

import sys
sys.setrecursionlimit(10**7)
from itertools import accumulate, combinations, permutations, product 

from math import factorial, ceil, floor
def factorize(n):
    """return the factors of the Arg and count of each factor
    
    Args:
        n (long): number to be resolved into factors
    
    Returns:
        list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
    """
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def combinations_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    
    if n < 0 or r < 0:
        raise Exception('combinations_count(n, r) not defined when n or r is negative')
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combinations_with_replacement_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    if n < 0 or r < 0:
        raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
    elif n == 0:
        return 1
    else:
        return combinations_count(n + r - 1, r)
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict 
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
from copy import deepcopy, copy 
from operator import itemgetter


from functools import reduce
def chmin(x, y):
    """change minimum
    if x > y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current minimum value
        y (long): potential minimum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x > y:
        x = y
        return (x, True)
    else:
        return (x, False)
def chmax(x, y):
    """change maximum
    if x < y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current maximum value
        y (long): potential maximum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x < y:
        x = y
        return (x, True)
    else:
        return (x, False)

from fractions import gcd 
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)



INF = 10 ** 18
MOD = 10 ** 9 + 7
modpow = lambda a, n, p = MOD: pow(a, n, p) 
def modinv(a, p = MOD):
    
    
    return modpow(a, p-2, p)
def modinv_list(n, p = MOD):
    if n <= 1:
        return [0,1][:n+1]
    else:
        inv_t = [0,1]
        for i in range(2, n+1):
            inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
        return inv_t
def modfactorial_list(n, p = MOD):
    if n == 0:
        return [1]
    else:
        l = [0] * (n+1)
        tmp = 1
        for i in range(1, n+1):
            tmp = tmp * i % p
            l[i] = tmp
        return l
def modcomb(n, k, fac_list = [], p = MOD):
    
    
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if len(fac_list) <= n:
        a = factorial(n) % p
        b = factorial(k) % p
        c = factorial(n-k) % p
    else:
        a = fac_list[n]
        b = fac_list[k]
        c = fac_list[n-k]
    return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
def modadd(a, b, p = MOD):
    return (a + b) % MOD
def modsub(a, b, p = MOD):
    return (a - b) % p
def modmul(a, b, p = MOD):
    return ((a % p) * (b % p)) % p
def moddiv(a, b, p = MOD):
    return modmul(a, modpow(b, p-2, p))

""" initialize variables and set inputs

    
    

    
    
    
    
    

    
    
    
    

    
    
"""


r = lambda: sys.stdin.readline().strip()
r_int = lambda: int(r())
R = lambda: list(map(int, r().split()))
Rfloat = lambda: list(map(float, r().split()))
Rtuple = lambda: tuple(map(int, r().split()))
Rmap = lambda: map(int, r().split())

""" how to treat input







"""




S = r()
count = 0
if len(S) == 1:
    print(0)
    exit()
for i in S[::2]:
    if i == "0":
        count += 1
for i in S[1::2]:
    if i == "1":
        count += 1
print(min(count, len(S)-count))



"""memo: how to use defaultdict of list

Dic = defaultdict(list)

Dic[x].append(y)

for k, v in Dic.items():
"""

Solution (Python):
S = input()
A = [int(S[i]) for i in range(len(S))]
X = [0]
Y = [1]
for i in range(len(S)-1):
  if X[i] == 0:
    X.append(1)
  elif X[i] == 1:
    X.append(0)
for i in range(len(S)-1):
  if Y[i] == 0:
    Y.append(1)
  elif Y[i] == 1:
    Y.append(0)
B = 0
C = 0
for k in range(len(S)):
  if A[k] == X[k]:
    B += 0
  else:
    B += 1
for l in range(len(S)):
  if A[l] == Y[l]:
    C += 0
  else:
    C += 1
print(min(B,C))

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

    cnt0 = 0  
    for i, s in enumerate(S):
        if i % 2 != s:
            cnt0 += 1
    print(min(cnt0, len(S)-cnt0))


main()

Solution (Python):
s = input()

if len(s) % 2:
  white_black = '10' * (len(s) // 2) + '1'
  black_white = '01' * (len(s) // 2) + '0'
else:
  white_black = '10' * (len(s) // 2)
  black_white = '01' * (len(s) // 2)

if s == white_black or s == black_white:
  count = 0
else:
  diff_wb = sum([len(x) for x, y in zip(s, white_black) if x != y])
  diff_bw = sum([len(x) for x, y in zip(s, black_white) if x != y])
  count = min(diff_wb, diff_bw)

print(count)

Solution (Python):
s = input()
n = len(s)
s1 = '1'
s0 = '0'
for x in range(n-1):
    if s1[x] == '1':
        s1 = s1 + '0'
        s0 = s0 + '1'
    else:
        s1 = s1 +'1'
        s0 = s0 +'0'
s11  =0
s00 = 0
for a in range(n):
    if s1[a] != s[a]:
        s11 += 1
    else:
        s00 += 1
print(min(s11,s00))

Solution (Python):
s = input()

ans1 = 0
ans2 = 0
for i,j in enumerate(s):
    if i % 2 == 0 and j == '0':
        ans1 += 1
    if i % 2 == 1 and j == '1':
        ans1 += 1
    if i % 2 == 0 and j == '1':
        ans2 += 1
    if i % 2 == 1 and j == '0':
        ans2 += 1
print(min(ans1, ans2))

Solution (Python):
a = input()
b = [bool(int(a[i])) for i in range(len(a))]
b.insert(0, True)
c = [bool(int(a[i])) for i in range(len(a))]
c.insert(0, False)
bc = 0
cc = 0

for i in range(1, len(b)):
    if b[i-1] == b[i]:
        b[i] = not b[i-1]
        bc += 1
    if c[i-1] == c[i]:
        c[i] = not c[i - 1]
        cc += 1

print(min(bc, cc))

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

Solution (Python):
import numpy as np
s = list(map(int, list(str(input()))))
s = np.array(s)

s1 = np.array([0 if i%2 == 0 else 1 for i in range(len(s))])
s2 =np.array([0 if i%2 == 1 else 1 for i in range(len(s))])

print(min(np.sum(np.abs(s-s1)), np.sum(np.abs(s-s2))))

Solution (Python):
s = input()
n = len(s)
count = 0
data = []
for i in range(n):
    data.append(int(s[i]))
for  i in range(n -1):
    if data[i] == data[i + 1]:
        data[i + 1] = (data[i + 1] + 1) % 2
        count += 1
print(count)

Solution (Python):
S = input()


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

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

Solution (Python):
S=input()

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


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

print(min(n1,n2))

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

count1  = 0
count2 = 0

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

    if i % 2 == 0 and s[i] == '0':
        count2 += 1
    elif i % 2 and s[i] == '1':
        count2 += 1

print(min(count1, count2))

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

n_operation = 0
for i, s_val in enumerate(S):
    if i == 0:
        continue
    last_val = S[i-1]
    if s_val == last_val:
        if s_val == '0':
            S[i] = '1'
        else:
            S[i] = '0'
        n_operation += 1

print(n_operation)

Solution (Python):

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

if cost1 < cost2:
    print(cost1)
else:
    print(cost2)

Solution (Python):
S = input()
N = len(S)
cost1 = 0
cost2 = 0
for i in range(N):
    if i % 2 == 0:
        if S[i] == "0":
            cost1 += 1
        else:
            cost2 += 1
    else:
        if S[i] == "1":
            cost1 += 1
        else:
            cost2 += 1

if cost1 < cost2:
    print(cost1)
else:
    print(cost2)

Solution (Python):
S = input()

a = "01"*(10**5)
b = "10"*(10**5)
acnt = 0
bcnt = 0
for i in range(len(S)):
  if a[i] != S[i]:
    acnt += 1
  if b[i] != S[i]:
    bcnt += 1
print(min(acnt, bcnt))

Solution (Python):
s = raw_input()
diff01 = 0
diff10 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '1':
            diff01 += 1
        else:
            diff10 += 1
    else:
        if s[i] == "1":
            diff10 += 1
        else:
            diff01 += 1
print min(diff10, diff01)

Solution (Python):
s=input()
s_len = len(s)
l = '01' * (s_len//2) + '0' * (s_len%2)
s,l=int(s,2),int(l,2)
c= sum(list(map(int,format(s^l,'0b'))))
print(min(c,s_len-c))

Solution (Python):

S = list(map(int, list(input())))
S0 = [i%2 for i in range(len(S))]
S1 = [(i+1)%2 for i in range(len(S))]

countS0 = 0
for i, j in enumerate(S):
    if j != S0[i]:
        countS0 += 1
        
countS1= 0
for i, j in enumerate(S):
    if j != S1[i]:
        countS1 += 1
        
print(min(countS0, countS1))

Solution (Python):
n = input()
length = len(n)
li = ["0","1"]
first=length
second=length
for i in range(length):
  j = i%2
  if n[i]==li[j]:
    first-=1
  else:
    second-=1
print(min(first,second))

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

odd_count = 0
for i in range(len(tile_color)):
  if int(tile_color[i]) % 2 == i % 2 :
    odd_count += 1

if len(tile_color)/2 < odd_count:
  print(len(tile_color)-odd_count)
else:
  print(odd_count)

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

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

Solution (Python):
S = list(input())
black = 0
white = 0


for i, n in enumerate(S):
    if i % 2 == 0:
        if n == '1':
            black += 1
    else:
        if n == '0':
            black += 1


for i, n in enumerate(S):
    if i % 2 == 0:
        if n == '0':
            white += 1
    else:
        if n == '1':
            white += 1

print(min(black, white))

Solution (Python):
s=input()
l=len(s)
a=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count('0')
a1=a.count('1')
b0=b.count('0')
b1=b.count('1')
x=max(a0+b1,a1+b0)
print(l-x)

Solution (Python):
s = input()
s = str(s)
s1 = ""
s2 = ""
for i in range(1,len(s)+1):
	if(i%2==0):
		s1=s1+"1"
	else:
		s1=s1+"0"
for i in range(1,len(s)+1):
	if(i%2==0):
		s2=s2+"0"
	else:
		s2=s2+"1"

c1=0
c2=0
for i in range(0,len(s)):
	if(s1[i:i+1]!=s[i:i+1]):
		c1=c1+1
	if(s2[i:i+1]!=s[i:i+1]):
		c2=c2+1
print(min(c1,c2))

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

def check(start,s_list):
    cnt = 0
    for s in s_list:
        if start != s:
            cnt += 1
        if start == 0:
            start = 1
        else:
            start = 0
    return cnt

print(min(check(0,s_list),check(1,s_list)))

Solution (Python):
S=input()
def s(a):return sum([(i^a^int(S[i]))&1 for i in range(len(S))])
print(min(s(0),s(1)))

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


ans = 0

def solve(S, b):
    ans = 0
    for s in S:
        ans += int(s) ^ b
        b ^= 1
    return ans

ans = solve(S, 0)
ans = min(ans, solve(S, 1))
print(ans)

Solution (Python):
s = input()
res_s0 = 0
res_s1 = 0


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




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




print(min(res_s0, res_s1))

Solution (Python):
S = input()
N = len(S)
t0, t1 = 0, 1
a = 0
b = 0
for s in S:
	if s == "1":
		a += t0
	else:
		a += t1
	t0, t1 = t1, t0
print(min(a,N-a))

Solution (Python):
s = input()
cnt, cnt_ = 0, 0
a = "10" * (len(s)//2+1)
for i in range(len(s)):
    if s[i] != a[i]:
        cnt += 1
    if s[i] != a[i + 1]:
        cnt_ += 1
print(min(cnt, cnt_))

Solution (Python):
s = input()
a = ""
cnt, cnt_ = 0, 0
while len(a) <= len(s):
    a += "10"

for i in range(len(s)):
    if s[i] != a[i]:
        cnt += 1
    if s[i] != a[i + 1]:
        cnt_ += 1
print(min(cnt, cnt_))

Solution (Python):
from sys import stdin

S = stdin.readline().rstrip()

white_odd = 0
white_even = 0
N = len(S)

i = 0
while i < N:
    if S[i] == '1':
        white_odd += 1
    if not i+1 < N:
      break
    if S[i+1] == '0':
        white_odd += 1
    i += 2
white_even = N - white_odd


if white_odd < white_even:
    print(white_odd)
else:
    print(white_even)

Solution (Python):

s = input()
ans = 0

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

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

Solution (Python):
S = input()

t1 = t2 = 0
for i in range(len(S)):
    if S[i] != str(i%2): t1 += 1
    if S[i] != str((i+1)%2): t2 += 1

print(min(t1,t2))

Solution (Python):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    N = len(S)
    count = 0
    count_ = 0
    for i in range(N):
        if i % 2 == 0:
            if S[i] == '0':
                count += 1
            else:
                count_ += 1
        else:
            if S[i] == '1':
                count += 1
            else:
                count_ += 1
    if count < count_:
        print(N - count_)
    else:
        print(N - count)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np

s0 = input()
s1 = s0
cnt0 = cnt1 = 0

for i in range(len(s0)):
    if (i%2 == 0) & (s0[i] == '1'):
        cnt0+=1
    elif (i%2 == 1) & (s1[i] == '0'):
        cnt0+=1

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

print(np.minimum(cnt0,cnt1))

Solution (Python):
S = input()
l=0
m=0
hoge=0
ho=1

for i in S:
        hoge = (hoge+1)%2
        ho = (ho+1)%2
        if i=="1":
                l+=hoge
                m+=ho
        if i=="0":
                l+=ho
                m+=hoge

print(min(l,m))

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

Solution (Python):
S = input()
a, b = 0, 0

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

Solution (Python):
s=input()
bin_num = int(s,2)
mask = 0
s_len = len(s)
for i in range(s_len):
    mask = (mask<<1) + (i%2)
mask_inv = (2**s_len-1)-mask
mask = bin_num ^ mask
mask_inv = bin_num ^ mask_inv
print(min(bin(mask).count("1"), bin(mask_inv).count("1")))

Solution (Python):
bool_zeroone = True
count = 0
sl = list(input())
for c in sl:
    if bool_zeroone and c == '0':
        count += 1
    elif not bool_zeroone and c == '1':
        count += 1
    bool_zeroone = not bool_zeroone

answer = min(count, len(sl) - count)
print(answer)

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()
answer = min(x1,x2)
print(answer)

Solution (Python):
s = list(map(int,list(str(input()))))
if len(s)==1:
    print(0)
    exit()
sum_odd = sum(s[0::2])
sum_even = sum(s[1::2])
if_odd = len(s[0::2])-sum_odd +sum_even
if_even = len(s[1::2])-sum_even +sum_odd
print(min([if_odd,if_even]))

Solution (Python):


line = input()
ans = 0
isChange = False

for i in range(len(line)-1):
    if line[i] == line[i+1] and isChange == False:
        isChange = True
    elif line[i] == line[i+1] and isChange == True:
        isChange = False
    if isChange:
        ans += 1

if ans < len(line) - ans:
    print(ans)
else:
    print(len(line) - ans)

Solution (Python):
S = input()
N = int('10' + S, 2)

def make_alternate_binary(S):
    a = 0
    b = 0
    a += 1 << S + 1
    b += 1 << S + 1
    
    for i in range(S):
        a += (i % 2) << i
        b += ((i + 1) % 2) << i
    return a, b

co1, co2 = make_alternate_binary(len(S))
print(min(bin(N ^ co1).count('1'), bin(N ^ co2).count('1')))

Solution (Python):
S = input()
N = int('10' + S, 2)

def make_alternate_binary(S):
    a = 0
    b = 0
    a += 1 << S + 1
    b += 1 << S + 1
    
    for i in range(S):
        a += (i % 2) << i
        b += ((i + 1) % 2) << i
    return a, b

co1, co2 = make_alternate_binary(len(S))
print(min(bin(N ^ co1).count('1'), bin(N ^ co2).count('1')))

Solution (Python):
S = input()

count = 0

for i in range(1, len(S)):
    if S[i - 1] == '0' and S[i] != '1':
        S = S[: i] + '1' + S[i + 1:]
        count += 1
    elif S[i - 1] == '1' and S[i] != '0':
        S = S[: i] + '0' + S[i + 1:]
        count += 1
print(count)

Solution (Python):
S = list(map(int, input()))
score = 0
length = len(S)

for i in range(length):
	goal = lambda x : 0 if x % 2 == 0 else 1
	score += abs(S[i] - goal(i))
	
if score < length / 2:
	print(score)
else:
	print(length - score)

Solution (Python):
S=input()

ans=[]
for i in range(2):
    cnt=0
    for j in range(len(S)):
        if int(S[j])%2!=(i+j)%2:
            cnt+=1
    ans.append(cnt)
print(min(ans))

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

Solution (Python):
S = list(input())
count_g = [0,0]
count_k = [0,0]
for index, x in enumerate(S):
    if index % 2 == 0:
        if x == '0':
            count_g[0] += 1
        else:
            count_g[1] += 1
        
    else:
        if x == '0':
            count_k[0] += 1
        else:
            count_k[1] += 1
a = [count_k[0]+count_g[1], count_k[1]+count_g[0]]
print(min(a))

Solution (Python):
s = input()

s1=""
s2=""

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

ans1=0
ans2=0

for i in range(len(s)):
    if(s[i:i+1]!=s1[i:i+1]): ans1+=1
    if(s[i:i+1]!=s2[i:i+1]): ans2+=1

print(min(ans1, ans2))

Solution (Python):
s = input()
count1 = 0
count2 = 0

for i in range(len(s)):
    if i%2 ==0 and s[i]=='0':
        count1 = count1 +1
    if i%2 ==1 and s[i]=='1':
        count1 = count1+1
    if i%2 ==1 and s[i]=='0':
        count2 = count2 +1
    if i%2 ==0 and s[i]=='1':
        count2 = count2+1

print(min(count1,count2))

Solution (Python):
s = input()

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

cnt01 = 0
cnt10 = 0
for i in range(len(s)):
    if s[i] != s01[i]:
        cnt01 += 1
    if s[i] != s10[i]:
        cnt10 += 1

if cnt01 > cnt10:
    print(cnt10)
else:
    print(cnt01)

Solution (Python):
import numpy as np

S = np.array([int(i) for i in list(input())])
N = len(S)

def zebra(A):
    for i in range(N-1):
        if A[-1] == 0:
            A.append(1)
        elif A[-1] == 1:
            A.append(0)
    return A

A0 = np.array(zebra([0]))
A1 = np.array(zebra([1]))

dis0 = np.count_nonzero(S - A0)
dis1 = np.count_nonzero(S - A1)

print(min(dis0, dis1))

Solution (Python):
S = input()

count_0 = 0
count_1 = 0

for i,s in enumerate(S):
    if s == "0" and i%2==0:
        count_1 += 1
        continue
    elif s=="1" and i%2==0:
        count_0 += 1
        continue
    if s == "1" and i%2==1:
        count_1 += 1
    elif s=="0" and i%2==1:
        count_0 += 1

print(min(count_0,count_1))

Solution (Python):
S = input()

count_0 = 0
count_1 = 0

for i,s in enumerate(S):
    if s == "0" and i%2==0:
        count_1 += 1
    elif s=="1" and i%2==0:
        count_0 += 1

    if s == "1" and i%2==1:
        count_1 += 1
    elif s=="0" and i%2==1:
        count_0 += 1

print(min(count_0,count_1))

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

if n % 2 == 0:
    a = int("10"*(int(n/2)),2)
    b = int("01"*(int(n/2)),2)
else:
    a = int("10"*(int((n-1)/2)) + "1", 2)
    b = int("01"*(int((n-1)/2)) + "0", 2)

ansa = bin(s^a).count("1")
ansb = bin(s^b).count("1")
print(min(ansa,ansb))

Solution (Python):

w, b = 0, 0
s = input()
for i, sv in enumerate(s):
    if i % 2 == 0:
        if sv == "0":
            b += 1
        else:
            w += 1
    else:
        if sv == "0":
            w += 1
        else:
            b += 1

print(min(w, b))

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

if n%2 == 0:
  a = int("10"*(int(n/2)),2)
  b = int("01"*(int(n/2)),2)
else:
  a = int("10"*(int((n-1)/2)) + "1",2)
  b = int("01"*(int((n-1)/2)) + "0",2)

ansa = bin(s^a).count("1")
ansb = bin(s^b).count("1")
print(min(ansa,ansb))

Solution (Python):
S = input()
a = S[0]

if len(set(S))==1:
	print(len(S)//2)
	exit()

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

Solution (Python):
s = input()
s1 = s[::2]
s2 = s[1::2]
count1 = 0
count2 = 0
count3 = 0
count4 = 0

for i in s1:
    if i == "1":
        count1 += 1
    else:
        count2 += 1
for j in s2:
    if j == "1":
        count3 += 1
    else:
        count4 += 1

answer1 = count2 + count3
answer2 = count1 + count4

if answer1 >= answer2:
    print(answer2)
else:
    print(answer1)

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

Solution (Python):
s=list(input())
a=[]
b=[]

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

for i in range(len(s)):
  if a[i]!=s[i]:
    ansa=ansa+1
  if b[i]!=s[i]:
    ansb=ansb+1
    
print(min(ansa,ansb))