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)
for i in range(len(S)):
    S[i]=int(S[i])
ans=0
count=0
if len(S)==1:
    ans=0
else:
    for j in range(1,len(S)-1):
        if S[j-1]==S[j]==S[j+1]:
            if S[j]!=0:
                S[j]=0
            else:
                S[j]=1
            count+=1
        elif S[j-1]==S[j] and S[j+1]!=S[j]:
            S[j-1]=S[j+1]
            count+=1
        elif S[j-1]!=S[j] and S[j+1]==S[j]:
            S[j+1]=S[j-1]
            count+=1
ans=count
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
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))]
print(min(bin(~(int(S,2)&int("".join(p1),2))).count("1"),bin(~(int(S,2)&int("".join(p2),2))).count("1")))

Submission status: Wrong Answer

Solution code:
s = input()
lb = 0
lw = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            lb += 1
        else:
            lw += 1
    else:
        if s[i] == '0':
            lw += 1
        else:
            lb += 1
print(max(lb,lw))

Submission status: Wrong Answer

Solution code:
s = input()
lb0 = 0
lb1 = 0
lw0 = 0
lw1 = 0
for i in range(0,len(s)-1,2):
    if s[0] == '0':
        if s[i] == '1':
            lb0 += 1
        if s[i+1] == '0':
            lb0 += 1
        if s[i] == '0':
            lb1 += 1
        if s[i+1] == '1':
            lb1 += 1
    else:
        if s[i] == '1':
            lw0 += 1
        if s[i+1] == '0':
            lw0 += 1
        if s[i] == '0':
            lw1 += 1
        if s[i+1] == '1':
            lw1 += 1
lb = min(lb0,lb1)
lw = min(lw0,lw1)
print(max(lb,lw))

Submission status: Wrong Answer

Solution code:
s = input()
lb = 0
lw = 0
for i in range(0,len(s)-1,2):
    if s[i] == '1':
        lb += 1
    if s[i+1] == '0':
        lb += 1
    if s[i] == '0':
        lw += 1
    if s[i+1] == '1':
        lw += 1
if len(s) % 2 != 0:
    if s[0] == '1' and s[-1] == '1':
        lb += 1
    if s[0] == '0' and s[-1] == '0':
        lw += 1
print(min(lb,lw))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
lb0 = 0
lb1 = 0
lw0 = 0
lw1 = 0
for i in range(0,len(s)-1,2):
    if s[0] == '0':
        if s[i] == '1':
            lb0 += 1
        if s[i+1] == '0':
            lb0 += 1
        if s[i] == '0':
            lb1 += 1
        if s[i+1] == '1':
            lb1 += 1
    else:
        if s[i] == '1':
            lw0 += 1
        if s[i+1] == '0':
            lw0 += 1
        if s[i] == '0':
            lw1 += 1
        if s[i+1] == '1':
            lw1 += 1
ans1 = max(lb0,lw0)
ans2 = max(lb1,lw1)
print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
S = input()

import math

even_s=[]
odd_s=[]

for i in range(len(S)):
        if i%2 == 0:
                even_s.append(int(S[i]))
        else:
                odd_s.append(int(S[i]))

e_num = sum(even_s)
o_num = sum(odd_s)

res = int(math.ceil(len(S)/2)) - max(e_num,o_num) + min(e_num,o_num)


print(res)

Submission status: Wrong Answer

Solution code:
S = input()


even_s=[]
odd_s=[]

for i in range(len(S)):
        if i%2 == 0:
                even_s.append(int(S[i]))
        else:
                odd_s.append(int(S[i]))

e_num = sum(even_s)
o_num = sum(odd_s)


res = int(len(S)/2) - max(e_num,o_num) + min(e_num,o_num)

print(res)

Submission status: Wrong Answer

Solution code:
s = list(map(int,input()))
s_r = []
n = len(s)
for i in range(n):
  s_r.append(s[i])
  
