Problem:


Score : 300 points

Problem Statement

There are N cubes stacked vertically on a desk.

You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.

You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent, and remove them. Here, the cubes that were stacked on the removed cubes will fall down onto the object below them.

At most how many cubes can be removed?

Constraints

1 \leq N \leq 10^5

|S| = N

Each character in S is 0 or 1.

Input

Input is given from Standard Input in the following format:

S

Output

Print the maximum number of cubes that can be removed.

Sample Input 1

0011

Sample Output 1

4

All four cubes can be removed, by performing the operation as follows:

Remove the second and third cubes from the bottom. Then, the fourth cube drops onto the first cube.

Remove the first and second cubes from the bottom.

Sample Input 2

11011010001011

Sample Output 2

12

Sample Input 3

0

Sample Output 3

0



Sample input:
0011


Sample output:
4

Submission status: Accepted

Solution code:
s = input()
list_0 = 0
list_1 = 0
half = 0

for i in range(len(s)):
  if s[i] == "1" and list_0 == 0:
    list_1 += 1
  elif s[i] == "1" and list_0 != 0:
    list_0 =list_0 - 1
    half += 1
  elif s[i] =="0" and list_1 == 0:
    list_0 += 1
  else:
    list_1 = list_1 - 1
    half += 1

print(half * 2)

Submission status: Accepted

Solution code:
s=list(input())
print(len(s)-(max(s.count('0'),s.count('1'))-min(s.count('0'),s.count('1'))))

Submission status: Accepted

Solution code:
s=list(input())
cnt_1=s.count('1')
MIN=min(len(s)-cnt_1,cnt_1)
print(MIN*2)

Submission status: Accepted

Solution code:
# coding: utf-8

mojiretsu = input().rstrip()

stk = []
ans = 0

for i in mojiretsu:
    if len(stk) > 0 and stk[len(stk)-1] != i:
        stk.pop()
        ans += 2
    else:
        stk.append(i)


print(ans)

Submission status: Accepted

Solution code:
S = input()
n = len(S)
r = S.count("0")
b = S.count("1")

print(n - abs(r - b))

Submission status: Accepted

Solution code:
s=list(input())
len_s=len(s)
cnt_1=0
for i in range(len_s):
    if s[i]=='1':
        cnt_1+=1
cnt_0=len_s-cnt_1
print(min(cnt_1,cnt_0)*2)

Submission status: Accepted

Solution code:
from collections import deque
S=input()

stack=deque()
cnt=0
for s in S:
    if not stack:
        stack.append(s)
    elif s!=stack[-1]:
        stack.pop()
        cnt+=2
    else:
        stack.append(s)
        
print(cnt)

Submission status: Accepted

Solution code:
S=input()

stack=[]
cnt=0
for s in S:
    if not stack:
        stack.append(s)
    elif s!=stack[-1]:
        stack.pop()
        cnt+=2
    else:
        stack.append(s)
        
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np

s = list(map(int, input().strip()))
s = np.array(s, dtype=np.bool)
len_s = len(s)

p = 0
count = 0

while p < len_s - 1:
    if s[p] != s[p + 1]:
        count += 2
        if p < len_s - 2:
            s[p:-2] = s[p + 2:]
        if p > 0:
            p -= 1
        else:
            p = 0

        len_s -= 2
    else:
        p += 1

print(count)

Submission status: Accepted

Solution code:
colors = input()
n_cube = len(colors)
n_1 = colors.count("1")
n_0 = n_cube - n_1
ans = 2 * min(n_0, n_1)
print(ans)

Submission status: Accepted

Solution code:
S=input()
print(2*(min(S.count('1'),S.count('0'))))

Submission status: Accepted

Solution code:
s = input()
n = len(s)
stack = []

for i in range(n):
    if len(stack) > 0:
        if stack[-1] != s[i]:
            stack.pop()
        else:
            stack.append(s[i])
    else:
        stack.append(s[i])

print(n - len(stack))

