TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
# -*- coding: utf-8 -*-

S = input()
N = len(S)
L = int(S, 2)   




cnt = 0
s = set()
s.add(S)
while True:
    #print(s)
    s2 = set()
    for d in s:
        for i in range(len(d)-1):
            if d[i] != d[i+1]:
                ns = None
                if i+2 < len(d):
                    ns = d[:i]+d[i+2:]
                else:
                    ns = d[:i]
                if ns is not None and len(ns) > 0:
                    s2.add(ns)
    if len(s2) > 0:
        cnt += 2
        s = s2
    else:
        break

print(cnt)


# -*- 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)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = list(map(int, input()))
print(s)
c = 0
count = 0
while(c==0):
  for i in range(len(s)):
    if sum(s) == len(s) or sum(s) == 0:
      c=1
      break
    print(i,len(s),s)
    if i == len(s)-1:
      break
    if len(s) == 2 and sum(s) == 1:
      count+=2
      c=1
      break
    if s[i] + s[i+1] == 1:
      del s[i]
      del s[i]
      count += 2
      break
print(count)    
  

s = list(map(int, input()))
c1,c0=0,0
for i in s:
  if i==1:
    c1+=1
  if i==0:
    c0+=1  
print(len(s)-abs(c1-c0))    
  

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import sys
from collections import deque


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(input())
    d_1 = deque(S[1:])
    d_2 = deque(S[0])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft
            l = d_2.pop()
            if r == l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans)


if __name__ == '__main__':
    main()


import sys
from collections import deque


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = list(map(int, list(input())))
    d_1 = deque(S[1:])
    d_2 = deque([S[0]])
    ans = 0
    for i in range(1, len(S)):
        if d_2:
            r = d_1.popleft()
            l = d_2.pop()
            if r != l:
                ans += 2
            else:
                d_2.append(l)
                d_2.append(r)
        else:
            d_2.append(d_1.popleft())
    print(ans)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
# input
S = list(input())
N = len(S)


cnt = 0
del_ind = []
append = del_ind.append

for i in range(1, N):
    if "".join(S[i - 1:i + 1]) in ["01", "10"]:
        cnt += 2
        N -= 2
        del S[i - 1:i + 1]
print(cnt)

# input
S = list(input())
N = len(S)


cnt = 0
del_ind = []
append = del_ind.append

for i in range(0, N):
    if "".join(S[i:i + 2]) in ["01", "10"]:
        cnt += 2
        N -= 2
        del S[i:i + 2]
print(cnt)

# input
S = input()
N = len(S)


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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S = input()

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

S = input()

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
# -*- coding: utf-8 -*-
s = input()
s = list(s)
x = 0
maxIndex = len(s) - 1
count = 0
while True:
    if len(s) <= x:
        break
    if s[x] != s[x + 1]:
        s.pop(x)
        s.pop(x)
        maxIndex = len(s) - 1
        count += 1
    else:
        x += 1
print(count * 2)


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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s=input()
a_1=s.count("1")
b_1=s.cpunt("0")
if a_1<=b_1:
  print(2*a_1)
else:
  print(2*b_1)

s=input()
a_1=s.count("1")
b_1=s.count("0")
if a_1<=b_1:
  print(2*a_1)
else:
  print(2*b_1)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
from math import factorial

class UnionFind:
  def __init__(self, n):
    self.par = [-1 for _ in range(n)]
  def root(self, x):
    return x if self.par[x] < 0 else self.root(self.par[x])
  def unite(self, x, y):
    x, y = self.root(x), self.root(y)
    if x != y:
      if self.par[y] < self.par[x]:
        x, y = y, x
      self.par[x] += self.par[y]
      self.par[y] = x
    return x != y
  def find(self, x, y):
    return self.root(x) == self.root(y)
  def size(self, x):
    return -self.par[self.root(x)]

n, m = map(int, input().split())
tree = UnionFind(n)
b = []
for _ in range(m):
  a, c = map(int, input().split())
  b.append([a - 1, c - 1])
b.reverse()
ans = [sum(range(n))]
for i, p in enumerate(b):
  if not tree.find(p[0], p[1]):
    ans.append(ans[-1] - tree.size(p[0])*tree.size(p[1]))
    tree.unite(p[0], p[1])
  elif i != m - 1:
    ans.append(ans[-1])
for i in reversed(ans):
  print(i)

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

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


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a = input()

init_len = len(a)
print(len(a))

while True:
  flg = True
  if a.find("01") > 0:
    a = a.replace("01","")
    flg = False
    
  if a.find("10") > 0:
    a = a.replace("10","")
    flg = False
  
  if flg:
    break
print(str(init_len-len(a)))

a = input()

cnt0 = a.count("0")
cnt1 = a.count("1")

print(str(min(cnt0,cnt1)*2))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
lt = len(s)