ans_l = 0
for i in range(n-1):
  if s[i] == s[i+1]:
    ans_l += 1
    if s[i] == 0:
      s[i+1] = 1
    else:
      s[i] = 0
    
ans_r = 0
for i in range(1, n-1):
  if s_r[n-i] == s_r[n-i-1]:
    ans_r += 1
    if s_r[n-i-1] == 0:
      s_r[n-i] = 1
    else:
      s_r[n-i] = 0
      
print(min(ans_l, ans_r))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S = list(input())
ans = 0
tmp = S[0]
for i in range(0,len(S)-1,2):
    if tmp != S[i]:
        ans += 1
        S[i] = tmp
    if S[i] == S[i+1]:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s = [int(i) for i in s]
head1_count = 1
head0_count = 0
error1 = 0
error0 = 0
for count,number in enumerate(s):
    if count%2==0:
        if number == 0:
            error1 += 1
        if number == 1:
            error1 += 1
    else:
        if number == 1:
            error1 += 1
        if number == 0:
            error0 += 1
if error1 == error0:
    print(0)
else:
    print(min(error0,error1))

Submission status: Wrong Answer

Solution code:
s = input()
l = [int(i) for i in s[0::2]]
r = [int(i) for i in s[1::2]]
print(l)
print(r)
if len(s) == 1:
    print(0)
