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: Runtime Error

Solution code:
import numpy as np

S = input()
S_int = int(S)

tile_color = []

keta = len(S)
for i in range(keta):
    if S_int/10 == int(S_int/10):
        tile_color.insert(0, '0')
    else:
        tile_color.insert(0, '1')
    S_int = int(S_int/10)

length_of_S = len(tile_color)

candidate_1 = np.zeros((1,length_of_S))
candidate_1[0,0::2] = 1
candidate_2 = np.zeros((1,length_of_S))
candidate_2[0,1::2] = 1

tile_color = [int(n) for n in tile_color]

distance = [np.sum(np.abs(tile_color - candidate_1[0,:])), np.sum(np.abs(tile_color - candidate_2[0,:]))]

print(int(min(distance)))

Submission status: Runtime Error

Solution code:
def subtract_lst (lst1, lst2):
    ans = 0
    for i in range(len(lst1)):
        e1 = lst1[i]
        e2 = lst2[i]
        if e1 != e2:
            ans += 1
    return ans

if __name__ == '__main__':
    s = input()
    a = ""
    b = ""
    for i in range(len(s) // 2):
      a = a + "10"
      b = b + "01"
    if lenS % 2 == 1:
        a = a + "1"
        b = b + "0"
    print (min(subtract_lst (a, s), subtract_lst (b, s)))

Submission status: Runtime Error

Solution code:
def subtract_lst (lst1, lst2, ans):
    for i in range(len(lst1)):
        e1 = lst1[i]
        e2 = lst2[i]
        if e1 != e2:
            ans += 1
    return ans

if __name__ == '__main__':
    s = input()
    a = ""
    b = ""
    for i in range(len(s) // 2):
      a = a + "10"
      b = b + "01"
    if lenS % 2 == 1:
        a = a + "1"
        b = b + "0"
    print (min(subtract_lst (a, s, 0), subtract_lst (b, s, 0)))

Submission status: Runtime Error

Solution code:
S = input().strip()
ansB = 0
ansW = 0
for i,c in emumerate(S):
  if (i % 2 == 0):
    if (c == '0'):
      ansW += 1
  else:
   	if (c == '1'):
      ansB += 1

ans = min(ansW, ansB)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
li=list(n)
if len(n)==1:
  print(0)
elif len(n)%2==0:
  counta=0 
  countb=0
  a=list("10"*int((int(n)/2)))
  b=list("01"*int((int(n)/2)))
  for i in range(len(n)):
    counta+= abs(int(li[i])-int(a[i]))
    countb+=abs(int(li[i])-int(b[i]))
  print(min(counta,countb))

elif len(n)%2==1 and len(n) != 1:
  countaa=0 
  countbb=0
  aa=list("10"*int(((int(n)-1)/2))+"1")
  bb=list("01"*int(((int(n)-1)/2))+"0")
  for i in range(len(n)):
    countaa+=abs(int(li[i])-int(aa[i]))
    countbb+=abs(int(li[i])-int(bb[i]))
  print(min(countaa,countbb))

Submission status: Runtime Error

Solution code:
n=input()
li=list(n)
if len(n)==1:
  print(0)
elif len(n)%2==0 and len(n) != 1:
  counta=0 
  countb=0
  a=list("10"*int((int(n)/2)))
  b=list("01"*int((int(n)/2)))
  for i in range(len(n)):
    counta+= abs(int(li[i])-int(a[i]))
    countb+=abs(int(li[i])-int(b[i]))
  print(min(counta,countb))

elif len(n)%2==1 and len(n) != 1:
  countaa=0 
  countbb=0
  aa=list("10"*int(((int(n)-1)/2))+"1")
  bb=list("01"*int(((int(n)-1)/2))+"0")
  for i in range(len(n)):
    countaa+=abs(int(li[i])-int(a[i]))
    countbb+=abs(int(li[i])-int(b[i]))
  print(min(countaa,countbb))

Submission status: Runtime Error

Solution code:
S = input()
target = ''
for i in range(len(S)):
  if i & 1:
    target += '0'
  else:
    target += '1'
    
def dist(a, b):
  res = 0
  for i in range(len(a)):
    res += (a[i] == b[i])
  return res

res = dist(S, target)
target = target.replace('0', 'x').replace('1', '0').('x', '1')
print(min(res, dist(S, target)))

Submission status: Runtime Error

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

arr = [0 for _ in range(N)]
idx = 0
pre = '1'
if S[0] == '0':
    idx += 1
    arr[0] = 0
    pre = '0'

for i in range(N):
    if pre == S[i]:
        arr[idx] += 1
    else:
        idx += 1
        arr[idx] += 1
    pre = S[i]

max_lensum = 0
for i in range(0, idx+1, 2):
    #print("arr", arr)
    #print("arr", arr[i:min(i+2*K+1, idx+1)])
    lensum = sum(arr[i:min(i+2*K+1, idx+1)])
    if lensum > max_lensum:
        max_lensum = lensum
    if i+2*K+1 > idx: break
print(max_lensum)

Submission status: Runtime Error

Solution code:
#ABC124-C 別解
S = input()
c = 0
zo = 0
oz = 0
for i in range(0, len(S), 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: Runtime Error

Solution code:
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i in range(1,N):
  if H[i]>=max(H[:i]):
    ans += 1
print(ans)

Submission status: Runtime Error

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

ans = 0
if N > 1:
  for i in range(1, N):
    if (H[i] >= H[i - 1]:
      ans += 1

print(ans + 1)

Submission status: Runtime Error

Solution code:
S = input()
z_count = 0
o_count = 0
k_count = 0
g_count = 0
for i in range(len(S)):
  if S[i] == "0":
    z_count += 1
    if i % 2 == 0:
      g_count += 1
    else:
      k_count += 1
  else:
    o_count += 1
    if i % 2 == 0:
      g_count += 1
    else:
      k_count += 1
    
if z_count <= o_count:
  if g_count <= k_count:
    print(len(S) - g_count)
  else:
    print(len(s) - k_count)
    
else:
  if g_count <=

Submission status: Runtime Error

Solution code:
import sys
n,k = map(str, input().split())
s = list(str(input()))

zero_count_list = []
zero_count = 0
one_count_list = []
one_count = 0
s_size = len(s)

for index, i in enumerate(s):
    if i == "0":
        zero_count += 1
    else:
        if zero_count != 0:
            zero_count_list.append(zero_count)
        zero_count = 0
    if index == s_size - 1:
        if zero_count != 0:
            zero_count_list.append(zero_count)

for index, i in enumerate(s):
    if i == "1":
        one_count += 1
    else:
        if one_count != 0:
            one_count_list.append(one_count)
        one_count = 0
    if index == s_size - 1:
        if one_count != 0:
            one_count_list.append(one_count)
if k => len(zero_count_list):
    print(s_size)
    sys.exit(0)

Submission status: Runtime Error

Solution code:
# tiles = list(map(int, input()))
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        if tile == color:
            counts = counts + 1
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Submission status: Runtime Error

Solution code:
N=str(input())
anser=0
for i in range(len(N)-1):
	if N[i]==N[i+1]:
		if N[i]==0:
			N[i]='1'
		else:
			N[i]='0'
		anser+=1
print(anser)

Submission status: Runtime Error

Solution code:

s = input()
c = 0

for i in range(1, len(s)):
    if :
        
    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: Runtime Error

Solution code:
a=sum(i%2^int(c)for i,c in enumerate(input()));print(min(a,n-a))

Submission status: Runtime Error

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枚以上はちゃんと読み込む
  strint=[]
  original_string=[]
  
  for i in range(len(S)):
    string.append(S[i])
    original_string.append(S[i])
    
  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"
    if gramed=="001":
      string[i]="1"
    if gramed=="011":
      string[i+2]="0"
    if gramed=="110":
      string[i]="0"
    if gramed=="100":
      string[i+2]="1"
    if gramed=="111":
      string[i+1]="1"
  
  #print(string)
  #print(original_string)
  
  for i in range(len(S)):
    if original_string[i]!=string[i]:
      ans=ans+1
  
print(ans)

Submission status: Runtime Error

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枚以上はちゃんと読み込む
  strint=[]
  original_string=[]
  
  for i in range(len(S)):
    string.append(S[i])
    original_string.append(S[i])
    
  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"
    if gramed=="001":
      string[i]="1"
    if gramed=="011":
      string[i+2]="0"
    if gramed=="110":
      string[i]="0"
    if gramed=="100":
      string[i+2]="1"
    if gramed=="111":
      string[i+1]="1"
  
  print(string)
  print(original_string)
  
  for i in range(len(S)):
    if original_string[i]!=string[i]:
      ans=ans+1
  
print(ans)

Submission status: Runtime Error

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

def henkan(a):
    if a == "0":
        a = "1"
    else:
        a = "0"
    return a
    
ans = 0
a = 0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        a = henkan(S[i+1])
        ans += 1
        print("a", a)
        S[i+1] = a
        print(S)
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
sum01 = 0
sum10 = 0

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

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i+:i+1] == 0:
      sum10 += 1
  if (i % 2) == 1:
    if S[i:i+1] == 1:
      sum10 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)

Submission status: Runtime Error

Solution code:
tiles = map(int, input())
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        counts = counts + 1 if tile != color else 0
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Submission status: Runtime Error

Solution code:
import numpy as np
H = input()
H = str.split(H)
H = np.array(H, int)
x = []
y = []
for i in range(len(H)):
    x.append(i%2)
    y.append((i+1)//2)
print(H == np.array(x))
print(H == np.array(y))
a = sum(H == np.array(x))
b = sum(H == np.array(y))

if(a>=b):
    print(len(H)-a)
else:
    print(len(H)-b)

Submission status: Runtime Error

Solution code:
S = input()
sum01 = 0
sum10 = 0

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i:i+1] == '1':
      sum01 += 1
  if (i % 2) == 1:
    if S[i:i+1] == '0':
      sum01 += 1

for i in range(len(S)):
  if (i % 2) == 0:
    if S[i+:i+1] == '0':
      sum10 += 1
  if (i % 2) == 1:
    if S[i:i+1] == '1':
      sum10 += 1
        
if sum01 > sum10:
  print(sum10)
else:
  print(sum01)

Submission status: Runtime Error

Solution code:
Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    return
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change+=1

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))

