Problem:


Score : 200 points

Problem Statement

Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.

To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:

The 0 key: a letter 0 will be inserted to the right of the string.

The 1 key: a letter 1 will be inserted to the right of the string.

The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.

Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?

Constraints

1 ≦ |s| ≦ 10 (|s| denotes the length of s)

s consists of the letters 0, 1 and B.

The correct answer is not an empty string.

Input

The input is given from Standard Input in the following format:

s

Output

Print the string displayed in the editor in the end.

Sample Input 1

01B0

Sample Output 1

00

Each time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00.

Sample Input 2

0BB1

Sample Output 2

1

Each time the key is pressed, the string in the editor will change as follows: 0, (empty), (empty), 1.



Sample input:
01B0


Sample output:
00

Submission status: Accepted

Solution code:
s = input()

n = len(s)
s_ans = ""

for i in range(n):
    if s[i] == "0":
        s_ans = s_ans + "0"

    elif s[i] == "1":
        s_ans = s_ans + "1"

    elif s[i] == "B":
        len_ans = len(s_ans)
        if len_ans >= 1:
            s_ans = s_ans[:len_ans-1]

        elif len_ans == 0:
            s_ans = s_ans

        else:
            print("error2")

    else:
        print("error1")

print(s_ans)

Submission status: Accepted

Solution code:
s = list(input())
out = []

for s1 in s:
	if s1 == 'B':
		if out != []:
			out.pop()
	else:
		out.append(s1)
print(''.join(out))

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
ans = ""
for i in range(len(s)):
    if s[i] == '0':
        ans += '0'
    elif s[i] == '1':
        ans += '1'
    else:
        ans = ans[:-1]
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

S = list(input())
lis = []
for s in S:
    if s=='0':
        lis.append(str(0))
    if s=='1':
        lis.append(str(1))
    if s=='B':
        if len(lis):
            lis.pop()

print(''.join(lis))

Submission status: Accepted

Solution code:
s = input().strip()
x = ""
cur = 0
for i in range(len(s)):
    if s[i]=="0":
        x += "0"
        cur += 1
    elif s[i]=="1":
        x += "1"
        cur += 1
    else:
        if cur>0:
            x = x[:-1]
            cur -= 1
print(x)

Submission status: Accepted

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

s = sr()
st = []
for c in s:
    if c == '0':
        st.append('0')
    elif c == '1':
        st.append('1')
    else:
        if st:
            st.pop()
print(''.join(st))

Submission status: Accepted

Solution code:
s=input()
ans=[]
for i in range(len(s)):
  if s[i]=='0':
    ans.append('0')
  elif s[i]=='1':
    ans.append('1')
  else:
    if ans:
      ans.pop()
print(''.join(ans))

Submission status: Accepted

Solution code:
s = input()

ans = []
for l in s:
    if l == '0':
        ans.append('0')
    elif l == '1':
        ans.append('1')
    else:
        if ans:
            ans.pop()

print(''.join(ans))

Submission status: Accepted

Solution code:
S = input()

ans = []
for c in S:
    if c=='B':
        if ans: ans.pop()
    else:
        ans.append(c)
print(''.join(ans))

Submission status: Accepted

Solution code:
def solve():
  S = input()
  ans = []
  for s in S:
    if s!='B':
      ans.append(s)
    else:
      if len(ans):
        ans.pop(-1)
  ans = ''.join(ans)
  return ans
print(solve())

Submission status: Accepted

Solution code:
s = input()
res = ''
for elem in s:
  if elem == 'B':
    res = res[:-1]
  else:
    res += elem
print(res)

Submission status: Accepted

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

ans = []
for i in range(n):
  if s[i] == '0':
    ans.append('0')
  elif s[i] == '1':
    ans.append('1')
  elif ans == []:
    continue
  else:
    ans.pop()
    
print(''.join(ans))

Submission status: Accepted

Solution code:
s = input()
a = []
for i in s:
    if i != "B":
        a.append(i)
    else:
        if a:
            a.pop()
print(*a, sep = "")

Submission status: Accepted

Solution code:
s = input()

st = []

for i in range(len(s)):
    if s[i] == "0":
        st.append("0")
    elif s[i] == "1":
        st.append("1")
    else:
        if len(st) != 0:
            st.pop()
        else:
            continue

print("".join(st))

Submission status: Accepted

Solution code:
S=[x for x in input()]
ans=[]
for i in range(len(S)):
  if S[i]!='B':
    ans.append(S[i])
  else:
    try:
      ans.pop()
    except:
      continue
print(''.join(ans))

Submission status: Accepted

Solution code:
from collections import deque
S = input()
T = deque([])
for s in S:
  if s=="B" and len(T)>0:
    T.pop()
  elif s=="B":
    pass
  else:
    T.append(s)
print("".join(T))

Submission status: Accepted

Solution code:
s=input()
l=[]
for i in s:
  if i=="0":
    l.append("0")
  elif i=="1":
    l.append("1")
  elif i=="B":
    if l!=[]:
    	l.pop()