Submission status: Accepted

Solution code:
s  = input()

cntr = 0
cntb = 0

for i in range(len(s)):
	if s[i] == '0':
		cntr += 1
	elif s[i] == '1':
		cntb += 1

print(2 * min(cntr, cntb))

Submission status: Accepted

Solution code:
s=input()
red=s.count('0')
blue=s.count('1')
print(min(red,blue)*2)

Submission status: Accepted

Solution code:
s = input()
cntB = s.count("0")
cntR = s.count("1")
print(min(cntR, cntB)*2)

Submission status: Accepted

Solution code:
from collections import Counter
S = Counter(input())
print(2 * min(S["0"], S["1"]))

Submission status: Accepted

Solution code:
from collections import Counter
s=input()
if len(set(s)) == 1:
  print(0)
else:
  cs=Counter(s)
  print(min(cs['0'],cs['1'])*2)

Submission status: Accepted

Solution code:
S = input()
one = 0
zero = 0
for i in S:
    if i == "1":
        one += 1
    else:
        zero += 1
print(min(one,zero)*2)

Submission status: Accepted

Solution code:
s = input()
r = 0
b = 0
for i in s:
    if i == "1":r += 1
    else: b += 1

now = max(b,r) - min(b,r)
ans = len(s)-now
print(ans)

Submission status: Accepted

Solution code:
s=input()
num0=0
num1=0
for i in range(len(s)):
    if s[i]=="0":
        num0+=1
    else:
        num1+=1
print(2*min(num0,num1))

Submission status: Accepted

Solution code:
S = input()

r = S.count('0')
b = S.count('1')

print(min(r, b)*2)

Submission status: Accepted

Solution code:
#スタックのデータ構造を用いて解く場合の、サンプル例
N=input()
stack=[]
count=0
for n in N:
    #初めのループは配列がからなので、素直に最初の数字(0 or 1)を格納する
    if not stack:
        stack.append(n)
    #配列の最後の要素が、新たな要素と異なるのであれば、キューブを削除（配列の最後の要素を消す）した上でカウンターに２を足す
    elif stack[-1]!=n:
        stack.pop()
        count += 2
    #配列の最後の要素が、新たな要素と同じであれば、キューブを積み上げる（配列の最後に要素を追加）
    else:
        stack.append(n)
print(count)

Submission status: Accepted

Solution code:
n=input()
print(min(n.count('0'),n.count('1'))*2)

Submission status: Accepted

Solution code:
s = input()
zero = s.count('0')
one = s.count('1')

print(min(zero, one) * 2)

Submission status: Accepted

Solution code:
S = str(input())
S= list(S)
switch = 0  
for i in range(len(S)):
    S[i] = int(S[i])
count_0 = 0
count_1 = 0
for i in range(len(S)):
    if S[i] == 0:
        count_0 = count_0 + 1
    else:
        count_1 = count_1 + 1
        
if count_0 > count_1:
    count = count_1
else:
    count = count_0
    
result = 2 * count
print(result)

Submission status: Accepted

Solution code:
from collections import Counter
def counter(li, n):
    count = Counter()
    count.update(li)
    return count[n]

import sys
input = sys.stdin.readline
S = list(input())[:-1]
S = list(map(int, S))
N = len(S)
count_0 = counter(S, 0)
count_1 = N-count_0
print(N-abs(count_1-count_0))

Submission status: Accepted

Solution code:
S = input()

m = S.count('1')
n = S.count('0')

print(min(n,m)*2)

Submission status: Accepted

Solution code:
s = list(input())

red = s.count('0')
blue = s.count('1')

print(min(red,blue)*2)

Submission status: Accepted

Solution code:
qube = input()

red = qube.count("0")
blue = qube.count("1")

ans = min(red, blue) * 2
print(ans)

Submission status: Accepted

Solution code:
s = input()
one,zero = s.count("1"),s.count("0")
print(min(one,zero)*2)

Submission status: Accepted