min_change = change


change_first=1
if Tiles[0] == "0":
    cur = "1"
else:
    cur = "0"

for i in range(1, N_len):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_first+=1
        if min_change <= change_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]
        
if min_change > change_first:
    min_change = change_first

        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse+=1
        if min_change <= change_reverse:
            break


        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

    #print("new cur={}".format(cur))
    
if min_change > change_reverse:
    min_change = change_reverse


change_reverse_first=1
if Tiles[N_len-1] == "0":
    cur = "1"
else:
    cur = "0"

for i in reversed(range(0, N_len-1)):
    #print("i={}".format(i))
    #print("cur={}".format(cur))
    #print("next={}".format(Tiles[i]))
    if cur is Tiles[i]:
        change_reverse_first+=1
        if min_change <= change_reverse_first:
            break

        if Tiles[i] == "0":
            cur = "1"
        else:
            cur ="0"
    else:
        cur=Tiles[i]

if min_change > change_reverse_first:
    min_change = change_reverse_first
    
print(min_change)

Submission status: Runtime Error

Solution code:
tiles = map(int, input().split())
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        counts = counts + 1 if tile != color else 0
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Submission status: Runtime Error

Solution code:
H = input()
H = str.split(H)
H = np.array(H, int)
x = []
y = []
for i in range(len(H)):
    x.append(i%2)
    y.append((i+1)//2)
print(H == np.array(x))
print(H == np.array(y))
a = sum(H == np.array(x))
b = sum(H == np.array(y))

if(a>=b):
    print(len(H)-a)
else:
    print(len(H)-b)

Submission status: Runtime Error

Solution code:
def c_coloring_colorfully(S):
    s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '')
    s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '')
    ans1, ans2 = 0, 0
    for k, s in enumerate(S):
        if s != s1[k]:
            ans1 += 1
        if s != s2[k]:
            ans2 += 1
    return min(ans1, ans2)

