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):
s=list(input()).sort();a=s.index('1');print(2*min(a,len(s)-a))

s=sorted(list(input());a=s.index('1');print(2*min(a,len(s)-a))

s=sorted(list(input()))
if s[0]==s[-1]:
  print(0)
else:
  a=s.index('1')
  print(2*min(a,len(s)-a)

s=sorted(list(input()))
if s[0]==s[-1]:
  print(0)
else:
  a=s.index('1')
  print(2*min(a,len(s)-a))

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):
L = list(input())
L_ = []
a = L.pop(0)
cnt = 0

while True:
    if len(L) == 0:
        break
    else:
        b = L.pop(0)
    if a is not b:
        cnt += 1
        L = L_ + L
        L_ = []
        a = L.pop(0)
    elif a is b:
        L_.append(a)
        a = b
    # print(L_, a,  L)

print(cnt * 2)



L = list(input())
L_ = []
a = L.pop(0)
cnt = 0

while True:
    if len(L) == 0:
        break
    else:
        b = L.pop(0)
    if a is not b:
        cnt += 1
        if len(L_) != 0:
            a = L_.pop()
        else:
            a = L.pop(0)
    elif a is b:
        L_.append(a)
        a = b
    # print(L_, a,  L)

print(cnt * 2)



L = list(input())
cnt_0 = L.count("0")
cnt_1 = L.count("1")

print(min(cnt_0, cnt_1) * 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):
S = input()
ans = len(S)
while True:
    if S.find('01') >= 0:
        S = S.replace('01', '')
    if S.find('10') >= 0:
        S = S.replace('10', '')
    else:
        break
ans -= len(S)
print(ans)


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('0')*2,S.count('1')))

S=input()
print(min(S.count('0')*2,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):
import re
s=input()
N=len(s)
while True:
    n = len(s)
    s = re.sub(r'10|10', "", s)
    if n == len(s):
        print(N-n)
        break

s=input()

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

s=input()

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

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=str(input())
print(min(s.count('0'),s.count('1')))

s=str(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):
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)

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)

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

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

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

Verdicts: Wrong Answer

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):
import numpy as np

S = str(input())

r = '01'
b = '10'

count=0
i=0
while i < (len(S)-1):
    if r == S[i:i+2]:
        S = S.replace(r,'',1)
        count+=1
        i=0
    if b == S[i:i+2]:
        S = S.replace(b,'',1)
        count+=1
        i=0
    else:
        i+=1
        
print(int(2*count))

import numpy as np

S = str(input())

A = S.count('0')

B = S.count('1')

ans = len(S)-int(abs(A-B))

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):
from collections import deque
s = deque(input())

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)


s = list(input())

# Note: init
# cnt = 0

#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)

#         cnt += 2

#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*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):
n_list = list(input())
#print(n_list)

while(1):
  flag = "ng"
  n_len = len(n_list)
  for i in range(n_len-1):
    if n_list[i] != n_list[i+1]:
      n_list.pop(i)
      n_list.pop(i)
      flag = "ok"
      break
  if flag == "ng":
    break
#print(n_list)
print(len(n_list))

n_list = list(input())
n_len_o = len(n_list)
#print(n_list)
a = 0
while(1):
  flag = "ng"
  n_len = len(n_list)
  for i in range(a,n_len-1):
    if n_list[i] != n_list[i+1]:
      n_list.pop(i,i+1)
      if a != 0:
        a = i - 1
      flag = "ok"
      break
  if flag == "ng":
    break
print(n_len_o-len(n_list))

n_list = list(input())
n_len_o = len(n_list)
a = 0
while(1):
  flag = "ng"
  n_len = len(n_list)
  for i in range(a,n_len-1):
    if n_list[i] != n_list[i+1]:
      n_list.pop(i)
      n_list.pop(i)
      if i != 0:
        a = i - 1
      else:
        a = 0
      flag = "ok"
      break
  if flag == "ng":
    break
print(n_len_o-len(n_list))

