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):
result1 = 0
S = input()
l = len(S)
for i in range(l):
  if i % 2 == 0:
    if S[i] == "0":
      result1 += 1
  else:
    if S[i] == "1":
      result1 += 1
print(min(result1,l - result1))

Solution (Python):
S = input()
L = [int(i) for i in S]
b = 1
B = 0
for i in L:
  if i != b:
    B += 1
  b = 1 - b
l = len(L)
print(min(B, l - B))

Solution (Python):
S = input()
b = 1
B = 0
l = 0
for i in S:
  if int(i) != b:
    B += 1
  b = 1 - b
  l += 1
print(min(B, l - B))

Solution (Python):
S = input()
b = 1
B = 0
for i in S:
  if i != str(b):
    B += 1
  b = 1 - b
l = len(S)
print(min(B, l - B))

Solution (Python):
S = input()
b = 1
B = 0
for i in S:
  if int(i) != b:
    B += 1
  b = 1 - b
l = len(S)
print(min(B, l - B))

Solution (Python):
S = input()
b = 1
B = 0
for i in S:
  if int(i) != int(b):
    B += 1
  b = not b
l = len(S)
print(min(B, l - B))

Solution (Python):
from collections import Counter
moji = str(input())
guall = len(moji)//2
kiall = guall + len(moji) % 2
gucount=dict(Counter(moji[1::2]))
kicount=dict(Counter(moji[0::2]))
if len(moji) == 1:
    ans = 0
elif max(gucount, key=gucount.get) != max(kicount, key=kicount.get):
    ans = guall - max(gucount.values()) + kiall - max(kicount.values())
else:
    if kiall - max(kicount.values()) > guall - max(gucount.values()):
        ans = max(kicount.values()) + guall - max(gucount.values())
    else:
        ans = max(gucount.values()) + kiall - max(kicount.values())
print(ans)

Solution (Python):
s=input()
s=list(s)
c=0
for i in range(0,len(s),2):
    if s[i]=='0':
        c+=1
for i in range(1,len(s),2):
    if s[i]=='1':
        c+=1
d=0
for i in range(0,len(s),2):
    if s[i]=='1':
        d+=1
for i in range(1,len(s),2):
    if s[i]=='0':
        d+=1
    
print(min(c,d))

Solution (Python):
s = input()
cnt = 0
for i, ss in enumerate(s):
  if ss == str(i % 2):
    cnt += 1
print(min(cnt, len(s) - cnt))

Solution (Python):
S = [int(x) for x in list(input())]
bw = [0, 1]
wb = [1, 0]
ans1 = 0
ans2 = 0
for i in range(len(S)):
  if(S[i]!=bw[i%2]):
    ans1 += 1
  if(S[i]!=wb[i%2]):
    ans2 += 1
print(min(ans1,ans2))

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

diff0 = 0
diff1 = 0

for i in range(n):
    m = int(s[i])
    if i % 2 != m:
        diff0 += 1
    else:
        diff1 += 1
print(min(diff0, diff1))

Solution (Python):
import math


def main():
    
    
    
    
    

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

    print(min(count1, count2))


if __name__ == '__main__':
    main()

Solution (Python):
s = list(str(input()))
cnt = 0

if len(s)>1 and s[0]==s[1]:
    if s[0] == '1':
        s[1] = '0'
    else:
        s[1] = '1'
    cnt += 1

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

print(cnt)

Solution (Python):
s = input()
os = s[1::2]
es = s[::2]
l = os.count('0')+es.count('1')
print(min(l, len(s)-l))

Solution (Python):
N = list(map(int, list(input())))
p1 = 0
p2 = 0
flag = 0
for i in N:
  if i == flag:
    p1 += 1
  else:
    p2 += 1
  flag = 1 - flag
print(min(p1, p2))

Solution (Python):
S = input()

A = [1 if i % 2 == 0 else 0 for i in range(len(S))]
B = [1 if i % 2 != 0 else 0 for i in range(len(S))]

A_cost = 0
B_cost = 0

i = 0

for i in range(len(S)):
    if int(S[i]) != A[i]:
        A_cost += 1
    if int(S[i]) != B[i]:
        B_cost += 1

print(min(A_cost,B_cost))

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

count = 0

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

        if s[i] == '1':
            s[i] = '0'
        else:
            s[i] = '1'

print(count)

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

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

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


L = []
M = []

