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:
s = input()
oddone = ''
evenone = ''

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

def diffCount(s1, s2):
    count = 0
    if len(s1) != len(s2):
	print('error')
	return

    for i in range(len(s1)):
        if s1[i] != s2[i]:
	    count += 1

    return count

print(min(diffCount(s, oddone), diffCount(s, evenone)))

Submission status: Runtime Error

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_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]
else:
  if 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: Runtime Error

Solution code:
S=input()

b=0,w=0
for i in range(len(S)):
  if S[i]==str(i%2):
    b+=1
  else:
    w+=1
    
print(b if b<w else w)

Submission status: Runtime Error

Solution code:
s = list(input())

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

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

    prev = s[i]

print(count)

Submission status: Runtime Error

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

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(N)]

nl = []
for i in range(N):
    for j in range(l[i][1]):
        nl.append(l[i][0])
    
sorted_nl = sorted(nl)

ans = 0
for i in range(M):
    ans += sorted_nl[i]
    
print(ans)

Submission status: Runtime Error

Solution code:
 = list(input())
count = 0
n = len(s)
if n % 2 == 0:
    for i in range(0,int((n/2)-1)):
        if s[(2*i)+1] == "0":
            count = count + 1
    for i in range(0,int((n/2)-1)):
        if s[2*i] == "1":
            count = count + 1
else:
    for i in range(0,int((n-1)/2)):
        if s[2*i] == "0":
            count = count + 1
    for i in range(0,int(((n-1)/2)-1)):
        if s[2*i + 1] == "1":
            count = count + 1
count2 = n - count
print(min(count,count2))

Submission status: Runtime Error

Solution code:
import sys

def judge(string):
    mem = ""
    for char in string:
        if mem == char:
            return False
        mem = char

    return True


def main():
    sinputl = sys.stdin.readline

    input = sinputl().strip()
    length = len(input)
    input = int(input, base=2)

    paint = [length]

    for i in range(2 ** length):
        status = input ^ i
        print(bin(status)[2:].zfill(length))
        if judge(bin(status)[2:].zfill(length)):
            paint.append(bin(i).count('1'))

        
    print(min(paint))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
S=input()
N=len(S)
A=len([_ for i in range(N) if str(i%2)==S[i]])
print(min(A,N-A))

Submission status: Runtime Error

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

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

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ S[i]:
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))

Submission status: Runtime Error

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

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

count_0 = 0
count_1 = 0

for i in range(len(S)):
	if (i % 2 == 1) ^ S[i]:
		count_0 += 1
	else:
		count_1 += 1
		
print(min(count_0, count_1))

Submission status: Runtime Error

Solution code:
s = input()
x, count0, count1 = 0
for i in s:
    count0 = count0+1 if i==str(x) else count0
    x = int(not(x))
x = 1
for i in s:
    count1 = count1 + 1 if i == str(x) else count1
    x = int(not(x))
print(min(count0, count1))

Submission status: Runtime Error

Solution code:
import math
s=str(input())
b=''
c=0
d=math.ceil(len(s)/2)
if len(s) == 1:
    print(0)
elif s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Submission status: Runtime Error

Solution code:
s=str(input())
b=''
c=0
d=int(round(len(s)/2))
if len(s) == 1:
    print(0)
elif s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
if len(s) != len(b):
    b = b[:-1]
    print(b)
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Submission status: Runtime Error

Solution code:
s=str(input())
a=0
b=''
c=0
d=round(int(len(s)/2))
if len(s) == 1:
    print(0)
elif len(s)%2 ==1:
    for v in range(d+1):
        if v < d and s[v+a]== '0':
            b+='01'
        elif v < d and s[v+a] =='1':
            b +='10'
        elif b[-1] == '0':
            b+= '1'
        else:
            b+= '0'
        a+=1
elif s[0]=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Submission status: Runtime Error

Solution code:
s=str(input())
a=[0]
b=''
c=0
d=int(len(s)/2)
if d == 0:
    print(0)
elif a=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Submission status: Runtime Error

Solution code:
s=str(input())
a=[0]
b=''
c=0
d=int(len(s)/2)
if a=='0':
    for i in range(d):
        b+="01"
