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: Wrong Answer

Solution code:
S = list(input())

count = 0
is_continue = False

while True:
  is_continue = False
  for i in range(len(S) - 2):
    if S[i] != S[i+1]:
      S.pop(i)
      S.pop(i)
      count += 2
      is_continue = True
      break
  
  if is_continue == False:
    if len(S) >= 2:
      if S[0] != S[1]:
        S.pop(0)
        S.pop(0)
        count += 2
    print(count)
    exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

def erase(lis, cnt):
    #print("try")
    i = 0
    this_cnt = 0
    while(i < len(lis)-1):
        
        if lis[i] != lis[i+1]:
            del lis[i]
            del lis[i]
            this_cnt += 1
            cnt += 1
            #print(cnt, lis)
        else:
            i+=2
    #print("cnt so far: ", cnt, "this_cnt: ", this_cnt)
    if this_cnt > 0:
        erase(lis, cnt)

    return cnt

        
def main():
    string = input()
    lis = [int(v) for v in string]
    
    #print(lis)
    cnt = erase(lis, 0)
    #print(cnt)
    ans = cnt * 2
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
def f(s):
    ans = 0
    num = 0
    for c in s:
        if c == "0":
            num += 1
        else:
            if num > 0:
                num -= 1
                ans += 2
    return ans

def solve(s):
    return max(map(f, [s,s[::-1]]))

assert solve("0011") == 4
assert solve("11011010001011") == 12
assert solve("0") == 0

s = input()
print(solve(s))

Submission status: Wrong Answer

Solution code:
S = input()

zero_cnt = S.count("0")
one_cnt = S.count("1")

print( min(zero_cnt, one_cnt) )

Submission status: Wrong Answer

Solution code:
S = input()
len_org = len(S)
while True:
    len_before = len(S)
    S.replace("10","").replace("01","")
    len_after = len(S)
    if len_before == len_after:
        break

print(len_org - len_after)

Submission status: Wrong Answer

Solution code:
s = input()
stack = []
r = 0
for c in s:
  n = int(c)
  if len(stack) > 0 and stack[-1] ^ n == 1:
    stack.pop()
    r += 1
  else:
    stack.append(n)
print(r)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
S = input()
print(2*min(S.count("0"), S.count("1c")))

Submission status: Wrong Answer

Solution code:
x = input()
l = len(x)
l0 = sum([1 for c in x if c == '1'])
l1 = l - l0
if l1 == l:
    print(l)
elif l0 == l:
    print(l)
else:
    if l1 < l0:
        print(l - l0 + l1)
    else:
        print(l - l1 + l0)

Submission status: Wrong Answer

Solution code:
import sys


def main(inp):
    cube_state, *cubes = inp
    stack_state = 1
    count = 0
    for cube in cubes:
        if cube == cube_state:
            stack_state += 1
        else:
            stack_state -= 1
            count += 2
        if stack_state == 0:
            if cube_state == "0":
                cube_state = "1"
            else:
                cube_state = "0"
    return count


if __name__ == '__main__':
    inp = sys.stdin.readline().strip()
    print(main(inp))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = [i for i in input().split()]
print(a)

Submission status: Wrong Answer

Solution code:
s = input()
s = '11011010001011'
 
count = 0
 
def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str
 
def remove_cube(string, count):
  count = string.count('10')
  if count > 0:
    new_text = string.replace('10', '', count)
  count = string.count('01')
  if count > 0:
    new_text = string.replace('01', '', count)
  return new_text
 
string = s
can_remove = True
while can_remove:
  search_count = string.count('10')
  if search_count > 0:
    new_text = string.replace('10', '', search_count)
  else:
    search_count = string.count('01')
    if search_count > 0:
      new_text = string.replace('01', '', search_count)

  if new_text != string:
    string = new_text
    count += search_count * 2
    can_remove = True
  else:
    can_remove = False
 
print(count)

Submission status: Wrong Answer

Solution code:
s = '11011010001011'

count = 0

def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str

def remove_cube(string):
  new_text = string.replace('10', '', 1)
  if new_text == string:
    new_text = string.replace('01', '', 1)
  return new_text

string = s
can_remove = True
while can_remove:
  removed = remove_cube(string)
  if removed != string:
    string = removed
    count += 2
    can_remove = True
  else:
    can_remove = False

print(count)

Submission status: Wrong Answer

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

# 入力された文字列
string = input()

# 最大処理数。100000以下なら文字列長。
max = min(len(string), 100000)

# 削除した文字数
del_count = 0