Solution code:
from collections import Counter
n=str(input())
l=list(n)
c=Counter(l)
a=c["0"]
b=c["1"]
m=min(a,b)
print(2*m)

Submission status: Accepted

Solution code:
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353



S = sys.stdin.buffer.readline().decode().rstrip()

S = list(S)

S = np.array(S, dtype='U1')

ans = len(S) - abs((S == '0').sum() - (S == '1').sum())
print(ans)

Submission status: Accepted

Solution code:
S = input()
I, O = 0, 0
for i in range(len(S)):
  if S[i] == '1':
    I += 1
  elif S[i] == '0':
    O += 1
print(min(I, O) * 2)

Submission status: Accepted

Solution code:
s=input()
red_count=s.count('0')
blue_count=s.count('1')
print(min(red_count,blue_count)*2)

Submission status: Accepted

Solution code:
s = input()
zero = 0
one = 0
 
for i in range(len(s)):
    if s[i]=="0":
        zero += 1
    else:
        one += 1
else:
    ans = min(zero,one)*2
 
print(ans)

Submission status: Accepted

Solution code:
s = input()
zero = 0
one = 0

for i in range(len(s)):
    if s[i]=="0":
        zero += 1
    else:
        one += 1
else:
    ans = min(zero,one)*2

print(ans)

Submission status: Accepted

Solution code:
s = str(input())

total = len(s)

zero = s.count('0')
one = s.count('1')

print(total - abs(zero-one))

Submission status: Accepted

Solution code:
def solve():
    S = input()

    zeros = S.count('0')
    ones = S.count('1')
    ans = min(zeros, ones) * 2
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
A=[j for j in input()]

ans=[A.count("0"),A.count("1")]
print(min(ans)*2)

Submission status: Accepted

Solution code:
s = input()
cnt_zero = 0
cnt_one = 0
for letter in s:
    if letter == "0":
        cnt_zero += 1
    else:
        cnt_one += 1
res = min(cnt_zero, cnt_one) * 2
print(res)

Submission status: Accepted

Solution code:
S = input()
zero = S.count('0')
one = len(S) - zero

print(2*min(zero,one))

Submission status: Accepted

Solution code:
s=input()
cnt0=0
cnt1=0
for i in range(len(s)):
  if s[i]=='0':
    cnt0+=1
  else:
    cnt1+=1
if cnt1<cnt0:
  print(2*cnt1)
else:
  print(2*cnt0)

Submission status: Accepted

Solution code:
s=input()
if len(s)==1:
    print(0)
else:
    print(min(s.count("1"),s.count("0"))*2)

Submission status: Accepted

Solution code:

S = input()

zero = S.count("0")
one = S.count("1")

print(len(S) - (max(zero, one) - min(zero, one)))

Submission status: Accepted

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

def solve_short(S: str):
    print(2*min(S.count('0'), S.count('1')))

