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:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(10**8)

def operation(s,memo=-1,ans=0):
    if len(s) <= 0:
        return ans
    elif s[0] == memo == "0": #変えるパターン
        return operation(s[1:],"1",ans+1)
    elif s[0] == memo == "1": #変えるパターン
        return operation(s[1:],"0",ans+1)
    else:
        return operation(s[1:],s[0],ans)

def solve(s):
    return min(operation(s,"0"),operation(s,"1"))

def main():
    S = input()
    print(solve(S))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

import sys
sys.setrecursionlimit(10**10)

def operation(s,memo=-1,ans=0):
    if len(s) <= 0:
        return ans
    elif s[0] == memo == "0": #変えるパターン
        return operation(s[1:],"1",ans+1)
    elif s[0] == memo == "1": #変えるパターン
        return operation(s[1:],"0",ans+1)
    else:
        return operation(s[1:],s[0],ans)

def solve(s):
    return min(operation(s,"0"),operation(s,"1"))

def main():
    S = input()
    print(solve(S))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys

rr = lambda: sys.stdin.readline().rstrip()

s = rr()
cnt = 0
for i in range(len(s) - 1):
  si = s[i]
  si1 = s[i+1]
  if si & si1:
    continue
  else:
    s[i+1] = si
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
st = list(input())
s = [int(i) for i st]

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s=input()
l = []
l.append(s[0])
c = 0
for i in range(1, n):
  if s[i] == l[i-1]:
    c += 1
    l.append(str(abs(int(s[i])-1)))
  else:
    l.append(s[i])
print(c)

Submission status: Runtime Error

Solution code:
s=input()
l = []
l.append(s[0])
c = 0
for i in range(1, n):
  if s[i] == l[i-1]:
    c += 1
    l.append(str(-(int(s[i])-1)))
  else:
    l.append(s[i])
print(c)

Submission status: Runtime Error

Solution code:
# ABC124C

s = input()
s = [int(t) for t in list(s)]
repaint = 0
for i in range(1, len(s)):
    if s[i-1] == s[i]:
        repaint += 1
        s[i] = 1 - s[i]
paint(repaint)

Submission status: Runtime Error

Solution code:
S = input()
S1 = ''
S2 = ''
if i in range(len(S)):
    if i % 2 ==0 :
        S1 += '0'
        S2 += '1'
    else :
        S1 += '1'
        S2 += '0'
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S2[i]:
        min2 += 1 
print(min(min1,min2))

Submission status: Runtime Error

Solution code:
S = input()
S1 = ''
S2 = ''
if i in range(len(S)):
    if i % 2 ==0 :
        S1 += '0'
        S2 += '1'
    else :
        S1 += '1'
        S2 += '0'
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min2 += 1 
print(min(min1,min2))

Submission status: Runtime Error

Solution code:
S = list(input())
S1 = []
S2 = []
if i in range(len(S)):
    if i % 2 ==0 :
        S1.append('0')
        S2.append('1')
    else :
        S1.append('1')
        S2.append('0')
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min2 += 1 
print(min(min1,min2))

Submission status: Runtime Error

Solution code:
S = list(input())
S1 = []
S2 = []
if i in range(len(S)):
    if i % 2 ==0 :
        S1.append('0')
        S2.append('0')
    else :
        S1.append('1')
        S2.append('2')
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min2 += 1 
print(min(min1,min2))

Submission status: Runtime Error

Solution code:
s = list(input())
s1 = []
s2 = []
for i in range(len(s)):
    if i % 2 == 0:
        s1.append('0')
        s2.append('1')
    else:
        s1.append('1')
        s2.append('0')
print(min(min_1, min_2))

Submission status: Runtime Error

Solution code:
l=len(s)

ans=0

if s[0]=="0":
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "1":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "0":
                ans+=1

else:
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "0":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "1":
                ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
s = input()
c1 = 1 if s[0] == '0' else 0
a = []
a.append('1')
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c1+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
a = []
c2 = 1 if s[0]=='1' else 0
for i in range(1,len(s)):
  if s[i] == a[len(a)-1]:
    c2+=1
    a.append('0' if s[i]=='1' else '1')
  else:
    a.append(s[i])
    
    
print(min(c1,c2))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

ss = [int(i) for i in STR()]
s = deepcopy(s)
ans1 = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        s[i] = int(not s[i - 1])
        ans1 += 1
s = deepcopy(s)
s[0] = int(not s[0])
ans2 = 0
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        s[i] = int(not s[i - 1])
        ans2 += 1
