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()
print(2 * min([sum([v == '1' for v in s]), sum([v == '0' for v in s])]))

Submission status: Accepted

Solution code:
def unification(S: str) -> int:
    c0 = sum([int(c) for c in S])
    c1 = sum([1 - int(c) for c in S])

    return min(c0, c1) * 2


if __name__ == "__main__":
    S = input()
    answer = unification(S)
    print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
a,b,c = LI()
print(min(b//a,c))
"""

#B
"""
a,b,k = LI()
i = 1
ans = [1]
while i <= min(a,b):
    i += 1
    if a%i == 0 and b%i == 0:
        ans.append(i)
print(ans[-k])
"""

#C
s = list(map(int,S()))
print(2*min(sum(s),len(s)-sum(s)))

#D
"""
def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]
def unite(x,y):
    x = root(x)
    y = root(y)
    if x == y:
        ans.append(ans[-1])
        return
    sx = s[x]
    sy = s[y]
    if rank[x] < rank[y]:
        par[x] = y
        s[y] += sx
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
        s[x] += sy
    ans.append(ans[-1]+sx*sy)
n,m  = LI()
v = LIR(m)
v = v[::-1]
par = [i for i in range(n)]
rank = [0 for i in range(n)]
s = [1 for i in range(n)]
ans = [0]
k = n*(n-1)//2
v.pop(-1)
for a,b in v:
    if ans[0] == k:
        ans.append(k)
        continue
    a -= 1
    b -= 1
    unite(a,b)
for i in ans[::-1]:
    print(k-i)
"""
#E
"""
n,a,b = LI()
s = input()
ans = 0
i = 0
while i < n:
    j = i+1
    if s[i:j] in s[:i]:
        while s[i:j] in s[:i]:
            j += 1
            if j >= n-1:break
        ans += min(b,a*(j-i))
    else:
        ans += a*(j-i)
    i = j
print(ans)
"""
#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
stack = []
cnt = 0

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

Submission status: Accepted

Solution code:
S = []
ans = 0
for c in input():
    if len(S) > 0 and c != S[-1]:
        S.pop()
        ans += 2
    else:
        S.append(c)
print(ans)

Submission status: Accepted

Solution code:
from collections import deque
S = deque(input())
S2 = deque([])
counter = 0
while True:
    if len(S) == 0:
        break
    s = S.popleft()
    if len(S2) == 0:
            S2.append(s)
            continue
    
    elif s!=S2[-1]:
            S2.pop()
            counter +=2
    else:
        S2.append(s)
print(counter)

Submission status: Accepted

Solution code:
s=input()

x=s.count('1')
y=s.count('0')

a=max(x,y)
b=min(x,y)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


fin = sys.stdin.readline
S = fin().rstrip("\n")

stack = []

for color in S:
    if not stack or stack[-1] == color:
        stack.append(color)
    else:
        stack.pop()

print(len(S) - len(stack))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
print(S.count("0") * 2 if S.count("1") > S.count("0") else S.count("1") * 2)

Submission status: Accepted

Solution code:
S = input()
S = [int(i) for i in S]
sum_S=sum(S)
print(min(sum_S,len(S)-sum_S)*2)

Submission status: Accepted

Solution code:
def daruma(s):
    ans = 0
    s_stack = [s[0]]
    for i in range(1, len(s)):
        if len(s_stack) != 0:
            if s_stack[-1] + s[i] == "01" or s_stack[-1] + s[i] == "10":
                s_stack.pop()
                ans += 2
            else:
                s_stack.append(s[i])
        else:
            s_stack.append(s[i])
    return ans

def main():
    s = input()
    ans = daruma(s)
    print(ans)

main()

Submission status: Accepted

Solution code:
S = input()
S_list = []
i = 0
for s in S:
    S_list.append(s)

count_0 = S_list.count('0')
count_1 = S_list.count('1')

counter = 2 * min(count_0, count_1)
print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
fin = sys.stdin.readline
ob = list(fin())
print(min(ob.count("0"), ob.count("1"))*2)

Submission status: Accepted

Solution code:
import numpy as np
import copy

cubes = list(input())
cubes = np.array(list(map(int, cubes)))

zeroNum = 0
oneNum = 0
for i in range(0, len(cubes)):
    if cubes[i] == 0:
        zeroNum += 1
    else :
        oneNum += 1

print(min(zeroNum, oneNum) * 2)

Submission status: Accepted

Solution code:
S=list(input())
red=len(list(filter(lambda e:e=='0', S)))
blue=len(list(filter(lambda e:e=='1', S)))
d=abs(red-blue)
print(red+blue-d)

Submission status: Accepted

Solution code:
s = input()
counter = 0
length = len(s)
count0 = s.count('0')
count1 = s.count('1')

print("{}".format(int(length - abs(count0 - count1))))

Submission status: Accepted

Solution code:
a = input()
s = list(a)
s_int = [int(i) for i in s ]
t = len(s_int)
i = 0
c0 = s_int.count(0)
c1 = s_int.count(1)
if c0 > c1:
    print(2*c1)
else:
    print(2*c0)

Submission status: Accepted

Solution code:
s = list(input())
c0 = 0
c1 = 0
for i in range(len(s)):
    if s[i] == "0":
        c0 += 1
    elif s[i] == "1":
        c1 += 1
print(min(c0,c1)*2)

Submission status: Accepted

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

sa = abs(S.count("0") - S.count("1"))

print(len(S)-sa)

Submission status: Accepted

Solution code:
stack=[]
ans=0
for c in input():
    if len(stack)>0 and c!=stack[-1]:
        stack.pop()
        ans+=2
    else:
        stack.append(c)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(2*min(one, zero))

Submission status: Accepted

Solution code:
S = input()

num0 = S.count("0")
num1 = len(S)-num0

print(min(num0,num1)*2)

Submission status: Accepted

Solution code:
l=list(input())
o=0
z=0
for i in range(len(l)):
    if l[i]=="0":
        z+=1
    elif l[i]=="1":
        o+=1

if z > o:
    print(2*o)
else:
    print(2*z)

Submission status: Accepted

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

Submission status: Accepted

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

from collections import Counter
S = input()
c = Counter(S)
print(min(c.get('0', 0), c.get('1', 0)) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
C1 = S.count("0")
C2 = S.count("1")

print(min(C1,C2)*2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    c = Counter(S)
    if len(c) != 2:
        return 0
    return min(c.values()) * 2


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = list(input())
zeros = sum([1 if int(x) == 0 else 0 for x in S])
ones = sum([1 if int(x) == 1 else 0 for x in S])

print(min(zeros, ones) << 1)

Submission status: Accepted

Solution code:
N = input()
zero = N.count('0')
one = N.count('1')
ans = min(zero, one) * 2
print(ans)

Submission status: Accepted

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

print(min(L.count(0),L.count(1))*2)

Submission status: Accepted

Solution code:
import collections
s = list(input())
c = collections.Counter(s)
print(2*min(c['0'],c['1']))

Submission status: Accepted

Solution code:
from collections import deque
S = deque(input())
S2 = deque([])
counter = 0
flag = True
while True:
    if len(S) == 0:
        break
    s = S.popleft()
    if len(S2) == 0:
            S2.append(s)
            flag = False
            continue
    
    elif s!=S2[-1]:
            S2.pop()
            flag = False
            counter +=2
    else:
        S2.append(s)
    if flag:
        break
print(counter)

Submission status: Accepted

Solution code:
s = input()
a = [s.count(c) for c in '01']
print(min(a) * 2)

Submission status: Accepted

Solution code:
S = input()
num_0 = 0
num_1 = 0
for i in S:
    if i == '0':
        num_0 += 1
    else:
        num_1 += 1
print(len(S) - abs(num_0 - num_1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

count = 0
index = -1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

r = S.count("0")
b = len(S) - r

result = len(S) - abs(r - b)

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

stack=[]
for si in s:
    stack.append(si)
    if len(stack) >= 2 and stack[-1] != stack[-2]:
        del stack[-2:]
print(len(s)-len(stack))

Submission status: Accepted

Solution code:
s = input()
sl = list(s)
a = sl.count("1")
b = sl.count("0")
if a<b:
    print(a*2)
else:
    print(b*2)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()

stack=[]
for si in s:
    stack.append(si)
    if len(stack) >= 2 and stack[-1] != stack[-2]:
        del stack[-1]
        del stack[-1]
print(len(s)-len(stack))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
S = input()
ans = 0
zero = 0
one = 0
for c in S:
    if c == '0':
        zero += 1
        if one > 0:
            zero -= 1
            one -= 1
            ans += 1
    else:
        one += 1
        if zero > 0:
            zero -= 1
            one -= 1
            ans += 1
print(ans * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
istr=input()
c0=0
c1=0
for ch in istr:
    if ch == '0':
        c0+=1
    else:
        c1+=1
print(min(c0,c1)*2)

Submission status: Accepted

Solution code:
a=list(input())
b=a.count("0")
min_count=2*min(b,len(a)-b)
print(min_count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import deque

S = input()

# スタックを用いた解法
# ()の整合性判定にも使える

que = deque()
res = 0
for d in S:
    if len(que) == 0:
        que.append(d)
    elif que[-1] != d:  # 01 or 10
        res += 2
        que.pop()   # ペアを作成
    else:
        que.append(d)

print(res)

Submission status: Accepted

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
s=S()
r=s.count("0")
b=len(s)-r
print(min(r,b)*2)

Submission status: Accepted

Solution code:
import re

s = input()
zero = re.findall("0", s)
one = re.findall("1", s)
print(2 * min(len(zero), len(one)))

Submission status: Accepted

Solution code:
S=input()

li = [s for s in list(S)]

if (li.count("1") > li.count("0")):
    print(li.count("0")*2)
else:
    print(li.count("1")*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = raw_input().split()
s = l[0]

def get_removals(s):
    ret = []
    for i in range(len(s) - 1):
        if int(s[i]) + int(s[i + 1]) == 1:
            ret.append(i)
    return ret

def remove(s, index):
    if index == 0:
        return s[2:]
    if index == (len(s) - 1):
        return s[:index-1]
    return  s[0:index] + s[index + 2:]

num_removals = []

ones = 0
zeros = 0
for num in s:
    if num == '0':
        ones += 1
    if num == '1':
        zeros += 1
max_candidate = min(ones, zeros) * 2

def process(s, count):
    removals = get_removals(s)
    if len(removals) == 0:
        num_removals.append(count)
        if count == max_candidate:
            print(max_candidate)
            exit()
        return
    count += 2
    max_remove = 0
    ss = []
    for removal in removals:
        s1 = remove(s, removal)
        ss.append(s1)
        num_removes = len(get_removals(s1))
        if max_remove < num_removes:
            max_remove = num_removes
    for s1 in set(ss):
        if len(get_removals(s1)) == max_remove:
            process(s1, count)

# process(s, 0)
print(max_candidate)

Submission status: Accepted

Solution code:
S = list(map(int,input()))
num1 = 0
num0 = 0

for i in range(len(S)):
    if S[i]:
        num1 += 1
    else:
        num0 += 1

print(min(num1,num0)*2)

Submission status: Accepted

Solution code:
s=str(input())
s=list(s)
l=[]
for i in s:
	l.append(int(i))
c=0
d=0
for i in l:
    if i==0:
        c+=1
    else:
        d+=1

ans=2*min(c,d)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=str(input())
if s.count('1')>s.count('0'):
    print(s.count('0')*2)
else:
    print(s.count('1')*2)

Submission status: Accepted

Solution code:
S = str(input())
s = S
cont0 = s.count('0')
cont1 = s.count('1')
if cont0 > cont1:
    print(cont1 * 2)
else:
    print(cont0 * 2)

Submission status: Accepted

Solution code:
s = input()
count1 = s.count('1')
count0 = s.count('0')

if count0 >= count1:
    print(count1*2)
else:
    print(count0*2)

Submission status: Accepted

Solution code:
li = list(map(int,input()))
count0 = li.count(0)
count1 = li.count(1)
print(min(count0,count1)*2)

Submission status: Accepted

Solution code:
s = input()

if '1' in s and '0' in s:
    print(min(s.count('1'),s.count('0'))*2)
else:
    print(0)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    S = input()

    ans = f(S)
    print(ans)


def f(S):
    c = Counter(S)
    return min(c['0'], c['1']) * 2


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque
import copy
S = deque(input())
S2 = deque([])
counter = 0
while True:
    flag = True
    while True:
        if len(S) == 0:
            break
        s = S.popleft()
        if len(S2) == 0:
            S2.append(s)
            flag = False
            continue
        
        elif s!=S2[-1]:
            S2.pop()
            flag = False
            counter +=2
        else:
            S2.append(s)
    
    if flag:
        break
    else:
        S = copy.deepcopy(S2)
print(counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
a=0
b=0
x=0

for h in range(len(S)):
	if S[h]=="1":
		a=a+1
	else:
		b=b+1

print(a*2 if a<b else b*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C
S = input()
SL = list(map(int, list(S)))

ones = sum(SL)
zeros = len(SL) - ones
ans = min(ones, zeros) * 2
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    S = list(input())
    c = Counter(S)
    print(len(S) - abs(c['0'] - c['1']))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
inData = str(input())
ansList = []
dataLen = len(inData)
zeroCnt = 0
oneCnt = 0
for i in range(0, dataLen):
    if inData[i] == '0':
        zeroCnt += 1
    else:
        oneCnt += 1

print(2 * min([zeroCnt, oneCnt]))

Submission status: Accepted

Solution code:
cubes= list(input())
one=0
zero=0

for i in cubes:
  if i=='1':
    one+=1
  else:
    zero+=1
if one>= zero:
  print(zero*2)
else:
  print(one*2)

Submission status: Accepted

Solution code:
import collections
s=list(map(str,input()))
c=collections.Counter(s)
print(2*min(c["1"],c["0"]))

Submission status: Accepted

Solution code:
S = str(input())
count_0 = 0
count_1 = 0
for i in range(len(S)):
  if int(S[i]) == 0:
    count_0 += 1
  else:
    count_1 += 1
print((min(count_0,count_1))*2)

Submission status: Accepted

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

Submission status: Accepted

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

S = input()

# 最終出力は1のみか0のみとなるはず
# つまり、0と1の個数をカウントし、その差分から答えが求められる

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

fin = abs(c0-c1)    # 最後に残る0か1の個数
res = len(S) - fin

print(res)

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 = str(input())
if s.count("0") > 0 and s.count("1") > 0:
    print(2*min(s.count("0"),s.count("1")))
else:
    print(0)

Submission status: Accepted

Solution code:

S = input()
work=list(S)
i=0
o_cout=0
z_cout=0
for x in work:
    if(x=='1'):
        o_cout+=1
    else:
        z_cout+=1
    
if(o_cout>z_cout):
    cout=z_cout
else:
    cout=o_cout
    

print(cout*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

# import math
# import numpy as np
# import copy
# from collections import defaultdict, Counter
# from itertools import product
# from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

S = input()
N = len(S)
c0 = S.count("0")
c1 = S.count("1")

print(2*min(c0, c1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = s.count('1')
b = s.count('0')

num = min(a,b)*2
print(num)

Submission status: Accepted

Solution code:
s = str(input())
count0= 0
count1 = 0
for i in range(len(list(s))):
    if s[i] == '0':
        count0 += 1
    else:
        count1 += 1
print(min(count1,count0)*2)

Submission status: Accepted

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

Submission status: Accepted

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

print(min(one, zero)*2)

Submission status: Accepted

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

Submission status: Accepted

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

if 0 not in S:
    print(0)

elif 1 not in S:
    print(0)

else:
    zeros = S.count(0)
    ones = S.count(1)
    if zeros > ones:
        print(ones * 2)
    else:
        print(zeros * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

S = np.array(list(map(int, input())))

n0 = (S == 0).sum()
n1 = (S == 1).sum()

print(min(n0, n1) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = input()

S = [s for s in S]
S = [int(s, 0) for s in S]
S.sort()
if 1 in S and  0 in S:
    print(min(S.count(0)*2,S.count(1)*2))
else:
    print(0)

Submission status: Accepted

Solution code:
s=input()
ind=0
ret=0
while ind < len(s)-1:
  if s[ind]!=s[ind+1]:
    s=s[:ind]+s[ind+2:]
    #print(s)
    ret+=2
    if ind > 0:
      ind-=1
  else:
    ind+=1
print(ret)

Submission status: Accepted

Solution code:
S=input()
if S.count("1")>=S.count("0"):
  print(S.count("0")*2)
else:
  print(S.count("1")*2)

Submission status: Accepted

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

c=0
i=0
f=0
while(1):
    if i+1 == N or N < 2:
        break
    if S[i] != S[i+1]:
        del S[i:i+2]
        c += 2
        N -= 2
        if i >= 1:
            i -= 2
        else:
            i -= 1
    i += 1
    #print(i,N,S,f)                                                                      
print(c)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random
# import pandas as pd
# import torch


s = list(str(input()))


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

ans = 2*min(count[0],count[1])
#
print(ans)
# escape = False
# begin = len(s)
#
# def rem(s):
#     for i in range(1,len(s)):
#         # print(s)
#         if s[i-1] != s[i]:
#             s.pop(i)
#             s.pop(i-1)
#             break
#     return s
#
#
# pre = len(s)
# proceed = 0
# while proceed != pre:
#     pre = len(s)
#     s = rem(s)
#     after = len(s)
#
# end = len(s)
# print(begin-end)

Submission status: Accepted

Solution code:
s=input()
n_0=0
n_1=0
ans=0

for i in range(len(s)):
    if(s[i]=="0"):
        n_0+=1
    else:
        n_1+=1

ans=min(n_0*2,n_1*2)
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
N = len(S)
num0 = 0
for i in range(N):
	if S[i] == '0':
		num0 = num0 + 1

num1 = 0
for i in range(N):
	if S[i] == '1':
		num1 = num1 + 1
print(N - abs(num0 - num1))

Submission status: Accepted

Solution code:
import numpy as np
s = np.array(list(input()))

print(min((s=='0').sum(),(s=='1').sum())*2)

Submission status: Accepted

Solution code:
import re

tmp = raw_input()

length = len(tmp)


tmp1 = tmp.replace("0", "")
tmp2 = tmp.replace("1", "")

if len(tmp1) > len(tmp2):
    tmp3 = len(tmp1) - len(tmp2)

else:
    tmp3 = len(tmp2) - len(tmp1)


division = length - tmp3

print(division)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cin = input()
count_0 = 0
count_1 = 0
for i in range(len(cin)):
  if int(cin[i]) == 0:
    count_0 = count_0 + 1
  else:
    count_1 = count_1 + 1
m = min(count_0,count_1)
ans = m*2
print(ans)

Submission status: Accepted

Solution code:
#ABC120C-Unification.py

from sys import stdin

input = stdin.readline

S = input().rstrip()

Nblock = min(S.count('1'), S.count('0'))

print(Nblock*2)

Submission status: Accepted

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

from sys import stdin


############################################

#from sys import stdin
import numpy as np

# read data for n sequences.
data = stdin.readline().split()
data=str(data)
data2=[]
for a in data[2:-2]:
    data2.append(int(a))
data=data2

start = data[0]
count=0
for i, c in enumerate(data):
    # end
    if i == len(data)-1:
        break
    # startと3こ続いた
    if c==start and data[i+1]==start:
        count+=2
        
    # 同じのが三個続いた
    if i!=0:
        if c==data[i-1]==data[i+1]:
            count+=2
            start=c

count0=0
for i, c in enumerate(data):
    if c==0:
        count0+=1
count1=len(data)-count0

if count1>count0:
    print(len(data)-(count1-count0))
else:
    print(len(data)-(count0-count1))

Submission status: Accepted

Solution code:
s = input()
ones = [1 for x in s if x=="1" ]
print(min(len(ones),len(s)- len(ones))*2)

Submission status: Accepted

Solution code:
s = input()

print(min(s.count('0'), s.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:
data=input()
n1 = data.count('1')
n0 = data.count('0')
print(min(n1, n0) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = str(input())

a=N.count('1')
b=N.count('0')
if a < b:
    print(a*2)
elif a >= b:
    print(b*2)

Submission status: Accepted

Solution code:
# coding: utf-8
s = list(input())
zero = s.count("0")
one = s.count("1")
print(min(zero,one)*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
ans = len(s)-abs(s.count('0')-s.count('1'))

print(ans)

Submission status: Accepted

Solution code:
S = [int(_) for _ in input()]
length = len(S)
temp = [S[0]]
for x in S[1:]:
    if(len(temp) == 0):
        temp.append(x)
    elif( temp[-1] == x):
        temp.append(x)
    else:
        temp.pop(-1)
print(length-len(temp))

Submission status: Accepted

Solution code:
S = list(input())
a = 0
b = 0
for i in range(len(S)):
  if int(S[i]):
    a += 1
  else:
    b += 1
if a < b:
  print(a*2)
else:
  print(b*2)

Submission status: Accepted

Solution code:
# coding: utf-8

S = list(map(int, input()))
N = len(S)

zero = len([s for s in S if s == 0])
one = len([s for s in S if s == 1])
print(len(S) - abs(zero - one))

Submission status: Accepted

Solution code:
def spaceinput():
    return list(map(int,input().split(" ")))



s=input()

s=list(s)

n1=0
n0=0

for ss in s:
    if ss=='0':
        n0+=1
    else:
        n1+=1
    
print(min(n0,n1)*2)

Submission status: Accepted

Solution code:
s = input()

zero = 0
one = 0

for c in s:
    if c == "0":
        zero += 1
    else:
        one += 1

print(min(zero, one) * 2)

Submission status: Accepted

Solution code:
s = list(input())

zerocnt = s.count('0')
onecnt = len(s) - zerocnt
if zerocnt <= onecnt:
  print(zerocnt * 2)
else:
  print(onecnt * 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
sl = list(str(s))

c1 = sl.count('1')
c0 = sl.count('0')

r = abs(c1-c0)

print(len(s)-r)

Submission status: Accepted

Solution code:
S = str(input())

a = [int(x) for x in S]
b = min(a.count(0), a.count(1))

print(b * 2)

Submission status: Accepted

Solution code:
inp = input()
le = len(inp)
ze =0
ic = 0


k = list(inp)
for f in k:
  if f == "0":
    ze += 1
  else:
    ic += 1
m = le - abs(ze-ic)
print(m)

Submission status: Accepted

Solution code:
string = input()
str_lis = list(string)
num_lis = [int(x) for x in str_lis]
s = sum(num_lis)
l = len(num_lis)
d = l - s
x = min(s, d)
print(x * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
P=raw_input();print min(P.count('0'),P.count('1'))*2