tmp = []
for it in range(lt-1):
	tmp.append(s[it:it+2])

it = 0
# print(tmp)
# if "01" in tmp:
# 	it = tmp.index("01")
# 	print(tmp.index("01"))
# 	tmp = tmp[:it-1]+tmp[it+2:]
# print(tmp[:it-1])
# print(tmp[it+2:])
# print(tmp)
count = 0
while True:
	if lt == 1:
		print(0)
		break

	if "01" in tmp:
		it = tmp.index("01")
		# print(tmp.index("01"))
		tmp = tmp[:it-1]+tmp[it+2:]
		count += 2
	elif "10" in tmp:
		it = tmp.index("10")
		# print(tmp.index("10"))
		tmp = tmp[:it-1]+tmp[it+2:]
		count += 2
	else:
		# print(lt-len(tmp)*2)
		break


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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
# ans = 0
# while '01' in s or '10' in s:
#     # print('yes')
#     if '01' in s:

#         ans += 2
#     if '10' in s:

#         ans += 2
#     # print(s, ans)

# # print(ans)

ans = min(s.count('0'), s.count('1'))
print(ans)

s = input()
# ans = 0
# while '01' in s or '10' in s:
#     # print('yes')
#     if '01' in s:

#         ans += 2
#     if '10' in s:

#         ans += 2
#     # print(s, ans)

# # print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S=input()

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

print(min(S[::2].count(0), S[1::2].count(1)) + min(S[::2].count(1), S[1::2].count(0)))

S = input()
s1 = S.count('1')
s0 = S.count('0')
print(2*min(s1, s0))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s=input().split('')
one=s.count('1')
zero=s.count('0')
print(2*min(one,zero))

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




Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
S = input()

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

print(abs(num_0 - num_1))


S = input()

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

print(min(num_0, num_1)*2)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
# -*- 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) != 0:
        return 0
    return min(c.values()) * 2


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


if __name__ == '__main__':
    main()


# -*- 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()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
cubes = input()

removed_cubes_count = 0

while True:
    removed_cubes = cubes.translate({
        '01': '',
        '10': ''
    })

    removed_cubes_count += len(cubes) - len(removed_cubes)

    if len(cubes) == len(removed_cubes):
        break

    cubes = removed_cubes_count


print(removed_cubes_count)


cubes = input()

removed_cubes_count = 0

while True:
    count01 = cubes.count('01')
    count10 = cubes.count('10')

    if count01 == 0 and count10 == 0:
        break

    removed_cubes_count += count01 + count10

    cube = cube.translate({
        '01': '',
        '10': ''
    })

print(removed_cubes_count)

cubes = input()

removed_cubes_count = 0

while True:
    count01 = cubes.count('01')
    count10 = cubes.count('10')

    if count01 == 0 and count10 == 0:
        break

    removed_cubes_count += count01 + count10

    cubes = cubes.translate({
        '01': '',
        '10': ''
    })



print(removed_cubes_count)


cube = input()

zero_count = 0
one_count = 0

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

if zero_count < one_count:
    print(zero_count * 2)
else:
    print(one_count * 2)


Verdicts: Wrong Answer

Runtime Error

Time Limit Exceeded

Accepted
Problem: 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?

Submission attempts (in order):
#! /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))
pirnt(ans*2)

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

S = input()
ls = list(S)
ls = [int(x) for x in ls]
offset = 0
count = 0
while True:
    if ls[offset] == ls[offset +1]:
        del ls[offset:offset +2]
        count += 2
    elif offset +1 ==len(ls):
        break

    else:
        offset += 1

print(count)

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

S = input()
ls = list(S)
ls = [int(x) for x in ls]
offset = 0
count = 0
while True:
    if ls[offset] == ls[offset +1]:
        del ls[offset:offset +2]
        count += 2
        offset = 0
    elif offset + 1 == len(ls):
        break
    else:
        offset += 1

print(count)

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

S = input()
ls = list(S)
ls = [int(x) for x in ls]
offset = 0
count = 0
while True:
    if ls[offset] == ls[offset +1]:
        del ls[offset:offset +2]
        count += 2
    elif offset +1 ==len(ls):
        break
    else:
        offset += 1

print(count)

#! /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)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
S=list(map(int,input()))
a=0
b=0
for i in range(lin(S)):
  if S[i]==1:
    a+=1
  else:
    b+=1
print(2*min(a,b))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s = str(input())
n = s.size()
cntz = 0
cnto = 0
for i in range(n):
    if s[i] == '0':
        cntz += 1
    elif s[i] == '1':
        cnto += 1
print(min(cnto,cntz))


s = str(input())
cntz = 0
cnto = 0
for i in s:
    if i == '0':
        cntz += 1
    elif i == '1':
        cnto += 1
ans = 2*min(cnto,cntz)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
str = input()
n = len(str)