print(min(ans1, ans2))

Submission status: Runtime Error

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

a = "10" * (n // 2) + ("1" if n % 2 == 0 or n == 1 else "")
b = "01" * (n // 2) + ("0" if n % 2 == 0 or n == 1 else "")

sum_a = 0
for i in range(n):
    if s[i] != a[i]: sum_a += 1

sum_b = 0
for i in range(n):
    if s[i] != b[i]: sum_b += 1

print(min(sum_a, sum_b))

Submission status: Runtime Error

Solution code:
color = [int(i) for i in input()]
n = len(color)
ans = 0

if n%2==1:
    arfa = [10]*n//2 + [1]
    beta = [01]*n//2 + [0]
else:
    arfa = [10]*n//2
    beta = [01]*n//2

ansa=0;ansb=0
for i in range(n):
    if color[i]!=arfa[i]:
        ansa += 1
    if color[i]!=beta[i]:
        ansb += 1
print(min([ansa,ansb]))

Submission status: Runtime Error

Solution code:
s = input()
cnt1 = 0
cnt2 = 0
for i in range(len(s)):
    if i%s == 0:
        if s[i] == "0":
            cnt1 += 1
        else:
            cnt2 += 1
    else:
        if s[i] == "1":
            cnt1 += 1
        else:
            cnt2 += 1
print(min(cnt1,cnt2))

Submission status: Runtime Error

Solution code:
s=list(input())
a=[]
b=[]
if s%2==0:
  for i in range(n//2):
    a.append("0")
    a.append("1")
    b.append("1")
    b.append("0")
else:
  for i in range(n//2-1):
    a.append("0")
    a.append("1")
    b.append("1")
    b.append("0")
  a.append("0")
  b.append("1")
  
ans1=0
ans2=0

for i in range(n):
  if s[i]!=a[i]:
    ans1+=1
  else:
    ans2+=1
print(min(ans1,ans2))

Submission status: Runtime Error

Solution code:
s=list[input()]
a=[]
b=[]
if s%2==0:
  for i in range(n//2):
    a.append(0)
    a.append(1)
    b.append(1)
    b.append(0)
else:
  for i in range(n//2-1):
    a.append(0)
    a.append(1)
    b.append(1)
    b.append(0)
  a.append(0)
  b.append(1)
  
ans1=0
ans2=0

for i in range(n):
  if s[i]!=a[i]:
    ans1+=1
  else:
    ans2+=1
print(min(ans1,ans2))

Submission status: Runtime Error

Solution code:
def main():
  import sys
  input = sys.stdin.readline
  s=list(input())
  count1,count2,l=0,0,len(s)
  for i in range(l):
    count1=count1+1 if (i%2==0 and int(s[i])==1) or (i%2==1 and int(s[i])==0) else count1
    count2=count2+1 if (i%2==1 and int(s[i])==1) or (i%2==0 and int(s[i])==0) else count2
  print(min(count1,count2))

if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
n=input()
def check(n,st_num):
    count=0
    dic={1:1,0:2}
    for i in range(1,-(-len(n)//2)):
        try:
            if n[2*i]+n[2*i+1]==st_num:
                count+=0
            else:
                count+=dic[abs(int(n[2*i])+int(n[2*i+1])-1)]
        except:
            if n[2*i]!=st_num[0]:
                count+=1
    
    return count
    
if '1' not in n:
    print(n//2)
if n[:2]=="10":
    print(check(n,"10"))
elif n[:2]=="01":
    print(check(n,"01"))
else:
    print(0 if len(n)==1 else check(n,"10")+1)

Submission status: Runtime Error

Solution code:
s=list(input())
cnt=0
for i in range(1,n):
  if s[i]==s[i-1]=='1':
    cnt+=1
    s[i]='0'
  elif s[i]==s[i-1]=='0':
    cnt+=1
    s[i]='1'
print(cnt)

Submission status: Runtime Error

Solution code:
zero_one = [0 if i%2==0 else 1 for i in range(len(S))]
one_zero = [0 if i%2==1 else 1 for i in range(len(S))]

count_zero_one = 0
count_one_zero = 0

for i in range(length):
  if int(S[i]) != zero_one[i]:
    count_zero_one += 1
  if int(S[i]) != one_zero[i]:
    count_one_zero += 1

if count_zero_one <= count_one_zero:
  print(count_zero_one)
else:
  print(count_one_zero)

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)
for i in range(n-1):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n-1):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))A

Submission status: Runtime Error

Solution code:
S=input()
s=0
for i in range(len(S)):
  if S[i]==S[i+1]==S[i+2]==0:
    s+=1
    S[i+1]=1
  elif S[i]==S[i+1]==S[i+2]==1:
    s+=1
    S[i+1]==0
  elif S[i]==S[i+1] and S[i+1]!=S[i+2]:
    s+=1
    S[i]=S[i+2]
  elif S[i]!=S[i+1] and S[i+1]==S[i+2]:
    s+=1
    S[i+2]==S[i]
  else:
    s=s
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import Levenshtein

S = list(input())
lenS = len(S)

patternA = []
patternB = []
countA = 0
countB = 0

for x in range(lenS):
    print(S[x])
    if x % 2 == 0:
        if S[x] == "0":
            countA += 1
        else:
            countB += 1
    else:
        if S[x] == "1":
            countA += 1
        else:
            countB += 1

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#ABC124_C
S=input()
 
S_rev=list(S)[::-1]
 
s=0
st0=0
st1=0
 
def bit_count(x):
    x=bin(x)[2:]
    ans=0
    for i in range(len(x)):
        if int(x[i])==1:
            ans+=1
    return ans
            
 
for i in range(len(S)):
    if i%2==0:
        st0+=2**i
    else:
        st1+=2**i
    if int(S_rev[i])==1:
        s+=2**i
 
cand0=st0^s
cand1=st1^s
 
    
bc0=bit_count(cand0)
bc1=bit_count(cand1)
if bc0>bc1:
    print(bc1)
else:
    print(bc0

Submission status: Runtime Error

Solution code:
a = list(input())
b = a[::2].index('0') + a[1::2].index('1')
c = min(b, len(a) - b)
print(c)

Submission status: Runtime Error

Solution code:
a = input()
b = a[::2].index('0') + a[1::2].index('1')
c = min(b, len(a) - b)
print(c)

Submission status: Runtime Error

Solution code:
s=input()
sento1 = 0
sento0 = 0
for i in range(len(s)):

  if i % 2 == 0:
    
    if s[i] == '1':
      sento1 += 1
      
    elif s[i] == '0':
      sento0 += 1
      
  else:
    if s[i] == '0':
      sento1 += 1
    elif s[i] == '1'
      sento0 += 1
      
print(min(sento1,sento0))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[]) {
  long long onecouter = 0, zerocounter = 0;
  std::string number;
  std::cin >> number;
  int length = number.length();
  char idx = '0';
  for (long long  i = 0; i < length; i++) {

    if (number[i] == idx) zerocounter++;
    if (idx == '0') idx = '1';
    else idx = '0';
    if (number[i] == idx) onecouter++;
  }

  std::cout << min(zerocounter,onecouter) << '\n';

  return 0;
}

Submission status: Runtime Error

Solution code:
s = list(input())
count = 0
for i in range(1,n):
  if s[i] == s[i-1]:
    if s[i] == "0":
      s[i] = "1"
    else:
      s[i] = "0"
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
deata = list(input())
count = 0
for i in range(1, len(data)):
  if data[i] == data[i-1]:
    if data[i] == "0":
      data[i] = "1"
    else:
      data[i] = "0"
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
S = int(input())
n = len(S)
a = "10" * n + "1" * (n % 2)
b = "01" * n + "0" * (n % 2)

print(min(bin(int(s,2) ^ int(a, 2) , bin(int(s, 2) ^ int(b, 2)))))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#010101…と101010…の2通り
#2通りともコストを計算して小さい方を採用するだけ。
#文字列処理のほうが楽。if文注意
s = input()
even = true
ans1=0#010101…
ans2=1#101010…
for c in s:
  if even:
    if c == '0':
      ans2 += 1
    else:
      ans1 += 1
  else:
    if c == '0':
      ans1 += 1
    else:
      ans2 += 1
print(min([ans1,ans2]))

Submission status: Runtime Error

Solution code:
s=input()
w=str()
b=str()
cnt1=0
cnt2=0
for i in range(n):
    if i%2==0:
        w+='1'
        b+='0'
    else:
        w+='0'
        b+='1'
for i in range(n):
    if s[i]!=w[i]:
        cnt1+=1
    if s[i]!=b[i]:
        cnt2+=1
print(min(cnt1,cnt2))

Submission status: Runtime Error

Solution code:
S = list(input())

count = 0
for i,s in enumerate(S):
    if i!=0:
        if S[i-1] == s:
            count += 1
            if s == "0":
                S[i] = "1"
            else:
                S[i] = "0"
            print(S)
print(count)

Submission status: Runtime Error

Solution code:
import copy
import sys
S = list(input())
SS = copy.deepcopy(S)
s = 1
ss = 1
if len(S) == 1:
    print(0)
    sys.exit()

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

S = SS
for i in range(len(S)-1):
    if S[i] == S[i+1] == '0':
        S[i+1] = '1'
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                ss += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                ss += 1
        break
    elif S[i] == S[i+1] == '1':
        S[i+1] = '0'
        for l in range(i+1, len(S)-1):
            if S[l] == S[l+1] == '0':
                S[l+1] = '1'
                ss += 1
            elif S[l] == S[l+1] == '1':
                S[l+1] = '0'
                ss += 1
        break
print(min(s,ss))

Submission status: Runtime Error

Solution code:
S=list(map(int,list(input())))
even=S[0::2]
odd=S[1::2]

sum_even=sum(even)
sum_odd=sum(odd)
len_even=int(len(S)//2)
len_odd=int(len(S)//2)+1

if sum_odd<sum_even:
  ans=lene_even-sum_even+sum_odd
elif sum_odd>sum_even:
  ans=len_odd-sum_odd+sum_even
else:
  ans=len_even-sum_even

print(ans)

Submission status: Runtime Error

Solution code:
S=list(map(int,list(input())))
even=S[0::2]
odd=S[1::2]

sum_even=sum(even)
sum_odd=sum(odd)
len_even=int(len(S)//2)
len_odd=int(len(S)//2)+1

if sum_odd<sum_even:
  ans=lene_even-sum_even+sum_odd
elif sum_odd>sum_even:
  ans=len_odd-sum_odd+sum_even
else:
    ans=len_even-sum_even

print(ans)

Submission status: Runtime Error

Solution code:
cnt=0
for i in range(len(n)):
    if n[0]==0:
        if i%2==0 and n[i]!=0 :
            cnt+=1
        if i&2==1 and n[i]!=1 :
            cnt+=1
    else:
        if i%2==0 and n[i]!=1 :
            cnt+=1
        if i&2==1 and n[i]!=0 :
            cnt+=1
print(cnt-1)

Submission status: Runtime Error

Solution code:
s = str(input())

test0 = [x%2 for x in range(n)]
test1 = [x%2+1 for x in range(n)]

cnt0 = 0
cnt1 = 0

for i, v in enumerate(s):
    if int(v) != test0[i]:
        cnt0+=1
    if int(v) != test1[i]:
        cnt1+=1
        
print(min(cnt0, cnt1))

Submission status: Runtime Error

Solution code:
s = input()
set = [0, 1]
diff = 0

for i in range(len(s)):
    set.reverse()
    print(s)
    if set[1] == int(s[i]):
        diff += 1

print(min([diff, len(s)-diff]))

Submission status: Runtime Error

Solution code:
s = input()
option1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 = 0
print(min(ans_1, ans_2))

Submission status: Runtime Error

Solution code:
list1 = list(input())

#貪欲
for i in range(1,len(list1)):
	if list1[i] == list1[i-1]:
		if list1[i] == "1":
			list1[i] = "0"
		else:
			list1[i] = "1"
		count += 1
print(count)

Submission status: Runtime Error

Solution code:
#2019/10/24
S = list(map(int, list(open(0).read())))
# print(S)
print(S[::2].count(0) + S[1::2].count(1) if S[0]==1 else S[::2].count(1) + S[1::2].count(0))

Submission status: Runtime Error

Solution code:
S = list(int(input()))
T = S
T[0] = abs(T[0] - 1)
trial = 0
tr =1
s = len(S)
if s > 1:
    for i in range(1, s):
        if S[i] == S[i-1]:
            S[i] = abs(S[i]-1)
            trial += 1
    for k in range(1, s):
        if T[k] == T[k-1]:
            T[k] =abs(T[k]-1)
            tr += 1

print(min(trial, tr))

Submission status: Runtime Error

Solution code:
S = list(int(input()))
trial = 0
tr =0
s = len(S)
if s > 1:
    for i in range(1, s):
        if S[i] == S[i-1]:
            S[i] = abs(S[i]-1)
            trial += 1
    for k in range(1, s):
        if S[s-k] == S[s-k-1]:
            S[s-k-1] = abs(S[s-k]-1)
            tr += 1
print(min(trial, tr))

Submission status: Runtime Error

Solution code:
S = list(int(input()))
trial = 0
try =0
s = len(S)
if s > 1:
    for i in range(1, s):
        if S[i] == S[i-1]:
            S[i] = abs(S[i]-1)
            trial += 1
    for k in range(1, s):
        if S[s-k] == S[s-k-1]:
            S[s-k-1] = abs(S[s-k]-1)
            try += 1
print(min(trial, try))

Submission status: Runtime Error

Solution code:
S = list(int(input()))
trial = 0
if len(S) > 1:
    for i in range(1, len(S)):
        if S[i] == S[i-1]:
            S[i] = abs(S[i]-1)
            trial += 1
print(trial)

Submission status: Runtime Error

Solution code:
S = list(int(input())
trial = 0
if len(S) > 1:
    for i in range(1, len(S)):
        if S[i] == S[i-1]:
            S[i] = abs(S[i]-1)
            trial += 1
print(trial)

Submission status: Runtime Error

Solution code:
S = list(int(input())
trial=0
if len(S) > 1:
    for i in range(1, len(S)):
        if S[i] == S[i-1]:
            S[i] = abs(S[i]-1)
            trial += 1
print(trial)

Submission status: Runtime Error

Solution code:
s = int(input())

n = len(s)

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

print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
s,a="",""
sd,ad=0,0
for i in range(len(n)):
  if i%2:
    s+="1"
    a+="0"
  else:
    s+="0"
    a+="1"
for i in range(n):
  if n[i]!=a[i]:ad+=1
  if n[i]!=s[i]:sd+=1
print(min(ad,sd))

Submission status: Runtime Error

Solution code:
a=input()

if len(a)==1:
  print(0)
  exit()
  
b=[::2]
c=[1::2]

b0=b.count("0")
b1=b.count("1")
c0=c.count("0")
c1=c.count("1")

print(min(b0+c1,b1+c0))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = int(input())
count = 0
for i in ragen(len(s)):
    if (i % 2 == 0 and s[i] ==0) or (i % 2 ==1 and s[i] == 1):
        pass
    else:
        count += 1
print(min[count,len(s) - count])

Submission status: Runtime Error

Solution code:
s = int(input())
count = 0
for i in ragen(len(s)):
    if (i % 2 == 0 and s[i] ==0) or (i % 2 ==1 and s[i] == 1):
        pass
    else:
        count += 1
print(min[c,len(s) - c])

Submission status: Runtime Error

Solution code:
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

Submission status: Runtime Error

Solution code:
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans1[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

Submission status: Runtime Error

Solution code:
lis = [int(input()) for _ in range(6)]
if lis[0]/min(lis[1:]) == 1:
  print(5)
else:
  print(lis[0]//min(lis[1:])+5)

Submission status: Runtime Error

Solution code:
lis = [int(input()) for _ in range(6)]
if lis[0] % min(lis[1:]) == 0:
  print(5)
else:
  print(lis[0]//min(lis[1:])+5)

Submission status: Runtime Error

Solution code:
lis = [int(input()) for _ in range(6)]
if lis[0] % min(lis[1:]) == 0:
  print(5)
else:
  print(lis[0]//min(lis[1:])+5)

Submission status: Runtime Error

Solution code:
From0 = ['0','1']*(10**6)
From1 = ['1','0']*(10**6)
s = list(input())
F0 = From0[::len(s)]
F1 = From1[::len(s)]
count_0 = 0
count_1 = 0
for i in range(len(s)):
  if s[i] != F0[i]:
    count_0 += 1
for i in range(len(s)):
  if s[i] != F1[i]:
    count_1 += 1
print(min(count_0,count_1))

Submission status: Runtime Error

Solution code:
From0 = ['0','1']*(10**5)
From1 = ['1','0']*(10**5)
s = list(input())
F0 = From0[::len(s)]
F1 = From1[::len(s)]
count_0 = 0
count_1 = 0
for i in range(len(s)):
  if s[i] != F0[i]:
    count_0 += 1
for i in range(len(s)):
  if s[i] != F1[i]:
    count_1 += 1
print(min(count_0,count_1))

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2 and len(s)>=4:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
elif len(s)%2==0 and len(s)>=4:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Submission status: Runtime Error

Solution code:
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
else:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()

count01=0
count10=0

for val in range(len(s)):
    if val%2 == 1:
        if s%2 == 1:
            count01 += 1
        else:
            count10 += 1
    
    elif val%2 == 0:
        if s%2 == 0:
            count01 += 1
        else:
            count10 += 1
    
    s = int(s/10)

if count10 > count01:
    print(len(s)-count10)
else:
    print(len(s)-count01)