else:
    for i in range(d):
        b+="10"
for u in range(len(s)):
    if s[u] != b[u]:
        c+=1
print(c)

Submission status: Runtime Error

Solution code:
S = input()
s1 = '0'
s2 = '1'
c1 = 0
c2 = 0

for i in range(len(S)):
    if i == 0:
        s1 = '0'
        s2 = '1'
    elif i % 2 == 1:
        s1 += 1
        s2 += 0
    else:
        s1 += 0
        s2 += 1

for i in range(len(S)):
    if S[i] == s1[i]:
        c2 += 1
    else:
        c1 += 1

print(min(c1, c2))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 09:24:23 2019

@author: avina
"""

s = input().strip()

k = s[0]
cnt_1 = 0;cnt_2 = 1
for i in range(1,len(s)):
    if k == s[i] and i%2 !=0:
        cnt_1+=1
    
    if i%2 ==0 and k != s[i]:
        cnt_1+=1
        e =s[i]

for i in range(1,len(s)):
    
    if e != s[i] and i%2 ==0:
        cnt_2 +=1
    
    if e == s[i] and i%2 != 0:
        cnt_2+=1

print(min(cnt_1, cnt_2))

Submission status: Runtime Error

Solution code:
s = input()

cnt_0 = 0
cnt_1 = 0
for i in range(0, len(s), 2):
  if s[i] == '0':
    cnt_0 += 1
  else:
    cnt_1 += 1

if cnt_0 > cnt_1:
  start = '0'
  second = '1'
elif cnt_0 == cnt_1:
  if s[len(s)-1] == '1':
    start = '0'
    second = '1'
  else:
    start = '1'
    second = '0'
else:
  start = '1'
  secont = '0'
cnt = 0
for i in range(0, len(s)):
  if not i%2:
    if s[i] != start:
      cnt += 1
  else:
    if s[i] != second:
      cnt += 1
print(cnt)

Submission status: Runtime Error

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

L_s = sorted(L)
A = sum(L_s[0::2])

print(A)

Submission status: Runtime Error

Solution code:
s = input()
if len(s) == 1:
    print(0)
else:
    r = 0
    f = s[0]
    for i in s[1:]:
        if i == f:
            r += 1
        	f = '1' if i == '0' else '0'
    	else:
        	f = i
    print(r)

Submission status: Runtime Error

Solution code:
s = input()
if len(s) == 1:
    print(0)
else:
    r = 0
    f = s[0]
    for i in s[1:]:
        if i == f:
            r += 1
        	f = '1' if i == '0' else '0'
        f = i
    print(r)

Submission status: Runtime Error

Solution code:
s = input()
x = [s[j] for j in range(0,len(s10))]
x.insert(0,'2')
count = 0
for j in range(1,len(x)):
    if x[j] == '0' and x[j] == x[j-1]:
        x[j] = '1'
        count = count + 1
    elif x[j] == '1' and x[j] == x[j-1]:
        x[j] = '0' 
        count = count + 1
print(count)

Submission status: Runtime Error

Solution code:
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*len(S)//2
else:
  sample = unit*len(S)//2+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
if len(S) % 2 == 0:
  whiteS = '01'*len(S)//2
  blackS = '10'*len(S)//2
else:
  whiteS = '01'*len(S)//2 + '0'
  blackS = '10'*len(S)//2 + '1'
  
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*len(S)//2
else:
  sample = unit*len(S)//2+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)

Submission status: Runtime Error

Solution code:
S = input()
back = 0
for i in S:
    if i == back:
        back = '0' if i=='1' else '1'
        n += 1
    else:
        back = S

print(n);

Submission status: Runtime Error

Solution code:
a  = input()
s = 0
t = 0
k = ["0","1"]
for n,i in enumerate(a):
  if i != k[(n%2)]:
    s+=1
  if i != k[(n%2)+1]:
    t+=1
print(min(s,t))

Submission status: Runtime Error

Solution code:
gen = get_input()

S = list(input())

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

count2 = 0
s2 = S[:]
for i in reversed(range(len(S)-1)):
    if s2[i] == s2[i +1]:
        s2[i] = '0' if s2[i+1] == '1' else '1'
        count2 += 1

print(min(count, count2))

Submission status: Runtime Error

Solution code:
List=input()
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for i,j = zip(List,a):
	if i != j:
      c1 += 1

for i,j = zip(List,b):
	if i != j:
      c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)

Submission status: Runtime Error

Solution code:
List=[int(i) for i in input().split()] 
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for i,j = zip(List,a):
	if i != j:
      c1 += 1

for i,j = zip(List,b):
	if i != j:
      c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)

Submission status: Runtime Error

Solution code:
List=list(map(int,input().split()))
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for i,j = zip(List,a):
	if i != j:
      c1 += 1

for i,j = zip(List,b):
	if i != j:
      c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)

Submission status: Runtime Error

Solution code:
List=list(map(int,input().split()))
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for i,j = zip(List,a):
	if i != j:
      c1 += 1

for i,j = zip(List,b):
	if i != j:
      c2 += 1

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

Submission status: Runtime Error

Solution code:
List=list(map(int,input().split()))
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for i,j = zip(List,a):
	if i != j:
      c1 += 1

for i,j = zip(List,b):
	if i != j:
      c2 += 1

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

Submission status: Runtime Error

Solution code:
S = input()
s = list(map(int, S))
t = s.copy()
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1

for i in t:
    if t[i]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))

Submission status: Runtime Error

Solution code:
S = input()
s = list(map(int, S))
t = s.copy()
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1

for i in t:
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))

Submission status: Runtime Error

Solution code:
S = input()
s = list(map(int, S)
t = s.copy()
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1

for i in t:
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))

Submission status: Runtime Error

Solution code:
s = list(map(int, input().split()))
t = s.copy()
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1

Submission status: Runtime Error

Solution code:
s = list(map(int, input().split()))
t = s.copy()
x = 0
y = 1

if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	x +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	x +=1

for i in t:
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	y +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	y +=1

print(min([x,y]))

Submission status: Runtime Error

Solution code:
s = list(map(int, input().split()))
t = s.copy()
cnta = 0
cntc = 0
ans = [cnta, cntc]
if t[0] == 0:
    t[0]=1
else:
    t[0]=0

for i in s:
    if s[i+1]==0 and s[i+1] == s[i]:
    	s[i+1]=1
    	cnta +=1
    elif s[i+1]==1 and s[i+1]==s[i]:
    	s[i+1]=0
    	cnta +=1

for i in t:
    if t[i+1]==0 and t[i+1] == t[i]:
    	t[i+1]=1
    	cntc +=1
    elif t[i+1]==1 and t[i+1]==t[i]:
    	t[i+1]=0
    	cntc +=1

print(min(ans))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = list(int, map(input().split()))
ans1 = 0
ans2 = 0
for i in range (len(S)-1):
  if i % 2 == 0:
    if S[i] == 0:
      ans1 += 1
  else:
    if S[i] == 1:
      ans1 += 1
for i in range(len(S)-1):
  if i % 2 == 0:
    if S[i] == 1:
      ans2 += 1
  else:
    if S[i] == 0:
      ans2 += 1
print(min(ans1, ans2))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main(n):
	odd = "1"
	even= "0"
	if(n[0] =="0"):
		# zero mode
		odd = "0"
		even= "1"
	a = sum((((i % 2 != 0) and n[i] == odd)) for i in range(1, len(n),2))
	b = sum((((i % 2 == 0) and n[i] == even)) for i in range(0, len(n),2))
	return sum(a,b)

print(main(input()))

Submission status: Runtime Error

Solution code:
s = [int(x) for x in list(input())]
a = [x%2 for x in range(len(s))]
b = [(1 - x%2) for x in range(len(s))]
c1=0
c2=0
for i in range(len(s)):
    if a[i] != s[i]:
        c1 += 1
    if b[i] != s[i]:
        c2 += 1

p

Submission status: Runtime Error

Solution code:
def main(n):
	n = input()
	r = 0
	f = n[0]
	if(f =="0"):
		# zero mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="1"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="0"):
					r+=1
	else:
		# one mode
		for i in range(1, len(n)):
			if(i % 2 == 0): # 偶
				# 1
				if(n[i]=="0"):
					r+=1
			else: # basic
				# 0
				if(n[i]=="1"):
					r+=1
	# sum(result)
	return r

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

Submission status: Runtime Error

Solution code:
data = input()
a,b = data.split()
if(a==b):
  print(a+b)
elif(a>b):
  print(2*a-1)
else:
  print(2*b-1)

Submission status: Runtime Error

Solution code:
cnt_st0 = 0
cnt_st1 = 0
in_str = str(input())
for i, m in enumerate(in_str):
  if i % 2 == 0:
    if m == '0':
      cnt_st1 += 1
    else:
      cnt_st0 += 1
  else:
    if m == '0':
      cnt_st0 += 1
    else:
      cnt_st1 += 1
      
print(min(cnt_st0, cnt_St1))

Submission status: Runtime Error

Solution code:
s = '9' + input()
t = len(s) - 1
A = '9' + '01'*int(t/2) + '0'*int(t%2)
B = '9' + '10'*int(t/2) + '1'*int(t%2)

s = int(s)
A = int(A)
B = int(B)

sa = s^A
sa = sa.count('1')
sb = s^B
sb = sb.count('1')

if sa >= sb:
    print(sa)
else:
    print(sb)

Submission status: Runtime Error

Solution code:
s = '9' + input()
t = len(s)
A = '9' + '01'*int(t/2) + '0'*int(t%2)
B = '9' + '10'*int(t/2) + '1'*int(t%2)

s = int(s)
A = int(A)
B = int(B)

sa = s^A
sa = sa.count('1')
sb = s^B
sb = sb.count('1')

if sa >= sb:
    print(sa)
else:
    print(sb)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = input()
wb = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
bw = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

cnt_wb = 0
cnt_bw = 0
for i in range((len(S))):
  if wb[i] != S[i]:
    cnt_wb += 1
  if bw[i] != S[i]:
    cnt_bw += 1
    
print (min(cnt_eb, cnt_bw))

Submission status: Runtime Error

Solution code:
S = input()
wb = ["0" if i % 2 == 0 else "1" for i in range(len(S))]
bw = ["1" if i % 2 == 0 else "0" for i in range(len(S))]

cnt_wb = 0
cnt_bw = 0
for i in range((len(S))):
  if w_b[i] != S[i]:
    cnt_wb += 1
  if bw[i] != S[i]:
    cnt_bw += 1
    
print (min(cnt_eb, cnt_bw))

Submission status: Runtime Error

Solution code:
s=input()
key1=0
key2=0
for i in len(s):
  if s[i]=='0':
    key1++
for i in len(s):
  if s[i]=='1':
    key2++
print(min(key1,key2))

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main(void){
  string ref1 = "";
  string ref2 = "";
  string a;
  cin >> a;

  for (int i = 0;i < a.length(); i++){
    if (i %2 ==0){
      ref1 = "1" + ref1;
      ref2 = "0" + ref2;
    }
    else{
      ref2 = "1" + ref2;
      ref1 = "0" + ref1;
      // ref2 = ref2 + pow(10, i);
    }
  }

  int count1 = 0;
  int count2 = 0;

  for (int i = 0; i < ref1.length(); i++){
    if(ref1[i] != a[i]){
      count1 = count1 + 1;
    }  
  }  

  for (int i = 0; i < ref2.length(); i++){
    if(ref2[i] != a[i]){
      count2 = count2 + 1;
    }  
  }

  if (count1 < count2){
    cout << count1 << endl;
  }
  else{
    cout << count2 << endl;
  }
}

Submission status: Runtime Error

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

middle = S[1:-1]
white = middle.count('.')
black = middle.count('#')

if (S.count('.') == 0 or S.count('#') == 0) or ((S.count('.') == 1 and S[0] == '.') or (S.count('#') == 1 and S[-1] == '#')):
  print('0')
else:
  if white < black:
    if S[-1] == '.':
      print(white+1)
    else:
      print(white)
  else:
    if S[0] == '#':
      print(black+1)
    else:
      print(black)

Submission status: Runtime Error

Solution code:
#coding:utf-8

S = input()

N = len(S)
ans = 0
SR = []
if S[0] == '0':
	for i in range(int(N/2)):
		SR.append('0')
		SR.append('1')
else:
	for i in range(int(N/2)):
		SR.append('1')
		SR.append('0')

for i in range(N):
	if S[i] != SR[i]:
		ans += 1
		
print(ans)

Submission status: Runtime Error

Solution code:
def change(i):
  if i == "0":
    return False
  else:
    return True

def tyle(s, r, k):
  result = r
  for i in range(k, len(s) - 1, 1):
    if s[i] == s[i+1]:
      s[i+1] = not s[i+1]
      result += 1
      index = i
      break
  else:
    return result
  return tyle(s, result, index)

s = [change(i) for i in input()]
print(tyle(s, 0, 0))

Submission status: Runtime Error

Solution code:
def change(i):
  if i == "0":
    return False
  else:
    return True

def tyle(s, r):
  result = r
  for i in range(len(s) - 1):
    if s[i] == s[i+1]:
      s[i+1] = not s[i+1]
      result += 1
      break
  else:
    return result
  return tyle(s, result)

s = [change(i) for i in input()]
print(tyle(s, 0))

Submission status: Runtime Error

Solution code:
s = raw_input()
n = len(s)
a = 0
b = 0
for i in range(n):
	if ((i%2 == 0) and (s[i] == '0')):
		a += 1
	if ((i%2 == 1) and (s[i] == '1')):
		a += 1
	if ((i%2 == 0) and (s[i] == '1')):
		b += 1
	if ((i%2 == 1) and (s[i] == '0')):
		b += 1
print(min(a,b))

Submission status: Runtime Error

Solution code:
import math
import os
import random
import re
import sys
from collections import defaultdict

sys.stdin = open('input.in', 'r')
sys.stdout = open('output.out', 'w') 

def onezero(a):
	count = 0
	for i in range(0, len(a), 2):
		if a[i] == 0:
			count += 1
	for i in range(1, len(a), 2):
		if a[i] == 1:
			count += 1
	return count

def zeroone(a):
	count = 0
	for i in range(0, len(a), 2):
		if a[i] == 1:
			count += 1
	for i in range(1, len(a), 2):
		if a[i] == 0:
			count += 1
	return count


def count(n):
	return min(onezero(n),zeroone(n))

if __name__ == '__main__':
	N = [int(d) for d in input()]
	print(count(N))

Submission status: Runtime Error

Solution code:
S = input()
li = []
for s in S:
    li.append(int(s))

count = 0
first = li[0]i
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] != first:
            count += 1
    else:
        if li[i] == first:
            count += 1

count2 = 1
for i in range(len(li)):
    if i % 2 == 0:
        if li[i] == first:
            count2 += 1
    else:
        if li[i] != first:
            count += 1

print(min(count,count2))

Submission status: Runtime Error

Solution code:
num = input()
num_char = list(num)
num_char2 = list(num)
if num_char[0] == "0":
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 0
		num_char[i + 1] = 1
else:
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 1
		num_char[i + 1] = 0
        
cnt = 0
for i in range(len(num_char)):
  if str(num_char[i]) != num_char2[i]:
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
c2,c3 = 0,0
def ret(a,b,c):
  global c2,c3
  if a == b:
    if c == 2:
      c2 += 1
    else:
      c3 += 1
    if b == "0":
      return "1"
    else:
      return "0"
  else:
    return b
S = input()
S2,S3 = list(S),list(S)
default = S2[0]
for j,k in enumerate(S2):
  if j == 0:
    continue
  S2[j] = ret(S2[j-1],k,2)
  print(S2,c2)
for j,k in enumerate(S3):
  if j == 0:
    S3[0] = ret(default,S3[0],3)
  S3[j] = ret(S3[j-1],k,3)
  print(S3,c3)
print(c2 if c2 <= c3 else c3)

Submission status: Runtime Error

Solution code:
def ret(a,b,c):
  global c2,c3
  if a == b:
    if b == "0":
      return "1"
   	else:
      return "0"
    if c == 2:
      c2 += 1
    else:
      c3 += 1
  else:
    return b
S = input()
S2,S3 = list(S),list(S)
c2,c3 = 0,0
default = S2[0]
for j,k in enumerate(S2):
  if j == 0:
    continue
  S2[j] = ret(S2[j-1],k,2)
for j,k in enumerate(S3):
  if j == 0:
    S3[0] = ret(default,S3[0])
  S3[j] = ret(S3[j-1],k,3)
print(c2 if c2 >= c3 else c3)

Submission status: Runtime Error

Solution code:
s = list(map(int, input().split()))
l = len(s)

s1 = [ ((-1)^i + 1)/2 for i in range(l)]
s2 = [ ((-1)^(i+1) + 1)/2 for i in range(l)]

m = 0
n = 0
for i in range(l):
  m += (s[i] - s1[i])^2
  n += (s[i] - s2[i])^2

print(min(m,n))

Submission status: Runtime Error

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

s1 = [ ((-1)^i + 1)/2 for i in range(l)]
s2 = [ ((-1)^(i+1) + 1)/2 for i in range(l)]

m = 0
n = 0
for i in range(l):
  m += (s[i] - s1[i])^2
  n += (s[i] - s2[i])^2

print(min(m,n))

Submission status: Runtime Error

Solution code:
num = input()
num_char = list(num)
if num_char[0] == "0":
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 0
		num_char[i + 1] = 1
else:
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 1
		num_char[i + 1] = 0
for i in num_char:
	print(i, end = "")

Submission status: Runtime Error

Solution code:
num = input()
num_char = list(num)
if num_char[0] == "0":
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 0
		num_char[i + 1] = 1
else:
	for i in range(0, int(len(num_char)),2):
		num_char[i] = 1
		num_char[i + 1] = 0
for i in num_char:
  print(i, end = "")

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)
s = bin(int(s, 2))
s_10 = '1' * (n % 2) + '01' * (n // 2)
s_01 = '0' * (n % 2) + '10' * (n // 2)
s_10 = bin(int(s_10, 2))
s_01 = bin(int(s_01, 2))
r = s ^ s_01
l = s ^ s_10
print(min(r.count('1'), l.count('1')))

Submission status: Runtime Error

Solution code:
s=input()
bf='01'*(len(s)//2)
wf='10'*(len(s)//2)
if len(s)%2==1:
  bf+='0'
  wf+='1'
ans=min(len([x!=y if x,y in zip(list(s),list(bf))]),len([x!=y if x,y in zip(list(s),list(wf))]))
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
bf='01'*(len(s)//2)
wf='10'*(len(s)//2)
if len(s)%2==1:
  bf+='0'
  wf+='1'
ans=min(len([x!=y if x,y in zip(s,bf)]),len([x!=y if x,y in zip(s,wf)]))
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
bf='01'*(len(s)//2)+('0'*(len(s)&1))
wf='10'*(len(s)//2)+('1'*(len(s)&1))
ans=min(len([x!=y if x,y in zip(s,bf)]),len([x!=y if x,y in zip(s,wf)]))
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
bf='01'*(len(s)//2)+'0'*(len(s)&1)
wf='10'*(len(s)//2)+'1'*(len(s)&1)
ans=min(len([x!=y if x,y in zip(s,bf)]),len([x!=y if x,y in zip(s,wf)]))
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
def func():
    from collections import Counter as c
    ev,od = [],[]
    for i in range(len(S)):
        ev.append(S[i]) if i%2 == 0 else 0
        od.append(S[i]) if i%2 == 1 else 0
    ev = c(ev).most_common()
    od = c(od).most_common()
    if len(od) == 0:
        return 0
    if ev[0][0] != od[0][0]:
        return len(S)-ev[0][1]-od[0][1]
    else:
        if len(ev) == 1 or len(od) == 1:
            return len(S)//2
        else:
            return max(ans,len(S)-ev[0][1]-od[1][1],len(S)-ev[1][1]-od[0][1])
print(func())

Submission status: Runtime Error

Solution code:
S = input()
#複数の定義はまとめられる
cntA, cntB = 0, 0

for i, t in enumerate(S):
    if i%2 == 0:
        if t == '0': #標準入力Sはstr型だから0ではなく'0'のようにする
            cntA += 1
        else:
            cntB += 1
    else:
        if t == '1':
            cntA += 1
        else:
            cntB += 1
print (min(ci, c2))

Submission status: Runtime Error

Solution code:
import sys
import math

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

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

Solution code:
import math
n = int(input())
num = [int(input()) for i in range(5)]
print(int(4+math.ceil(n/min(min(num)))))

Submission status: Runtime Error

Solution code:
N = int(input())
H = [int(x) for x in input().split()]
count = 0
for i in range(N):
  for j in range(i):
    if H[i] < H[j]:
      break
  else:
      count+=1
print(count)

Submission status: Runtime Error

Solution code:
n = input()
c1 = c2 = 0
l = len(n)
c1 = l - len([i for i in l[0::2] if i == "0"]) - len([i for i in l[1::2] if i == "1"])
c2 = l - len([i for i in l[0::2] if i == "1"]) - len([i for i in l[1::2] if i == "0"])

print(min(c1,c2))

Submission status: Runtime Error

Solution code:
n = input()
c1=c2=0
l = len(n)
c1 = l - len([i for i in l[0::2] if i == "0"]) - len([i for i in l[1::2] if i == "1"])
c2 = l - len([i for i in l[0::2] if i == "1"]) - len([i for i in l[1::2] if i == "0"])

print(min(c1,c2))

Submission status: Runtime Error

Solution code:
n = input()
c1=c2=0
l = len(n)
c1 = n - len([i for i in l[0::2] if i == "0"]) - len([i for i in l[1::2] if i == "1"])
c2 = n - len([i for i in l[0::2] if i == "1"]) - len([i for i in l[1::2] if i == "0"])

print(min(c1,c2))

Submission status: Runtime Error

Solution code:
n = input()
c1=c2=0
l = len(n)
c1 = n - (len([i for i in l[0::2] if i == "0"])) - (len([i for i in l[1::2] if i == "1"]))
c2 = n - (len([i for i in l[0::2] if i == "1"])) - (len([i for i in l[1::2] if i == "0"]))

print(min(c1,c2))

Submission status: Runtime Error

Solution code:
# coding=utf-8

tile = input()

cor_list = ["10"*50000, "01"*50000]

diff_1 = int("0b"+tile, 2) ^ int("0b"+cor_list[0][:len(tile)], 2)  
diff_2 = int("0b"+tile, 2) ^ int("0b"+cor_list[1][:len(tile)], 2)

score_1 = sum([int(s) for s in bin(diff_1)[2:]])
score_2 = sum([int(s) for s in bin(diff_2)[2:]])
print(min[score_1, score_2])

Submission status: Runtime Error

Solution code:
S = input().rstrip()
s = list(S)
print(s)
N = len(S)
c = 0
if N == 1:
  print(0)
else:
  for i in range(1,N)
  	if S[i-1] == '0' and S[i] == '0':
      S[i] = 1
      c +=1
    elif S[i-1] == '1' and S[i] == '1':
      S[i] = 0
      c +=1
print(c)

Submission status: Runtime Error

Solution code:
import math
number = int(input())
if (number != 0):
    digit = int(math.log10(number))
else :
    digit=0

a=[]
while(True):
    if (number%10==0):
        a.append("0")
    elif (number%10!=0):
        a.append("1")
    
    number= int(number/10)
    if (number == 0):
        break
b= []
i = digit

while(i !=-1):
    b.append(a[i])
    i -= 1
print(b)

count1=0
count2=0
for j in range(0,digit+1):
    if (j % 2 ==0):
        if b[j]=="1":
            count1 +=1 
    elif (j %2 ==1):
        if b[j]=="0":
            count1 +=1
for j in range(0,digit):
    if (j % 2 ==0):
        if b[j]=="0":
            count2 +=1 
    elif (j %2 ==1):
        if b[j]=="1":
            count2 +=1
print(min(count1,count2))