# 削除があった場合True
del_flg = True

# 削除文字がなくなるまでループする
while del_flg:
    del_flg = False

    # 
    for idx in range(max):
        if idx == max or idx > max:
            break
            
        # 照合対象の文字を切り出す
        target = string[idx : idx + 2]
        
        if target == "01" or target == "10":
            # 削除文字に一致した場合、元の文字列からそれを削除しカウントを進め、
            # 削除フラグを立てる
            string = string.replace(string[idx : idx + 2], '')
            del_count += 2
            max -= 2
            del_flg = True

print(del_count)

Submission status: Wrong Answer

Solution code:
S = input()

zero = 0
one = 1
for n in S:
  if n == "0":
    zero+=1
  elif n == "1":
    one+=1

print(min(zero,one)*2)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import copy

string = [x for x in input()]

concat_string = copy.copy(string)
count = 0
while True:
    num_delete = 0
    flags_delete = [False] * len(string)
    
    i = 0
    j = 1
    while True:
        if j >= len(concat_string) or i < 0:
            break
        if concat_string[i] != concat_string[j]:
            flags_delete[i] = True
            flags_delete[j] = True
            num_delete += 2
            
            if i == 0:
                i = j + 1
                j = i + 1
            else:
                i = i - 1
                j = j + 1
        else:
            i = j
            j = i + 1
           
    if num_delete == 0:
        break
    
    count += num_delete
    concat_string = [concat_string[i] for i in range(len(concat_string)) if flags_delete[i] == False]

print(count)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import copy

string = [x for x in input()]

concat_string = copy.copy(string)
count = 0
while True:
    num_delete = 0
    flags_delete = [False] * len(string)
    
    i = 0
    j = 1
    while j < len(concat_string):
        if concat_string[i] != concat_string[j]:
            flags_delete[i] = True
            flags_delete[j] = True
            num_delete += 2
            
            if i == 0:
                i = j + 1
                j = i + 1
            else:
                i = i - 1
                j = j + 1
        else:
            i = j
            j = i + 1
           
    if num_delete == 0:
        break
    
    count += num_delete
    concat_string = [concat_string[i] for i in range(len(concat_string)) if flags_delete[i] == False]

print(count)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import copy

string = [x for x in input()]

concat_string = copy.copy(string)
count = 0
while True:
    num_delete = 0
    flags_delete = [False] * len(string)
    
    i = 0
    j = 1
    while j < len(concat_string) - 1:
        if concat_string[i] != concat_string[j]:
            flags_delete[i] = True
            flags_delete[j] = True
            num_delete += 2
            
            if i == 0:
                i = j + 1
                j = i + 1
            else:
                i = i - 1
                j = j + 1
        else:
            i = j
            j = i + 1
           
    if num_delete == 0:
        break
    
    count += num_delete
    concat_string = [concat_string[i] for i in range(len(concat_string)) if flags_delete[i] == False]

print(count)

Submission status: Wrong Answer

Solution code:
from itertools import groupby

s = input()

g = []

for i, v in groupby(s):
    g.append(len(list(v)))
    
i = 0
j = 1

if len(g) < 2:
    print(0)
    exit()

first = g[i] # 最初に現れる方
second = g[j] # firstじゃない方
ans = 0

while True:
    if first < second:
        ans += 2*first
        first = 0
        second -= first
        i += 2
        if i >= len(g) or j >= len(g):
            break
        first += g[i]
    elif second < first:
        ans += 2*second
        first -= second
        i += 2
        j += 2
        if i >= len(g) or j >= len(g):
            break
        first += g[i]
        second = g[j]
    else:
        ans += 2*first
        i += 2
        j += 2
        if i >= len(g) or j >= len(g):
            break
        first = g[i]
        second = g[j]
        
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

num_0 = S.count('0')
num_1 = S.count('1')

