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()
N=len(S)

red=S.count("0")
blue=N-red

if red>=blue:
    print(N-red+blue)
else:
    print(N+red-blue)

Submission status: Accepted

Solution code:
S = list(input())

zero_count = 0
one_count = 0

for i in range(len(S)):
	if S[i] == '0':
		zero_count += 1
	else:
		one_count += 1

print(2 * min(zero_count, one_count))

Submission status: Accepted

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

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
c = [s[0]]
for i in range(1,len(s)):
    if(len(c)==0 or (c[-1]=='1' and s[i]=='1') or (c[-1]=='0' and s[i]=='0')):
        c.append(s[i])
    else:
        del c[-1]
print(len(s)-len(c))

Submission status: Accepted

Solution code:
S = str(input())

count_0 = S.count("0")
count_1 = S.count("1")

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

Submission status: Accepted

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

Submission status: Accepted

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

S = input()

zero_number = S.count('0')
one_number = S.count('1')

print(min(zero_number, one_number) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
data = input()
data_list = [c for c in data]
# print(data_list)
count = 1
delete_count = 0
number_of_one = data_list.count('1')
number_of_zero = data_list.count('0')

min_num = min(number_of_zero, number_of_one)
print(min_num * 2)

Submission status: Accepted

Solution code:
S = input()

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

print(2 * min(zero, one))

Submission status: Accepted

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

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()
a = s.count('0')
b = s.count('1')
print(len(s) - max(a, b) + min(a, b))

Submission status: Accepted

Solution code:
from sys import stdin
import collections
S = stdin.readline().rstrip()
co = collections.Counter(S)
if len(co.most_common()) == 1:
    print('0')
else:
    print(co.most_common()[1][1] * 2)

Submission status: Accepted

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

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=S()
  return min(s.count('0'),s.count('1'))*2

print(main())

Submission status: Accepted

Solution code:
#Coding: Utf-8
N=input()
 
A=N.count("1")
B=N.count("0")
if A==0 or B==0:
  print(0)
  exit()
 
print(min(A,B)*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC120C - Unification
s = input().rstrip()
print(min(s.count("0"), s.count("1")) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input();
l=len(s)
zero,one=0,0
for i in s:
	if i=='0': zero+=1
	else: one+=1
print(min(zero, one)*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 = input()
c0 = 0
c1 = 0
for i in S:
    if i == "0":
        c0 += 1
    else:
        c1 += 1
print(min(c0, c1) * 2)

Submission status: Accepted

Solution code:
import sys
import itertools
from collections import deque
from operator import itemgetter

input = sys.stdin.readline
S = input()
counter = 0

A = S.count('1')
B = S.count('0')
print(2*min(A,B))

Submission status: Accepted

Solution code:
#Coding: Utf-8
N=input()

A=N.count("1")
B=N.count("0")
if A==0 or B==0:
  print(0)
  exit()

print(min(A,B)*2)

Submission status: Accepted

Solution code:
s = input()
#0と1は存在する限り打ち消しあう
print(2*min(s.count("0"), s.count("1")))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

s=np.array(list(map(int,list(input()))))
k = s*2-1
print(len(k)-abs(sum(k)))

Submission status: Accepted

Solution code:
S=input()
print(min(S.count('1'),S.count('0'))*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 = input()

# 適当に取り除く操作を繰り返せばよい
ans = 2 * min(S.count('0'), S.count('1'))

# 出力
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input() 

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
cnt_1 = S.count('1')
cnt_0 = S.count('0')

print(min(cnt_1 , cnt_0) * 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:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()
    N = len(S)

    stack = deque([])
    for c in S:
        if len(stack) == 0:
            stack.append(c)
            continue

        a = stack.pop()
        if a == c:
            stack.append(a)
            stack.append(c)

    print(N - len(stack))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
cc = [c for c in S]
nbZero = 0
nbOne = 0
for c in cc:
    if c == "0":
        nbZero = nbZero + 1
    else:
        nbOne = nbOne + 1
d = min(nbZero, nbOne)
print(2*d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())

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

Submission status: Accepted

Solution code:
inpString = [ i for x in input() for i in x ]
n0 = inpString.count('0')
n1 = inpString.count('1')
print( 2*min(n0,n1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = 0
p = 0
for c in input():
  n = int(c) * 2 - 1
  p += max(abs(s) - abs(s+n), 0) * 2
  s += n
print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().rstrip()

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

Submission status: Accepted

Solution code:
data = input()

x = data.count("0")
y = data.count("1")

print(min(x,y) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

num0 = 0
num1 = 0
for i in S:
    if i == '0':
        num0 += 1
    else:
        num1 += 1

ans = min(num0,num1)*2
print(ans)

Submission status: Accepted

Solution code:
s = input()
n0, n1 = 0, 0

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

Submission status: Accepted

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

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 = input()

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

Submission status: Accepted

Solution code:
S = input()
One = S.count("1")
Zero = S.count("0")
print(len(S) - max(One, Zero) + min(One, Zero))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~


S = input().rstrip()

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

print(min(r, b) * 2)

Submission status: Accepted

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

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

S = input().rstrip()

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

print(min(r, b) * 2)

Submission status: Accepted

Solution code:
import sys
rr = lambda: sys.stdin.readline().strip()
ri = lambda: int(rr())
rs = lambda: [int(_) for _ in rr().split()]

S = list(rr())
a = S.count('0')
b = S.count('1')

print(min(a, b) * 2)

Submission status: Accepted

Solution code:
S = input()
SS = []
for s in range(len(S)):
  SS.append(int(S[s]))
zero = SS.count(0)
one = SS.count(1)
print(min(zero, one)*2)

Submission status: Accepted

Solution code:
bin_str = str(input())  # 入力されたビット列そのまま文字列
bitdigits = len(bin_str)  # 桁数

cntzero = bin_str.count("0")
cntone = bin_str.count("1")

if cntzero < cntone:
    print(cntzero * 2)
else:
    print(cntone * 2)

Submission status: Accepted

Solution code:
def main():
    s = list(map(int,input()))
    print(min(len(s)-sum(s),sum(s))*2)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


def solve(S: str):
    N  = len(S)
    RN = S.count('0')
    BN = N - RN
    print(min(RN,BN)*2)

    return


# Generated by 1.1.4 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: int
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = str(input())
S_list = []

red = 0
blue = 0

for i in range(len(S)):
  if S[i]=="0":
    red+=1
  else:
    blue+=1

print(2*min(red,blue))

Submission status: Accepted

Solution code:
def ans(S):
  zero = 0
  one  = 0
  for i in range(len(S)):
    if S[i] == "0":
      zero += 1
    else:
      one += 1
  return len(S) - abs(zero - one)

S = input()
print(ans(S))

Submission status: Accepted

Solution code:
s = list(input())
ans = 0

zero = s.count('0')
one = len(s) - zero
ans = min(zero, one) * 2

print(ans)

Submission status: Accepted

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

zero = S.count('0')
if zero == N or zero == 0:
    print(0)
    exit()

one = N - zero
if zero == one:
    ans = N
elif zero > one:
    ans = one * 2
else:
    ans = zero * 2

print(ans)

Submission status: Accepted

Solution code:
S = input()

cnt_0 = 0
cnt_1 = 0

for i in range(len(S)):
    if S[i] == "0":
        cnt_0 += 1
    else:
        cnt_1 += 1

min_num = min(cnt_0, cnt_1)

if len(S) > 1:
    print(min_num * 2)
else:
    print(0)

Submission status: Accepted

Solution code:
S=input()
n=len(S)
i=0
cnt0=0
cnt1=0
while i<n:
       if S[i]=="1":
              cnt1+=1
       else:
              cnt0+=1
       i+=1
ans=min(cnt0,cnt1)
print(ans*2)

Submission status: Accepted

Solution code:
s = input()
cnt0 = 0
cnt1 = 0
for i in s:
    if i == '0':
        cnt0 += 1
    else:
        cnt1 += 1
print(2 * min(cnt0, cnt1))

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 = input()

l = []
for s in S:
	si = int(s)
	if not l:
		l.append(si)
	else:
		if (l[-1] + si) & 1:
			l.pop()
		else:
			l.append(si)
print(len(S) - len(l))

Submission status: Accepted

Solution code:
S = input()

onecount = 0
zerocount = 0
for i in range(len(S)):
    if S[i] == "0":
        zerocount += 1
    else:
        onecount += 1
print(min(zerocount, onecount)*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())
red = 0
blue = 0
for i in range(len(S)):
    if S[i] == "0":
        red += 1
    else:
        blue += 1
print(2*min(red, blue))

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
for i in range(len(S)):
    if S[i] == '0':
        red += 1
blue = len(S) - red
print(2*min(red, blue))

Submission status: Accepted

Solution code:
def solve(S):
    zeros = 0
    ones = 0
    for i in range(len(S)):
        if S[i] == "0":
            zeros += 1
        elif S[i] == "1":
            ones += 1
    return len(S) - abs(zeros - ones)


S = input()
print(solve(S))

Submission status: Accepted

Solution code:
L = [int(i) for i in list(input())]
N = len(L)

one = L.count(1)
zero = L.count(0)

if one < zero :
  print(one * 2)
else :
  print(zero * 2)

Submission status: Accepted

Solution code:
S = list(input())
cnt0 = S.count('0')
cnt1 = len(S)-cnt0
print(min(cnt0,cnt1)*2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(min(cnt, n-cnt) * 2)

Submission status: Accepted

Solution code:
S = input()
red = S.count("0")
blue = S.count("1")
if red == 0 or blue == 0:
    print(0)
else:
    print(min(red, blue) * 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from _collections import deque

s = input()
stack = deque()
for i in range(len(s)):
    stack.append(s[i])
    while len(stack) > 1:
        x = stack.pop()
        y = stack.pop()
        if x == y:
            stack.append(x)
            stack.append(y)
            break
print(len(s) - len(stack))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input data
s = input()

# solve
n = len(s)
blue = s.count("1")
red = n - blue

print(min(blue,red)*2)

Submission status: Accepted

Solution code:
S = input()

ones = S.count("1")
zeros = S.count("0")

ans = min(ones,zeros)*2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(input())
red_cnt=0
blue_cnt=0
for s in S:
    if s=="0":
        red_cnt+=1
    elif  s=="1":
        blue_cnt+=1
print(min(red_cnt,blue_cnt)*2)

Submission status: Accepted

Solution code:
s = input().strip()
s = s[::-1]
ans = len(s)
i = 0
while (i + 1) < len(s):
    if s[i] != s[i + 1]:
        s = s[:i] + s[i + 2:]
        i = max(i - 1, 0)
    else:
        i += 1
print(ans - len(s))

Submission status: Accepted

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

S = input()
N = len(S)

cnt_0 = 0
cnt_1 = 0
for i in range(N):
    if S[i] == '0':
        cnt_0 += 1
    else:
        cnt_1 += 1

ans = N - abs(cnt_0 - cnt_1)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
li = [0,0]
for it in S:
  li[int(it)]+=1
a,b = li
print ( min(a,b) * 2 )

Submission status: Accepted

Solution code:
S = input()

print(len(S) - abs(S.count('0') - S.count('1')))

Submission status: Accepted

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

count = 0
for i in range(N):
    if S[i] == "0":
        count += 1

ans = min(count, N - count) * 2
print(ans)

Submission status: Accepted

Solution code:
# S = '0011'
# S = '11011010001011'
# S = '0'
S = input()

red = 0
blue = 0

for i in S:
    if i == '0':
        red += 1
    else:
        blue += 1

print(min(red,blue) * 2)

Submission status: Accepted

Solution code:
S = input()

count_red = S.count('0')

print(min(count_red*2, ((len(S)-count_red)*2)))

Submission status: Accepted

Solution code:
S = raw_input();

S1 = S.count('1');
S0 = S.count('0');

if S1 > S0:
	print S0 * 2;

else:
	print S1 * 2;

Submission status: Accepted

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


if __name__ == "__main__":
  main()

Submission status: Accepted

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

print(ans)

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()
num1 = S.count("1")
num0 = S.count("0")
print(len(S)-abs(num0-num1))

Submission status: Accepted

Solution code:
s = input()
total = 0

count_0 = s.count('0') * 2
count_1 = s.count('1') * 2

if count_0 < count_1:
  print(count_0)
else:
  print(count_1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    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()


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

print(min(zero, one)*2)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    S = str(input())
    N = len(S)
 
    count_0 = S.count('0')
    count_1 = S.count('1')
 
    answer = 2 * min(count_0, count_1)
 
    print(answer)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    S = str(input())
    N = len(S)

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

    answer = 2 * min(count_0, count_1)

    print(answer)

Submission status: Accepted

Solution code:
S = [int(c) for c in input()]
zeros = S.count(0)
ones = S.count(1)
print(2 * min(zeros, ones))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
count0=0
count1=0
for i in range(len(S)):
    if S[i]=="0":
        count0+=1
    else:
        count1+=1
dif=abs(count1-count0)
print(len(S)-dif)

Submission status: Accepted

Solution code:
S = input()
ans = 0
i = 0
while i < len(S):
    if any(['01' in S[i:i+2],'10' in S[i:i+2]]):
        S = S[:i]+S[i+2:]
        ans += 2
        i -= 1
    else:
        i += 1
print(ans)

Submission status: Accepted

Solution code:
S = input()
sum_0 = 0
sum_1 = 0
for i in S:
  if (i == '0'):
    sum_0 += 1
  else:
    sum_1 += 1
print(2 * min(sum_0, sum_1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ones = S.count('1')
zeros = len(S) - ones
res = min(ones, zeros) * 2
print(res)

Submission status: Accepted

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


def solve(S: str):
    count_dict = collections.defaultdict(int)
    for s in S:
        count_dict[s] += 1
    print(min(count_dict['0'],count_dict['1'])*2)
    return


# Generated by 1.1.4 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():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S, cnt = (str(input()), 0)
for c in S:
    cnt = cnt+1 if c=="1" else cnt-1
print(len(S)-abs(cnt))

Submission status: Accepted

Solution code:
S=str(input())

cnt0=sum(s=='0' for s in S)
if len(S)/2>cnt0:
    print(cnt0*2)
else:
    print((len(S)-cnt0)*2)

Submission status: Accepted

Solution code:
S = input()
N = len(S)
count_0 = 0
for s in S:
    if s == "0":
        count_0 += 1
print(min(count_0, N - count_0) * 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((len(S)-abs(n0-n1)))

Submission status: Accepted

Solution code:
S = input()
redcount = 0
bluecount = 0
for i in S:
    if i == "1":
        redcount += 1
    else:
        bluecount += 1

print(len(S)-abs(bluecount-redcount))

Submission status: Accepted

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

s = list(input())
l = {
    "0": 0,
    "1": 0,
}

for v in s:
    if l.get(v):
        l[v] += 1
    else:
        l[v] = 1
        
print(min(l["0"], l["1"]) * 2)

Submission status: Accepted

Solution code:
N = input()

num0 = 0
num1 = 0
for i in N:
    if i == '0':
        num0 = num0 + 1
    else:
        num1 = num1 + 1

print(2*min(num0,num1))

Submission status: Accepted

Solution code:
N = input()

A = []
for i in N:
    A.append(i)

cnt = 0
j = 0
while len(A) >= 2 and len(A)-1 > j:
    if A[j] != A[j+1]:
        cnt = cnt + 2    
        del A[j]
        del A[j]
        if j != 0:
            j -= 1
    else:
        j += 1

print(cnt)

Submission status: Accepted

Solution code:
import numpy as np

S = str(input())

cnt_0 = S.count('0')
cnt_1 = S.count('1')

ans = 2*min(cnt_0, cnt_1)
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

s = input()
n = len(s)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

#print (S)

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

print (2 * min(blue, red))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

Z = len([i for i in S if i == "0"])
print(min([Z, len(S)-Z])*2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S = S.replace("0","r")
S = S.replace("1","b")
r = 0
b = 0
for s in S:
    if s == "r":
        r+=1
    else:
        b+=1
print(min([r,b])*2)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

zero_cnt = C.count(0)
one_cnt = C.count(1)
print(min(zero_cnt,one_cnt) *2)

Submission status: Accepted

Solution code:
s = input()
one = 0
zero = 0
for i in range(len(s)):
    if s[i] == "0":
        zero += 1
    else:
        one += 1
print(len(s) - abs(one - zero))

Submission status: Accepted

Solution code:
S = list(map(int, list(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()
n = len(s)
zcount = 0
for i in range(n):
  if s[i] == "0":
    zcount += 1
print(2 * min(zcount, n - zcount))

Submission status: Accepted

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

def solve():
    S = input()

    num0 = 0
    num1 = 0
    for moji in S:
        if moji == "0":
            num0 += 1
        else:
            num1 += 1
    erase_num = min(num0, num1)
    print(erase_num*2)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
S = input()
f, t = 0, 0
for i in S:
    if i == '0':
        f += 1
    else:
        t += 1

print(2*min(f, t))

Submission status: Accepted

Solution code:
s = str(input())
z = sum([str(x)=='0' for x in s])
o = sum([str(x)=='1' for x in s])
print(2*min(z, o))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd

from collections import Counter


def solve(S: str):
    c = Counter(S)
    c.setdefault('1', 0)
    c.setdefault('0', 0)
    return 2 * min(c.values())


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = (next(tokens))  # type: str
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding:utf-8


def main():
    S = input()
    RED = "0"
    BLUE = "1"
    red_count = 0
    blue_count = 0
    ans = 0

    for si in S:
        if si == RED:
            red_count += 1
        else:
            blue_count += 1

    if red_count == 0 or blue_count == 0:
        ans = 0
    else:
        ans = 2 * min(red_count, blue_count)

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter

S = input()

cnt = Counter(list(S))
x = min(cnt['0'], cnt['1'])
print(x * 2)

Submission status: Accepted

Solution code:
S = input()

dif = 0
for s in S:
  if s == '1': dif += 1
  elif s == '0': dif -= 1
    
print(len(S)-abs(dif))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

S = input()

zero = 0
one = 0

for s in S:

    if s == '0':
        zero += 1
    elif s == '1':
        one += 1

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

Submission status: Accepted

Solution code:
S = input()
N = len(S)
A = 0

for i in range(N):
    if S[i] == '1':
        A = A + 1

print(min(N - A, A)*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:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

S = input()
ls = list(S)
ls = [int(x) for x in ls]

ans = min(ls.count(0),ls.count(1))
print(ans*2)

Submission status: Accepted

Solution code:
S = input()

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

print(len(S) - abs(c0 - c1))

Submission status: Accepted

Solution code:
S=input()
red=0
blue=0
ans=0
for i,s in enumerate(S):
    if i==0:
        if s=='0':
            red+=1
        else:
            blue+=1
    else:
        if s=='0':
            red+=1
        else:
            blue+=1
            
        if (red>0)and(blue>0):
            ans+=2
            red-=1
            blue-=1
print(ans)

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()
origin_length = len(S)
zero_cnt = S.count('0')
ones_cnt = S.count('1')
print(min(zero_cnt,ones_cnt)*2)

Submission status: Accepted

Solution code:
from __future__ import print_function
import sys

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

cnt=0
S=list(input())
# eprint(S)

L=list()
L.append(S.pop())
while len(S)!=0:
    if S[-1]==L[-1]: # SのfrontとLのfrontが0と0とか一致しちゃった時だから，消せない．次のSのfrontを見よう 
        L.append( S.pop() )
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))
    else: # SのfrontとLのfrontが0と1となっている場合．消す．
        S.pop()
        L.pop()
        if L==[] and S!=[]:
            L.append(S.pop())
        cnt=cnt+2
        # eprint("S: " + str(S))
        # eprint("L: " + str(L))

print(cnt)

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