else:
    l_count1 = l.count(1)
    l_count0 = len(l)-l_count1
    r_count1 = r.count(1)
    r_count0 = len(r)-r_count1
    l_1 = l_count0+r_count1
    l_0 = l_count1+r_count0
    if (l_count1==len(l) and r_count0==len(r)) or (l_count0==len(l) and r_count1==len(r)):
        print(0)
    elif l_1 < l_0:
        print(l_1)
    else:
        print(l_0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=str(input())
cnt1=0
cnt2=0
for i in range(len(s)):
    if i%2==0:
        if s[i]=="0":
            cnt1+=1
            print(s[i])
        else:
            continue
    if i%2!=0:
        if s[i]==1:
            cnt1+=1
        else:
            continue
            
        #10101010101がお好み


for i in range(len(s)):
    if i%2!=0:
        if s[i]=="0":
            cnt2+=1
        else:
            continue
    if i%2==0:
        if s[i]=="1":
            cnt2+=1
        else:
            continue
            #01010101010がお好み
print(min(cnt1,cnt2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
tile=[0 if i&1==0 else 1 for i in range(N)]
ans=0
for i in range(N):
  if S[i]!=tile[i]:
    ans+=1
print(ans if ans<= N//2 else N-ans)

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
S=input()

a=[S[::2].count(l) for l in "01"]
b=[S[1:][::2].count(k) for k in "01"]

print(a,b)
print(min(a[0]+b[1],a[1]+b[0]))

Submission status: Wrong Answer

Solution code:
def test():
    s = list(map(int,list(input())))
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            s[i+1] ^= 1
    print(s) 


if __name__ == "__main__":
    test()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

# 先頭を0, 1 で二回走査すればいい？
ans = 0

count = 0
before = 0
for i in range(1, len(S)):
    if S[i] == before:
        count += 1
    before ^= 1

ans = count

count = 0
before = 1
for i in range(1, len(S)):
    if S[i] == before:
        count += 1
    before ^= 1

ans = min(ans, count)

print(ans)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

# 先頭を0, 1 で二回走査すればいい？
ans = 0

count = 0
before = 0
for i in range(1, len(S)):
    if S[i] == before:
        count += 1
    before ^= 1

ans = count

count = 0
before = 1
for i in range(1, len(S)):
    if S[i] == before:
        count += 1
    before ^= 1

ans = min(ans, count)

print(count)

Submission status: Wrong Answer

Solution code:
#C - Coloring Colorfully(ABC124)
S=input()
c=S[::2].count("0")
if c>len(S)/2:
    a="0"
    b="1"
else:
    a="1"
    b="0"

if len(S)%2==1:
    S+=b
ans=0
for i,n in zip(S[::2],S[1::2]):
    if i!=a:
        ans+=1
    if n!=b:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
#C - Coloring Colorfully(ABC124)
S=input()
c=S[::2].count("0")
if c>len(S)/2:
    a="0"
    b="1"
else:
    a="1"
    b="0"

if len(S)%2==1:
    S+=b

ans=0
print(a,b)
for i,n in zip(S[::2],S[1::2]):
    print(i,n)
    if i!=a:
        ans+=1
    if n!=b:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
#C - Coloring Colorfully(ABC124)
S=input()
c=S[::2].count("0")
if c>len(S)/2:
    a="0"
    b="1"
else:
    a="1"
    b="0"
ans=0
for i,n in zip(S[::2],S[1::2]):
    if i!=a:
        ans+=1
    if n!=b:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
S=int(input())
Sstr=str(S)
s=len(Sstr)
Sk=[]
Sg=[]
for i in range(0,s,2):
    Sk.append(Sstr[i])
for i in range(1,s,2):
    Sg.append(Sstr[i])
Sk0=Sk.count('0')
Sk1=Sk.count('1')
Sg0=Sg.count('0')
Sg1=Sg.count('1')
Stotal=[Sk0,Sk1,Sg0,Sg1]
if Sk0+Sg1<Sk1+Sg0:
    print(Sk0+Sg1)
else:
    print(Sk1+Sg0)

Submission status: Wrong Answer

Solution code:
S=int(input())
Sstr=str(S)
s=len(Sstr)
Sk=[]
Sg=[]
for i in range(0,s,2):
    Sk.append(Sstr[i])
for i in range(1,s,2):
    Sg.append(Sstr[i])
Sk0=Sk.count('0')
Sk1=Sk.count('1')
Sg0=Sg.count('0')
Sg1=Sg.count('1')
Stotal=[Sk0,Sk1,Sg0,Sg1]
if min(Stotal)==Sk0 or min(Stotal)==Sg1:
    print(Sk0+Sg1)
else:
    print(Sk1+Sg0)

Submission status: Wrong Answer

Solution code:
S=int(input())
Sstr=str(S)
s=len(Sstr)
Sk=[]
Sg=[]
for i in range(0,s,2):
    Sk.append(Sstr[i])
for i in range(1,s,2):
    Sg.append(Sstr[i])
Sk0=Sk.count('0')
Sk1=Sk.count('1')
Sg0=Sg.count('0')
Sg1=Sg.count('1')
Stotal=[Sk0,Sk1,Sg0,Sg1]
if max(Stotal)==Sk0 or max(Stotal)==Sg1:
    print(Sk1+Sg0)
else:
    print(Sk0+Sg1)

Submission status: Wrong Answer

Solution code:
s = list(int(x) for x in input())
n = len(s)
ans = []
#s[0]固定
count = 0
for i in range(2, n):
  if s[0] == s[1]:
    count += 1
  if i%2 == 0 and s[i] != s[0]:
    count += 1
  elif i%2 == 1 and s[i] == s[0]:
    count += 1
ans.append(count)
#s[0]変更
count = 1
for i in range(2, n):
  if s[0] != s[1]:
    count += 1
  if i%2 == 0 and s[i] == s[0]:
    count += 1
  elif i%2 == 1 and s[i] != s[0]:
    count += 1
ans.append(count)

if len(s) == 1:
  print(0)
elif len(s) == 2:
  if s[0] == s[1]:
    print(1)
  else:
    print(0)
else:
  print(min(ans))

Submission status: Wrong Answer

Solution code:
s = list(int(x) for x in input())
n = len(s)
ans = []
#s[0]固定
count = 0
for i in range(2, n):
  if s[0] == s[1]:
    count += 1
  if i%2 == 0 and s[i] != s[0]:
    count += 1
  elif i%2 == 1 and s[i] == s[0]:
    count += 1
ans.append(count)
#s[0]変更
count = 1
for i in range(2, n):
  if s[0] != s[1]:
    count += 1
  if i%2 == 0 and s[i] == s[0]:
    count += 1
  elif i%2 == 1 and s[i] != s[0]:
    count += 1
ans.append(count)
print(min(ans))

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0

s = []

if S == "0":
    print(0)
    exit()

i = 0
while len(S) != len(s):
    s.append(S[i])
    if s[i] == "0" and s[i-1] == "0":
        ans += 1
        s[i] = "1"
    elif s[i] == "1" and s[i-1] == "1":
        ans += 1
        s[i] = "0"
    else:
        i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
ans = 0
S = input()

ans += S.count("00")
ans += S.count("10010")
ans += S.count("11")
ans += S.count("01101")
ans += S.count("00100")
ans += S.count("11011")
print(ans)

Submission status: Wrong Answer

Solution code:
ans = 0
S = input()

ans += S.count("00")
ans += S.count("10010")
ans += S.count("11")
ans += S.count("01101")
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
even_0 = S[1::2].count('0')
odd_0 = S[::2].count('0')
if N % 2 == 0:
    if even_0 > odd_0:
        print(int(odd_0 + (N / 2) - even_0))
    else:
        print(int(even_0 + N / 2 - odd_0))
else:
    if even_0 > odd_0:
        print(int(odd_0 + (N // 2) - even_0))
    else:
        print(int(even_0 + N // 2 + 1 - odd_0))

Submission status: Wrong Answer

Solution code:
import copy

S = list(map(int, list(input()))) # str型だと書き換えの方法がスライスしかなくて面倒
N = len(S)
#print(S)
T = copy.copy(S)

ans1 = 0
ans2 = 0

for i in range(N-1):
    if S[i] == S[i+1]:
        S[i+1] = 1 ^ S[i+1]
        ans1 += 1
        #print(S)

T[0] = 1 ^ T[0]
for i in range(N-1):
    if T[i] == T[i+1]:
        T[i+1] = 1 ^ T[i+1]
        ans2 += 1
        #print(T)

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

Submission status: Wrong Answer

Solution code:
S = input()

As = []
Bs = []
count = 0
a = False
for i in range(len(S) - 1):
    count += 1
    if S[i] == S[i+1]:
        if a:
            As.append(count)
        else:
            Bs.append(count)
        a = not a
        count = 0
if a:
  As.append(count)
else:
  Bs.append(count)

ans = sum(As) if sum(As) < sum(Bs) else sum(Bs)

print(ans)

Submission status: Wrong Answer

Solution code:
a = input("")
b = list(a)
j = 0;
k = 0;
for m in b:
    if int(m) == 0 or int(m) == 1:
        k = k+1;
if k == len(b):
    if (int(b[0])==1 or int(b[0])==0) and len(b) == 1:
        print(0)
    else:
        for i in range(len(b)-1):
            if(b[i]==b[i+1]):
                if int(b[i]) == 0:
                    b[i+1] = "1"
                else:
                    b[i+1] = "0"
                j = j + 1;
            
print(j)

Submission status: Wrong Answer

Solution code:
a = input("")
b = list(a)
j = 0;
if (int(b[0])==1 or int(b[0])==0) and len(b) == 1:
    print(0)
else:
    for i in range(len(b)-1):
        if(b[i]==b[i+1]):
            if int(b[i]) == 0:
                b[i+1] = "1"
            else:
                b[i+1] = "0"
            j = j + 1;
            
print(j)

Submission status: Wrong Answer

Solution code:
x=input()
x=[i for i in x]
n=len(x)
y=['1']
a=0
b=0
for i in range(n-1):
    if i%2==0:
        y.append('0')
    else:
        y.append('1')
z=['0']
for i in range(n-1):
    if i%2==0:
        z.append('1')
    else:
        z.append('0')
for i in range(n):
    if x[i]!=y[i]:
        a+=1
    if x[i]!=z[i]:
        b+=a
print(min(a,b))

Submission status: Wrong Answer

Solution code:
N = input()
S = [int(c) for c in N]

A = [0] * len(S)
B = [0] * len(S)

for i in range(len(S)//2):
  A[i*2+1] = 1
  B[i*2] = 1
  
  
ca =0
cb =0
for i in range(len(S)):
  ca += abs(S[i]-A[i])
  cb += abs(S[i]-B[i])
print(min(ca, cb))

Submission status: Wrong Answer

Solution code:
s=input()

BW=s[::2]
WB=s[1::2]

x=BW.count("0") + WB.count("1")
y=BW.count("0") + WB.count("1")

print(min(x,y))

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
ans = 0
if n <= 2:
    if n == 2:
        if s[0] == s[1]:
            ans += 1
else:
    for i in range(1,n-1):
        if s[i] == s[i+1] and s[i] == s[i-1]:
            if s[i] == "1":
                s[i] = "0"
            elif s[i] == "0":
                s[i] = "1"
            ans += 1
        elif s[i-1] == s[i]:
            ans += 1
        elif s[i-1] == s[i+1]:
            continue
        else:
            if s[i+1] == "1":
                s[i+1] = "0"
            elif s[i+1] == "0":
                s[i+1] = "1"
            ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
m = 0
l = 0

for i in range(n//2):
    if s[2*i] == '1':
        m += 1
    else:
        l += 1
for i in range(n//2):
    if s[2*i+1] == '0':
        m += 1
    else:
        l += 1

if l>m:
    print(m)
else:
    print(l)

Submission status: Wrong Answer

Solution code:
def MAP(): return map(int,input().split())
import collections
s = input()
even = collections.defaultdict(int)
odd =  collections.defaultdict(int)
n, m =0, 0
for i,v in enumerate(s):
    if i%2==0:
        even[v]+=1
        n+=1
    else:
        odd[v]+=1
        m+=1

if even["0"] > even["1"]:
    even_symbol = "0"
else:
    even_symbol = "1"
if odd["0"] > odd["1"]:
    odd_symbol = "0"
else:
    odd_symbol = "1"

if even[even_symbol]==odd[odd_symbol]:
    print((even[even_symbol]) + (m-odd[odd_symbol]))
elif even[even_symbol]>odd[odd_symbol]:
    print((n-even[even_symbol]) + (odd[odd_symbol]))
else:
    print((even[even_symbol]) + (m-odd[odd_symbol]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  s = input()
  if len(s) == 1:
    return 0

  if len(s) == 2:
    if s[0] == s[1]:
      return 1
    else:
      return 0

  t = list(map(int, s[:]))
  result = 0
  if t[0] == t[1]:
    if t[1] == t[2]:
      t[1] ^= 1
    else:
      t[0] ^= 1
    result += 1
  for i in range(2, len(s)):
    if t[i] == t[i - 1]:
      t[i] ^= 1
      result += 1
  return result

print(main())

Submission status: Wrong Answer

Solution code:
S = input()
odd0 = 0
odd = 0
even0 = 0
even = 0
for i in range(len(S)):
    if i%2==0:
        even += 1
        if S[i] == "0":
            even0 += 1
    if i%2==1:
        odd += 1
        if S[i] == "0":
            odd0 += 1
if odd0 > even0:
    print(odd - odd0 + even0)
else:
    print(even - even0 + odd0)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
if n == 1:
  print(0)
  exit()

cnt_e = 0
cnt_o = 0
for i in range(0,n,2):
  if s[i] == '1':
    cnt_e += 1
for i in range(1,n,2):
  if s[i] == '1':
    cnt_o += 1
print(min((n+1)//2 - cnt_o + cnt_e, n//2 - cnt_e + cnt_o))

Submission status: Wrong Answer

Solution code:
def main(s):
    pattern1 = ["0" if i % 2 == 0 else "1" for i in range(len(s))]
    pattern2 = ["1" if i % 2 == 0 else "0" for i in range(len(s))]
    dist1 = 0
    dist2 = 0
    for i in range(len(s)):
        if s[i] != pattern1[i]:
            dist1 += 1
        if s[i] != pattern2[i]:
            dist2 += 1

    return min(dist1, dist2)

Submission status: Wrong Answer

Solution code:
def main(s):
    count = 0
    before = "X"
    for i, char in enumerate(s):
        if i == 0:
            continue
        if char == before:
            count += 1
            before = "1" if char == "0" else "0"
        else:
            before = char
    return count


s = input()
# s = "000"  # 1
# s = "10010010"  # 3
# s = "0"  # 0
print(main(s))

Submission status: Wrong Answer

Solution code:
s=input()

a=int(s)

print(a)

Submission status: Wrong Answer

Solution code:
S = list(map(int, input().split()))

l = len(S)
c1 = 0 
c2 = 0

for i in range(l):
  if i%2 ==0:
    if S[i] == 0:
      c1 += 1
    else:
      c2 += 1
  else:
    if S[i] == 0:
      c2 += 1
    else:
      c1 += 1
    
print(min(c1,c2))

Submission status: Wrong Answer

Solution code:
S = list(map(int, input().split()))

l = len(S)
c1 = 0 
c2 = 0

for i in range(l):
  if i%2 ==0:
    if S[i] == 0:
      c1 += 1
  else:
    if S[i] == 0:
      c2 += 1
    
print(min(c1,c2))

Submission status: Wrong Answer

Solution code:
S = list(map(int, input().split()))

l = len(S)
c1 = 0 
c2 = 0

for i in range(l):
  if i%2 ==0:
    if S[i] == 0:
      c1 += 1
  else:
    if S[i] == 0:
      c2 += 1
    
print(max(c1,c2))

Submission status: Wrong Answer

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

count_even = 0
count_odd = 0

for i in range(len(s)):
    if i % 2 == 0 and s[i] == 1:
        count_even += 1
    if i % 2 == 1 and s[i] == 1:
        count_odd += 1

if len(s) % 2 == 0:
    ans = (int(len(s)/2) - max(count_even, count_odd)) + min(count_even, count_odd)
else:
    if count_even >= (len(s)+1)/2:
        ans = (int(len(s)/2) - count_even) + count_odd
    else:
        ans = count_even + (len(s)-1)/2 - count_odd

print(int(ans))

Submission status: Wrong Answer

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

count_even = 0
count_odd = 0

for i in range(len(s)):
    if i % 2 == 0 and s[i] == 1:
        count_even += 1
    if i % 2 == 1 and s[i] == 1:
        count_odd += 1

if len(s) % 2 == 0:
    ans = (int(len(s)/2) - max(count_even, count_odd)) + min(count_even, count_odd)
else:
    if count_even <= (len(s)+1)/2:
        ans = (int(len(s)/2) - count_even) + count_odd
    else:
        ans = count_even + (len(s)-1)/2 - count_odd

print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    S = input()
    s1 = S[::2]
    s2 = S[1::2]
    print()
    print(s1)
    print(s2)
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
    print("1")

resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    S = input()
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
print("1")

resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    S = input()
    print()
    print(S)
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue
    for i in range(len(S)):
        continue


resolve()

Submission status: Wrong Answer

Solution code:
S = input()
S = [int(i) for i in list(S)]

a = []
b = True
for i in range(len(S)):
    if b:
        a.append(1)
        b=False
    else:
        a.append(0)
        b=True
c = a[::-1]

combined1 = [abs(x-y) for (x, y) in zip(S, a)]
combined2 = [abs(x-y) for (x, y) in zip(S, c)]

if len(S)==1:
    print(0)
else:
    print(min(sum(combined1), sum(combined2)))

Submission status: Wrong Answer

Solution code:
S = int(input())
S = [int(i) for i in list(str(S))]

a = []
b = True
for i in range(len(S)):
    if b:
        a.append(1)
        b=False
    else:
        a.append(0)
        b=True
c = a[::-1]

combined1 = [abs(x-y) for (x, y) in zip(S, a)]
combined2 = [abs(x-y) for (x, y) in zip(S, c)]

if len(S)==1:
    print(0)
else:
    print(min(sum(combined1), sum(combined2)))

Submission status: Wrong Answer

Solution code:
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
elif len(s)%2:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
else:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Submission status: Wrong Answer

Solution code:
S = input().rstrip()
l = len(S)

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

cnt10 = 0
cnt01 = 0

for i in range(1, l):
    if i % 2:
        # odd
        if S[i] == '1':
            cnt10 += 1
        else:
            cnt01 += 1
    else:
        # even
        if S[i] == '0':
            cnt10 += 1
        else:
            cnt01 += 1

print(min(cnt01, cnt10))

Submission status: Wrong Answer

Solution code:
s = input()
for i in range(1,len(s)):
    if s[i-1] == "0" and s[i] == s[i-1]:
        s = s[:i] + "1" + s[i+1:]
    elif s[i-1] == "1" and s[i] == s[i-1]:
        s = s[:i] + "0" + s[i+1:]
print(s)

Submission status: Wrong Answer

Solution code:
s=list(map(int,str(input())))
print(s)
n=len(s)
a=0
b=0
for i in range(n):
  if ((i%2)+s[i])%2==0:
    a+=1
  else:
    b+=1
print(n-max(a,b))

Submission status: Wrong Answer

Solution code:
org = input()
s = []

for i in range(len(org)):
    s.append(org[i])

def isSolved(s):
    temp = s[0]
    for i in range(1, len(s)):
        if temp == s[i]:
            return False
        temp = s[i]

    return True

def convert(org, i):
    s = list(org)
    count = 1
    if s[i] == '0':
        s[i] = '1'
    else:
        s[i] = '0'

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

    if isSolved(s):
        return count
    else:
        return 1000000

minV = 1000000

if isSolved(s):
    print(0)
else:
    for i in range(len(s)):
        minV = min(minV, convert(s, i))

print(minV)
#print(s)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

s = input()

ans1 = ans2 = 0
for i,c in enumerate(s):
    if str(i&2) == c:
        ans1 += 1
    else:
        ans2 += 1

print(min(ans1,ans2))

Submission status: Wrong Answer

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

aim = 1

for _ in range(int(N/2)):
    aim <<= 2
    aim |= 0b10
if N % 2 == 1 and N != 0:
    aim <<= 1
    aim |= 0b1

S = int(S, 2)
mask = "1" * (N)
mask = int(mask, 2)
aim = aim & mask

differences = bin(S ^ aim)
Num1 = differences.count("1")
Num0 = differences.count("0") - 1

print(min(Num1, Num0))

Submission status: Wrong Answer

Solution code:
s="0b"+input()
a=int("0b"+"10"*(len(s)//2-1)+"0"*(len(s)%2==1),0)
s=int(s,0)
c=lambda x:str(bin(x)).count("1")
print(min(c(s^a),c(s^(-~a))))

Submission status: Wrong Answer

Solution code:
#124

S = str(input())

N = len(S)
count = 0

if S[0] == '0':
    for j in range (1,N):
        if j % 2 == 0 and S[j] == '1 ':
           count += 1
        elif j % 2 == 1 and S[j] == '0':
           count += 1

elif S[0] == '1':
    for j in range (1,N):
        if j % 2 == 0 and S[j] == '0' :
            count += 1
        elif j % 2 == 1 and S[j] == '1':
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
zero = ""
one = ""
for i in range(n):
  if i%2 == 0:
    zero += "0"
    one += "1"
  else:
    zero += "1"
    one += "0"
z = 0
o = 0
for i in range(n):
  tmp = s[i]
  if tmp != zero[i]:
    z += 1
  if tmp != one[i]:
    o += 1
if z < o:
  print(z)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
S = int(S, 2)
a = sum([2 ** i for i in range(0, n, 2)])
b = a << 1

an = bin(a ^ S).count("1")
bn = bin(b ^ S).count("1")
print(min(an, bn))

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
S = int(S)
a = sum([2 ** i for i in range(0, n, 2)])
b = sum([2 ** i for i in range(1, n, 2)])

an = bin(a ^ S).count("1")
bn = bin(b ^ S).count("1")
print(min(an, bn))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

s = input()
odd = [int(s[i]) for i in range(len(s)) if i % 2]
even = [int(s[i]) for i in range(len(s)) if not i % 2]

odd_c = Counter(odd)
freq_odd = odd_c.most_common()
even_c = Counter(even)
freq_even = even_c.most_common()

if len(odd) == 0 or len(even)== 0:
  count = 0
elif len(freq_odd) == 1 or len(freq_even) == 1:
  if len(freq_odd) == len(freq_even):
    if freq_odd[0][0] == freq_even[0][0]:
      count = len(freq_odd)
    else:
      count = 0
      
  elif len(freq_odd) > len(freq_even):
    if freq_even[0][0] == 0:
      count = freq_odd[1][1]
    else:
      count = freq_odd[0][1]
  else:
    if freq_odd[0][0] == 0:
      count = freq_even[1][1]
    else:
      count = freq_even[0][1]
# 奇数番目、偶数番目ごとに０の出現回数を比較 => 少ないほうをすべて１に変換すれば交互に０１並ぶ
elif freq_odd[0][1] >= freq_even[0][1]:
  count = freq_even[0][1] + freq_odd[1][1]
else:
  count = freq_odd[0][1] + freq_even[1][1]

print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter

s = input()
odd = [int(s[i]) for i in range(len(s)) if i % 2]
even = [int(s[i]) for i in range(len(s)) if not i % 2]

odd_c = Counter(odd)
freq_odd = odd_c.most_common()
even_c = Counter(even)
freq_even = even_c.most_common()

if len(odd) == 0 or len(even)== 0:
  count = 0
elif len(freq_odd) == 1 or len(freq_even) == 1:
  if len(freq_odd) == len(freq_even):
    count = len(s) // 2
  elif len(freq_odd) > len(freq_even):
    if freq_even[0][0] == 0:
      count = freq_odd[1][1]
    else:
      count = freq_odd[0][1]
  else:
    if freq_odd[0][0] == 0:
      count = freq_even[1][1]
    else:
      count = freq_even[0][1]
# 奇数番目、偶数番目ごとに０の出現回数を比較 => 少ないほうをすべて１に変換すれば交互に０１並ぶ
elif freq_odd[0][1] >= freq_even[0][1]:
  count = freq_even[0][1] + freq_odd[1][1]
else:
  count = freq_odd[0][1] + freq_even[1][1]

print(count)

Submission status: Wrong Answer

Solution code:
s = list(input())

count_1  = 0
count_2 = 0

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

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

print(min(count_1, count_2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from itertools import repeat
S = input()
N = len(S)
if N<2:
    print('0')
else:
    a = int(S, 2)
    r = "10"*(N//2+1)
    s1 = int(r[0:], 2)
    s2 = int(r[1:], 2)
    print(min(bin(s1^a).count("1"), bin(s2^a).count("1")))

Submission status: Wrong Answer

Solution code:
from itertools import repeat
S = input()
N = len(S)
if N<2:
    print('0')
else:
    a = int(S, 2)
    r = "".join(list(repeat('10', int(N/2)+1)))
    if len(r)%2==0:
        r = r[:-1]
    s1 = int(r[:-1], 2)
    s2 = int(r[1:], 2)
    print(min(bin(s1^a).count("1"), bin(s2^a).count("1")))

Submission status: Wrong Answer

Solution code:
from itertools import repeat
S = input()
N = len(S)
if N<2:
    print('0')
else:
    a = int(S, 2)
    r = "".join(list(repeat('10', int((N+1)/2))))
    s1 = int(r[:-1], 2)
    s2 = int(r[1:], 2)
    print(min(bin(s1^a).count("1"), bin(s2^a).count("1")))