Verdicts: Wrong Answer

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(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()
a_0 = s.count('0')
a_1 = s.count('1')
print(abs(a_0-a_1)*2)

S = input()
a = []
for s in S:
    try:
        if s != a[-1]:
            a.pop()
        else:
            a.append(s)
    except:
        a.append(s)
print(len(S)-len(a))

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 = str(input())
cnt=0
while len(s)//2 >0:
    if '10' in s:
        cnt+=2 * s.count('10')
        s=s.replace('10', '') 
    elif '01' in s:
        cnt+=2 * s.count('01')
        s=s.replace('01', '') 
    else:
        print(cnt)
        break
    print(cnt)

import numpy as np
s = str(input())
cnt=0
l=["01","10"]
while len(s)//2 >1:
    if '10' in s:
        cnt+=2 * s.count('10')
        s=s.replace('10', '') 
    elif '01' in s:
        cnt+=2 * s.count('01')
        s=s.replace('01', '') 
    else:
        break
print(cnt)

s = str(input())
cnt=0

while len(s) >2:
    if '10' in s:
        cnt+=2 * s.count('10')
        s=s.replace('10', '') 
    elif '01' in s:
        cnt+=2 * s.count('01')
        s=s.replace('01', '') 
print(cnt)

s = str(input())
cnt=0
while len(s)//2 >1:
    if '10' in s:
        cnt+=2 * s.count('10')
        s=s.replace('10', '') 
        if '01' in s:
            cnt+=2 * s.count('01')
            s=s.replace('01', '') 
    if '01' in s:
        cnt+=2 * s.count('01')
        s=s.replace('01', '') 
        if '10' in s:
            cnt+=2 * s.count('10')
            s=s.replace('10', '') 
    else:
        break
print(cnt)

#120 C
S =input()
print(min(S.count('0'),S.count('1'))*2)


Verdicts: Wrong Answer

Wrong Answer

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):
import sys

def main():
    S  = list(map(int, input()))
    o = S.count(0)
    l = S.count(1)
    print(o,l)

    print(min(o, l) * 2)

main()

import sys
 
def main():
    S  = list(map(int, input()))
    o = S.count(0)
    l = S.count(1)
 
    print(min(o, l) * 2)
 
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):
#C
s = list(input())
zero = 0
one = 0
for i in s:
    if i == "1":
        one += 1
    else:
        zero += 1
print(min(one,zero))

#C

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


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


count_1 = 0
count_0 = 0

for i in range(len(S)):
  if S[i]=="1":
    count_1 = count_1 + 1
  elif S[i]=="0":
    count_0 = count_0 + 1
    

if count_1 >= count_0:
  print(count_0*2)
elif:
  print(count_1*2)

S = input()

len_now = len(S)
count = 0
pivot = len(S)-1

while True:
  if len(S)==1:
    break
  elif S[0]=="1" and S[1]=="1":
    break
  elif S[0]=="0" and S[1]=="0":
    break
  
  if S[pivot]=="0" and S[pivot+1]=="1":
    S = S[pivot+2:len(S)]
    count = count + 2
  elif S[pivot]=="1" and S[pivot+1]=="0":
    S = S[pivot+2:len(S)]
    count = count + 2
  pivot = pivot+1

print(count)

S = list(input())

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

print(int(zero*2) if zero <= one else int(one*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):
string = str(input())
zero = 0
one = 0
for char in string:
    if char == list(chars)[0]:
        zero += 1
    else:
        one += 1

if zero == 0 or one == 0:
    print(0)
else:
    print(min(zero, one) * 2)

string = str(input())
zero = 0
one = 0
chars = set(string)
for char in string:
    if char == list(chars)[0]:
        zero += 1
    else:
        one += 1

if zero == 0 or one == 0:
    print(0)
else:
    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):
s = input()
k = 0
while True:
  if "10" in s:
    i = s.index("10")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  elif "01" in s:
    i = s.index("10")
    s = list(s)
    s.pop(i)
    s.pop(i)
    s = "".join(s)
    k += 2
  else:
    print(k)
    break

s = input()
print(min(s.count("0"), s.count("1"))*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):
N = int(input())
n = list(map(int, list(str(N))))

def solve():
    ones = sum(n)
    zeros = len(n) - ones
    return len(n) - abs(ones - zeros)

print(solve())

N = 0
n = list(map(int, list(str(N))))

def solve():
    ones = sum(n)
    zeros = len(n) - ones
    return len(n) - abs(ones - zeros)

print(solve())

N = input()
n = list(map(int, list(N)))

def solve():
    ones = sum(n)
    zeros = len(n) - ones
    return len(n) - abs(ones - zeros)

print(solve())

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=list(input())
n=len(s)
a=s.count('1')
b=n-a
print(abs(a-b))

s=list(input())
n=len(s)
a=s.count('1')
b=n-a
c=abs(a-b)
print(n-c)


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

# coding: utf-8
# Your code here!

import copy

string = [x for x in input()]

concat_string = copy.copy(string)
num_delete = 0