print(abs(num_0 - num_1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
n = len(s)

cursor = 0
prev = ""
ans = 0

while cursor < n:
    cur = s[cursor]
    
    if cur != prev:
        prev = cur
        cursor += 1
        
    else:
        left = cursor-1
        right = cursor
        
        while left >= 0 and right < n:
            if s[left] != s[right]:
                break
            
            ans += 2
            left -= 1
            right += 1
            
        cursor = right+1
        prev = ""
        
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
n = len(s)

cursor = 0
prev = ""
ans = 0

while cursor < n:
    cur = s[cursor]
    
    if cur != prev:
        prev = cur
        cursor += 1
        
    else:
        left = cursor-1
        right = cursor
        
        while left >= 0 and right < n:
            if s[left] != s[right]:
                break
            
            ans += 2
            left -= 1
            right += 1
            
        cursor = right
        prev = ""
        
print(ans)

Submission status: Wrong Answer

Solution code:
cubes = input()

deleted_cube_len = 0

char_possible_deleted = cubes[0]
char_possible_deleted_len = 1

deleted_char_len = 0

is_deleting = False

for i in range(1, len(cubes)):
    if not is_deleting:
        if char_possible_deleted == cubes[i]:
            char_possible_deleted_len += 1
        else:
            is_deleting = True

    if is_deleting:
        if char_possible_deleted_len > deleted_char_len and char_possible_deleted != cubes[i]:
            deleted_char_len += 1
            deleted_cube_len += 2

        else:
            char_possible_deleted = cubes[i]
            char_possible_deleted_len = 1
            deleted_char_len = 0
            is_deleting = False

print(deleted_cube_len)

Submission status: Wrong Answer

Solution code:
cubes = input()

removed_cubes_count = 0
counted_char = cubes[0]
counted_char_len = 1
deleted_char_len = 0

for i in range(1, len(cubes)):
    if counted_char == cubes[i]:
        counted_char_len += 1
    else:
        if counted_char_len > deleted_char_len:
            deleted_char_len += 1
            removed_cubes_count += 2
        else:
            counted_char = cubes[i]
            counted_char_len = 0
            deleted_char_len = 0

print(removed_cubes_count)

Submission status: Wrong Answer

Solution code:
cubes = input()

removed_cubes_count = 0
counted_char = cubes[0]
counted_char_len = 1
deleted_char_len = 0

for i in range(1, len(cubes)):
    if counted_char == cubes[i]:
        counted_char_len += 1
    else:
        if counted_char_len >= deleted_char_len:
            deleted_char_len += 1
            removed_cubes_count += 2
        else:
            counted_char = cubes[i]
            counted_char_len = 0
            deleted_char_len = 0

print(removed_cubes_count)

Submission status: Wrong Answer

Solution code:
usr_input = input()
lst=[]
for element in usr_input:
    lst.append(element)

n = len(lst)
remainder = n
counter =0

while(remainder != 0):
    new_counter = 0
    for num in range(0,remainder-1,1):
        if lst[num]== lst[num+1]:
            lst.remove(lst[num])
            new_counter += 1
            lst.remove(lst[num])
            new_counter += 1
            lst.insert(num,'a')
            lst.insert(num,'b')
    counter += new_counter
    if new_counter >0:
        lst.remove('a')
        lst.remove('b')
    if len(lst)==remainder:
        remainder = 0
    else:
        remainder = len(lst)

print(counter)

Submission status: Wrong Answer

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

S = input()

S = list(S)
i = 0
count = 0
flag=0
while i < len(S)-1:
  i+=1
  if S[i] != S[i-1]:
    S.pop(i-1)
    S.pop(i-1)
    count +=2
    i -=1
    flag=1
  if flag == 1 and i==len(S)-1:
    flag=0
    i=0
print(count)

Submission status: Wrong Answer

Solution code:
check = input()
def solve_schedule():
    global check
    res = 0
    while True:
        loop_res = 0
        next = ''
        while len(check) > 0:
            if len(check) == 1:
                next += check
            if check[-2:] == '01' or check[-2:] == '10':
                loop_res += 2
                check = check[:-2]
            else:
                next += check[-1:]
                check = check[:-1]
            # print(check)
        next = next[::-1]

        res += loop_res
        if loop_res == 0: break
        check = next

    print(res)

if __name__ == "__main__":
    solve_schedule()

Submission status: Wrong Answer

Solution code:
S = input()
def solve_schedule():
    check = S
    res = 0
    while True:
        loop_res = 0
        next = ''
        while len(check) > 0:
            if len(check) == 1:
                next += check
            if check[-2:] == '01' or check[-2:] == '10':
                loop_res += 2
                check = check[:-2]
            else:
                next += check[-1:]
                check = check[:-1]
        next = next[::-1]

        res += loop_res
        if loop_res == 0: break
        check = next

    print(res)

solve_schedule()

Submission status: Wrong Answer

Solution code:
s = input()
count = 0

oi10 = "0"*10 + "1"*10
io10 = "1"*10+"0"*10

while oi10 in s or io10 in s:
    while oi10 in s:
        s = s.replace(oi10, "", 1)
        count += 10
    while io10 in s:
        s = s.replace(io10, "", 1)
        count += 10

while "01" in s or "10" in s:
    while "01" in s:
        s = s.replace("01", "", 1)
        count += 1
    while "10" in s:
        s = s.replace("10", "", 1)
        count += 1

print(count * 2)
print(s)

Submission status: Wrong Answer

Solution code:
S = input()

length = len(S) 

answer = length // 2 * 2

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S=input()
i=0
while i<=int(S)//2:
    A=S.replace("01","")
    B=A.replace("10","")
    i+=1
print(len(S)-len(B))

Submission status: Wrong Answer

Solution code:
n=list(input())
zero=n.count('0')
one=n.count('1')
print(min(zero,one))

Submission status: Wrong Answer

Solution code:
S=input()
A=S.replace("01","")
B=A.replace("10","")
print(len(S)-len(B))

Submission status: Wrong Answer

Solution code:
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])
    if S[i] == 0:
        S[i] = -1