def solve(S: str):
    stack = []
    N = len(S)
    for i, s in enumerate(S):
        if i == 0:
            stack.append(s)
        else:
            if len(stack) == 0:
                stack.append(s)
            else:
                if s != stack[-1]:
                    tmp = stack.pop()
                else:
                    stack.append(s)
    print(N - len(stack))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = str(input())
    solve_short(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def solve(S: str):
    stack = []
    N = len(S)
    for i, s in enumerate(S):
        if i == 0:
            stack.append(s)
        else:
            if len(stack) == 0:
                stack.append(s)
            else:
                if s != stack[-1]:
                    tmp = stack.pop()
                else:
                    stack.append(s)
    print(N - len(stack))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = str(input())
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def solve(S: str):
    stack = []
    N = len(S)
    for i, s in enumerate(S):
        if i == 0:
            stack.append(s)
        else:
            if len(stack) == 0:
                stack.append(s)
            else:
                if s != stack[-1]:
                    tmp = stack.pop()
                else:
                    stack.append(s)
    print(N - len(stack))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = str(input())
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
print(2 * min(s.count('0'), s.count('1')))

Submission status: Accepted

Solution code:
s = input()
r = s.count('0')
b = s.count('1')
print( min(r, b)*2 )

Submission status: Accepted

Solution code:
A = list(input())
N = len(A)

C0 = A.count("0")
C1 = A.count("1")

print(2 * min(C0, C1))

Submission status: Accepted

Solution code:
s=input()
a=s.count("1")
b=s.count("0")
print(min(a,b)*2)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     

def reverse_str(n):
    n = int(n)
    return str((1 - n) ** 2)

def main():
    s = S()
    dp = [(0, '') for _ in range(len(s)+1)]
    dp[0] = (1, s[0])
    for i in range(1, len(s)):
        prev_let = dp[i-1][1]
        prev_len = dp[i-1][0]
        if s[i] == prev_let:
            dp[i] = (prev_len + 1, s[i])
        elif prev_let == '':
            dp[i] = (prev_len + 1, s[i])
        else:
            if prev_len - 1 == 0:
                prev_let = ''
            else:
                prev_let = reverse_str(s[i])
            dp[i] = (prev_len - 1, prev_let)
    print(len(s) - dp[len(s)-1][0])

main()

Submission status: Accepted

Solution code:
s = input()
n = list()
for i in range(len(s)):
    n.append(int(s[i]))
print(min(len(n)-sum(n),sum(n))*2)

Submission status: Accepted

Solution code:
S=list(input())
A = len(S)
B = S.count("1")
print(A - abs(B-(A-B)))

Submission status: Accepted

Solution code:
S = input()

ans = min(S.count("0"), S.count("1")) * 2

print(ans)

Submission status: Accepted

Solution code:
s=input()
ans=[]
for i in s:
    if ans==[]:
        ans.append(i)
    elif ans[-1]!=i:
        ans.pop()
    else:
        ans.append(i)
print(len(s)-len(ans))

Submission status: Accepted

Solution code:
S = input()
stack = []
ans = 0
for s in S:
  if not stack:
    stack.append(s)
  elif stack[-1] != s:
    stack.pop()
    ans += 2
  else:
    stack.append(s)
    
print(ans)

Submission status: Accepted

Solution code:
from queue import *

q = LifoQueue()
S=input()
count=0
for s in S:
    if q.empty():
        q.put(s)
    else:
        q_1 = q.get()
        if q_1 != s:
            count+=2
        else:
            q.put(q_1)
            q.put(s)
print(count)

Submission status: Accepted

Solution code:
S = list(input())
c = 0
for i in range(len(S)):
    if S[i] == '0':
        c += 1
print(2*min(c, len(S)-c))

Submission status: Accepted

Solution code:
s=input()

a=s.count("0")
b=s.count("1")

print(len(s)-abs(a-b))

Submission status: Accepted

Solution code:
S=list(input())
sum0=0
for i in range(len(S)):
  if S[i]=="0":
    sum0+=1
 
print(2*min(sum0,len(S)-sum0))

Submission status: Accepted

Solution code:
s = input()
stack = []
ret = 0
for ch in s:
    if not stack or stack[-1] == ch:
        stack.append(ch)
    else:
        stack.pop()
        ret += 2
print(ret)

Submission status: Accepted

Solution code:
def main():
    S = input()
    cnt = S.count("0")
    print(2 * min(cnt, len(S) - cnt))
    return


main()

Submission status: Accepted

Solution code:
l = []
ans = 0

for s in input():
    if s == "0":
        if l and l[-1] == "1":
            l.pop()
            ans += 2
        else:
            l.append(s)
    else:
        if l and l[-1] == "0":
            l.pop()
            ans += 2
        else:
            l.append(s)

print(ans)

Submission status: Accepted

Solution code:
import collections
S = input()
c = collections.Counter(S)
if len(c.values()) == 2:
    print(min(c.values())*2)
else:
    print(0)

Submission status: Accepted

Solution code:
S=input()
print(len(S)-abs(S.count("1")-S.count("0")))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

S = list(input())
N = len(S)
S = np.array(S)
onecount = np.count_nonzero(S == "1")
print(2 * min(onecount, N - onecount))

Submission status: Accepted

Solution code:
def p_c():
    s = input()
    a = s.count("0")
    b = s.count("1")
    print(min(a, b) * 2)
    
p_c()

Submission status: Accepted

Solution code:
s = input()
count_0 = s.count("0")
count_1 = s.count("1")
print(min(count_0, count_1) * 2)

Submission status: Accepted

Solution code:
s = input()
cnt0 = s.count('0')
cnt1 = s.count('1')
print (min(cnt0, cnt1) * 2)

Submission status: Accepted

Solution code:
s = input()
cnt = 0
idx = 1
tmp = ''
hit = True
while(hit):
	hit = False
	for i in range(idx, len(s)):
		if s[i-1:i+1] == '01' or s[i-1:i+1] == '10':
			tmp = s[0:i-1] + s[i+1: ]
			cnt += 2
			idx = i - 1 if i > 1 else 1
			hit = True
			s = tmp
			break
            
print (cnt)

Submission status: Accepted

Solution code:
import os, sys, re, math

S = input()

s1 = S.replace('1', '')
s2 = S.replace('0', '')

print (min(len(s1), len(s2)) * 2)

Submission status: Accepted

Solution code:
S = input()
reds = len([s for s in S if s == '0'])
blues = len([s for s in S if s == '1'])
ret = min(blues, reds) * 2
print(ret)

Submission status: Accepted

Solution code:
import collections

s = input()
num = collections.Counter(s)
print(min(num["0"],num["1"])*2)

Submission status: Accepted

Solution code:
S = input()
print( (min(S.count('0'),S.count('1')))*2)

Submission status: Accepted

Solution code:
s = list(input())
cnt0 = 0
for i in s:
    if i == "0":
        cnt0 += 1
# print(cnt0*2) if cnt0 <= len(s)//2 else print((len(s)-cnt0) * 2)
print(min(cnt0,len(s)-cnt0)*2)

Submission status: Accepted

Solution code:
s = list(input())
cnt0 = 0
for i in s:
    if i == "0":
        cnt0 += 1
print(cnt0*2) if cnt0 <= len(s)//2 else print((len(s)-cnt0) * 2)

Submission status: Accepted

Solution code:
S = input()
stack = []
stack.append(S[0])
for i in range(1, len(S)):
    if len(stack) == 0:
        stack.append(S[i])
        continue
    cube = stack.pop()
    if cube != S[i]:
        continue
    stack.append(cube)
    stack.append(S[i])
print(len(S) - len(stack))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = input()
len_a = len(a)
sum_a = sum(list(map(int,list(a))))
ret = min(sum_a,len_a-sum_a) * 2
print(ret)

Submission status: Accepted

Solution code:
s=input()
cnt=0
for c in s:
  cnt+=(int(c)-0.5)*2
print(len(s)-abs(int(cnt)))

Submission status: Accepted

Solution code:
def solve(s):
    zero = s.count('0')
    one = s.count('1')
    return len(s) - abs(zero-one)


if __name__ == '__main__':
    s = input()
    print(solve(s))

Submission status: Accepted

Solution code:
s = list(str(input()))
n = len(s)
red = s.count("0")
blue = n - red
print(n - abs(red - blue))

Submission status: Accepted

Solution code:
def main():
    S = input()
    c0, c1 = 0, 0
    c0 = S.count('0')
    c1 = S.count('1')
    print(2*min(c0, c1))
    


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()
zero = S.count('0')
one = S.count('1')

print(min(zero, one)*2)

Submission status: Accepted

Solution code:
s=list(input())
z=0
o=0
for i in s:
    if i=="0":
        z+=1
    else:
        o+=1
print(2*min(z,o))

Submission status: Accepted

Solution code:
s = input()
bef = ''
count = 0
lis = []
tmp = 0
for x in s:
  if x == bef or bef =='':
    tmp += 1
  else:
    lis.append(tmp)
    tmp = 1
  bef = x
lis.append(tmp)
  
print(min(sum(lis[0:][::2]), sum(lis[1:][::2])) * 2)

Submission status: Accepted

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    S = input()
    stack = []
    ans = 0

    for i in range(len(S)):
        if len(stack) == 0:
            stack.append(S[i])
        else:
            if stack[-1] != S[i]:
                stack.pop()
                ans += 2
            else:
                stack.append(S[i])

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S1 = input()
S2 = ''
res = 0

for s in S1:
    if len(S2) == 0 or S2[-1] == s:
        S2 += s
    else:
        S2 = S2[:-1:]
        res += 2

print(res)

Submission status: Accepted

Solution code:
S = input()

count_one = S.count("1")
count_zero = S.count("0")

print(min(count_one, count_zero)*2)

Submission status: Accepted

Solution code:
s = input()
x = 0
for c in s:
    if c == '1':
        x = x + 1
print(min(x, len(s) - x) * 2)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import re
def print_ans(S):
    """Test Case
    >>> print_ans("0011")
    4
    >>> print_ans("11011010001011")
    12
    >>> print_ans("0")
    0
    """
    flg = True
    ans = 0
    # while flg:
    #     tmp = re.sub(r"01|10", "", S)
    #     if len(tmp) == len(S):
    #         flg = False
    #         break
    #     else:
    #         ans += len(S) - len(tmp)
    #         S = tmp
    # print(ans)
    list_0 = []
    list_1 = []
    for s in S:
        if s =="0":
            list_0.append(s)
        else:
            list_1.append(s)
    print(min(len(list_0), len(list_1)) * 2)
        


if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)