i = 0
j = 1
not_delete_list = []
while True:
    if j >= len(concat_string) or i < 0:
        break
    if concat_string[i] != concat_string[j]:
        num_delete += 2
        
        if i == 0:
            i = j + 1
            j = i + 1
        else:
            if len(not_delete_list) > 0:
                i = not_delete_list.pop(-1)
                j = j + 1
            else:
                i = j + 1
                j = i + 1
    else:
        not_delete_list.append(i)
        i = j
        j = i + 1


print(num_delete)

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):
def main():
    string = input()
    lists = list(string)
    original_len = len(lists)
    zero = lists.count('0')
    one = lists.count('1')
    print(original_len - min(zero,one)*2)
if __name__ == "__main__":
    main()



def main():
    string = input()
    lists = list(string)
    original_len = len(lists)
    zero = lists.count('0')
    one = lists.count('1')
    print(min(zero,one)*2)
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):
S = str(input())
Smae = S
while True:
    S = S.replace('01', '')
    S = S.replace('10', '')
    if '01' not in S or '10' not in S:
        break
print(len(Smae) - len(S))

S = str(input())

C0, C1 = 0, 0
for i in S:
    if i == "0":
        C0 += 1
    else:
        C1 += 1
mini = min(C0, C1)
print(2 * mini)

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()
c=0
n=1
while n>0:
  n=s.count('01')
  s=s.replace('01','')
  c=c+n
  n=s.count('10')
  s=s.replace('10','')
  c=c+n
print(c*2)

s=input()
c=0
while n>0:
  n=s.count('01')
  s.replace('01','')
  c=c+n
  n=s.count('10')
  s.replace('10','')
  c=c+n
print(c)

s=input()
c=0
while n>0:
  n=s.count('01')
  s=s.replace('01','')
  c=c+n
  n=s.count('10')
  s=s.replace('10','')
  c=c+n
print(c)

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

Verdicts: Wrong Answer

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):
import math

s = input()
n = len(s)

cnt = 0

for i in range(1, math.floor(n/2)+1):
    s = s.replace('01', '', 1)
    if len(s) < n:
      n = len(s)
      cnt += 1
      
print(cnt)

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

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

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())
cnt = 0
i = 0
while True:
    if S[i] != S[i + 1]:
        del S[i:i+2]
        cnt += 1
        i = 0
        continue
    elif i + 2 == len(S):
        print(cnt * 2)
        exit()
    i += 1







S = list(input())

zero_S = S.count('0')
one_S = S.count('1')

print(min(zero_S, one_S) * 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 = list(input())
cnt1 = 0
cnt0 = 0
for i in s:
    if i == '1':
        cnt1 += 1
    else:
        cnt0 += 1
print(max(cnt1, cnt0))



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



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



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

count = 0
while True:
    n = len(s)
    if n == 0 or sum(s) == 0 or sum(s) == n:
        break
    sn = s + '\n'
    for i in range(n):
        if sn[i-1] + sn[i] == '10' or sn[i-1] + sn[i] == '01':
            s = sn[:i-1] + sn[i+1:n]
            count += 1
            break

print(count * 2)

s = input()

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

print(2 * min(zero, one))

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()
num0,num1=0,0
for i in s:
  if i=='0':
    nums0+=1
  elif i=='1':
    nums1+=1
print(2*min(num0,num1))

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

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

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


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)


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)


S = input()

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

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


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)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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(2*min(S.count("0")-S.count("1")))