now = S[0]
cnt = 1
ans = 0
for i in range(1, len(S)):

    if cnt > 0:
        if S[i] == now:
            ans += 2
            cnt -= 1
            now *= -1
        else:
            cnt += 1
    else:
        now = S[i]
        cnt += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:53 2019

@author: Yamazaki Kenichi
"""
S = input()
print(min(S.count('0'),S.count('1')))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 19:52:53 2019

@author: Yamazaki Kenichi
"""
S = input()
print(max(S.count('0'),S.count('1')))

Submission status: Wrong Answer

Solution code:
# # coding: utf-8
# data = list(input())
# removed_block = 0
# i = 1
# log = data[0]
# while i < (len(data) + 1):
#     try:
#         if data[i] != log:
#             data.pop(i)
#             data.pop(i - 1)
#             removed_block += 2
#             i = 1
#             log = data[0]
#         else:
#             i += 1
#     except:
#         break
# print(removed_block)

# coding: utf-8
n = input()
print(min(n.count('0'), n.count('1')))

Submission status: Wrong Answer

Solution code:
S = input()
subS = S
cnt = 0
while True:
    flg = True
    if "01" in subS:
        flg = False
        tmp = subS.replace("01", "")
        cnt += len(subS) - len(tmp)
        subS = tmp
    if "10" in subS:
        flg = False
        tmp = subS.replace("10", "")
        cnt += len(subS) - len(tmp)
        subS = tmp
    if flg:
        break

Submission status: Wrong Answer

Solution code:
s = input()
s=list(s)
zeroc=0
onec=0
for i in s:
  if i == 0:
    zeroc+=1
  if i == 1:
    onec+=1
print(min(zeroc,onec)*2)

Submission status: Wrong Answer

Solution code:
ans=0
s_=""
s=input()
while s!=s_:
	s_=s
	s=s.replace("01","")
	ans+=len(s_)-len(s)
	s_=s
	s=s.replace("10","")
	ans+=len(s_)-len(s)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque
S =input()
counter = 0
S = list(S)
q = deque([])
for i in range(len(S)):
    q.append(S[i])
for i in range(1000000):
    if q:
        s1 = q.popleft()
    else:
        break
    if q:
        s2 = q.pop()
    else:
        break
    if(s1 != s2):
        counter+=2
    else:
        q.appendleft(s1)
        q.append(s2)
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
S =input()
counter = 0
S = list(S)
q = deque([])
for i in range(len(S)):
    q.append(S[i])
for i in range(3000000):
    if q:
        s1 = q.pop()
    else:
        break
    if q:
        s2 = q.pop()
    else:
        break
    if(s1 != s2):
        counter+=2
    else:
        q.appendleft(s1)
        q.append(s2)
print(counter)

Submission status: Wrong Answer

Solution code:
from collections import deque
S =input()
counter = 0
S = list(S)
q = deque([])
for i in range(len(S)):
    q.append(S[i])
for i in range(1000000):
    if q:
        s1 = q.pop()
    else:
        break
    if q:
        s2 = q.pop()
    else:
        break
    if(s1 != s2):
        counter+=2
    else:
        q.appendleft(s1)
        q.append(s2)
print(counter)

Submission status: Wrong Answer

Solution code:
from collections import deque
S =input()
counter = 0
S = list(S)
q = deque([])
for i in range(len(S)):
    q.append(S[i])
for i in range(100000):
    if q:
        s1 = q.pop()
    else:
        break
    if q:
        s2 = q.pop()
    else:
        break
    if(s1 != s2):
        counter+=2
    else:
        q.appendleft(s1)
        q.append(s2)
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
S =input()
counter = 0
S = list(S)
q = deque([])
for i in range(len(S)):
    q.append(S[i])
