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
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    N = len(S)
    opt1 = "1"
    opt2 = "0"
    for i in range(1, N):
        opt1 += "1" if opt1[i - 1] == "0" else "0"
        opt2 += "1" if opt2[i - 1] == "0" else "0"
    count1 = 0
    count2 = 0
    for i in range(N):
        if S[i] != opt1[i]:
            count1 += 1
        if S[i] != opt2[i]:
            count2 += 1
    print min(count1, count2)


if __name__ == '__main__':
    main()

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

def make_valid(leng):
    s0 = ''
    s1 = ''
    last0 = '0'
    last1 = '1'
    for i in range(leng):
        s0 = s0 + last0
        s1 = s1 + last1
        last0, last1 = last1, last0
    return (s0, s1)


def count_dif(s, s1):
    ret = 0
    for idx,c in enumerate(s):
        if c != s1[idx]:
            ret += 1
    return ret

v0,v1 = make_valid(leng)
min_dif = min(count_dif(S,v0), count_dif(S,v1))
print(min_dif)

Solution (Python):
s=input()
r1=0
r2=0
sw="0"
for z in s:
  if sw==z:
    r1+=1
  else:
    r2+=1
  if sw=="0":
    sw="1"
  else:
    sw="0"
print(min((r1,r2)))

Solution (Python):
S = input()

zero = 0
for i, e in enumerate(S):
    if i % 2 == 0 and e == '1':
        zero += 1
    elif i % 2 == 1 and e == '0':
        zero += 1
one = 0
for i, e in enumerate(S):
    if i % 2 == 0 and e == '0':
        one += 1
    elif i % 2 == 1 and e == '1':
        one += 1

print(min(zero, one))

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

Solution (Python):
S = input()
od = [0, 0]
ev = [0, 0]
for i, s in enumerate(S):
    if i % 2 == 0:
        if s == '0':
            ev[0] += 1
        else:
            ev[1] += 1        
    else:
        if s == '0':
            od[0] += 1
        else:
            od[1] += 1
print(min(od[0]+ev[1], od[1]+ev[0]))

Solution (Python):
S = input()
N = len(S)
count = 0
for i, s in enumerate(S):
	if i % 2 == 0:
		if s == "0":
			count += 1
	else:
		if s == "1":
			count += 1

print(min(count, N - count))

Solution (Python):
S = input()
c = 0
x = 0
for i in S:
    if i == str(c):
        x+=1
    c = (c+1)%2
print(min(x,len(S)-x))

Solution (Python):
import sys






"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        
        
        
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)


"""ここからメインコード"""


def main():
    
    r, e, p = range, enumerate, print
    ip = IP()
    id = Idea()
    mod = 10 ** 9 + 7

    """この下から書いてね"""
    s = list(input())
    s.append("2")
    res = ans = i = 0
    while i < len(s) - 2:
        if s[i] != s[i + 1]:
            i += 1
        elif s[i] == s[i + 1] and s[i + 1] == s[i + 2]:
            i += 2
            ans += 1
        else:
            s[i + 1] = "1" if s[i + 1] == "0" else "0"
            ans += 1
            i += 1
    p(ans)


main()

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

p1 = ['1' if i%2==0 else '0' for i in range(len(S))]
p2 = ['0' if i%2==0 else '1' for i in range(len(S))]

d1 = len([1 for s,p in zip(S,p1) if not s == p])
d2 = len([1 for s,p in zip(S,p2) if not s == p])

print(min(d1,d2))

Solution (Python):
S = input()

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

check = 1
count2 = 0
for i in range(len(S)):
    if check == int(S[i]):
        count2 += 1
    check = 1-check

print(len(S) - max(count, count2))

Solution (Python):
S=input()
e=[0,0]
o=[0,0]
for i,s in enumerate(S):
    if i%2:
        o[0]+=1
        o[1]+=int(s)
    else:
        e[0]+=1
        e[1]+=int(s)