Submission status: Accepted

Solution code:
s = input()
c0 = s.count('0')
c1 = s.count('1')
print(2*min(c0, c1))

Submission status: Accepted

Solution code:
from collections import deque

d = deque()
s=input()
ans=0
for i in s:
    d.append(i)
    if(len(d)>=2):
        if(d[len(d)-1]!=d[len(d)-2]):
            d.pop()
            d.pop()
            ans+=2
print(ans)

Submission status: Accepted

Solution code:
def main():
    s=input()
    print(2*min(s.count('1'),s.count('0')))

main()

Submission status: Accepted

Solution code:

S=input()
s = [int(i) for i in S]
cnt0=s.count(0)
cnt1=s.count(1)

print(2*min(cnt0,cnt1))

Submission status: Accepted

Solution code:
def judge(S):
    a = list(S)
    Num0 = a.count("0")
    Num1 = a.count("1")
    return min(Num0,Num1)*2

S = input()
print(judge(S))

Submission status: Accepted

Solution code:
S = input()

red = 0
blue = 0
for i in range(len(S)):
    if S[i] == '0':
        red += 1
    else:
        blue += 1
print(min(red,blue)*2)

Submission status: Accepted

Solution code:
s = input()
n = len(s)
red_cnt = 0
for i in s:
  if i == "0":
    red_cnt += 1