for i in range(len(S)//2):
    L.append("0")
    L.append("1")
    M.append("1")
    M.append("0")

if (len(S)) % 2 != 0:
    
    L.append("0")
    M.append("1")
    

cn_1 = 0
cn_2 = 0

for i in range(len(S)):
    if S[i] != L[i]:
        cn_1 = cn_1 + 1
    else:
        cn_2 = cn_2 + 1
        
print(min(cn_1, cn_2))

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

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

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

for i in range(len(s)):
    if i % 2 == 0:
        s[i] = bool(s[i])
    else:
        s[i] = not s[i]

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

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

res1 = 0
res2 = 0

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

print(min(res1,res2))

Solution (Python):
S=input()
temp=0

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

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

print(ans)

Solution (Python):

import sys
input=sys.stdin.readline
import numpy as np

def main():
    S = np.array(list(map(int,input().rstrip())))
    L = len(S)
    A = np.arange(L) & 1
    B = 1 - A
    x1 = (A!=S).sum()
    x2 = (B!=S).sum()
    print(min(x1,x2))

if __name__=="__main__":
    main()

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

Solution (Python):
a=input()
b=int(len(a))
c=0
d=0
if b%2==0:
  for i in range(b//2):
    if a[2*i]=="1":
      c=c+1
    if a[2*i+1]=="0":
      c=c+1
  for i in range(b//2):
    if a[2*i]=="0":
      d=d+1
    if a[2*i+1]=="1":
      d=d+1
  if c>d:
    print(d)
  else:
    print(c)
if b%2==1:
  for i in range(b//2):
    if a[2*i]=="1":
      c=c+1
    if a[2*i+1]=="0":
      c=c+1
  if a[-1]=="1":
    c=c+1
  for i in range(b//2):
    if a[2*i]=="0":
      d=d+1
    if a[2*i+1]=="1":
      d=d+1
  if a[-1]=="0":
    d=d+1
  if c>d:
    print(d)
  else:
    print(c)

Solution (Python):
s = input()

t, u = '', ''
for i in range(len(s)):
    t += '1' if i%2 == 0 else '0'
    u += '0' if i%2 == 0 else '1'

s = int(s, 2)
t = int(t, 2)
u = int(u, 2)
print(min(bin(s^t).count('1'), bin(s^u).count('1')))

Solution (Python):
s = str(input())
con = 0
con2 = 0
ans = 0
ans2 = 0
for i in range(len(s)):
  if i % 2 == 0:
    ans += 1
    if s[i] == '0':
      con += 1
  else:
    ans2 += 1
    if s[i] == '1':
      con2 += 1
L = [con + con2, (ans - con) + (ans2 - con2)]
print(min(L))

Solution (Python):
S=list(input())
l=len(S)
s=0
for i in range(l-1):
    if S[i]==S[i+1] and S[i]=='0':
        s+=1
        S[i+1]='1'
    elif S[i]==S[i+1] and S[i]=='1':
        s+=1
        S[i+1]='0'
print(s)

Solution (Python):
s = input()
if len(s) == 1:
    ans = 0
else:
    ans_w = sum([ 1 for i in s[::2] if i != '1']) + sum([ 1 for i in s[1::2] if i != '0'])
    ans_b = sum([ 1 for i in s[::2] if i != '0']) + sum([ 1 for i in s[1::2] if i != '1'])
    ans = min([ans_w, ans_b])
print(ans)

Solution (Python):
import sys
import copy
import math
import itertools
import numpy as np
S = input()

cnt = [0,0]
for i in range(len(S)):
    if i%2==0 and int(S[i]) == 1:
        cnt[0]+=1
    elif i%2 == 1 and int(S[i]) == 0:
        cnt[0]+=1
    
    if i%2==0 and int(S[i]) == 0:
        cnt[1]+=1
    elif i%2 == 1 and int(S[i]) == 1:
        cnt[1]+=1
    
if cnt[0]<=cnt[1]:
    print(cnt[0])
else:
    print(cnt[1])

Solution (Python):
a = list(input())
b = list(reversed(a))
ans_f = 0
ans_r = 0
for i in range(len(a)-1):
  if a[i] == a[i+1]:
    a[i+1] = str(abs(int(a[i]) - 1))
    ans_f += 1
for i in range(len(a)-1):
  if b[i] == b[i+1]:
    b[i+1] = str(abs(int(b[i]) - 1))
    ans_r += 1
print(min(ans_f,ans_r))

Solution (Python):

"""
Created on Fri Sep 11 01:37:10 2020

@author: liang
"""

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

Solution (Python):
S = input()

N = len(S)
O,E = 0,0
for i,s in enumerate(S):
  O +=(i%2)^int(s)
  E +=(i%2)^(not int(s))
print(min(O,E))

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

ans_1 = 0
ct = 0
for i in range(N):
  if int(S[i]) != ct:
    ans_1 += 1
  ct += 1
  ct %= 2
  
ans_2 = 0
ct = 1
for i in range(N):
  if int(S[i]) != ct:
    ans_2 += 1
  ct += 1
  ct %= 2
  
print(min(ans_1, ans_2))

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

s = list(map(int, input().strip()))

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

print(min(ans1, ans2))

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

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

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

Solution (Python):
S = input()

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

Solution (Python):
S = input()
checker = '01'*100001
keep1 = checker[:len(S)]
keep2 = checker[1:len(S)+1]
ans_1 = 0
ans_2 = 0
for i in range(len(S)):
    if S[i] != keep1[i]:
        ans_1 += 1
    else:
        ans_2 += 1
print(min(ans_1, ans_2))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = input()
cnt1 = 0
for i, j in enumerate(s):
    if (i+1)&1:
        if j=='1':
            cnt1 += 1
    else:
        if j=='0':
            cnt1 += 1

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

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

keep = '01' * 100000
keep_1 = keep[:s_length]
keep_2 = keep[1:s_length + 1]


ans_1 = 0
ans_2 = 0
for i in range(s_length):
    if s[i] != keep_1[i]:
        ans_1 += 1
    else:
        ans_2 += 1
print(min(ans_1, ans_2))

Solution (Python):
S=input()
s=[]
total=0
for i in range(len(S)):
    s.append(int(S[i]))
for i in range(0,len(s)-1):
    if s[i]==s[i+1]:
        total+=1
        s[i+1]=abs(1-s[i])
print(total)

Solution (Python):
s=input()
s1 = []
s2 = []
ans1 = 0
ans2 = 0
for i in range(len(s)):
    if i%2 != 0:
        s1.append('0')
    else:
        s1.append('1')
for i in range(len(s)):
    if i%2 == 0:
        s2.append('0')
    else:
        s2.append('1')

for x, y in zip(s, s1):
    if x != y:
        ans1 +=1
for x, y in zip(s, s2):
    if x != y:
        ans2 +=1

print(min(ans1,ans2))

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

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

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

cnt = 0

for i in range(len(S)-1):
    if S[i] == S[i+1] == '0':
        S[i+1] = '1'
        cnt += 1
    elif S[i] == S[i+1] == '1':
        S[i+1] = '0'
        cnt += 1
    else:
        pass

print(cnt)

Solution (Python):
s=input()
o1=0
o0=0
e1=0
e0=0
for i in range(0,len(s),2):
  if s[i]=='1': o1+=1
  else: o0+=1
for i in range(1,len(s),2):
  if s[i]=='1': e1+=1
  else: e0+=1
if o1+e0<o0+e1: print(len(s)-(o0+e1))
else: print(len(s)-(o1+e0))

Solution (Python):
S = list(input())
ans = 0
ans2 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            ans += 1
    else:
        if S[i] == "1":
            ans += 1

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

print(min(ans,ans2))

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


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


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

print(min(cnt1,cnt2))

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7





S = input()
N = len(S)
cnt_wb = 0 
cnt_bw = 0 
for i in range(N):
    if (S[i] == '0') ^ (i % 2 == 0):
        cnt_wb += 1
    else:
        cnt_bw += 1
print(min(cnt_wb, cnt_bw))

Solution (Python):
s = input()

if s[0] == "1":
    ans = 0
    for i in range(len(s)) :
        if i % 2 == 0 and s[i] != "1" :
            ans += 1
        elif i % 2 == 1 and s[i] != "0" :
            ans += 1
else :
    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(ans)

Solution (Python):
def examA():
    A = LI()
    A.sort()
    ans = A[1] + max(A[1]-1,A[0])
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    S = SI()
    N = len(S)
    S12 = ["01"*N, "10"*N]
    ans = inf
    for s in S12:
        cnt = 0
        for i in range(N):
            if s[i]==S[i]:
                continue
            cnt += 1
        ans = min(ans,cnt)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

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

Solution (Python):
def main():
    s = list(input())
    n = len(s)
    cnt0, cnt1 = 0, 0

    for i in range(n):
        if i % 2 == 0 and s[i] != "0":
            cnt0 += 1
        elif i % 2 == 1 and s[i] != "1":
            cnt0 += 1

    for i in range(n):
        if i % 2 == 0 and s[i] != "1":
            cnt1 += 1
        elif i % 2 == 1 and s[i] != "0":
            cnt1 += 1

    print(min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Solution (Python):
s = input()

result = 10 ** 9

tmp = 0
for i, c in enumerate(s):
  if i & 1:
    if c == '0':
      tmp += 1
  else:
    if c == '1':
      tmp += 1
      
result = min(result, tmp)
tmp = 0


for i, c in enumerate(s):
  if i & 1:
    if c == '1':
      tmp += 1
  else:
    if c == '0':
      tmp += 1
      
result = min(result, tmp)
print(result)

Solution (Python):
import copy
S=input()
ListS = list(S)
revListS = copy.deepcopy(ListS)
norm = 0
rev = 0
N = len(ListS)
for i in range(1,N):
  if ListS[i] == ListS[i-1]:
    ListS[i] = str(abs(int(ListS[i])-1))
    norm += 1
  if revListS[N-i-1] == revListS[N-i]:
    revListS[N-i-1] = str(abs(int(revListS[N-i-1])-1))
    rev += 1
res = min(norm,rev)
print(res)

Solution (Python):
s=input()
canw=0
canb=0
for i in range(len(s)):
  if i%2==1:
    if s[i]=='1':
      canw+=1
    else:
      canb+=1
  elif i%2==0:
    if s[i]=='1':
      canb+=1
    else:
      canw+=1

print(min(canb,canw))

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

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

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

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

Solution (Python):
s = input()

start = ['0', '1']
ans = 10**6
for offset in [0,1]:
    now = 0
    for i in range(len(s)):
        j = (i+offset) % 2
        if s[i] != start[j]:
            now += 1
    ans = min(ans, now)

print(ans)

Solution (Python):
s=input()

start_0=0
start_1=0

for i,j in enumerate(s):
  if i%2==0 and j=="1":
    start_0+=1
  elif i%2!=0 and j=="0":
    start_0+=1
  elif i%2==0 and j=="0":
    start_1+=1
  elif i%2!=0 and j=="1":
    start_1+=1
    
print(min(start_0, start_1))

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

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

  else:
    if s[i]=="1":
      cnt+=1

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

Solution (Python):
s=input()
mae=""
cnt=0
for i in range(len(s)):
  if mae==s[i]:
    cnt+=1
    if s[i]=="0":
      mae="1"
    else:
      mae="0"

  else:
    mae=s[i]
    
print(cnt)

Solution (Python):
S = input()

c = 0
l = len(S)

for i in range(l):
    if S[i] == str(i % 2):
        c += 1

print(min(c, l-c))

Solution (Python):
s = input()
x = ""
y = ""
x_con = 0
y_con = 0
for i in range(len(s)):
  if i % 2 == 0:
    x += "0"
    y += "1"
  else:
    x += "1"
    y += "0"

for i in range(len(s)):
  if s[i] != x[i]:
    x_con += 1
  if s[i] != y[i]:
    y_con += 1
  
print(min(x_con, y_con))

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

Solution (Python):
s=input()
ans=[0,0]
for i in range(len(s)):
    now=int(s[i])
    ans[0]+=now^0^(i%2)
    ans[1]+=now^1^(i%2)
print(min(ans))

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

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

if S[0]=="0":
  ans += S[0::2].count("1")
  ans += S[1::2].count("0")
  
else:
  ans += S[0::2].count("0")
  ans += S[1::2].count("1")
  
print(ans)

Solution (Python):
s = [int(x) for x in list(input())]
x = len(s)
y = [0 if i % 2 ==0 else 1 for i in range(x)]
z = [1 if i % 2 ==0 else 0 for i in range(x)]
count1 = 0
count2 = 0
ans1 = list(zip(s,y))
ans2 = list(zip(s,z))
for a in ans1:
  if a[0] != a[1]:
    count1 += 1
for a in ans2:
  if a[0] != a[1]:
    count2 += 1
print(min(count1,count2))

Solution (Python):
S = input()
L = len(S)
c = 0
j = 0
for i in range(L):
  c += abs(j-int(S[i]))
  j ^= 1
print(min(c, L-c))

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

cnt_1 = 0
cnt_2 = 0

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

for j in range(N):
  if j%2 == 0:
    if S[j] == "1":
      cnt_2 += 1
  else:
    if S[j] == "0":
      cnt_2 += 1
      
print(min(cnt_1,cnt_2))

Solution (Python):
S=input()
chars = []
moves1 = 0
moves2 = 0
n = 0
for c in S:
    n += 1
    if c == '0':
        if n % 2 == 0:
            moves1 += 1
        else:
            moves2 += 1
    else:
        if n % 2 == 0:
            moves2 += 1
        else:
            moves1 += 1

print(min(moves1,moves2))

Solution (Python):
s=input()

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

diff_tmp1 = 0
diff_tmp2 = 0
for i in range(len(s)):
  if tmp1[i] != s[i]:
    diff_tmp1 += 1
  elif tmp2[i] != s[i]:
    diff_tmp2 += 1
print(min(diff_tmp1,diff_tmp2))

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

Solution (Python):
str10,str01 = '',''
for i in range(5 * (10**4) + 1):
    str10 += '10'
    str01 += '01'

s = str(input())
len_s = len(s)
str10 = str10[:len_s]
str01 = str01[:len_s]


cnt10,cnt01 = 0,0
for i in range(len_s):
    if s[i]!=str10[i]:
        cnt10 += 1
    if s[i]!=str01[i]:
        cnt01 += 1
print(min(cnt10,cnt01))

Solution (Python):

s=input()
S=len(s)

li_0=[]
for i in s:
    li_0.append(int(i))

li=[0,1]*10**5
li_1=[]
li_2=[]

cnt1=0
cnt2=0

for i in range(S):
    li_1.append(li[i])
    li_2.append(li[i+1])

for i in range(S):
    if li_0[i]==li_1[i]:
        cnt1+=1
    if li_0[i]==li_2[i]:
        cnt2+=1

if cnt1>=cnt2:
    print(S-cnt1)
else:
    print(S-cnt2)

Solution (Python):
s = input()
oi = "01"*(len(s)//2)
io = "10"*(len(s)//2)
if len(s)%2 == 1:
    oi += "0"
    io += "1"

oans = 0
ians = 0
for i in range(len(s)):
    if s[i] != oi[i]:
        oans += 1
    if s[i] != io[i]:
        ians += 1
print(min(oans, ians))

Solution (Python):
s = input()

words = [w for w in s]

cnt = 0
for r in range(len(words) - 1):
    if words[r+1] == words[r]:
        if words[r+1] == '0':
            words[r+1] = '1'
        else:
            words[r+1] = '0'
        cnt += 1

print(cnt)

Solution (Python):
def resolve():
    '''
    code here
    '''
    S = input()

    ans1 = 0
    res1 = 0
    ans2 = 1
    res2 = 0
    for item in S:
        item = int(item)
        if ans1%2 != item:
            res1 += 1
        if ans2%2 != item:
            res2 += 1

        ans1 += 1
        ans2 += 1

    print(min(res2, res1)) 


if __name__ == "__main__":
    resolve()

Solution (Python):
s = input()
n = len(s)
s0 = "01" * (n//2)
s1 = "10" * (n//2)
if n % 2 == 1:
  s0 += "0"
  s1 += "1"

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

Solution (Python):
def main():
    S = list(input().rstrip())
    list1, list2 = [], []
    for i in range(len(S)):
        if i % 2 == 0:
            list1.append('1')
            list2.append('0')
        else:
            list1.append('0')
            list2.append('1')
    v1 = sum([1 for e, s in zip(list1, S) if e != s])
    v2 = sum([1 for e, s in zip(list2, S) if e != s])
    print(min([v1, v2]))


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    count = 0
    for i, c in enumerate(S):
        if i % 2 == int(c):
            count += 1

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


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    ans1 = ans2 = 0
    for i, c in enumerate(S):
        if i % 2 == int(c):
            ans1 += 1
        else:
            ans2 += 1

    print(min(ans1, ans2))
    return


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
n = int(len(s))
ans_1,ans_2 = 0,0

for i in range(n):
    if i % 2 == 0:
        t = "0"
    if i % 2 == 1:
        t = "1"
    if s[i] != t:
        ans_1 += 1

for i in range(n):
    if i % 2 == 0:
        t = "1"
    if i % 2 == 1:
        t = "0"
    if s[i] != t:
        ans_2 += 1

print(min(ans_1,ans_2))

Solution (Python):
S = input().rstrip()
w = 0
b = 0
for i in range(len(S)):
    if i%2==0 and int(S[i])==0:
        w += 1
    elif  i%2==1 and int(S[i])==1:
        w += 1
    elif  i%2==0 and int(S[i])==1:
        b += 1
    elif  i%2==1 and int(S[i])==0:
        b += 1
print(min(w,b))

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

goal = [str(i%2) for i in range(len(S))]    
diff1 = 0 
diff2 = 0 

for i in range(len(S)):
    if S[i] != goal[i]:
        diff1 += 1
    else:
        diff2 += 1
        
print(min(diff1,diff2))

Solution (Python):
S=input()
a1=0
a2=0
p1='1'
p2='0'
for s in S:
  if s!=p1:
    a1+=1
  else:
    a2+=1
  p=p1
  p1=p2
  p2=p
print(min(a1,a2))

Solution (Python):
S = list(input())
p = S.copy()

cnt1 = 0
cnt2 = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        if S[i] == '1':
            S[i] = '0'
        else:
            S[i] = '1'
        cnt1 += 1

for j in range(len(p)-2,-1,-1):
    if p[j] == p[j+1]:
        if p[j] == '1':
            p[j] = '0'
        else:
            p[j] = '1'
        cnt2 += 1

print(min(cnt1,cnt2))

Solution (Python):
S = input().rstrip()
L = len(S)
cnt = 0
for i in range(L):
    if int(S[i]) != i%2:
        cnt += 1
print(min(cnt, L-cnt))

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

if len_s%2==0:
    ans_0=['0','1']*int(len_s/2)
    ans_1=['1', '0']*int(len_s/2)
else:
    ans_0=['0'] + ['1', '0']*int((len_s-1)/2)
    ans_1=['1'] + ['0','1']*int((len_s-1)/2)
    



count_0 =0
for i in range(len_s):
    if ans_0[i] is not s[i]:
        count_0+=1

count_1 =0
for i in range(len_s):
    if ans_1[i] is not s[i]:
        count_1 += 1
print(min(count_0, count_1))

Solution (Python):
s = str(input())
o1 = s[::2].count('1')
e1 = s[1::2].count('0')
x = len(s)-(o1+e1) 
o2 = s[::2].count('0')
e2 = s[1::2].count('1')
y = len(s)-(o2+e2)
print(min(x,y))

Solution (Python):
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
sys.setrecursionlimit(500*500)
import itertools
from collections import Counter,deque

def main():
    s = input().rstrip()
    l = len(s)
    a = 0
    ans = 0

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

if __name__=="__main__":
    main()

Solution (Python):
s = list(input())
now_1 = "0"
cnt_1 = 0
for i in range(len(s)):
    if s[i] != now_1:
        cnt_1 += 1
    if now_1 == "0":
        now_1 = "1"
    else:
        now_1 = "0"
now_2 = "1"
cnt_2 = 0
for i in range(len(s)):
    if s[i] != now_2:
        cnt_2 += 1
    if now_2 == "0":
        now_2 = "1"
    else:
        now_2 = "0"
print(min(cnt_1,cnt_2))

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

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

Solution (Python):

def resolve():
    import sys
    input = sys.stdin.readline
    
    
    s = input().rstrip()

    pattern1 = 0
    pattern2 = 0

    for i, c in enumerate(s):
        if i % 2 == 0:
            if c == "0":
                pattern1 += 1
            else:
                pattern2 += 1
        else:
            if c == "0":
                pattern2 += 1
            else:
                pattern1 += 1

    print(min(pattern1, pattern2))

if __name__ == "__main__":
    resolve()

Solution (Python):


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = input()

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

if count > len(S):
    count = len(S) - count

print(count)

Solution (Python):
s = input()


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


ot = len(s)//2 if len(s)%2==0 else (len(s)+1)//2
et = len(s)//2

ans = min(abs(e0-et)+abs(o1-ot),abs(e1-et)+abs(o0-ot))
print(ans)

Solution (Python):
s = input()
 
start0 = 0
start1 = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] == "0":
      start1 += 1
    elif s[i] == "1":
      start0 += 1
  elif i % 2 == 1:
    if s[i] == "0":
      start0 += 1
    elif s[i] == "1":
      start1 += 1

print(min([start0, start1]))