eblack,ewhite=e[0]-e[1],e[1]
oblack,owhite=o[0]-o[1],o[1]
print(min(eblack+owhite,ewhite+oblack))

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input().strip()
    slen = len(s)

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

    for i in range(slen):
        if s[i] != str((i+1)%2):
            ans2 += 1
    
    print(min(ans1, ans2))

solve()

Solution (Python):
S = input()
N = len(S)
c1 = c2 = 0
for i in range(N):
    if (S[i] == '0') ^ (i % 2):
        c1 += 1
    elif (S[i] == '1') ^ (i % 2):
        c2 += 1
print(min([c1, c2]))

Solution (Python):
def solve():
  S = input()
  cnt = 0
  flag = False
  for s in S:
    flag = not flag
    if s == str(int(flag)): continue
    cnt = cnt + 1

  return min(cnt, len(S) - cnt)

print(solve())

Solution (Python):
s = input()
    
ans1, ans2 = 0, 0

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

print(min(ans1, ans2))

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

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

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

print(min(ans, n-ans))

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

def ans1(a):
	c = 0
	for i in range(len(a)):
		if(i%2 == 0 and a[i]==1):
			c = c + 1
		elif(i%2 == 1 and a[i] == 0):
			c = c + 1
	return c
	
def ans2(a):
	c = 0
	for i in range(len(a)):
		if(i%2 == 0 and a[i]==0):
			c = c + 1
		elif(i%2 == 1 and a[i] == 1):
			c = c + 1
	return c

ans = min(ans1(a), ans2(a))
print(ans)

Solution (Python):
s = input()
l = len(s)
x = ''
for i in range(l):
    x += str(i % 2)
ax = 0
ay = 0
for i in range(l):
    if s[i] == x[i]:
        ax += 1
    else:
        ay += 1
print(min(ax, ay))

Solution (Python):
S = input()
S1 = S[::2]
S2 = S[1::2]
ans1 = S1.count('0') + S2.count('1')
ans2 = S1.count('1') + S2.count('0')
ans = min(ans1,ans2)
print(ans)

Solution (Python):
S = input()

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

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

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