print(min(red_cnt,n-red_cnt)*2)

Submission status: Accepted

Solution code:
S=str(input())
count_0=0
count_1=0
for i in range(len(S)):
  if S[i]=='0':
    count_0 += 1
  else:
    count_1 += 1
answer=len(S)-abs(count_0-count_1)
print(answer)

Submission status: Accepted

Solution code:
s=list(input())
print(min(s.count("0")*2,s.count('1')*2) if len(s)!=1 else 0)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
num_0 = 0
num_1 = 0
for i in range(len(s)):
    if s[i] == "0":num_0 += 1
    else: num_1 += 1
print(min(num_0,num_1)*2)

Submission status: Accepted

Solution code:
s = input()
print(len(s)-abs(sum(1 if c == '0' else -1 for c in s)))

Submission status: Accepted

Solution code:
s = input()
print(len(s) - abs(s.count('0') - s.count('1')))

Submission status: Accepted

Solution code:
s = input()
cnt0 = 0
cnt1 = 0
cnt0 = s.count("0")
cnt1 = s.count("1")
print (min(cnt0,cnt1)*2)

Submission status: Accepted

Solution code:
li = list(input())
a = li.count("0")
import math
if a < math.ceil(len(li)/2):
    print(2*a)
else:
    print(2*(len(li)-a))