S = input()
print(c_doloring_colorfully(S))

Submission status: Runtime Error

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)-1):
        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(S)
print(count)

Submission status: Runtime Error

Solution code:
raw = input()
s = bin(int(raw, 2))
n = len(raw)
m1 = bin(int("1010101010101"[:n],2))
m2 = bin(int("0101010101010"[:n],2))

if s == m1 or s == m2:
    print("0")
    exit(1)

a = bin((int(s,2))^int(m1,2)).count("1")
b = bin((int(s,2))^int(m2,2)).count("1")

print(a if a < b else b)

Submission status: Runtime Error

Solution code:
import numpy as np
H = input()
H = str.split(H)
H = np.array(H, int)

x = []
y = []
for i in range(len(H)):
    x.append(i//2)
    y.append((i+1)//2)

a = sum(H == np.array(x))
b = sum(H == np.array(y))

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

Submission status: Runtime Error

Solution code:
for char in input():
  S.append(char)
#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=='1':
      C1+=1
  else:
    if S[i]=='0':
      C1+=1
      
#route 2
C2=0
for n in range(len(S)):
  if n%2==0:
    if S[n]=='0':
      C2+=1
  else:
    if S[n]=='1':
      C2+=1
      
if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Runtime Error

Solution code:

n = list(input())
n_2 = n.copy()
ex = 0
ex_2 = 0

if len(n) <= 1:
    print(0)
elif len(n)==2:
    b = (int)(n[1 - 1])
    m = (int)(n[1])
    if b == 0 and m == 0:
        ex += 1
    if b == 1 and m == 1:
        ex += 1
else:
    for i, l in enumerate(n):
        if i >= 1:
            b = (int)(n[i - 1])
            m = (int)(n[i])
            if b == 0 and m == 0:
                n[i - 1] = 1
                ex += 1
            elif b == 1 and m == 1:
                n[i - 1] = 0
                ex += 1
            if len(n) - (i + 1) > 0:
                b = (int)(n[i - 1])
                m = (int)(n[i])
                f = (int)(n[i + 1])
                if b == 0 and m == 0 and f == 0:
                    n[i] = 1
                    ex += 1
                if b == 1 and m == 1 and f == 1:
                    n[i] = 0
                    ex += 1
                if b == 1 and m == 1 and f == 0:
                    n[i - 1] = 0
                    ex += 1
                if b == 0 and m == 0 and f == 1:
                    n[i - 1] = 1
                    ex += 1
                if b == 0 and m == 1 and f == 1:
                    n[i + 1] = 0
                    ex += 1
                if b == 1 and m == 0 and f == 0:
                    n[i + 1] = 1
                    ex += 1
                print(n)
    ex_2 = ex
    ex = 0
    n = n_2
    print(n)
    for i, l in enumerate(n):
        if i >= 1:
            b = (int)(n[i - 1])
            m = (int)(n[i])
            if b == 0 and m == 0:
                n[i] = 1
                ex += 1
            elif b == 1 and m == 1:
                n[i] = 0
                ex += 1
            if len(n) - (i + 1) > 0:
                b = (int)(n[i - 1])
                m = (int)(n[i])
                f = (int)(n[i + 1])
                if b == 0 and m == 0 and f == 0:
                    n[i] = 1
                    ex += 1
                if b == 1 and m == 1 and f == 1:
                    n[i] = 0
                    ex += 1
                if b == 1 and m == 1 and f == 0:
                    n[i - 1] = 0
                    ex += 1
                if b == 0 and m == 0 and f == 1:
                    n[i - 1] = 1
                    ex += 1
                if b == 0 and m == 1 and f == 1:
                    n[i + 1] = 0
                    ex += 1
                if b == 1 and m == 0 and f == 0:
                    n[i + 1] = 1
                    ex += 1
                print(n)
print(ex,ex_2)
if ex<ex_2:
    print(ex)
else:
    print(ex_2)

Submission status: Runtime Error

Solution code:
for char in input():
  S.append(char)
#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]=='1':
      C1+=1
  else:
    if S[i]=='0':
      C1+=1

#route 2
S=X
C2=0
for n in range(len(S)):
  if n%2==0:
    if S[n]=='0':
      C2+=1
  else:
    if S[n]=='1':
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Runtime Error

Solution code:

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(len(S)-2):
        if S[i] == S[i+1] == S[i+2]:
            S[i+1] = Change(S[i+1])
            count += 1
        if S[i] == S[i + 1]:
            S[i + 1] = Change(S[i + 1])
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = str(input())
l1 = []
for c in n:
	l1.append(c)

z, o = '0', '1'

one, zero = [], []

for i in range(len(l1)):
	if i%2 == 0:
		one.append(o)
		zero.append(z)
	else:
		one.append(z)
		zero.append(o)

c1, c2 = 0,0
for i in range(len(l1)):
	if l[i] == one[i]:
		c1 += 1
	if l[i] == zero[i]:
		c2 += 1

ans = min(c1, c2)
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

n = str(input())
print(n)
l1 = []
for c in n:
	l1.append(c)

z, o = '0', '1'

one, zero = [], []

for i in range(len(l1)):
	if i%2 == 0:
		one.append(o)
		zero.append(z)
	else:
		one.append(z)
		zero.append(o)

c1, c2 = 0,0
for i in range(len(l1)):
	if l[i] == one[i]:
		c1 += 1
	if l[i] == zero[i]:
		c2 += 1

ans = min(c1, c2)
print(ans)

Submission status: Runtime Error

Solution code:
S=list(input())
N=len(S)
S_int=list(S)
for i in range(N):
    S_int[i]=int(S[i])
cnt_1=0
cnt_2=0
if all([S_int[i]!=S_int[i+1] for i in range(N)]):
    print(0)
for i in range(N):
    if i%2==0 and S_int[i]==0:
        S_int[i]=1
        cnt_1+=1
    elif i%2==1 and S_int[i]==1:
        S_int[i]=0
        cnt_1+=1
for i in range(N):
    if i%2==0 and S_int[i]==1:
        S_int[i]=0
        cnt_2+=1
    elif i%2==1 and S_int[i]==0:
        S_int[i]=1
        cnt_2+=1
print(min(cnt_1,cnt_2))

Submission status: Runtime Error

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


count = 0
S = list(input())
if len(S) >= 3 and 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(len(S)-1):
        if S[i] == S[i+1] == S[i+2]:
            S[i+1] = Change(S[i+1])
            count += 1
        if S[i] == S[i + 1]:
            S[i + 1] = Change(S[i + 1])
            count += 1
print(count)

Submission status: Runtime Error

Solution code:
S = list(map(int, input()))
 
S_1 = [S[::i] for i in range(len(S)//2) if S[::i]==1]
S_0 = [S[::i] for i in range(len(S)//2) if S[::i]==0]
 
S_min = min(len(S_1), len(S_0))
 
print(2*S_min)

Submission status: Runtime Error

Solution code:
S=[]
for char in input():
  S.append(char)
  
#route 1
C1=0
for i in range(len(S)):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

S=[]
for char in input():
  S.append(char)
#route 2
C2=0
for n in range(len(S)):
  if n%2==0:
    if S[n]==0:
      S[n]=1
      C2+=1
  else:
    if S[n]==1:
      S[n]=0
      C2+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Runtime Error

Solution code:
S=[]
for char in input():
  S.append(char)

#route 2
C2=0
for n in range(int(len(S))+1):
  if n%2==0:
    if S[n]==0:
      S[n]=1
      C2+=1
  else:
    if S[n]==1:
      S[n]=0
      C2+=1
      
#route 1
C1=0
for i in range(int(len(S))+1):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Runtime Error

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

o = 0

for i in range(p):
    if i % 2 == 0:
        if n[i] == '0':
            o= o+1
            
    else:
        if n[i] =='1':
            o= o+1

if ans>p/2:
    print(p-o)
else:
    print(o)

Submission status: Runtime Error

Solution code:
S=[]
for char in '000':
  S.append(char)

#route 2
C2=0
for n in range(int(len(S))+1):
  if n%2==0:
    if S[n]==0:
      S[n]=1
      C2+=1
  else:
    if S[n]==1:
      S[n]=0
      C2+=1
      
#route 1
C1=0
for i in range(int(len(S))+1):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Runtime Error

Solution code:
S=[]
for char in '000':
  S.append(char)

#route 2
C2=0
for n in range(len(S)+1):
  if n%2==0:
    if S[n]==0:
      S[n]=1
      C2+=1
  else:
    if S[n]==1:
      S[n]=0
      C2+=1
      
#route 1
C1=0
for i in range(len(S)+1):
  if i%2==0:
    if S[i]==1:
      S[i]=0
      C1+=1
  else:
    if S[i]==0:
      S[i]=1
      C1+=1

if C1>=C2:
  print(C1)
else:
  print(C2)

Submission status: Runtime Error

Solution code:
s = list(input())
int pattern_a_count = 0
int pattern_b_count = 0

for index, value in enumerate(s):
  if index % 2 =0:
    if value == 0:
      pattern_a_count += 1
  if index % 2 =1:
    if value == 1:
      pattern_a_count += 1
      
for index, value in enumerate(s):
  if index % 2 =0:
    if value == 1:
      pattern_b_count += 1
  if index % 2 =1:
    if value == 0:
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(pattern_a_count)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	s=io()
	num_st=[0,0]
	for i, c in enumerate(list(s)):
		if int(c) == i % 2:
			num_st[0]+=1
		else:
			num_st[1]+=1
	
	return min(num_st)

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Submission status: Runtime Error

Solution code:
s = list(input())
int pattern_a_count = 0
int pattern_b_count = 0

for index, value in enumerate(s):
  if index % 2 =0:
    if value == "0":
      pattern_a_count += 1
  if index % 2 =1:
    if value == "1":
      pattern_a_count += 1
      
for index, value in enumerate(s):
  if index % 2 =0:
    if value == "1":
      pattern_b_count += 1
  if index % 2 =1:
    if value == "0":
      pattern_b_count += 1
      
res = pattern_b_count
if pattern_a_count <= pattern_b_count:
  res = pattern_a_count
print(pattern_a_count)

Submission status: Runtime Error

Solution code:
s = list(input())
int pattern_a_count = 0
int pattern_b_count = 0

for index, value in enumerate(s):
  if index % 2 =0:
    if value == "0":
      pattern_a_count += 1
  if index % 2 =1:
    if value == "1":
      pattern_a_count += 1
      
for index, value in enumerate(s):
  if index % 2 =0:
    if value == "1":
      pattern_b_count += 1
  if index % 2 =1:
    if value == "0":
      pattern_b_count += 1

Submission status: Runtime Error

Solution code:
S = int(input())
S_list = [int(x) for x in list(str(S))]
S_str = str(S)
S_list_1 = S_list.split('0')
S_list_2 = S_list.split('1')
output = 0

for i in range(len(S_list_1)):
  output += int(S_list_1[i]) // 2
for i in range(len(S_list_2)):
  output += int(S_list_2[i]) // 2
  
print(output)

Submission status: Runtime Error

Solution code:
S = int(input())
S_list = [int(x) for x in list(str(S))]
S_str = str(S)
S_list_1 = input().split('0')
S_list_2 = input().split('1')
output = 0

for i in range(len(S_list_1)):
  output += int(S_list_1[i]) // 2
for i in range(len(S_list_2)):
  output += int(S_list_2[i]) // 2
  
print(output)

Submission status: Runtime Error

Solution code:
char_list = list(input())
count1 = 0
count2 = 0
if len(char_list) == 1:
    print(count)
else:
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "0":
                continue
            else:
                count1 += 1
        else:
            if char_list[i] is "1":
                continue
            else:
                count1 += 1
    for i in range(len(char_list)):
        if i % 2 == 0:
            if char_list[i] is "1":
                continue
            else:
                count2 += 1
        else:
            if char_list[i] is "0":
                continue
            else:
                count2 += 1
print(min(count1,count2))

Submission status: Runtime Error

Solution code:
Tiles=input()
N_len=len(Tiles)
if N_len == 1:
    print("0")
    exit
    
cur=Tiles[0]

change=0
for i in range(1, N_len):
    if cur is TilePuttern[i]:
        change+=1
        cur = "0" if Tiles[i] == 0 else "1"
    else:
        cur=Tiles[i]
        
change_reverse=0
cur=Tiles[N_len-1]
for i in reversed(range(1, N_len-1)):
    if cur is TilePuttern[i]:
        change_reverse+=1
        cur = "0" if Tiles[i] == 0 else "1"
    else:
        cur=Tiles[i]

print(change if change < change_reverse else change_reverse)

Submission status: Runtime Error

Solution code:
char_list = list(input())
count1 = 0
count2 = 0
if len(char_list) == 1:
    print(count)
else:
    for i in char_list:
        if i % 2 == 0
            if char_list[i] is "0"
                continue
            else:
                count1 += 1
        else:
            if char_list[i] is "1"
                continue
            else:
                count1 += 1
    for i in char_list:
        if i % 2 == 0
            if char_list[i] is "1"
                continue
            else:
                count2 += 1
        else:
            if char_list[i] is "0"
                continue
            else:
                count2 += 1
print(min(count1,count2))

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split('')))
print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

s=input()
l=list(s)
l=list(map(int, l))
ans=0
if l[0] == l[1] and l[0] != l[2]:
    ans+=1
    if l[0] == 1: l[0] = 0 
    else: l[0] = 1    
for i in range(2, len(s)):
    if l[i] == l[i-1] and l[i] != l[i-2]:
        ans+=1
        if l[i] == 1: l[i] = 0 
        else: l[i] = 1
    elif l[i] == l[i-1] and l[i] == l[i-2]:
        ans+=1
        if l[i-1] == 1: l[i-1] = 0
        else: l[i-1] = 1
print(ans)

Submission status: Runtime Error

Solution code:
string=list(input())
if int(string[1])==0:
  c=1
else:
  c=0
a=0
for s in string:
  if int(s)==0 and c==1:
    c-=1
  elif int(s)==0 and c==0:
    c+=1
    a+=1
  elif int(s)==1 and c==0:
	c+=1
  elif int(s)==1 and c==1:
	c-=1
    a+=1
print(a)

Submission status: Runtime Error

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

S = list(input().replace('\n',''))
S = map(int, S)
prev = S[0]
ans = 0
for i in range(1, len(S)-1):
  cur = S[i]
  if prev ^ cur == 0:
    ans += 1
    prev = 2 + ~cur
  else:
    prev = cur

print(ans)

Submission status: Runtime Error

Solution code:
string=list(input())
if int(string[1]==0):
  c=1
else:
  c=0
a=0
for s in string:
  if int(s)==0 and c==1:
    c-=1
  elif int(s)==0 and c==0:
    c+=1
    a+=1
  elif int(s)==1 and c==0:
	c+=1
  elif int(s)==1 and c==1:
	c-=1
    a+=1
print(a)

Submission status: Runtime Error

Solution code:
l = len(colors)
count1 = 0
for i in range(l):
	if int(colors[i]) == (i % 2):
		count1 += int(colors[i])
print(min(count1, l-count1))