S=input();print(2*min(S.count("0"),S.count("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):
S = input()

c0=0
c1=0

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

S = input()

stack = []

ans = 0
for s in S:
    if len(stack)==0 or s==stack[-1]:
        stack.append(s)
    else:
        stack.pop()
        ans += 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()
ans=min(s.count('0'),s.count('1'))
print(ans)

s=input()
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):
from collections import Counter
S = list(input())
c = Counter(S)
ans = min(c["0"], c["1"])
print(ans)

n = list(input())
print(min(n.count("0"), n.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()
N = len(S)
 
for i in range(N/2):
    S = S.replace('01', '').replace('10', '')
 
print(N - len(S))

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)

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()
nall=len(s)
nzero=s.count("0")
none=nall-nzero
if n==0:
    print(0)
elif none<=nzero:
    print(nall-none*2)
else:
    print(nall-nzero*2)


s=input()
nall=len(s)
nzero=s.count("0")
none=nall-nzero
if nall==0:
    print(0)
elif none<=nzero:
    print(nall-none*2)
else:
    print(nall-nzero*2)



s=input()

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

print(2*min(c0,c1))


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):
import re
s=input()
m=0
for i in range(len(s)//2):
  dst = re.sub(r'01|10', "", s)
  dst = re.sub(r'000000111111', "", dst)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m

import re
s=input()
m=0
for i in range(len(s)/2):
  dst = re.sub(r'01|10', "", s)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m)

s=input();print(min(s.count("0"), s.count("1"))*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):
# -*- coding: utf-8 -*-

def main():
    s = input().split(" ")

    sl = list(s[0])
    prev = -1
    n = 0

    i = 0
    while True:
        if len(sl) <= i:
            break

        if (prev == 0 and sl[i] == '1') or (prev == 1 and sl[i] == '0'):
            # print(str(sl))
            # print("remove", i, prev, sl[i])
            del sl[i]
            del sl[i-1]
            n += 2
            if len(sl) <= i:
                break
            else:
                prev = int(sl[i-2])
                i = i-1
        else:
            prev = int(sl[i])
            i += 1

    print(n)

main()


# -*- coding: utf-8 -*-

def main():
    s = input().split(" ")

    sl = list(s[0])
    prev = -1
    n = 0

    i = 0
    while True:
        if len(sl) <= i:
            break

        if (prev == 0 and sl[i] == '1') or (prev == 1 and sl[i] == '0'):
            # print(str(sl))
            # print("remove", i, prev, sl[i])
            del sl[i]
            del sl[i-1]
            n += 2
            if i-2 < 0:
                prev = -1
                i = 0
            else:
                prev = int(sl[i-2])
                i = i-1
        else:
            prev = int(sl[i])
            i += 1

    print(n)

main()


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):
#coding: utf-8
s = list(map(int, input()))
if len(s) <= 1:
    print(0)
else:
    zero = [i for i, x in enumerate(s) if x == 0]
    one = [i for i, x in enumerate(s) if x == 1]
    zeros = s[:zero[-1]].count(0)
    ones = s[:one[-1]].count(1)
    print(zeros * 2 if zeros < ones else ones * 2)


#coding: utf-8
s = list(map(int, input()))
cnt = 0
while len(set(s)) > 1:
    for i in range(len(s)-1):
        if s[i] == 1 and s[i+1] == 0:
            cnt += 2
            del s[i:i+2]
            break
print(cnt)

# coding: utf-8
S = input()
zero, one = 0, 0
for i in range(len(S)):
    if S[i] == "0":
        zero += 1
    else:
        one += 1
print(min(zero, one)*2)

Verdicts: 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):
s = list(map(int, input()))0
print(min(len(s)-sum(s), sum(s))*2)

s = list(map(int, input()))
print(min(len(s)-sum(s), sum(s))*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()
for i in range(len(s)):
  if s[i]=="0":
    z+=1
  else:
    o+=1
print(2*min(0,1))

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

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

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

Verdicts: Runtime Error

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 s in S:
    if not stack:
        stack.append(s)
    elif stack[-1]!=s
        stack.pop()
        ans+=2
    else:
        stack.append(s)
print(ans)

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)

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 =s.count("0")
one =s.count("1")
MIN =min(zero,one)
print(min*2)    

s =input()
zero =s.count("0")
one =s.count("1")
MIN =min(zero,one)
print(MIN*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 = [i for i in input()]
one = S.count("1")
zero = S.count("0")
print(min(one,zero))

S = [i for i in 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):
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    z, o = 0, 0
    for i in range(len(S)):
        if S[i] == "0": z += 1
        else: o += 1
        print(2 * min(z, o))
    return 0

if __name__ == "__main__":
    solve()

import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    c = [0, 0]
    for i in range(len(S)):
        c[int(S[i])] += 1
    print(2 * min(c))

    return 0

if __name__ == "__main__":
    solve()

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


S_raw = sys.stdin.readline().strip()

def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<10**5:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

import sys


S_raw = sys.stdin.readline().strip()

def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<50000:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

import sys
from collections import Counter

S = sys.stdin.readline()
S_count = Counter(S)

print(2*(S_count.most_common()[-1][1]))


import sys
import numba


S_raw = sys.stdin.readline().strip()

@numba.jit
def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<50000:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

import sys


S_raw = sys.stdin.readline().strip()

def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<20:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

S = input()

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

print(min(num0,num1)*2)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

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 = input()
print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2 if len(S) > 1 else 0)

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

Verdicts: Runtime Error

Accepted