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



Sample input:
000


Sample output:
1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = list(input())
ans = len(S)
for i in range(2):
  cnt = 0
  for j in range(ans):
    if j % 2 == 0 and S[j] != str(i): cnt += 1
    if j % 2 == 1 and S[j] == str(i): cnt += 1
  ans = min(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = len(s)
for i in range(2):
  cnt = 0
  for j in range(ans):
    if j % 2 == 0 and s[j] != 0: cnt += 1
    if j % 2 == 1 and s[j] == 0: cnt += 1
  ans = min(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
l = list(s)

count = 0

if int(l[0]) == 0:
    for i in range(1, len(l), 2):
        if int(l[i]) != 0 or int(l[i-1]) != 1 :
            count = count + 1

if int(l[0]) == 1:
    for j in range(1, len(l), 2):
        if int(l[j]) != 1 or int(l[j-1]) != 0 :
            count = count +1

print(count)

Submission status: Wrong Answer

Solution code:
a=input()
b=int(len(a))
c=0
d=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)

Submission status: Wrong Answer

Solution code:
S = input()
checker = '0'
ans = 0
for i in range(len(S)):
  if checker != S[i]:
    ans+=1
  if i%2==0:
    checker = '0'
  else:
    checker = '1'
tmp = ans
ans = 0
checker = '1'
for i in range(len(S)):
  if checker != S[i]:
    ans+=1
  if i%2==0:
    checker = '1'
  else:
    checker = '0'
print(min(ans,tmp))

Submission status: Wrong Answer

Solution code:
S = input()
checker = '0'
ans = 0
for i in range(len(S)):
  if checker != S[i]:
    ans+=1
  if i%2==0:
    checker = '0'
  else:
    checher = '1'
tmp = ans
ans = 0
checker = '1'
for i in range(len(S)):
  if checker != S[i]:
    ans+=1
  if i%2==0:
    checker = '1'
  else:
    checher = '0'
print(min(ans,tmp))

Submission status: Wrong Answer

Solution code:
n = input()
N = len(n)
 
counta = 0
countb = 0
if N%2==0:
  for i in range(0,N-2,2):
    if n[i]=="0":
      counta+=1
    elif n[i]=="1":
      countb+=1
  for i in range(1,N-1,2):
    if n[i]=="1":
      counta+=1
    elif n[i]=="0":
      countb+=1
  print(min(counta,countb))
    
elif N%2==1:
  countc = 0
  countd = 0
  for i in range(0,N-1,2):
    if n[i]=="0":
      countc+=1
    elif n[i]=="1":
      countd+=1
  for i in range(1,N-2,2):
    if n[i]=="1":
      countc+=1
    elif n[i]=="0":
      countd+=1
  print(min(countc,countd))

Submission status: Wrong Answer

Solution code:
n = input()
N = len(n)

counta = 0
countb = 0
if N%2==0:
  for i in range(0,N-2,2):
    if n[i]=="0":
      counta+=1
    elif n[i]=="1":
      countb+=1
  for i in range(1,N-1,2):
    if n[i]=="1":
      counta+=1
    elif n[i]=="0":
      countb+=1
  print(min(counta,countb))
  
countc = 0
countd = 0
if N%2==1:
  for i in range(0,N-1,2):
    if n[i]=="0":
      countc+=1
    elif n[i]=="1":
      countd+=1
  for i in range(1,N-2,2):
    if n[i]=="1":
      countc+=1
    elif n[i]=="0":
      countd+=1
  print(min(countc,countd))

Submission status: Wrong Answer

Solution code:
s = input()
a = 0
b = 0
for i in s:
  if int(s) == 0:
    a += 1
  else:
    b += 1
print(min(a,b))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
s = input()
oi = "01"
io = "10"
oans = 0
ians = 0
for i in range(len(s)//2):
    if s[2*i]+s[2*i+1] != oi:
        if s[2*i] == "0" or s[2*i+1] == "1":
            oans += 1
        else:
            oans += 2
    if s[2*i]+s[2*i+1] != io:
        if s[2*i] == "1" or s[2*i+1] == "0":
            ians += 1
        else:
            ians += 2
print(min(oans, ians))

Submission status: Wrong Answer

Solution code:
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 != i:
            a += 1
        t = 1-t
    ans = a
    t = 0
    for i in s:
        if t != i:
            a += 1
        t = 1-t
    ans = min(a,ans)
    print(ans)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
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()
    ans = 0
    b = s[0]
    for i in s[1:]:
        i = int(i)
        if b == i:
            ans += 1
            b = 1-i
        else:
            b = i
    print(ans)



if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

n = int(len(s)/2)

a = [0]*len(s)
b = [0]*len(s)

for i in range(n):
  a[2*i] = 0
  a[2*i+1] = 1
  b[2*i] = 1
  b[2*i+1] = 0

if len(s)%2 ==1:
  a[len(s)-1] = 0
  b[len(s)-1] = 1 

print(a)
print(b)

an = 0
bn = 0

for j in range(len(s)):
  if a[j] != s[j]:
    an += 1
  if b[j] != s[j]:
    bn += 1

print(min(an, bn))

Submission status: Wrong Answer

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

n = int(len(s)/2)

a = [0]*len(s)
b = [0]*len(s)

for i in range(n):
  a[2*i] = 0
  a[2*i+1] = 1
  b[2*i] = 1
  b[2*i+1] = 0

an = 0
bn = 0

for j in range(len(s)):
  if a[j] != s[j]:
    an += 1
  if b[j] != s[j]:
    bn += 1

print(min(an, bn))

Submission status: Wrong Answer

Solution code:
s = list(input())

n = int(len(s)/2)
c = 0

if len(s) >= 2:
  if s[1] == s[0]:
    c +=1
    if s[0] == 0:
      s[1] = 1
    elif s[0] == 1:
      s[1] = 0

for i in range(n):
  if s[0] != s[2*i]:
    c += 1
  if s[1] != s[2*i+1]:
    c += 1

print(c)

Submission status: Wrong Answer

Solution code:
s = list(input())

n = int(len(s)/2)
c = 0

if len(s) >= 2:
  if s[1] == s[0]:
    c +=1
    if s[0] == 0:
      s[1] = 1
    elif s[0] == 1:
      s[1] = 0

for i in range(n):
  if s[0] != s[2*i]:
    c += 1
  if s[1] != s[2*i+1]:
    c += 1

print(c)

Submission status: Wrong Answer

Solution code:
cnt=0
cnt_2=0
s = str(input())
for i in range(len(s)):
    if s[i]=='0' and i%2==0:
        cnt+=1
    else:
        cnt_2+=1
    if s[i]=='1' and i%2!=0:
        cnt+=1
    else:
        cnt_2+=1
print(min(cnt,cnt_2))

Submission status: Wrong Answer

Solution code:
S = input()

if S[0] == 0:
    head = "0"
    re_head = "1"
else:
    head = "1"
    re_head = "0"

cnt = 0
for i in range(1, len(S)):
    if i % 2 == 1:
        if S[i] != re_head:
            cnt += 1
    elif i % 2 == 0:
        if S[i] != head:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
S = list(input())
f = False
c = 0

for i  in range(len(S) - 1):
    if i == len(S) - 2:
        break
    if S[i] != S[i + 1]:
        continue
    else:
        if S[i] == "0":
            S[i+1] = "1"
            c += 1
        else:
            S[i+1] = "0"
            c += 1

print(c)

Submission status: Wrong Answer

Solution code:
s = input()

sl = [int(s[i]) for i in range(len(s))]
ans1 = [i%2 for i in range(len(s))]
ans2 = [i%2+1 for i in range(len(s))]

diff1, diff2 = 0, 0
for i in range(len(sl)):
    if sl[i] != ans1[i]:
        diff1 += 1
    if sl[i] != ans2[i]:
        diff2 += 1

print(min(diff1, diff2))

Submission status: Wrong Answer

Solution code:
s = str(input())

print(s)
count =0
for xi in range(len(s)):
    if xi%2 ==0:t="0"
    if xi%2 ==1:t="1"

    if s[xi]==t:
        count+=1

# print(count)
print(min(count,len(s)-count))

Submission status: Wrong Answer

Solution code:
s = input()
ss = []
count = 0
for x in range(len(s)):
  ss.append(int(s[x]))
#print(ss)
for x in range(1,len(s)):
  if ss[x-1] == 0:
    ss[x] = 1
    count += 1
  else:
    ss[x] = 0

      
#print(ss)
print(count)

Submission status: Wrong Answer

Solution code:
s = input()
x = 0
y = 0
for i in range(len(s)):
  if i % 2 != int(s[i]):
    x += 1
for j in range(len(s)):
  if i % 2 == int(s[j]):
    y += 1
print(min(x, y))

Submission status: Wrong Answer

Solution code:
s=str(input());
count=0;
t=s.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
t=t.replace("00","01");
t=t.replace("11","10");
for i in range(len(s)):
    if(s[i]!=t[i]):
        count=count+1;



print(count);

Submission status: Wrong Answer

Solution code:
s = input()

ans0 = 0
ans1 = 0
for i, s_i in enumerate(s):
    if i % 2 == 0:
        if s_i == '0':
            ans1 += 1
        else:
            ans0 += 1
    else:
        if s_i == '0':
            ans0 += 1
        else:
            ans1 += 1
print(ans0, ans1)
print(min(ans0, ans1))

Submission status: Wrong Answer

Solution code:
s = input()

ans0 = 0
ans1 = 1
for i, s_i in enumerate(s):
    if i % 2 == 0:
        if s_i == '0':
            ans1 += 1
        else:
            ans0 += 1
    else:
        if s_i == '0':
            ans0 += 1
        else:
            ans1 += 1
print(min(ans0, ans1))

Submission status: Wrong Answer

Solution code:
S = input()
C = ['1', '0']
c = S[0]
cnt = 0
for i in range(1, len(S) - 1):
    if c == S[i]:
        c = C[ord(c) - ord('0')]
        cnt += 1
    else:
        c = S[i]
print(cnt)

Submission status: Wrong Answer

Solution code:

def solve():
    cnt0 = 0
    cnt1 = 0
    if N%2 == 0:
        for i in range(1,N,2):
            if S[i-1] != "0":
                cnt0 += 1
            if S[i] != "1":
                cnt0 += 1
            if S[i-1] != "1":
                cnt1 += 1
            if S[i] != "0":
                cnt1 += 1
        print(i)
    else:
        for i in range(0,N-1,2):
            if S[i] != "0":
                cnt0 += 1
            if S[i+1] != "1":
                cnt0 += 1
            if S[i] != "1":
                cnt1 += 1
            if S[i+1] != "0":
                cnt1 += 1
#    print(cnt0, cnt1)
    print(min(cnt0,cnt1))
        

if __name__ == "__main__":
    S = input()
    N = len(S)
    
    solve()

Submission status: Wrong Answer

Solution code:

def solve():
    cnt0 = 0
    cnt1 = 0
    if N%2 == 0:
        for i in range(1,N,2):
            if S[i-1] != "0":
                cnt0 += 1
            if S[i] != "1":
                cnt0 += 1
            if S[i-1] != "1":
                cnt1 += 1
            if S[i] != "0":
                cnt1 += 1
        print(i)
    else:
        for i in range(0,N-1,2):
            if S[i] != "0":
                cnt0 += 1
            if S[i+1] != "1":
                cnt0 += 1
            if S[i] != "1":
                cnt1 += 1
            if S[i+1] != "0":
                cnt1 += 1
    print(cnt0, cnt1)
    print(min(cnt0,cnt1))
        

if __name__ == "__main__":
    S = input()
    N = len(S)
    
    solve()

Submission status: Wrong Answer

Solution code:

def solve():
    cnt0 = 0
    cnt1 = 0
    for i in range(1,N,2):
        if S[i-1] != "0":
            cnt0 += 1
        if S[i] != "1":
            cnt0 += 1
        if S[i-1] != "1":
            cnt1 += 1
        if S[i] != "0":
            cnt1 += 1
#    print(cnt0, cnt1)
    print(min(cnt0,cnt1))
        

if __name__ == "__main__":
    S = input()
    N = len(S)
    solve()

Submission status: Wrong Answer

Solution code:

def solve():
    cnt0 = 0
    cnt1 = 0
    for i in range(1,N,2):
        if S[i-1] == "0":
            cnt0 += 1
            if S[i] != "1":
                cnt0 += 1
        if S[i-1] != "1":
            cnt1 += 1
            if S[i] != "0":
                cnt1 += 1
#    print(cnt0, cnt1)
    print(min(cnt0,cnt1))
        

if __name__ == "__main__":
    S = input()
    N = len(S)
    solve()

Submission status: Wrong Answer

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

s = s()

cnt0 = 0
cnt1 = 0
for i in range(1,len(s)):
	if i%2 == 0 :
		if s[i] == "0":
			cnt1 += 1
		else:
			cnt0 += 1
	else:
		if s[i] == "1":
			cnt1 += 1
		else:
			cnt0 += 1
print( min(cnt0, cnt1) )

Submission status: Wrong Answer

Solution code:
s = input()
LEN = len(s)
if LEN == 1:
    print(0)
    exit()
    
even = s[::2]
odd = s[1::2]

ew = even.count('1')
eb = LEN//2 - ew
ow = odd.count('1')
ob = (LEN+1)//2 - ow

print(min(eb + ow, ew + ob))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def read():
    S = input().strip()
    return S,


def solve(S):
    N = len(S)
    ans = [0, 0]  # 偶数番目、奇数眼目の1の個数
    for i in range(N):
        if S[i] == "1":
            ans[i % 2] += 1
    
    return min(ans[0]+N//2+N%2-ans[1], N//2-ans[0]+ans[1])


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

s = input()

ans = inf
tmp = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] != '0':
            tmp+=1
    else:
        if s[i] != '1':
            tmp+=1
ans = min(ans, tmp)
for i in range(len(s)):
    if i%2 == 0:
        if s[i] != '1':
            tmp+=1
    else:
        if s[i] != '0':
            tmp+=1
ans = min(ans, tmp)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
i=0
c=0
l=len(s)
while i<l:
 if i<l-2 and len(set(s[i:i+2])):c+=1;i+=2
 elif i<l-1 and len(set(s[i:i+1])):c+=1;i+=1
 i+=1
print(c)

Submission status: Wrong Answer

Solution code:
import collections

s = map(int,list(raw_input()))

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

Submission status: Wrong Answer

Solution code:
S = input()
count_a = 0
count_b = 0
l=len(S)
for i in range(l//2):
  if S[2*i] =='0':
    count_a +=1
  if S[2*i + 1]=='1':
    count_a +=1
  if S[2*i] =='1':
    count_b +=1
  if S[2*i + 1]=='0':
    count_b +=1
if l%2==1:
  if S[l-1] =='0':
    count_a +=1
  if S[l-1] =='1':
    count_a +=1
print(min(count_a, count_b))

Submission status: Wrong Answer

Solution code:
S = input()
count_a = 0
count_b = 0
for i in range(len(S)//2):
  if S[2*i] =='0':
    count_a +=1
  if S[2*i + 1]=='1':
    count_a +=1
  if S[2*i] =='1':
    count_b +=1
  if S[2*i + 1]=='0':
    count_b +=1
print(min(count_a, count_b))

Submission status: Wrong Answer

Solution code:
s=input()
a=[]
for i in range(0,len(s)//2*2,2):
  a.append(s[i:i+2])
a10=a.count('10')
a01=a.count('01')

print(a)

if len(s)%2:
  s1=int(s[-1])
else:s1=-1

if a10>a01:
  if s1==0:
    cnt=len(a)-a10+a01+1
  else:
    cnt=len(a)-a10+a01
elif a01>a10:
  if s1==1:
    cnt=len(a)-a01+a10+1
  else:
    cnt=len(a)-a01+a10
else:
  cnt=len(a)
print(cnt)

Submission status: Wrong Answer

Solution code:
s=input()
a=[]
for i in range(0,len(s),2):
  a.append(s[i:i+2])
a10=a.count('10')
a01=a.count('01')

if len(s)%2:
  s1=int(s[-1])
else:s1=-1

if a10>a01:
  if s1==0:
    cnt=len(a)-a10+a01+1
  else:
    cnt=len(a)-a10+a01
elif a01>a10:
  if s1==1:
    cnt=len(a)-a01+a10+1
  else:
    cnt=len(a)-a01+a10
else:
  cnt=len(a)
print(cnt)

Submission status: Wrong Answer

Solution code:
s=input()
a=[]
for i in range(len(s)//2):
  a.append(s[i:i+2])
a10=a.count('10')
a01=a.count('01')

if len(s)%2:
  s1=int(s[-1])
else:s1=-1

if a10>a01:
  if s1==0:
    cnt=len(a)-a10+a01+1
  else:
    cnt=len(a)-a10+a01
else:
  if s1==1:
    cnt=len(a)-a01+a10+1
  else:
    cnt=len(a)-a01+a10
print(cnt)

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)-1
a = [1]+[0]*n
b = [0]+[1]*n
difA = 0
difB = 0

for i in range(1,n):
    a[i] = 0 if a[i-1] == 1 else 1
    b[i] = 0 if b[i-1] == 1 else 1

for j in range(n+1):
    if a[j] != int(s[j]):
        difA += 1
    if b[j] != int(s[j]):
        difB += 1

ans = min(difA,difB)

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    S = str(input())
    ans = 0
    for i in range(len(S)):
        if (S[0] == '0'):
            if i % 2 == 1 and S[i] == '1':
                ans += 1
            elif i % 2 == 0 and S[i] == '0':
                ans += 1
        else:
            if i % 2 == 1 and S[i] == '1':
                ans += 1
            elif i % 2 == 0 and S[i] == '0':
                ans += 1
    
    if S[0] == '0':
        ans -= 1
    print(ans)
    return

resolve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

def main():
    S = input()
    N = len(S)
    s1 = ""
    s2 = ""
    for i in range(N):
        if i % 2 == 0:
            s1 = s1 + "1"
            s2 = s2 + "0"
        elif i % 2 == 1:
            s1 = s1 + "0"
            s2 = s2 + "1"

    ans = float("inf")
    tmp = 0
    for i, j in zip(S, s1):
        if i != j:
            tmp += 1
    ans = min(ans, tmp)
    tmp = 0
    for i, j in zip(S, s2):
        if i != j:
            tmp += 1
    ans = min(ans, tmp)
    print(tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

def main():
    S = input()
    N = len(S)
    if N == 1:
        print(0)
        exit()
    else:
        ans = 0
        for i in range(N-2):
            if S[i] == S[i+1] and S[i] == "0":
                S = S[:i+1] + "1" + S[i+2:]
                ans += 1
            elif S[i] == S[i+1] and S[i] == "1":
                S = S[:i+1] + "0" + S[i+2:]
                ans += 1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = list(input())

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
ans1,ans2=0,0
for i in range(1,len(s)-1,2):
    if s[i]!="1":
        ans1+=1
    if s[i+1]!="0":
        ans1+=1

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

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
if s[0]=="0":
    for i in range(1,len(s)-1,2):
        if s[i]!="1":
            ans+=1
        if s[i+1]!="0":
            ans+=1
    print(ans)
    exit()
else:
    for i in range(1,len(s)-1,2):
        if s[i]!="0":
            ans+=1
        if s[i+1]!="1":
            ans+=1
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
import collections
s = input()
c1 = s.count("1")
c0 = s.count("0")

print(min(c1,c0))

Submission status: Wrong Answer

Solution code:
def resolve():
    S = list(input())

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

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

    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s1 = list(input())
s2 = s1

n = len(s1)
c = 0
d = 0
for i in range(n-1):
    if s1[i]==s1[i+1]:
        s1[i+1] = abs(1-int(s1[i]))
        c += 1
"""
print("=====================")
for i in range(n-1,0,-1):
    print(s2)
    if s2[i] == s2[i-1]:
        s2[i-1] = abs(1-int(s2[i]))
        d += 1
"""    
print(c)
"""
else:
    print(2,d)
"""

Submission status: Wrong Answer

Solution code:
S = input()
S_int = map(int, S)

if len(S) == 1:
    print(0)
else:
    s = list(S_int)
    def reverse_count(s, initial):
        count = 0
        c = initial
        for i in range(len(s) - 1):
            if s[i] != c:
                count += 1
            c = (c + 1) % 2
        return count
        
    ### 0スタートと1スタートの場合両方で少ない方を出力
    print(min(reverse_count(s, 0), reverse_count(s, 1)))

Submission status: Wrong Answer

Solution code:
import math
s = input()
ls = len(s)
e0 = s[::2].count('0')
e1 = s[::2].count('1')
o0 = s[1::2].count('0')
o1 = s[1::2].count('1')
if s.count('0')>s.count('1'):
    if e0>e1:
        print(e1+o0)
    else:
        print(e0+o1)
else:
    if o0>o1:
        print(o1+e0)
    else:
        print(o0+e1)

Submission status: Wrong Answer

Solution code:
S = list(input())

cnt = 0
a = S[0]

for i in range(1,len(S)):
  if S[i] != a:
    cnt += 1
    if S[i] == "1":
      a = "0"
    else:
      a = "1"
  else:
    a = S[i]
    
print(int(cnt))

Submission status: Wrong Answer

Solution code:
S = '0b' + input()
s1 = '0b' + '10' * (len(S) // 2) + '1' * (len(S) % 2)
s2 = '0b' + '01' * (len(S) // 2) + '0' * (len(S) % 2)
Ss1 = bin(int(S, 2) ^ int(s1, 2))[2:]
Ss2 = bin(int(S, 2) ^ int(s2, 2))[2:]
print(min(sum([1 for x in Ss1 if int(x)]), sum([1 for x in Ss2 if int(x)])))

Submission status: Wrong Answer

Solution code:
S = input()
count1 = [S[i] for i in range(len(S)) if i % 2 == 0]
count2 = [S[i] for i in range(len(S)) if i % 2 != 0]
point = 1 if len(S) % 2 == 0 else 0
print(min(count1.count('0')+count1.count('1')-point, count2.count('0')+count2.count('1')-point))

Submission status: Wrong Answer

Solution code:
# input
S = list(input())

# check
length = len(S)
if len == 1:
    print(0)
else:
    bwb = ["0", "1"]
    wbw = ["1", "0"]
    cnt = [0] * 2
    for i in range(length):
        if S[i] == bwb[i % 2]:
            cnt[0] += 1
        if S[i] == wbw[i % 2]:
            cnt[1] += 1

    print(min([cnt]))

Submission status: Wrong Answer

Solution code:
s = str(input())
n = len(s)
p = [0] * n
if int(s[0]) % 2 == 0:
  for i in range(1, n, 2):
    p[i] = 1
elif int(s[0]) % 2 == 1:
  for i in range(1, n, 2):
    p[i] = 0
q = []
for i in range(n):
  q.append(int(s[i]) ^ int(p[i]))
print(q.count(1))

Submission status: Wrong Answer

Solution code:
import math
import copy

neko = 0
nuko = 0
s = input()
a = ["0","1"]
for i in range(len(s)-1):
    if s[i] == a[i%2]:
        neko += 1
    if s[i] == a[(i+1)%2]:
        nuko += 1
if neko > nuko:
    neko = nuko
print(neko)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

def main():
    S = input()
    l = len(S)
    ws = ''
    bs = ''
    for i in range(l):
        if i%2 == 0:
            ws += '0'
            bs += '1'
        else:
            ws += '1'
            bs += '0'
    wsc = 0
    bsc = 0
    for i in range(l):
        if S[i] != ws[i]:
            wsc += 1
        if S[i] != bs[i]:
            bsc += 1
    print(min(wsc, bsc))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

count = 0
for i in range(N-2):
  if S[i] == S[i+1]:
    if S[i] == "0":
      S[i+1] = '1'
    if S[i] == "1":
      S[i+1] = '0'
    count += 1
      
print(count)

Submission status: Wrong Answer

Solution code:
s = input()

# 1
n = len(s)
case0=0
case1=0

for i in range(n):
  if (i%2==0):
    if s[i]=='0':
      case0 += 1
    else:
      case1 += 1

print(min(case0,case1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s= str(input())
ans = 0
for i in range(len(s)):
    if i // 2 == 0:
        if s[i] == '0':
            ans += 1
    else:
        if s[i] == '1':
            ans += 1
print(min(ans,len(s)-ans))

Submission status: Wrong Answer

Solution code:
s= str(input())
ans = 0
for i in range(len(s)):
    if i // 2 == 0:
        if s[i] == '0':
            ans += 1
    else:
        if s[i] == '1':
            ans += 1
print(min (ans,len(s)-ans))

Submission status: Wrong Answer

Solution code:
s= str(input())
ans = 0
for i in range(len(s)):
    if i // 2 == 0:
        if s[i] == '0':
            ans += 1
    else:
        if s[i] == '1':
            ans += 1
print(min (ans,len(s)-ans))

Submission status: Wrong Answer

Solution code:
s= str(input())
ans = 0
for i in range(len(s)):
    if i // 2 == 0:
        if s[i] == '0':
            ans += 1
        else:
            ans -= 1
    else:
        if s[i] == '1':
            ans += 1
        else:
            ans -= 1
print((len(s)-abs(ans))//2)

Submission status: Wrong Answer

Solution code:
import numpy as np

s_ = int(input())
s = np.array(list(map(int, str(s_))))

a01 = np.tile([0,1], len(s)//2+1)
a10 = np.tile([1,0], len(s)//2+1)

if len(s)%2 != 0:
    a01 = np.delete(a01, len(s))
    a10 = np.delete(a10, len(s))
else:
    a01 = np.delete(a01, [len(s)-1,len(s)])
    a10 = np.delete(a10, [len(s)-1,len(s)])

ans01 = np.abs(s -a01)
ans10 = np.abs(s -a10)

if sum(ans01) >= sum(ans10):
    print(sum(ans10))
else:
    print(sum(ans01))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline
h=input()[:-1]
c=Counter(h)
num=min(c["0"],c["1"])
num1=max(c["0"],c["1"])
print(num if num!=0 else num1//2)

Submission status: Wrong Answer

Solution code:
s=input()
t=s[::2]
u=s[1::2]
a=t.count("0")
b=u.count("0")
if len(s)==1:
  print(0)
if a>=b:
  print(len(t)-a+b)
else:
  print(len(u)-b+a)

Submission status: Wrong Answer

Solution code:
s=input()
t=s[::2]
u=s[1::2]
a=t.count("0")
b=u.count("0")
if a>=b:
  print(len(t)-a+b)
else:
  print(len(u)-b+a)

Submission status: Wrong Answer

Solution code:
s = input()

l = 0
for i in range(0, len(s) - 2, 2):
    if s[i] != '1':
        l += 1
    if s[i + 1] != '0':
        l += 1

r = 0
for i in range(0, len(s) - 2, 2):
    if s[i] != '0':
        r += 1
    if s[i + 1] != '1':
        r += 1

ans = min(l, r)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

l = 0
for i in range(0, len(s) - 2, 2):
    if s[i] != '1':
        l += 1
    if s[i + 1] != '0':
        l += 1

r = 0
for i in range(0, len(s) - 2, 2):
    if s[i] != '1':
        r += 1
    if s[i + 1] != '0':
        r += 1

ans = min(l, r)
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(map(int,input()))
print(s)
n = len(s)
count1 = 0
count2 = 0
if n == 1:
    print(0) 
else:
    for i in range(n):
        if i % 2 == 0 and s[i] != 0:
            count1 += 1
        elif i%2 !=0 and s[i] != 1:
            count1 += 1
    for i in range(n):
        if i % 2 == 0 and s[i] != 1:
            count2 += 1
        elif i%2 !=0 and s[i] != 0:
            count2 += 1
    print(min(count1,count2))

Submission status: Wrong Answer

Solution code:
s = list(map(int,input()))
count1 = 0
count2 = 0
if len(s) == 1:
    print(0) 
else:
    for i in range(len(s)):
        if i % 2 == 0 and s[i] != 0:
            count1 += 1
        elif i%2 !=0 and s[i] != 1:
            count1 += 1
    for i in range(len(s)):
        if i % 2 == 0 and s[i] != 2:
            count2 += 1
        elif i%2 !=0 and s[i] != 0:
            count2 += 1
    print(min(count1,count2))

Submission status: Wrong Answer

Solution code:
s = str(input())
ans1=0
for i in range(len(s)):
  if(i%2==0 and s[i]!=0):ans1+=1
  if(i%2==1 and s[i]!=1):ans1+=1
ans2=0
for i in range(len(s)):
  if(i%2==0 and s[i]!=1):ans2+=1
  if(i%2==1 and s[i]!=0):ans2+=1
ans=min(ans1,ans2)
print(ans)

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)

s1 = [0]*n
s2 = [1]*n
for i in range(1,n,2):
  s1[i] = 1
  s2[i] = 0

count1 = 0
count2 = 0
for i in range(n):
  if s[i]!=s1[i]: count1 += 1
  if s[i]!=s2[i]: count2 += 1
print(min(count1,count2))

Submission status: Wrong Answer

Solution code:
s = input()

z_g = 0
z_k = 0
o_g = 0
o_k = 0

for i in range(len(s)-1):
    if i % 2 == 0:
        if s[i] == "0":
            z_g += 1
        else:
            o_g += 1
    else:
        if s[i] == "0":
            z_k += 1
        else:
            o_k += 1

if (z_g + o_k) > (z_k + o_g):
    print(z_k + o_g)
else:
    print(z_g + o_k)