for i in range(100000):
    if q:
        s1 = q.popleft()
    else:
        break
    if q:
        s2 = q.popleft()
    else:
        break
    if(s1 != s2):
        counter+=2
    else:
        q.append(s1)
        q.appendleft(s2)
print(counter)

Submission status: Wrong Answer

Solution code:
from collections import deque
S =input()
counter = 0
S = list(S)
q = deque([])
for i in range(len(S)):
    q.append(S[i])
for i in range(10000):
    if q:
        s1 = q.popleft()
    else:
        break
    if q:
        s2 = q.popleft()
    else:
        break
    if(s1 != s2):
        counter+=2
    else:
        q.append(s1)
        q.appendleft(s2)
print(counter)

Submission status: Wrong Answer

Solution code:
from collections import deque
S =input()
counter = 0
S = list(S)
q = deque([])
for i in range(len(S)):
    q.append(S[i])
for i in range(len(S)):
    if q:
        s1 = q.popleft()
    else:
        break
    if q:
        s2 = q.popleft()
    else:
        break
    if(s1 != s2):
        counter+=2
    else:
        q.append(s1)
        q.appendleft(s2)
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=list(str(input()))
b=a.count('0')
c=a.count('1')
print(b if b<=c else c)

Submission status: Wrong Answer

Solution code:
s=str(input())
i=len(s)
while True:
    s=s.replace("01","").replace("10","")
    if not ( ("01" and "10") in s):
        break
print(abs(len(s)-i))

Submission status: Wrong Answer

Solution code:
import queue
counter = 0
S = input()
S = list(S)
q = queue.Queue()
flg = 1
for i in range(len(S)):
  q.put(S[i])
for i in range(10000):
  if(q.empty()):
    break
  else:
    if (flg == 1):
      s1 = q.get()
    s2 = q.get()
    if (s1 != s2):
      counter+=2
      flg = 1
    else:
      s1 = s2
      flg = 0
print(counter)

Submission status: Wrong Answer

Solution code:
import queue
counter = 0
S = input()
S = list(S)
q = queue.Queue()
flg = 1
for i in range(len(S)):
  q.put(S[i])
for i in range(100):
  if(q.empty()):
    break
  else:
    if (flg == 1):
      s1 = q.get()
    s2 = q.get()
    if (s1 != s2):
      counter+=2
      flg = 1
    else:
      s1 = s2
      flg = 0
print(counter)

Submission status: Wrong Answer

Solution code:
import queue
counter = 0
S = input()
S = list(S)
q = queue.Queue()
flg = 1
for i in range(len(S)):
  q.put(S[i])
for i in range(len(S)-1):
  if (flg == 1):
    s1 = q.get()
  s2 = q.get()
  if (s1 != s2):
    counter+=2
    flg = 1
  else:
    q.put(s1)
    s1 = s2
    flg = 0
print(counter)

Submission status: Wrong Answer

Solution code:
s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
print(min(count.values()) * 2)

Submission status: Wrong Answer

Solution code:
S = input()

c0=0
c1=0

for s in S:
  if s=='0':
    c0 += 1
  else:
    c1 += 1
print(min(c0,c1))

Submission status: Wrong Answer

Solution code:
s=str(input())
i=len(s)
while True:
    s=s.replace("01","").replace("10","")
    if not ( ("01" or "10") in s):
        break
print(abs(len(s)-i))

Submission status: Wrong Answer

Solution code:
s=str(input())
i=len(s)
while True:
    s=s.replace("01","").replace("10","")
    if not ("01" or "10") in s:
        break
print(abs(len(s)-i))

Submission status: Wrong Answer

Solution code:
s=str(input())
i=len(s)
while True:
    s=s.replace("01","").replace("10","")
    if not ("01" or "10") in s:
        break
print(i-len(s))

Submission status: Wrong Answer

Solution code:
s=str(input())
n=len(s)
while True:
    s=s.replace("01","").replace("10","")
    if not ("01" or "10") in s:
        break
print(abs(len(s)-n))

Submission status: Wrong Answer

Solution code:
s=str(input())
n=s
while True:
    s=s.replace("01","").replace("10","")
    if not ("01" or "10") in s:
        break
print(len(n)-len(s))

Submission status: Wrong Answer

Solution code:
S=input()
num_one=S.count('1')
num_zero=S.count('0')
ans = 2*max(num_one,num_zero)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