if l==[]:
  print("")
else:
  print("".join(l))

Submission status: Accepted

Solution code:
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def check(n,s):
    v=str(n)
    for i in v:
        if i in s:
            return False
    return True
    

    
def solve():
    l=[]
    s=input()
    for i in s:
        if i=='0' or i=='1':
            l.append(i)
        else:
            if len(l)>0:
                l.pop()
    print(''.join(l))
        
        
        

for _ in range(1):
    solve()

Submission status: Accepted

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

def solve(s):
  l = []
  for c in s:
    if c == "0" or c == "1":
      l.append(str(c))
    elif len(l):
      l.pop()
  return "".join(l)




def main():
  s = input()
  print(solve(s))
  return

if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
s = input()

ans = ''

for i in s:
    ans = ans[:-1] if i == 'B' else ans + i    

print(ans)

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    s = input()
    edge = collections.deque()
    for i in s:
        if i == "0":
            edge.append("0")
        elif i == "1":
            edge.append("1")
        elif len(edge) > 0:
            edge.pop()
    print("".join(edge))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
s = input()
ans = ''
for si in s:
  if si=='0': ans+='0'
  elif si=='1': ans+='1'
  else: ans=ans[:-1]
print(ans)

Submission status: Accepted

Solution code:
def main():
    s=input()
    li=[]
    for i in range(len(s)):
        if(s[i]!='B'):
            li.append(s[i])
        else:
            if(len(li)!=0):
                li.pop()
    for i in li:
        print(i,end='')

main()

Submission status: Accepted

Solution code:
s = input()
output_s = ""

for i in s:
  if i == "B" and len( output_s) != 0:
    output_s = output_s[0:len( output_s)-1]
  elif i != "B":
    output_s += i
  
print(output_s)

Submission status: Accepted

Solution code:
from collections import deque
S = input()

def calculate(s):
    q = deque()
    for i in range(len(s)):

        if s[i] == "0":
            q.append("0")
            continue

        if s[i] == "1":
            q.append("1")
            continue

        if s[i] == "B":
            if len(q) > 0:
                q.pop()


    if len(q) == 0:
        print("(empty)")
    else:
        print("".join(list(q)))


calculate(S)

Submission status: Accepted

Solution code:
def main():
  s=input()
  a=[]
  for i in range(len(s)):
    if s[i]=='0':
      a.append('0')
    elif s[i]=='1':
      a.append('1')
    elif s[i]=='B':
      if a==[]:
          continue
      else:
          a.pop(-1)
  print(''.join(a))
  
  
if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
s = input()
l = len(s)
ans = []
for i in range(l):
	if s[i]=='0':
		ans.append('0')
	elif s[i]=='1':
		ans.append('1')
	else:
		if ans!=[]:
			ans.pop(-1)

n = len(ans)
for i in range(n-1):
	print(ans[i], end="")
print(ans[n-1])

Submission status: Accepted

Solution code:
s = input()
a = ""
for i in s:
  if i == "B":
    if not(a == ""):
      a = a[:-1]
  else:
    a += i
print(a)

Submission status: Accepted

Solution code:
s = input()

ans  = ''

for x in s:
    if x == 'B':
        if ans == '':
            continue 
        ans = ans[:-1]
    else:
        ans += x

print(ans)

Submission status: Accepted

Solution code:
s = input()

res = ""

for do in s:
    if do == "B":
        if len(res) != 0:
            res = res[0:len(res)-1]
        
    else:
        res += do

print(res)

Submission status: Accepted

Solution code:
s=input()
stack =[]
for i in s:
    if i != "B":
        stack.append(i)
    else:
        if not stack:
            continue
        else:
            stack.pop()
print("".join(stack))

Submission status: Accepted

Solution code:
from collections import deque
s = input()
lst = deque()
for i in range(len(s)):
  if s[i] == 'B':
    if len(lst) > 0:
      lst.pop()
    else:
      pass
  else:
    lst.append(s[i])
print(''.join(list(lst)))

Submission status: Accepted

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

s = input()
for i in range(5):
    s = re.sub(r"\dB", "", s)
print(s.replace("B", ""))

Submission status: Accepted

Solution code:
from collections import deque
S=input()
ans=[]
ans=deque(ans)
for letter in S:
    if letter=='0':
        ans.append('0')
    elif letter=='1':
        ans.append('1')
    else:
        if len(ans)!=0:
            ans.pop()

print(''.join(ans))

Submission status: Accepted

Solution code:
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

s = LS2()
ans = []
for a in s:
    if a != 'B':
        ans.append(a)
    else:
        if len(ans) != 0:
            del ans[-1]

print(''.join(ans))

Submission status: Accepted

Solution code:
from collections import deque
s=input()
n=len(s)
stack=deque([])
for i in range(n):
    if s[i]=="0":
        stack.append("0")
    elif s[i]=="1":
        stack.append("1")
    else:
        if stack:
            x=stack.pop()
stack=list(stack)
print("".join(stack))