Submission status: Accepted

Solution code:
S =str(input())

import collections
S= collections.Counter(S)

if len(S)==1:
    print(0)
    exit()

#print(S.items())
#print(min(S.items(),key=lambda x:x[1]))

aaa =min(S.items(),key=lambda x:x[1])

print(2*aaa[1])


# 0
# 0010110010101
# 0000000111111

Submission status: Accepted

Solution code:
s=input()
a=0
b=0

for i in s:
		if i=="0":
			a+=1
		else:
			b+=1
				
print(min(a,b)*2)

Submission status: Accepted

Solution code:
S = input()
jed = 0
nul = 0

for i in S:
    if i == "1":
        jed += 1
    else:
        nul += 1
print ((min(jed,nul)*2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=0,0
for s in input():
  if s=="0": a+=1
  else: b+=1
print(min(a,b)*2)

Submission status: Accepted

Solution code:
s=list(input())
print(2*min(s.count('0'),s.count('1')))

Submission status: Accepted

Solution code:
a = input()
c0 = a.count('0')
c1 = a.count('1')
print(2 * min(c0, c1))

Submission status: Accepted

Solution code:
S = input()
red = 0
blue = 0
for c in S:
   if c == '0':
      red+=1
   else:
      blue+=1
print(min(red, blue) * 2)

Submission status: Accepted

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

one = [1 if si=="1" else 0 for si in s]
tmp=sum(one)
ret = min(tmp, n-tmp)*2

print(ret)

Submission status: Accepted

Solution code:
import re

s = input()
n = len(s)

one = [1 if si=="1" else 0 for si in s]
tmp=sum(one)
ret = min(tmp, n-tmp)*2

print(ret)

Submission status: Accepted

Solution code:
n=input()
s=len(n)
if s%2==0:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2:].count("0")
    r1=s//2-r0
    print(min(l0,r1)*2+min(l1,r0)*2)
if s%2==1:
    l0=n[:s//2].count("0")
    l1=s//2-l0
    r0=n[s//2+1:].count("0")
    r1=s//2-r0
    tmp=min(l0,r1)*2+min(l1,r0)*2
    if n[s//2]=="0":
        if r1-l0>0 or r0-l1>0:
            tmp+=2
    else:
        if l0-r1>0 or l1-r0>0:
            tmp+=2
    print(tmp)

Submission status: Accepted

Solution code:
s = input()

print(min(s.count("0"), s.count("1"))*2)

Submission status: Accepted

Solution code:
S = input()

red = 0
blue = 0
for c in S:
    if c == '0':
        red += 1
    elif c == '1':
        blue += 1

print(min(red, blue)*2)

Submission status: Accepted

Solution code:
s = input()
cnt = [s.count('0'), s.count('1')]

print(len(s) - (max(cnt) - min(cnt)))

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

s = input()
r, b = 0, 0
for i in range(len(s)):
  if s[i] == '0':
    r += 1
  else:
    b += 1
print(2 * min(r, b))

Submission status: Accepted

Solution code:
def main():
    S = input()

    zero = S.count('0')
    one = S.count('1')
    print(min(zero, one)*2)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    S = list(map(int,list(input())))

    count_0 = 0
    count_1 = 0
    for val in S:
        if val == 0:
            count_0 += 1
        else:
            count_1 += 1
    print(min(count_0, count_1)*2)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
red=s.count("1")
blue=s.count("0")
print(min(red,blue)*2)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
list1 = list(input())
del list1[-1]
ans = 0
def func(flist):
    count0 = 0
    for i in flist:
        if i == "0":
            count0 += 1
    count1 = len(flist)-count0
    return len(flist)-abs(count1-count0)

if __name__ == "__main__":
    print(func(list1))

Submission status: Accepted

Solution code:
S = input()
count = [0, 0]
for x in S:
    count[int(x)] += 1

print(min(count)*2)

Submission status: Accepted

Solution code:
s = input()

c0 = s.count("0")
c1 = s.count("1")

print(min(c0, c1) * 2)

Submission status: Accepted

Solution code:
s=list(input())
if len(s)==1:
    print(0)
else:
    print(2*min(s.count('0'),s.count('1')))

Submission status: Accepted

Solution code:
S = input()
t = []
for s in S:
    if len(t) == 0:
        t += s
    elif t[-1] != s:
        t.pop()
    else:
        t += s
print(len(S)-len(t))

Submission status: Accepted

Solution code:
S = input()
a = S.count("0")
b = S.count("1")
print(min(a, b)*2)

Submission status: Accepted

Solution code:
S = input()
num0 = num1 = 0
for i in range(len(S)):
    if S[i] == '0':
        num0+=1
    else:
        num1+=1
ans = min( num0, num1 ) * 2
print(ans)

Submission status: Accepted

Solution code:
s=str(input())
x=s.count("0")
y=s.count("1")
print(min(x,y)*2)

Submission status: Accepted

Solution code:
S = list(input())
c0 = S.count('0')
c1 = S.count('1')
print(min(c0,c1) * 2)

Submission status: Accepted

Solution code:
s = input()
l = []
c = 0
for i in s:
  if not l:
    l.append(i)
  else:
    if i != l.pop():
      c += 2
    else:
      l.append(i)
      l.append(i)
print(c)

Submission status: Accepted

Solution code:
#sは文字列
s=input()

count_0=0
count_1=0

for i in range(len(s)):
    if s[i]=="0":
        count_0+=1
    else:
        count_1+=1
print(min(count_0,count_1)*2)

Submission status: Accepted

Solution code:
S = input()
a = S.count("1")
b = S.count("0")
print(min(a, b)*2)

Submission status: Accepted

Solution code:
s = list(input())

num0 = s.count("0")
num1 = s.count("1")

print(2*min(num1,num0))

Submission status: Accepted

Solution code:
S = input()

num_0 = S.count('0')
num_1 = S.count('1')
print(2*min(num_0,num_1))

Submission status: Accepted

Solution code:
s=input()

one=s.count("1")
zero=s.count("0")

if one>=zero:
  print(zero*2)
else:
  print(one*2)

Submission status: Accepted

Solution code:
S = list(input())
a = S.count('0')
b = S.count('1')
ans = 2 * min(a, b)
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
s=input()
if len(set(s))==1:
    print(0)
else:
    c=Counter(s).most_common()
    print(c[1][1]*2)

Submission status: Accepted

Solution code:
import collections
S = list(input())
S.append('0')
S.append('1')
S_counter = collections.Counter(S)
print((S_counter.most_common()[1][1]-1)*2)

Submission status: Accepted

Solution code:
S = input()
print(min(S.count("0"),S.count("1")) * 2)

Submission status: Accepted

Solution code:
s = list(input())
r = s.count("0")
b = s.count("1")
print(min(r, b) * 2)

Submission status: Accepted

Solution code:
s = input()
a = s.count('0')
b = len(s) - a
print(min(a, b) * 2)

Submission status: Accepted

Solution code:
S = input()

count_0 = S.count('0')
count_1 = len(S) - count_0

print(2*min(count_0, count_1))

Submission status: Accepted

Solution code:
S=list(input())
print(min(S.count("0"),S.count("1"))*2)

Submission status: Accepted

Solution code:
S = input()

zero_count = S.count('0')
one_count =S.count('1')

count = min(zero_count, one_count)

print(count * 2)