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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
S = input()
lis = []
for t in range(len(S)):
    lis.append(S[t])
evencount0 = 0
unevencount0 = 0
evencount1 = 0
unevencount1 = 0
if len(S)%2 == 0:
    for t in range(int(len(S)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int(len(S)/2) - evencount0
    for t in range(int(len(S)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int(len(S)/2) - unevencount0

else:
    for t in range(int((len(S) - 1)/2)):
        if S[2*t + 1] == "0":
            evencount0 += 1
    evencount1 = int(len(S)/2) - evencount0        

    for t in range(int((len(S)+1)/2)):
        if S[2*t] == "0":
            unevencount0 += 1
    unevencount1 = int(len(S)/2) - unevencount0

elist = [evencount0 , evencount1 , unevencount0 , unevencount1 ]
if evencount1 + unevencount0 > evencount0 + unevencount1:
    k = evencount0 + unevencount1
else:
    k = evencount1 + unevencount0
print(k)

Submission status: Wrong Answer

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

ans = 0
last_str = ''
for s in S:
  if last_str == '':
    last_str = s
  elif (last_str == s) and s == '0':
    ans += 1
    last_str = '1'
  elif (last_str == s) and s == '1':
    ans += 1
    last_str = '0'
  else:
    pass
print(ans)

Submission status: Wrong Answer

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

ans = 0
last_str = ''
for s in S:
  if last_str == '':
    last_str = s
  elif (last_str == s) and s == '0':
    ans += 1
    last_str = '1'
  elif (last_str == s) and s == '1':
    ans += 1
    last_str = '0'
  else:
    pass
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
cnt = 0
cntA = 0
cntB = 0
for i in range(n):
    #1から始まる
    if i%2 == 0:
        if S[i] == 1:
            cntA += 1
    if i%2 != 0:
        if S[i] == 0:
            cntA += 1
    #0から始まる
    if i%2 == 0:
        if S[i] == 0:
            cntB += 1
    if i%2 != 0:
        if S[i] == 1:
            cntB += 1

if cntA > cntB:
    cnt = cntB
if cntA == cntB:
    cnt = cntA
if cntA < cntB:
    cnt = cntA
    
print (cnt)

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S)
s = int(S, 2)
b = ''.join(map(str, [i % 2 for i in range(n)]))
p = int(b, 2)
q = int(b[1:] + b[0], 2)
print(min(bin(s ^ n).count('1') for n in [p, q]))

Submission status: Wrong Answer

Solution code:
s = input()
o1e0 = 0
o0e1 = 0

for n, i in enumerate(s):
    if (n // 2 == 0):
        if (i == "0"):
            o1e0 += 1
        else:
            o0e1 += 1

    else:
        if (i == "1"):
            o1e0 += 1
        else:
            o0e1 += 1

print(min(len(s) - o1e0, len(s) - o0e1))

Submission status: Wrong Answer

Solution code:
s = input()
o1e0 = 0
o0e1 = 0

for n, i in enumerate(s):
    print(n,i)
    if (n // 2 == 0):
        if (i == "0"):
            o1e0 += 1
        else:
            o0e1 += 1

    else:
        if (i == "1"):
            o1e0 += 1
        else:
            o0e1 += 1
            
print(min(len(s) - o1e0, len(s) - o0e1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

mat = list(sys.stdin.readline().strip())

odd = 0
even = 0
l = len(mat)
if l == 1:
    print(0)
else:
    for i, x in enumerate(mat):
        if int(x) == 1:
            if i % 2 == 0:
                even += 1
            else:
                odd += 1
    if (odd > even and l/2 > odd) or (even > odd and l/2 < odd):
        print(even + math.ceil(l / 2) - odd)
    else:
        print(odd + math.floor(l/2) - even)

Submission status: Wrong Answer

Solution code:
import sys
import math

mat = list(sys.stdin.readline().strip())

odd = 0
even = 0
l = len(mat)
if l == 1:
    print(0)
else:
    for i, x in enumerate(mat):
        if int(x) == 1:
            if i % 2 == 0:
                even += 1
            else:
                odd += 1

    if odd > even:
        print(even + math.ceil(l / 2) - odd)
    else:
        print(odd + math.floor(l/2) - even)

Submission status: Wrong Answer

Solution code:
import sys
import math

mat = list(sys.stdin.readline().strip())

odd = 0
even = 0
l = len(mat)
for i, x in enumerate(mat):
    if int(x) == 1:
        if i % 2 == 0:
            even += 1
        else:
            odd += 1

if odd > even:
    print(even + math.ceil(l / 2) - odd)
else:
    print(odd + math.floor(l/2) - even)

Submission status: Wrong Answer

Solution code:
number = input()
tile = [int(i) for i in number]
even = sum(tile[0::2])
odd = sum(tile[1::2])
ex1 = ((len(tile) // 2) - even) + odd
ex2 = ((len(tile) - (len(tile) // 2)) - odd) + even
print(min(ex1,ex2))

Submission status: Wrong Answer

Solution code:
import sys

a = input()
S = [int(c) for c in a]

ans = 0

if S[0] == 0:
	nxt = 1
else:
	nxt = 0

for i, tar in enumerate(S):
	if tar == 0:
		nxt = 1
	else:
		nxt = 0

	if i!=len(S)-1 and S[i] == S[i+1]:
		S[i+1] = nxt
		ans += 1
	

print(S,ans)

Submission status: Wrong Answer

Solution code:
str = input()
S = list(str)
N = len(S)
count = 0
for x in range(N):
    if x % 2 == 0 and S[x] == "0":
        count += 1
    elif x % 2 == 1 and S[x] == "1":
        count += 1
if count >= 50000:
    print(count - 50000)
else:
    print(count)

Submission status: Wrong Answer

Solution code:
S = int(input())

S_string = str(S)

S_half_integer = len(S_string)//2

list_01 = list('1' for i in range(S_half_integer))
list_10 = list('0' for i in range(S_half_integer))

for i in range(S_half_integer+1):
	list_01.insert(2*i, '0')
	list_10.insert(2*i, '1')

n2l_1 = ''
n2l_2 = ''

for (i, j) in zip(list_01, list_10):
	n2l_1 += i
	n2l_2 += j

S_renew_1 = S + int(n2l_1)
S_renew_2 = S + int(n2l_2)

S_renew_11 = str(S_renew_1)
S_renew_22 = str(S_renew_2)

count_1 = S_renew_11.count('1')
count_2 = S_renew_22.count('1')

print(min(count_1, count_2))

Submission status: Wrong Answer

Solution code:
S = list(map(str, input()))
listA = ["0"]
listB = ["1"]
countA = 0
countB = 0

for i in range(len(S) - 1):
  listA.append(str((i+1)%2))
  listB.append(str(i%2))
  if listA[i] != S[i]:
    countA = countA + 1
  if listB[i] != S[i]:
    countB = countB + 1

if countA <= countB:
  print(countA)
else:
  print(countB)

Submission status: Wrong Answer

Solution code:
S = list(map(str, input()))
listA = ["0"]
listB = ["1"]
countA = 0
countB = 0

for i in range(len(S) - 1):
  listA.append(str((i+1)%2))
  listB.append(str(i%2))

for i in range(len(S) - 1):
  if listA[i] != S[i]:
    countA = countA + 1
  if listB[i] != S[i]:
    countB = countB + 1

if countA <= countB:
  print(countA)
else:
  print(countB)

Submission status: Wrong Answer

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

t="01"*(-((-1)*l//2))
u="10"*(-((-1)*l//2))

x=0
y=0

def test(x,y):
    for i in range(l):
        if s[i] != t[i]:
            x += 1

        elif s[i] != u[i]:
            y += 1



print(min(x,y))

Submission status: Wrong Answer

Solution code:
*s,=map(int,input())
n=len(s)
a=sum(s)+n//2-sum(s[::2])*2
print(min(a,n-a))

Submission status: Wrong Answer

Solution code:
import numpy as np
tile=str(input())
a=['01','10'][int(tile[0])]*(10**5//2)
sum(np.array(list(tile),dtype=int)^np.array(list(a[:len(tile)]),dtype=int))

Submission status: Wrong Answer

Solution code:
import numpy as np
s = [int(i) for i in input()]

n = len(s)
if n == 1:
    print(0)

list01 = []
list10 = []
for i in range(n):
    if i//2 == 0:
        list01.append(0)
        list10.append(1)
    else:
        list01.append(1)
        list10.append(0)
        
list_a = np.array(s) - np.array(list01)
list_b = np.array(s) - np.array(list10)

count0 = np.sum(list_a == 0)
count1 = np.sum(list_b == 0)
countmax = max(count0,count1)
print(n-countmax)

Submission status: Wrong Answer

Solution code:
import numpy as np
s = [int(i) for i in input()]

n = len(s)

list01 = []
list10 = []
for i in range(n):
    if i//2 == 0:
        list01.append(0)
        list10.append(1)
    else:
        list01.append(1)
        list10.append(0)
        
list_a = np.array(s) - np.array(list01)
list_b = np.array(s) - np.array(list10)

count0 = np.sum(list_a == 0)
count1 = np.sum(list_b == 0)
countmax = max(count0,count1)
print(n-countmax)

Submission status: Wrong Answer

Solution code:
import numpy as np

S = input()

tile_color = []
for i in S:
    tile_color.append(int(i))

candidate = np.zeros((2,len(S)))
candidate[0, 0::2] = 1
candidate[1, 1::2] = 1

distance = [np.sum(np.abs(candidate[0,:] - tile_color)), np.sum(np.abs(candidate[1,:] - tile_color))]

print(min(distance))

Submission status: Wrong Answer

Solution code:
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
N = len(S)
if len(S) == -1:
    C1 = Counter(S[::2])
    C2 = Counter(S[1::2])

    odd = C1['0']+C2['1']
    even = C1['1']+C2['0']
    print(N-max(odd, even))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    l = int(input())
    l = [int(x) for x in list(str(l))]
    length = len(l)
    temp1 = []
    temp2 = []
    for i in range(length):
        temp1.append(i % 2)
        temp2.append((i + 1) % 2)
    t1 = 0
    t2 = 0
    for n in range(length):
        if temp1[n] != l[n]:
            t1 += 1
        if temp2[n] != l[n]:
            t2 += 1
    print(min(t1, t2))

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
length = len(l)
temp1 = []
temp2 = []
for i in range(length):
  temp1.append(i%2)
  temp2.append((i+1)%2)
t1=0
t2=0
for n in range(length):
  if temp1[n] != l[n]:
    t1+=1
  if temp2[n] != l[n]:
    t2+=1
print(min(t1, t2))

Submission status: Wrong Answer

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

N = len(S)
count_1010 = 0
count_0101 = 0
#処理 初めの数字について場合分け
#1始まり 1010...
for i in range(N):
    #奇数文字目 (1になる)
    if i % 2 == 0:
        if S[i] != "1":
            S[i] = "1"
            count_1010 += 1
    #偶数文字目 (0になる)
    else:
        if S[i] != "0":
            S[i] = "0"
            count_1010 += 1

#0始まり 0101...
for j in range(N):
    #奇数文字目 (0になる)
    if j % 2 == 0:
        if S[j] != "0":
            S[j] = "0"
            count_0101 += 1
    #偶数文字目 (1になる)
    else:
        if S[j] != "1":
            S[j] = "1"
            count_0101 += 1

#出力
print(min(count_0101, count_1010))

Submission status: Wrong Answer

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

N = len(S)
count_1010 = 0
count_0101 = 0
#処理 初めの数字について場合分け
#1始まり 1010...
for i in range(N):
    #奇数文字目 (1になる)
    if i % 2 == 0:
        if S[i] != "1":
            count_1010 += 1
    #偶数文字目 (0になる)
    else:
        if S[i] != "0":
            count_1010 += 1

#0始まり 0101...
for j in range(N):
    #奇数文字目 (0になる)
    if i % 2 == 0:
        if S[j] != "0":
            count_0101 += 1
    #偶数文字目 (1になる)
    else:
        if S[j] != "1":
            count_0101 += 1

#出力
print(min(count_0101, count_1010))

Submission status: Wrong Answer

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

count_1010 = 0
count_0101 = 0
#処理 初めの数字について場合分け
#1始まり
for i in range(len(S)):
    #奇数文字目 (1になる)
    if i % 2 == 0:
        if S[i] != "1":
            S[i] = "1"
            count_1010 += 1
    #偶数文字目 (0になる)
    else:
        if S[i] != "0":
            S[i] = "0"
            count_1010 += 1

#0始まり
for j in range(len(S)):
    #奇数文字目 (0になる)
    if i % 2 == 0:
        if S[j] != "0":
            S[j] = "0"
            count_0101 += 1
    #偶数文字目 (1になる)
    else:
        if S[j] != "1":
            S[i] = "1"
            count_0101 += 1

#出力
print(min(count_0101, count_1010))

Submission status: Wrong Answer

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

# 01010... か 10101...の二択

# 0...
err1 = 0
for i in range(n):
    if i % 2 == 0 and s[i] == 1:
        err1 += 1
    elif i % 2 == 1 and s[i] == 0:
        err1 += 1

# 1...
err2 = 0
for i in range(n):
    if i % 2 == 0 and s[i] == 0:
        err2 += 1
    elif i % 2 == 1 and s[i] == 1:
        err2 += 1

print(min(err1, err2))

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)-1
count=0
if s[0]=='0':
    for i in range(1,n):
        if i%2==1 and s[i]=='0':
            count+=1
        elif i%2==0 and s[i]=='1':
            count+=1
else:
    for i in range(1,n):
        if i%2==1 and s[i]=='1':
            count+=1
        elif i%2==0 and s[i]=='0':
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
S=input()
cnt_1=0
cnt_2=0
N=len(S)
if N%2==0:
	for i in range(N):
		if i%2==0:
			if S[i]=='1':
				cnt_1+=1
		else:
			if S[i]=='1':
				cnt_2+=1
	print(min(cnt_1+((N//2)-cnt_2),((N//2)-cnt_1)+cnt_2))
else:
	for i in range(N):
		if i%2==0:
			if S[i]=='1':
				cnt_1+=1
		else:
			if S[i]=='1':
				cnt_2+=1
	print(min(cnt_1+((N//2+1)-cnt_2),((N//2)-cnt_1)+cnt_2))

Submission status: Wrong Answer

Solution code:
S = list(input())
cnt = 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'
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
count = 0

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

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

Submission status: Wrong Answer

Solution code:
number=list(input())
paturn1=list("10"*(10**3))
paturn2=list("01"*(10**2))
convert1=[int(x)^int(y) for x,y in zip(number,paturn1)]
convert2=[int(x)^int(y) for x,y in zip(number,paturn2)]
print(min([convert1.count(1),convert2.count(1)]))

Submission status: Wrong Answer

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

ans = 0
for i in range(2):
    cnt = 0
    for j, s_j in enumerate(S):
        if j % 2 == 0 ^ s_j != i:
            cnt += 1
    ans = min(ans, cnt)

print(ans)

Submission status: Wrong Answer

Solution code:
print(sum(i%2^int(s)for i,s in enumerate(input())))

Submission status: Wrong Answer

Solution code:
#ABC124-C 別解
S = input()
c = 0
zo = 0
oz = 0
for i in range(0, len(S)//2 * 2, 2):
    if S[i] == '0':
        oz += 1
    else:
        zo += 1
    if S[i+1] == '0':
        zo += 1
    else:
        oz += 1
if len(S) & 1:
    if S[-1] == '0':
        oz += 1
print(min(oz, zo))

Submission status: Wrong Answer

Solution code:
import math
tile=input()
if len(str(tile))==1:
    print(0)
    exit()
tile=int(tile)
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)),2)
    tile2=int("10"*int(math.ceil(len(str(tile))/2)),2)
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
tile=int(input())
if len(str(tile))==1:
    print(0)
    exit()
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)),2)
    tile2=int("10"*int(math.ceil(len(str(tile))/2)),2)
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))

Submission status: Wrong Answer

Solution code:
"""
C - Coloring Colorfully
https://atcoder.jp/contests/abc124/tasks/abc124_c
"""
if __name__ == '__main__':
    S = str(input())

    len_S = len(S)
    S_list = []
    answer_type_1 = []
    answer_type_2 = []
    answer_type_3 = []
    answer_type_4 = []
    for i in range(0, len_S):
        S_list.append(S[i])
        if i % 4 == 0:
            answer_type_1.append("0")
            answer_type_2.append("0")
            answer_type_3.append("1")
            answer_type_4.append("1")
        elif i % 4 == 1:
            answer_type_1.append("0")
            answer_type_2.append("1")
            answer_type_3.append("0")
            answer_type_4.append("1")
        elif i % 4 == 2:
            answer_type_1.append("1")
            answer_type_2.append("1")
            answer_type_3.append("0")
            answer_type_4.append("0")
        else:
            answer_type_1.append("1")
            answer_type_2.append("0")
            answer_type_3.append("1")
            answer_type_4.append("0")

    answer_1 = 0
    answer_2 = 0
    answer_3 = 0
    answer_4 = 0

    for i, Si in enumerate(S_list):
        if S_list[i] != answer_type_1[i]:
            answer_1 += 1
        if S_list[i] != answer_type_2[i]:
            answer_2 += 1
        if S_list[i] != answer_type_3[i]:
            answer_3 += 1
        if S_list[i] != answer_type_4[i]:
            answer_4 += 1

    answer = min(answer_1, answer_2, answer_3, answer_4)

    print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = (input())
x=np.array(list(N),dtype=np.int)
count=0
count2=0
if len(x)==1:
    print(0)
else:
    now=0
    for n,i in enumerate(x):
        if i==now:
            if n%2==0:
                now=1
            else:
                now=0
        else:
            count+=1
            if n%2==0:
                now=1
            else:
                now=0
        
    now=1
    for n,i in enumerate(x):
        if i==now:
            if n%2==0:
                now=0
            else:
                now=1
        else:
            count2+=1
            if n%2==0:
                now=0
            else:
                now=1
if(count>count2):
    print(count2)
else:
    print(count)

Submission status: Wrong Answer

Solution code:
s=input()
even=False
count=0
def isZero(a):
    if a=="0":
        return True
    else:
        return False

if len(s)%2==0:
    even=True
else:
    even=False

if even==True:
    for i in range(0,len(s),2):
        if isZero(s[i])!=isZero(s[0]):
            count+=1
    for i in range(1,len(s),2):
        if isZero(s[i])==isZero(s[0]):
            count+=1

if even==False:
    #b=int((len(s)-1)/2)
    for i in range(1,len(s),2):
        if isZero(s[i])==isZero(s[0]):
            count+=1
    for i in range(1,len(s),2):
        if isZero(s[i])!=isZero(s[0]):
            count+=1

print(count)

Submission status: Wrong Answer

Solution code:
import math
s = input()
count0 = 0
count1 = 0

for i in range(len(s)):
    if int(s[i]) == 1:
        count1 += 1
    else:
        count0 += 1

if count1 > count0:
    a = count1 - count0
else:
    a = count0 - count1

ans = math.floor(a/2)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 文字列の入力
S = str(input())

ans=0

if len(S)==1:
  ans=0
elif len(S)==2:
  if S[0]==S[1]:
    ans=1
  else:
    ans=0
else: #3枚以上はちゃんと読み込む
  string=[]
  original_string=[]
  
  for i in range(len(S)):
    string.append(S[i])
    original_string.append(S[i])
    #print(S[i])
    #print(string)
    #print(original_string)
    
  for i in range(len(S)-2):
    gramed = str(string[i])+str(string[i+1])+str(string[i+2])
    
    if gramed=="000":
      string[i+1]="1"
      ans=ans+1
    if gramed=="001":
      string[i]="1"
      ans=ans+1
    if gramed=="011":
      string[i+2]="0"
      ans=ans+1
    if gramed=="110":
      string[i]="0"
      ans=ans+1
    if gramed=="100":
      string[i+2]="1"
      ans=ans+1
    if gramed=="111":
      string[i+1]="0"
      ans=ans+1
    
    #print("")
    #print(string)
    #print(original_string)  
print(ans)

Submission status: Wrong Answer

Solution code:
import math
tile=int(input())
if len(str(tile))==1:
    print(0)
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)))
    tile2=int("10"*int(math.ceil(len(str(tile))/2)))
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))

Submission status: Wrong Answer

Solution code:
import math
tile=int(input())
if len(str(tile))==1:
    print(0)
if len(str(tile))%2==1:
    tile1=int("01"*int(math.ceil(len(str(tile))/2)))
    tile2=int("10"*int(math.ceil(len(str(tile))/2)))
else:
    tile1=int("01"*int(len(str(tile))/2),2)
    tile2=int("10"*int(len(str(tile))/2),2)

tile_10=int(str(tile),2)
print(tile_10)
convert1=format(tile_10^tile1,'b').zfill(len(str(tile)))
convert2=format(tile_10^tile2,'b').zfill(len(str(tile)))
if convert1.count("1")<=convert2.count("1"):
    print(convert1.count("1"))
else:
    print(convert2.count("1"))

Submission status: Wrong Answer

Solution code:
s = input()
ans_1 = 0
ans_2 = 0
str_1 = list(s)
str_2 = list(s)
 
for i in range(len(str_1)-1):
	if str_1[i] == str_1[i+1]:
		str_1[i+1] = "0" if str_1[i+1]=="1" else "1"
		ans_1 +=1
 
str_2[0] = "0" if str_2[0]=="1" else "1"
for i in range(len(str_2)-1):
	if str_2[i] == str_2[i+1]:
		str_2[i+1] = "0" if str_2[i+1]=="1" else "1"
		ans_2 +=1
        
print(ans_1 if ans_1 <= ans_2 else ans_2)

Submission status: Wrong Answer

Solution code:
S = list(int(i) for i in input().split())  
# 10101010101.. or 0101010101.. としたいので 01 or 10 の繰り返し配列を対応させた後にSの配列と比較して最小値を出す
cnt = 0
if not 1 in S[0::2]:
    cnt += 1
cn = 0
if not 0 in S[1::2]:
    cn += 1
a = cnt + cn

add = 0
if not 0 in S[0::2]:
    add += 1
ad = 0
if not 1 in S[1::2]:
    ad += 1
b = add + ad

if a > b:
    print(b)
elif a == b:
    print(b)
else:
    print(a)

Submission status: Wrong Answer

Solution code:
"""
C - Coloring Colorfully
https://atcoder.jp/contests/abc124/tasks/abc124_c
"""
if __name__ == '__main__':
    S = str(input())

    len_S = len(S)
    S_list = []
    answer_type_1 = []
    answer_type_2 = []
    for i in range(0, len_S):
        S_list.append(S[i])
        if i % 4 in (0, 1):
            answer_type_1.append("0")
            answer_type_2.append("1")
        else:
            answer_type_1.append("1")
            answer_type_2.append("0")

    answer_1 = 0
    answer_2 = 0

    for i, Si in enumerate(S_list):
        if S_list[i] != answer_type_1[i]:
            answer_1 += 1
        if S_list[i] != answer_type_2[i]:
            answer_2 += 2

    answer = min(answer_1, answer_2)

    print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = (input())
x=np.array(list(N),dtype=np.int)
count=0
count2=0
if len(x)==1:
    print(0)
else:
    now=0
    for n,i in enumerate(x):
        if i==now:
            if n%2==0:
                now=1
            else:
                now=0
        else:
            count+=1
            if n%2==0:
                now=1
            else:
                now=0
        
    now=1
    for n,i in enumerate(x):
        if i==now:
            if n%2==0:
                now=0
            else:
                now=1
        else:
            count2+=1
            if n%2==0:
                now=0
            else:
                now=1
if(count>count2):
    print(count2)
else:
    print(count)

Submission status: Wrong Answer

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

# Patern.1
if l < 3:
    print("0")
    start = -1
elif (S[:3] == [1,1,0]) or (S[:3] == [0,0,1]):
    start = 0
    c_prev = S[start]
elif (S[:3] == [1,1,1]) or (S[:3] == [0,0,0]):
    start = 1
    c_prev = S[start]
elif (S[:3] == [1,0,0]) or (S[:3] == [0,1,1]):
    start = 2
    c_prev = S[start]
elif (S[:3] == [0,1,0]) or (S[:3] == [1,0,1]):
    start = 3
    c_prev = S[2]
    if len(S) == 3:
        start = -1
        print("0")

if start >= 0:
    cnt = 0
    print(S)
    for i in range(start, l):
        if c_prev == S[i]:
            cnt += 1
            S[i] = (S[i]+1)%2
        c_prev = S[i]
        print(S, i)
    print(cnt)

Submission status: Wrong Answer

Solution code:

def Change(a):
    if a == '0':
        s = '1'
    else:
        s = '0'
    return s


count = 0
S = list(input())
if len(S) >= 3:
    if S[0] == S[1] == S[2]:
        S[1] = Change(S[1])
        count += 1
if len(S) >= 2 and S[0] == S[1]:
    S[0] = Change(S[0])
    count += 1
if len(S) >= 3:
    for i in range(1, len(S)-2):
        if S[i-1] == S[i] == S[i+1]:
            S[i] = Change(S[i])
            count += 1
        elif S[i] == S[i+1]:
            S[i+1] = Change(S[i+1])
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
print(len(s))
c = 0

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

Submission status: Wrong Answer

Solution code:
s = [int(i) for i in list(input())]
count = 0

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

Submission status: Wrong Answer

Solution code:
S = input()
n = len(S) // 2
ll = 0
oo = 0
lo = 0
ol = 0
if n > 0:
    for i in range(n):
        if S[i:i+2] == "00":
            oo += 1
        elif S[i:i+2] == "10":
            lo += 1
        elif S[i:i+2] == "01":
            ol += 1
        elif S[i:i+2] == "11":
            ll += 1

bll = 0
boo = 0
blo = 0
bol = 0
if n > 0:
    for i in range(n):
        if S[i+1:i+3] == "00":
            boo += 1
        elif S[i+1:i+3] == "10":
            blo += 1
        elif S[i+1:i+3] == "01":
            bol += 1
        elif S[i+1:i+3] == "11":
            bll += 1

if len(S) % 2 == 0:
    if lo >= ol:
        print(oo + ll + 2*ol)
    else:
        print(oo + ll + 2*lo)
else:
    if lo > ol:
        ans = oo + ll + 2*ol + (1 if S[-1] == "0" else 0)
    elif lo < ol:
        ans = oo + ll + 2*lo + (1 if S[-1] == "1" else 0)
    else:
        ans = oo + ll + 2*lo

    if blo > bol:
        print(min(ans, boo + bll + 2*bol + (1 if S[0] == "1" else 0)))
    elif lo < ol:
        print(min(ans, boo + bll + 2*blo + (1 if S[0] == "0" else 0)))
    else:
        print(min(ans, boo + bll + 2*blo))

Submission status: Wrong Answer

Solution code:
from sys import stdin

tile = input()
tile_length = len(tile)
tile_color = list(tile)

tile_start_zero = tile_color
count_start_zero = 0

tile_start_one = tile_color
count_start_one = 0

""" START ZERO """
if tile_color[0] is '1':
	tile_start_zero[0] = '0'
	count_start_zero += 1

for i in range(tile_length-1):
	if tile_start_zero[i+1] is tile_start_zero[i]:
		if tile_start_zero[i] is '0':
			tile_start_zero[i+1] = '1'
		else: tile_start_zero[i+1] = '0'

		count_start_zero += 1

""" START ONE """
if tile_color[0] is '0':
	tile_start_one[0] = '1'
	count_start_one += 1

for i in range(tile_length-1):
	if tile_start_one[i+1] is tile_start_one[i]:
		if tile_start_one[i] is '1':
			tile_start_one[i+1] = '0'
		else: tile_start_one[i+1] = '1'

		count_start_one += 1

print(min(count_start_one, count_start_zero))

Submission status: Wrong Answer

Solution code:
S = input()
T = list(S)
L = len(T)
C1 = 0
C2 = 0

for i in range(0,L-2,1):
	if T[i] == '1':
		if T[i+1] == '1':
			T[i+1] = '0'
			C1 += 1
	else:
		if T[i+1] == '0':
			T[i+1] = '1'
			C1 += 1

T = list(S)
T.reverse()

for i in range(0,L-2,1):
	if T[i] == '1':
		if T[i+1] == '1':
			T[i+1] = '0'
			C2 += 1
	else:
		if T[i+1] == '0':
			T[i+1] = '1'
			C2 += 1

print(min(C1,C2))

Submission status: Wrong Answer

Solution code:
s = [int(i) for i in list(input())]
count = 0

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

Submission status: Wrong Answer

Solution code:
a = input()
n = len(a)
count0 = 0    #start from 0
count1 = 0    #start from 1
for i in range(n):
    if i % 2 == 0 and int(a[i]) ==1:
        count0 = count0 +1
        print(count0)
    elif i % 2 == 0 and int(a[i]) ==0:
        count1 = count1 +1
    elif i % 2 == 1 and int(a[i]) ==1:
        count1 = count1 +1
    elif i % 2 == 1 and int(a[i]) ==0:
        count0 = count0 +1

print(min(count0, count1))

Submission status: Wrong Answer

Solution code:
s = input()
c = 0

for i in range(1, len(s)):
    if i == 1 or i == len(s)-1:
        try:
            if s[i-1] == s[i]:
                c += 1
        except:
            break
    else:
        try:
            if s[i-1] != s[i+1]:
                c += 1
        except:
            break
print(c)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 21:45:12 2019

@author: sofugo
"""
import numpy as np
N = (input())
x=np.array(list(N),dtype=np.int)
count=0
if len(x)==1:
    print(0)
else:
    if x[0]==0:
        now=0
        for n,i in enumerate(x):
            if i==now:
                if n%2==0:
                    now=1
                else:
                    now=0
            else:
                count+=1
                if n%2==0:
                    now=1
                else:
                    now=0
            
                
    else:
        now=1
        for n,i in enumerate(x):
            if i==now:
                if n%2==0:
                    now=0
                else:
                    now=1
            else:
                count+=1
                if n%2==0:
                    now=0
                else:
                    now=1
            
print(count)

Submission status: Wrong Answer

Solution code:
s = input()
ans_1 = 0
ans_2 = 0
str_1 = list(s)
str_2 = list(s)

for i in range(len(str_1)-1):
	if str_1[i] == str_1[i+1]:
		str_1[i+1] = "0" if str_1[i+1]=="1" else "1"
		ans_1 +=1

str_2[0] = "0" if str_2[0]=="1" else "1"
for i in range(len(str_2)-1):
	if str_2[i] == str_2[i+1]:
		str_2[i+1] = "0" if str_2[i+1]=="1" else "1"
		ans_2 +=1
        
print(ans_1 if ans_1 < ans_2 else ans_2)