ls = []

for i in range(n):
  ls.append(str[i])


for i in range(len(ls)):
  if (ls[i] == ls[i+1]) or (len(ls) == 1):
    break
  if (ls[i] == 0 and ls[i + 1] == 1) or (ls[i] == 1 and ls[i + 1] == 0):
    del ls[i]
    del ls[i]

nokori = len(ls)
print(n - nokori)
  


str = input()

count1 = str.count('1')
count0 = str.count('0')
print(2 * min(count1, count0))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
cnt_0, cnt_1 = s.count('0'), s.count('1')
print(max(cnt_0, cnt_1) - min(cnt_0, cnt_1))

s = input()
cnt_0, cnt_1 = s.count('0'), s.count('1')
print(len(s) - (max(cnt_0, cnt_1) - min(cnt_0, cnt_1)))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
result = 0
while True:
  t = len(s)
  for i in range(len(s) - 1):
    if s[i] != s[i + 1]:
      result += 2
      s = s[:i] + s[i+2:]
      print(s)
      break
  if len(s) == t:
    break
print(result)


s = input()
result = 0
while True:
  t = len(s)
  i = 0
  a = []
  while i < len(s) - 1:
    if s[i] != s[i + 1]:
      result += 2
      i += 1
    else:
      a.append(s[i])
    i += 1
  s = ''.join(a)
  if len(s) == t:
    break
print(result)


s = input()
t = s.count('0')
print(2 * min(t, len(s) - t))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S=input()
stack=[]
ans=0

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

print(ans)

S=input()
stack=[]
ans=0

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

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S = list(map(int, input()))

count = 0
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    del S[i],S[i+1]
    count =2+count 
  else:
    if len(S)==i+1:
      print(count)
    else:
  		continue
    
print(count)
   


	

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

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

count = 0
for i in range(len(S)):
  if S[i]!=S[i+1]:
  	del S[i],S[i+1]
    count +=2
  	continue  
  elif S[len(S)]==S[len(S)+1]
  	break
  else:
  	continue
    
print(count)

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

count = 0
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    del S[i],S[i+1]
    count =2+count 
  else:
    if len(S)==i+1:
      print(count)
    else:
  		continue
    
print(count)
   


	

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  


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

S_1 = [S[i] for i in range(len(S)) if S[i]==1]
S_0 = [S[i] for i in range(len(S)) if S[i]==0]

S_min = min(len(S_1), len(S_0))

print(2*S_min)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
for a in Str:
    Codigo.append(a)

lenMax=len(Codigo)-1
k=0

while i < len(Codigo)-1:
    lenAnterior = len(Codigo)-1
    
    if Codigo[i] == "0" and Codigo[i+1]=="1":
        contador+=2
        Codigo.pop(i)
        Codigo.pop(i)
    elif Codigo[i] == "1" and Codigo[i+1]=="0":
        contador+=2
        Codigo.pop(i)
        Codigo.pop(i)
        
    if lenAnterior != len(Codigo)-1:
        i=i-1
    else:
        i=i+1

    k+=1

    if k >= lenMax:
        break
    
print(contador)

s = input()

ones = 0
zeros = 0
for c in s:
    if c == '1':
        ones += 1
    else:
        zeros += 1

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
S = input()
cnt_0 = 0
cnt_1 = 0
for i in S:
    if i == "0":
        cnt_0 += 1
    else:
        cnt_1 +=1
print(min(cnt_0,cnt_1))

S = input()
cnt_0 = 0
cnt_1 = 0
for i in S:
    if i == "0":
        cnt_0 += 1
    else:
        cnt_1 +=1
print(min(cnt_0,cnt_1)*2)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
cnt = 0
while '0' in s and '1' in s:
  for i in range(len(s)):
    if s[i] != s[i+1]:
      print('hoge', i)
      cnt += 1
      s = s[:i] + s[i+2:]
      break

print(cnt * 2)

s = list(input())

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = list(input())
t = []
p = 0
flg = True

while flg:
    flg = False
    j = 0
    for i in range(len(s)):
        if s[j] == s[j+1]:
            t.append(s[j])
            j += 1
        else:
            p += 2
            j += 2
        if j >= len(s) - 1:
            if j == len(s) - 1:
                t.append(s[j])
                break
            else:
                break
    if len(t) == len(s) or len(t) == 0:
        pass
    else:
        s = t
        t.clear()
        flg = True

print(p)

s = list(input())
p = s.count('0')
q = s.count('1')
print(2 * min(p,q))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s=input()
zero=0
one=0
for i in s:
  if i="0":
    zero+=1
  elif i="1":
    one+=1
print(min(zero,one)*2)

s=input()
zero=0
one=0
for i in s:
  if i=="0":
    zero+=1
  elif i=="1":
    one+=1