str01 = "01" * (N // 2)
str10 = "10" * (N // 2)
if N % 2 == 1:
    str01 += "0"
    str10 += "1"

ans01 = 0
ans10 = 0
for i in range(N):
    if S[i] != str01[i]:
        ans01 += 1
    if S[i] != str10[i]:
        ans10 += 1

print(min(ans01, ans10))

Solution (Python):
S = input()

count1 = 0
count2 = 0
for s_i, s in enumerate(S):
    if s_i % 2 == 0:
        if s == "0":
            count1 += 1
        else:
            count2 += 1
    else:
        if s == "1":
            count1 += 1
        else:
            count2 += 1

out = min(count1, count2)
print(out)

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

a=0
for i in range(l):
    if i%2 == 0:
        if S[i] == '1':
            a += 1
    else:
        if S[i] == '0':
            a += 1

b=0
for i in range(l):
    if i%2 == 0:
        if S[i] == '0':
            b += 1
    else:
        if S[i] == '1':
            b += 1

print(min(a,b))

Solution (Python):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

a=0
b=0

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

print(min(a,b))

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

S_10 = '10' * (len(S) // 2)
if len(S) % 2 == 1:
  S_10 += '1'
S_01 = '01' * (len(S) // 2)
if len(S) % 2 == 1:
  S_01 += '0'
  
s_10 = sum([x != y for (x, y) in zip(list(S), list(S_10))])
s_01 = sum([x != y for (x, y) in zip(list(S), list(S_01))])
print(min(s_10, s_01))

Solution (Python):
s = input()
cnt = 0
res = 0
n = len(s)

for i in range(n):
    if i % 2:
        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 == 0:
        if s[i] == "0":
            cnt += 1
    else:
        if s[i] == "1":
            cnt += 1
res = min(res, n - cnt)
print(res)

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

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

count = 0
for i in range(N):
    if S[i] == str(i % 2):
        count += 1

print(min(count, N - count))

Solution (Python):
S = input()
n = len(S)
start0 = ''
start1 = ''
ans0 = 0
ans1 = 0
for i in range(n):
    if i % 2 == 0:
        start0 += '0'
        start1 += '1'
    else:
        start0 += '1'
        start1 += '0'
for i in range(n):
    if start0[i] != S[i]:
        ans0 += 1
    if start1[i] != S[i]:
        ans1 += 1
print(min(ans0, ans1))

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

Solution (Python):

import sys
import math
import numpy as np
import itertools



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

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

print(min(answer[0],answer[1]))

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

if N % 2:
	A = '01'*(N//2)+'0'
	
else:
	A = '01'*(N//2)
	

c1 = 0
c2 = 0
for s,a in zip(S,A):
	if s!=a:
		c1+=1
	else:
		c2+=1

print(min(c1,c2))

Solution (Python):
S = input()
ans1 = 0
ans2 = 0
frag = True
for s in S:
  if s == '1' and frag:
    ans1 += 1
  elif frag:
    ans2 += 1
  elif s == '0':
    ans1 += 1
  else:
    ans2 += 1
  frag = not frag
print(min(ans1,ans2))

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

first_zero = 0
first_one = 0
for i in range(len(S)) :
    if i % 2 == 0 :
        if S[i] == "1" :
            first_zero += 1
        else :
            first_one += 1
    else :
        if S[i] == "0" :
            first_zero += 1
        else :
            first_one += 1
        
ans = min(first_zero,first_one)
print(ans)

Solution (Python):
s=input()
cnt_10=0
cnt_01=0

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

Solution (Python):
S = input()

count = 0
for i, si in enumerate(S):
    if i % 2 == 0 and si != '0':
        count += 1
    if i % 2 == 1 and si != '1':
        count += 1

mi = count

count = 0
for i, si in enumerate(S):
    if i % 2 == 0 and si != '1':
        count += 1
    if i % 2 == 1 and si != '0':
        count += 1

print(min(mi, count))

Solution (Python):
s=list(map(int, list(input())))
cnt1=0
cnt2=0
for i in range(len(s)):
    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):
tile = input()

head = tile[0]
tile = tile[1:]
tmp = head

counter = 0

for i in tile:
    if i == tmp and i == "1":
        i = "0"
        tmp = i
        counter += 1
    elif i == tmp and i == "0":
        i = "1"
        tmp = i
        counter += 1
    else:
        tmp = i

print(counter)

Solution (Python):
S=input()

def Diff(S,S2):
    r=0
    for i in range(len(S)):
        if S[i]!=S2[i]:
            r+=1
            
    return r


if len(S)%2==0:
    print(min(Diff(S,"01"*int(len(S)/2)),Diff(S,"10"*int(len(S)/2))))
else:
    print(min(Diff(S,"01"*int(len(S)/2)+"0"),Diff(S,"10"*int(len(S)/2)+"1")))

Solution (Python):
s = str(input())
c1 = 0
c2 = 0
x = 1
def hen(n):
  if n == 1:
    return 0
  else:
    return 1
for i in range(len(s)):
  si = int(s[i])
  if si == x:
    c1 += 1
  else:
    c2 += 1
  x = hen(x)
print(min(c1,c2))

Solution (Python):

"""
Created on Sat Apr 13 20:57:42 2019

@author: Yamazaki Kenichi
"""

S = input()

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

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

p = [S[i] for i in range(0,s) if i%2 == 0]
q = [S[i] for i in range(1,s) if i%2 == 1]

p_1 = p.count('1')
p_0 = len(p)-p_1

q_1 = q.count('1')
q_0 = len(q)-q_1

if p_1 > p_0:
    if q_0 > q_1:
        ans = p_0 + q_1

    else:
        if p_1-p_0 > q_1-q_0:
            ans = p_0+q_1
        else:
            ans = p_1+q_0

else:
    if q_1 > q_0:
        ans = p_1 + q_0

    else:
        if p_0-p_1 > q_0-q_1:
            ans = p_1+q_0
        else:
            ans = p_0+q_1

print(ans)

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

ans_0 = 0
tmp = 0
for i in s:
  if i != tmp:
    ans_0 += 1
  tmp = 1-tmp

ans_1 = 0
tmp = 1
for i in s:
  if i != tmp:
    ans_1 += 1
  tmp = 1-tmp
    
print(min(ans_0,ans_1))

Solution (Python):
str = input()
cnt = 0
num = 0
for i in str:
    if cnt % 2 == 0:
        if i == '0':
            num += 1
    else:
        if i == '1':
            num += 1
    cnt += 1

cnt2 = 0
num2 = 0
for i in str:
    if cnt2 % 2 == 0:
        if i == '1':
            num2 += 1
    else:
        if i == '0':
            num2 += 1
    cnt2 += 1

print(min(num,num2))

Solution (Python):
s = input()

pata = 0

patb = 0
for i, c in enumerate(s):
    val = i%2
    if val == 0:
        if c == "0":
            patb += 1
        if c == "1":
            pata += 1
    if val == 1:
        if c == "1":
            patb += 1
        if c == "0":
            pata += 1

print(min(pata, patb))

Solution (Python):
S = input()

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

Solution (Python):


S = input()

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

Solution (Python):

import sys
INF = float("inf")


def solve(S: str):
    N = len(S)
    ptn1 = [1 if i & 1 else 0 for i in range(N)]
    
    ans1 = 0
    for i, c in enumerate(S):
        if int(c) != ptn1[i]:
            ans1 += 1
    
    ptn2 = [0 if i & 1 else 1 for i in range(N)]
    
    ans2 = 0
    for i, c in enumerate(S):
        if int(c) != ptn2[i]:
            ans2 += 1
    

    print(min(ans1, ans2))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  
    solve(S)


if __name__ == '__main__':
    main()

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

Solution (Python):
hoge=list(input())
hoge_a=[]
hoge_b=[]
for i in range(len(hoge)):
  if(i%2==0):
    hoge_a.append(hoge[i])
  else:
    hoge_b.append(hoge[i])
    
ans=min(len(hoge_a)-hoge_a.count("0")+
        len(hoge_b)-hoge_b.count("1"),
        len(hoge_a)-hoge_a.count("1")+
        len(hoge_b)-hoge_b.count("0"))

print(ans)

Solution (Python):
s = [int(t) for t in list(input())]
n = len(s)
a = sum(s[0::2])
b = sum(s[1::2])

x = ((n+1)//2 - a) + b
y = a + (n//2-b)
print(min(x,y))

Solution (Python):
s = input()
odd = s[0::2]
even = s[1::2]

oddone = odd.count('1')
oddzero = odd.count('0')
evenone = even.count('1')
evenzero = even.count('0')

ans = min(oddone+evenzero, oddzero+evenone)

print(ans)

Solution (Python):
import sys
import numpy as np

reatInt = lambda: int(sys.stdin.readline())
reatIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]


ss = sys.stdin.readline()
e = 0
o = 0
for i, s in enumerate(ss):
    if i % 2 == 0:
        e += int(s == '0')
        o += int(s == '1')
    else:
        e += int(s == '1')
        o += int(s == '0')
ret = min(e, o)
print(ret)

Solution (Python):
S = input()

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

A = odd.count('0') + even.count('1')
B = odd.count('1') + even.count('0')
print(min(A, B))

Solution (Python):
s = input()
c = 0
nums = ["0", "1"]
for i,v in enumerate(s):
  if v == nums[i % 2]:
    c += 1
print(min(c, len(s)-c))

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'
c1=c2=0
for i in range(len(s)):
    if s1[i]!=s[i]:
        c1+=1
    if s2[i]!=s[i]:
        c2+=1
print(min(c1,c2))

Solution (Python):
s = input()
odd = s[1::2]
even = s[0::2]
odd0 = odd.count("0")
odd1 = odd.count("1")
even0 = even.count("0")
even1 = even.count("1")
print(min(odd0+even1, odd1+even0))

Solution (Python):
S = input()

cnt_init_0 = 0
cnt_init_1 = 0

for i, s in enumerate(S):
    if s == "0":
        if i % 2 == 0:
            cnt_init_1 += 1
        else:
            cnt_init_0 += 1
    else:
        if i % 2 == 0:
            cnt_init_0 += 1
        else:
            cnt_init_1 += 1
print(min(cnt_init_0, cnt_init_1))

Solution (Python):

import itertools
import sys
import math
from functools import lru_cache





from queue import Queue
from operator import mul
from functools import reduce
from queue import Queue
from operator import mul
from functools import reduce
from functools import lru_cache

input = sys.stdin.readline














s = input()
l = len(s) - 1
r1 = 0
r2 = 0
for i in range(l):
    if i % 2 == 0:
        if s[i] != '0':
            r1 += 1
        else:
            r2 += 1
    if i % 2 == 1:
        if s[i] != '1':
            r1 += 1
        else:
            r2 += 1
print(min(r1, r2))

Solution (Python):
S = input()
T1 = "01"*int(len(S)/2+1)
T2 = "10"*int(len(S)/2+1)
count1 = 0
count2 = 0
for s,t1,t2 in zip(S,T1,T2):
    if s != t1:
        count1 += 1
    if s != t2:
        count2 += 1
print(min(count1,count2))

Solution (Python):
S = input()

ans = len(S)+1

cnt = 0
for i in range(len(S)):
    if i%2 == 0:
        color = '0'
    else:
        color = '1'
    if S[i] != color:
        cnt += 1
if cnt < ans:
    ans = cnt


cnt = 0
for i in range(len(S)):
    if i%2 == 0:
        color = '1'
    else:
        color = '0'
    if S[i] != color:
        cnt += 1
if cnt < ans:
    ans = cnt

print(ans)

Solution (Python):
S = input()

n = 0
o = 0
for s in S:
    if o == 0:
        if s == '0':
            pass
        else:
            n = n + 1
    else:
        if s == '0':
            n = n + 1
        else:
            pass

    o = 1 - o
n = min(n, len(S) - n)
print(n)

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

s0=''
s1=''
for i in range(n):
    if (i%2==0):
        s0+='0'
        s1+='1'
    else:
        s0+='1'
        s1+='0'

a=0
b=0
for i in range(n):
    if s[i]!=s0[i]:
        a+=1
    if s[i]!=s1[i]:
        b+=1
print(min(a,b))

Solution (Python):
S = input()
length = len(S)
zo = ['0', '1'] * (length//2) + ['0']*(length % 2)
oz = ['1', '0'] * (length//2) + ['1']*(length % 2)
c1 = 0
c2 = 0
for i in range(length):
    if S[i] != zo[i]:
        c1 += 1
    if S[i] != oz[i]:
        c2 += 1
print(min(c1, c2))

Solution (Python):
s=list(input())
n=len(s)
lis1=['0' for i in range(n)]
lis2=['1' for i in range(n)]
for i in range(0,n,2):
    lis1[i]='1'
    lis2[i]='0'
ans1=0
ans2=0
for i in range(n):
    if lis1[i]!=s[i]:
        ans1+=1
    if lis2[i]!=s[i]:
        ans2+=1
print(min(ans1,ans2))

Solution (Python):
s = input()
s1=''
s2=''
for i in range(len(s)//2):
    s1+='01'
    s2+='10'
if len(s)%2==1:
    s1+='0'
    s2+='1'
ans1=0
ans2=0
for i in range(len(s)):
    if s[i]!=s1[i]:
        ans1+=1
    if s[i]!=s2[i]:
        ans2+=1
print(min(ans1,ans2))

Solution (Python):



from itertools import chain
from functools import reduce
from collections import OrderedDict, Counter, deque
import operator

S = input()
N = len(S)

b1 = S[0::2].count('0')
w1 = (N // 2 + (N & 1)) - b1
b2 = S[1::2].count('0')
w2 = (N // 2) - b2

print(min(b1 + w2, w1 + b2))

Solution (Python):
import collections as c
ip = lambda : map(int, input().split())


s = input()
c0 = [0,0]
for n,i in enumerate(s):
    if n%2==0 and i=='0':
        c0[0] += 1
    elif n%2==1 and i=='1':
        c0[1] += 1
    
length = len(s)
print(min([sum(c0),length-sum(c0)]))

Solution (Python):
S = input()
c1, c2 = '0', '1'
n1 = 0
n2 = 0
for s in S:
    n1 += int(s != c1)
    n2 += int(s != c2)
    c1, c2 = c2, c1
print(min(n1, n2))

Solution (Python):




def main():
  tiles = list(map(int, input()))
  color = 0
  count = 0

  for tile in tiles:
    if tile == color:
      count += 1

    color = 1 - color

  if count > len(tiles) // 2:
    count = len(tiles) - count

  print(count)


if __name__ == '__main__':
  main()

Solution (Python):


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

    
    ans1 = 0
    for i in range(0, len(S)):
        if i%2==0 and S[i] == "1":
            ans1 += 1
        elif i%2==1 and S[i] == "0":
            ans1 += 1
    
    
    ans2 = 0
    for i in range(0, len(S)):
        if i%2==0 and S[i] == "0":
            ans2 += 1
        elif i%2==1 and S[i] == "1":
            ans2 += 1

    print(min(ans1, ans2))

if __name__ == "__main__":
    solve()

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

Solution (Python):
tiles = list(input())
before = '-1'
c = 0
for tile in tiles:
	if before != tile:
		before = tile
	else:
		c += 1
		before = '0' if tile == '1' else '1'
print(c)

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

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

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

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

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

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

N = len(S)

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

Solution (Python):
s = input()

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

for i in range(len(s)):
    after = str((i+1) % 2)
    if s[i] != after:
        count2 += 1
print(min(count1,count2))

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

Solution (Python):
S = input()

print(
    min(
        sum(
            s==str(i%2) for i, s in enumerate(S)
        ),
        sum(
            s==str((i+1)%2) for i, s in enumerate(S)
        ),
    )
)

Solution (Python):
def main():
    s = input()
    diff1 = 0
    diff2 = 0
    for i, c in enumerate(s):
        if i % 2 == 0:
            if c == "0":
                diff1 += 1
            else:
                diff2 += 1
        else:
            if c == "1":
                diff1 += 1
            else:
                diff2 += 1
    print(min(diff1, diff2))


if __name__ == "__main__":
    main()

Solution (Python):
def main():
    input = sys.stdin.readline
    try:
        S = input()
        before = S[0]
        cnt = 0
        for s in S[1:]:
            if s == before:
                cnt += 1
                if s == "0":
                    before = "1"
                else:
                    before = "0"
            else:
                before = s
        print(cnt)
        
    finally:
        input = None

import sys; sys.setrecursionlimit(50000)
if __name__ == "__main__":
    main()

Solution (Python):
S=list(input())
le=len(S)
bl=0
for i,c in enumerate(S):
    if i%2==0:
        if c=='1':
            bl+=1
    else:
        if c=='0':
            bl+=1

if bl < le-bl:
    print(bl)
else:
    print(le-bl)

Solution (Python):
import sys

input = sys.stdin.readline
s = input()
cnt1 = 0
cnt2 = 0
flag = '0'
for i in s[:-1]:
    if flag == '0':
        if i == flag:
            flag = '1'
        else:
            cnt1 += 1
            flag = '1'
    else:
        if i == flag:
            flag = '0'
        else:
            cnt1 += 1
            flag = '0'
flag = '1'
for i in s[:-1]:
    if flag == '0':
        if i == flag:
            flag = '1'
        else:
            cnt2 += 1
            flag = '1'
    else:
        if i == flag:
            flag = '0'
        else:
            cnt2 += 1
            flag = '0'
print(min(cnt1,cnt2))

Solution (Python):
S=input()

O=0
E=0

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S = input()

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

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

print(min(ans1, ans2))