ans = 0
stack = []

for c in s[1:-1]:
  if stack == []:
    continue
  if c == stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)

Submission status: Wrong Answer

Solution code:
LX = []
for j in input():
    LX.append(int(j))

chk = 1
cnt = 0
while(chk == 1 and len(LX) > 1):
    chk = 0
    for i in range(0, max(1,len(LX)-2)):
        if (LX[i] + LX[i+1] == 1):
            chk = 1
            LX.pop(i)
            LX.pop(i)
            cnt += 1
            break
print(2 * cnt)

Submission status: Wrong Answer

Solution code:
LX = []
for j in input():
    LX.append(int(j))

chk = 1
cnt = 0
while(chk == 1 and len(LX) > 1):
    chk = 0
    print(LX)
    for i in range(0, max(1,len(LX)-2)):
        if (LX[i] + LX[i+1] == 1):
            chk = 1
            LX.pop(i)
            LX.pop(i)
            cnt += 1
            break
print(2 * cnt)

Submission status: Wrong Answer

Solution code:
from collections import Counter
print 2*min(Counter(raw_input().rstrip()).values())

Submission status: Wrong Answer

Solution code:
from collections import Counter
print 2*min(Counter(raw_input()).values())

Submission status: Wrong Answer

Solution code:
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B
"""
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
"""

#C
s = input()
an0 = 0
an1 = 0
for i in s:
    if s == "1":
        an1 += 1
    if s == "0":
        an0 += 1
print(min(an0, an1)*2)

Submission status: Wrong Answer

Solution code:
#A
"""
a, b, c = map(int, input().split())
print(min(b//a, c))
"""
#B
"""
a, b, k = map(int, input().split())
for i in range(max(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        k -= 1
        if k == 0:
             print(i)
"""

#C
s = input()
an0 = 0
an1 = 0
for i in s:
    if s == "1":
        an1 += 1
    if s == "0":
        an0 += 1
print(min(an0, an1))

Submission status: Wrong Answer

Solution code:
s=input();print(len(s)-sum([1,-1][i=="0"]for i in s))

Submission status: Wrong Answer

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

def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
c = counter(s)

try:
    cnt = min(c[0][1],c[1][1])
except:
    pass
print(cnt)

Submission status: Wrong Answer

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

def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
c = counter(s)

try:
    cnt =c[0][1]
    cnt = min(c[0][1],c[1][1])
except:
    pass
print(cnt*2)

Submission status: Wrong Answer

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

def counter(array):
    from collections import Counter
    return list(Counter(array).most_common())
c = counter(s)

try:
    cnt = min(cnt,c[0][1])
    cnt = min(cnt,c[0][0])
except:
    pass
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
print(len(s) - 2 * min([sum([v == '1' for v in s]), sum([v == '0' for v in s])]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
print(input().count("0") * 2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**5)
S = list(input())
n = len(S)

def f(flist,count):
    if len(count) == 0:
        return flist
    else:
        del flist[count[0]]
        del count[0]
        count = list(map(lambda x: x-1,count))
        return f(flist,count)

def Remove(binList,lenList):
    if list(set(binList)) == ["0"] or list(set(binList)) == ["1"]:
        return binList
    count = []
    count.clear()
    for i in range(0,lenList-1):
        if (binList[i] == "0" and binList[i+1] == "1") or (binList[i] == "1" and binList[i+1] == "0"):
            count += [i,i+1]

    count = list(set(count))
    binList = f(binList,count)
    lenList = len(binList)

    if len(count) == 0:
        return binList
    else:
        return Remove(binList, lenList)

S = Remove(S,n)
print(n-len(S))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**5-10**4*2)
S = list(input())
n = len(S)

def f(flist,count):
    if len(count) == 0:
        return flist
    else:
        del flist[count[0]]
        del count[0]
        count = list(map(lambda x: x-1,count))
        return f(flist,count)

def Remove(binList,lenList):
    if list(set(binList)) == ["0"] or list(set(binList)) == ["1"]:
        return binList
    count = []
    count.clear()
    for i in range(0,lenList-1):
        if (binList[i] == "0" and binList[i+1] == "1") or (binList[i] == "1" and binList[i+1] == "0"):
            count += [i,i+1]

    count = list(set(count))
    binList = f(binList,count)
    lenList = len(binList)

    if len(count) == 0:
        return binList
    else:
        return Remove(binList, lenList)

S = Remove(S,n)
print(n-len(S))

Submission status: Wrong Answer

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)