print(min(zero,one)*2)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import re,sys

s = str(input())
sl = list(s)

def ltox(s):
    if(len(s) <= 1):
        return (s)
    for i in range(1, len(s)-1):
        if(s[i-1] != s[i] and s[i-1] != 'x'):
            s[i] = 'x'
            s[i-1] = 'x'
    return [i for i in s if i != 'x']


bllx = len(s)
llx = sl.copy()
while True:
    
    print(llx)
    if(len(llx) == bllx):
        if(len(llx) == 2 and llx[0] != llx[1]):
            print(len(list(str(s))))
        else:
            print(len(list(str(s)))-len(llx))
        sys.exit()
    else:
        bllx = len(llx)



s = input()
sl = list(str(s))

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

r = abs(c1-c0)

print(len(s)-r)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s=input()
stk=0
h=0
for c in s:
  if x==1:
    if stk<0:
      h+=1
    stk+=1
  else:
    if stk >0:
      h+=1
    stk -=1
print(2*h)

s=input()
stk=0
h=0
for c in s:
  x=int(c)
  if x==1:
    if stk<0:
      h+=1
    stk+=1
  else:
    if stk >0:
      h+=1
    stk -=1
print(2*h)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
s=input();print(min(s.count("0"),s.count("1")))

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S=input()
print(min(S.count("0"),S.count("1")))

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = input()
	
print(min(s.count("1"),s.count("0")))

s = input()

print(abs(s.count("1")-abs(s.count("0")))

s = input()
	
print(abs(s.count("1")-s.count("0")))

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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
a = input()
s = list(a)
s_int = [int(i) for i in s ]
t = len(s_int)
i = 0
while 0 in s_int and 1 in s_int and i < len(s_int):
    if s_int[i] == 0 and s_int[i+1] == 1:
        s_int.pop(i)
        s_int.pop(i)
    elif s_int[i] == 1 and s_int[i+1] == 0:
        s_int.pop(i)
        s_int.pop(i)
    else:
        i += 1
print(t - len(s_int))

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)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
S = input()
A = S.count('0')
B = S.count('1')
print(min(A,B))

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S=input()
S=S.replace("10","3")
S=S.replace("01","3")
res=0
res+=S.count(3)
print(S.replace("3",""))

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



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



S=input()
res1,res2=0
for i in range(1000):
  S=S.replace("10","3")
  S=S.replace("01","3")
  res1+=S.count("3")*2
  S=S.replace("3","")
for j in range(1000):
  S=S.replace("10","3")
  S=S.replace("01","3")
  res2+=S.count("3")*2
  S=S.replace("3","")
if res1>res2:
  print(res2)
else:
  print(res1)

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



Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
S=print()
N=len(S)
c0=0;c1=0
for i in range(N):
  if "0"==S[i]:
    c0=c0+1
  elif "1"==S[i]:
    c1=c1+1
print(str(min(c0,c1)))
    

S=input()
N=len(S)
c0=0;c1=0
for i in range(N):
  if "0"==S[i]:
    c0=c0+1
  elif "1"==S[i]:
    c1=c1+1
print(str(2*min(c0,c1)))
    


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a = input()
count0 = 0
count1 = 0
a = int(a)
while(a > 0):
    if(a%2 ==0):
        count0 = count0 + 1
        a = a/10
    else:
        count1 = count1 + 1
        a = (a-1)/10

print(min(count0,count1)*2)


a = input()
count0 = 0
count1 = 0
b = len(a)
for i in range(b):
    if(a[i] == "0") :
        count0 = count0 + 1
    else:
        count1 = count1 + 1

print(min(count0,count1)*2)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
c0=0
c1=0
for i in input():
  if i=="1":
    c1+=1
  else:
    c0+=1
print(min(c0,c1))

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

S = input()
num_0 = list(S).count('0')
num_1 = list(S).count('1')
print(len(S) - abs(num_0 - num_1))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S = input().strip()
x = sum(c == '0' for c in S)
y = len(n) - x
print(2 * min(x, y))

S = input().strip()
x = sum(c == '0' for c in S)
y = len(S) - x
print(2 * min(x, y))

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
#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)

#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))

#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))

#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 = list(input())
an0 = 0
an1 = 0
for i in s:
    if i == "1":
        an1 += 1
    if i == "0":
        an0 += 1
print(min(an0, an1)*2)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
S=list(input())
red=len(list(filter(lambda e:e=='0', S)))
blue=len(list(filter(lambda e:e=='1', S)))
d=abs(red-bule)
print(red+bule-d)


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)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
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))


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)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s=int(input())
l=[]
def func(a):
    if a%2==0:
        return a/2
    else:
        return 3*a+1

while (s not in l):
    l.append(s)
    s=func(s)

print(len(l)+1)

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

print(2*min(a,b))

Verdicts: Runtime Error

Accepted