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:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7

s = input()
q = []
for i in range(len(s)):
    if s[i] == "0":
        q.append(0)
    elif s[i] == "1":
        q.append(1)
    elif s[i] == "B" and len(q)!=0:
        q.pop()
ans = ""
for i in range(len(q)):
    ans += str(q[i])
print(ans)

Submission status: Accepted

Solution code:
S = input()
string = ''
for c in S:
    if c == '0':
        string = string + '0'
    elif c == '1':
        string = string + '1'
    elif c == 'B':
        if string == '':
            pass
        else:
            string = string[:-1]
print(string)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
s = input()

ans =[]
for i in range(len(s)):
	if s[i] != "B":
		ans.append(s[i])
	else:
		if ans != []:
			del ans[-1]

print("".join(ans))

Submission status: Accepted

Solution code:
inputs = str(input())
ans = ""

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = ''
s_list = list(s)
for num in s_list:
  if num == '0' or num == '1':
    ans += str(num)
  else:
    ans = ans[:-1]
print(ans)

Submission status: Accepted

Solution code:
ope = input()
result = list()
for i in ope:
    if i =="0" or i == "1":
        result.append(i)
    if i =="B":
        if len(result)!=0:
            result.pop()        
print("".join(result))

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline().rstrip()

stack = []
for s_i in s:
    if s_i == "B":
        if stack:
            stack.pop()
    else:
        stack.append(s_i)

print("".join(stack))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans=""
for i in list(input()):
    if ans and i=="B":ans=ans[:-1]
    else:ans=ans+i if i!="B" else ans
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = ""
for k in s:
  if k == 'B':
    if ans != "":
      ans = ans[:len(ans)-1]
  else:
    ans += k
print(ans)

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 # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    s = input()

    ans = ''
    b = 0
    for c in reversed(s):
        if c == 'B':
            b += 1
        else:
            if b:
                b -= 1
                continue
            ans = c + ans
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(input())
ans = []
for c in s:
    if c == 'B':
        if len(ans) > 0:
            ans = ans[:-1]
    else:
        ans.append(c)
print(''.join(ans))

Submission status: Accepted

Solution code:
S=input()

ans=""

for s in S:
    if s!="B":
        ans+=s
    else:
        if ans!="":
            ans=ans[:-1]
print(ans)

Submission status: Accepted

Solution code:
s = str(input())

ans = ''

for i in range(len(s)):
    if s[i] == '0':
        ans = ans + '0'
    elif s[i] == '1':
        ans = ans + '1'
    else:
        ans = ans[:-1]
        
print(ans)

Submission status: Accepted

Solution code:
S = input()
ans = ""
for i in S:
    if i == "0":
        ans += "0"
    elif i == "1":
        ans += "1"
    else:
        if len(ans) != 0:
            ans = ans[:-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = []
for x in s:
    if x != 'B':
        ans.append(x)
    else:
        if ans:
            ans.pop()

print(''.join(ans))

Submission status: Accepted

Solution code:
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
s=input()
a=[]
for i in range(len(s)):
  if s[i]=='0':
    a.append('0')
  elif s[i]=='1':
    a.append('1')
  else:
    if len(a)>0:
      a.pop()
print(convert(a))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
u=input().rstrip()
ans=""
for i in range(len(u)):
    if u[i]=="B":
        if ans!="":
            x=ans
            ans=""
            for j in range(len(x)-1):
                ans+=x[j]
    else:
        ans+=u[i]
    #print(ans)
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()

    res = []
    for i in s:
        if i == "0":
            res.append("0")
        elif i == "1":
            res.append("1")
        else:
            if len(res) > 0:
                res.pop()

    print("".join(res))


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ans = []

for s in S:
    if s == '0': ans.append(s)
    elif s == '1': ans.append(s)
    elif ans: ans.pop()

print(''.join(ans))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
ans = ''
for ss in s:
    if ss == 'B':
        if ans:
            ans = ans[:-1]
    else:
        ans += ss
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = []

ret = True
for v in s:
  if v == "0": ans.append("0")
  elif v == "1": ans.append("1")
  else:
    if not ans:continue
    ans.pop(-1)
print("".join(ans))

Submission status: Accepted

Solution code:
s = input()

ans_li=[]
for i in range(len(s)):
    if s[i]==str(0):
        ans_li.append(str(0))
    if s[i]==str(1):
        ans_li.append(str(1))
    if s[i]=='B':
        if len(ans_li)==0:
            continue
        del ans_li[-1]
print(''.join(ans_li))

Submission status: Accepted

Solution code:
S=input()
ans=[]
for s in S:
    if s=="B":
        if len(ans)==0:
            continue
        else:
            ans=ans[:-1]
    else:
        ans.append(s)
print("".join(map(str,ans)))

Submission status: Accepted

Solution code:
def main():
    S = input()
    ans = []
    for s in S:
        if s == "B" and ans:
            ans.pop()
        if s == "0" or s == "1":
            ans.append(s)
    print("".join(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = list(input())[: -1]
res = []
for x in S:
  if x == "B":
    if len(res): res.pop()
  else: res.append(x)
print("".join(res))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc043/tasks/abc043_b
S = input()
ans = []
for s in S:
    if s == 'B':
        if ans:
            del ans[-1]
    else:
        ans.append(s)
print("".join(ans))

Submission status: Accepted

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

Submission status: Accepted

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

for i in s:
  if i == "0" or i == "1":
    ans += i
  else:
    ans = ans[:-1]
print(ans)

Submission status: Accepted

Solution code:
N=input()
ans=[]
for i in N:
    if i=='B':
        if not ans==[]:
            ans.pop()
    else:
        ans.append(i)
print(''.join(ans))

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)
###################################################

def main():
    s=input()
    ans=""
    for a in range(len(s)):
        if s[a]=="B":
            ans=ans[:-1]
        else:
            ans+=s[a]
    print(ans)
main()

Submission status: Accepted

Solution code:
s = list(input())

ans = []
for i in range(len(s)):
    if s[i] == "0":
        ans.append("0")
    elif s[i] == "1":
        ans.append("1")
    else:
        if len(ans) > 0:
            del ans[len(ans) - 1]

ans = ''.join(ans)
print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = ""
for i in range(len(s)):
    if s[i] == "0":
        ans = ans + "0"
    elif s[i] == "1":
        ans = ans + "1"
    else:
        if ans != "":
            ans = ans[:-1]
print(ans)

Submission status: Accepted

Solution code:
s=input()
ans=''

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

Submission status: Accepted

Solution code:
s = str(input())

t = 0
a = list()
p = 0
for x in s:
    if x == "0":
        if p==0:
            a.append("0")
        else:
            a[t] = "0"
            p -= 1
        t +=1
    elif x == "1":
        if p==0:
            a.append("1")
        else:
            a[t] = "1"
            p-=1
        t +=1
    elif x == "B":
        if t != 0:
            t -=1
            p+=1

i = 0
ans = str()
while i < t:
    ans += a[i]
    i +=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ANSlist = []

for i in range(len(S)):
    if S[i] == '0':
        ANSlist.append('0')
    elif S[i] == '1':
        ANSlist.append('1')
    elif S[i] == 'B':
        if len(ANSlist) >=1:
            del ANSlist[-1]

ANS = ''.join(ANSlist)

print(ANS)

Submission status: Accepted

Solution code:
from collections import deque

s = input()
ans = deque()

for i in s:
    if i == '0' or i == '1':
        ans.append(i)
    else:
        if len(ans) >= 1:
            ans.pop()
        else:
            continue
print(''.join(ans))

Submission status: Accepted

Solution code:
s = input()
disp = ''
for i in range(len(s)):
    if s[i] == 'B':
        disp = disp[0:-1]
    else:
        disp += s[i]
print(disp)

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    from collections import deque
    q = deque()
    for i in s:
        if i == 'B':
            if len(q) > 0:
                t = q.pop()
        else:
            q.append(i)
    print(*list(q), sep='')

if __name__ == '__main__':
    main()

155284

Submission status: Accepted

Solution code:
def main():
  s = input()

  ans = ""

  for c in s:
    if(c == "0"):
      ans += "0"
    elif(c == "1"):
      ans += "1"
    elif(c == "B"):
      if(ans != ""):
        ans = ans[0:len(ans) - 1]

  print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import deque
s=deque(list(input()))
p=deque()
for i in range(len(s)):
    w=s.popleft()
    if w=="0":
        p.append("0")
    elif w=="1":
        p.append("1")
    else:
        if len(p)==0:
            continue
        else:
            p.pop()

for i in range(len(p)):
    print(p[i],end="")

Submission status: Accepted

Solution code:
s = list(input())

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

print("".join(ans))

Submission status: Accepted

Solution code:
s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = ""

for i in range(len(s)-1):
    if s[i+1] != "B":
        dp[i+1] = dp[i] + s[i+1]
    else:
        dp[i+1] = dp[i][:len(dp[i])-1]
print(dp[len(s)-1])

Submission status: Accepted

Solution code:
S = input()
n = len(S)
stack = []

for i in range(n):
    s = S[i]
    
    if s != "B":
        stack.append(s)
    elif len(stack) > 0:
        stack.pop()
        
print("".join(stack))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()


s=input().rstrip()
ans=""
for i in range(len(s)):
    if s[i]=="B":
        ans=ans[:len(ans)-1]
    else:
        ans+=s[i]
print(ans)

Submission status: Accepted

Solution code:
s = list(input())

ans = []

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
ans=[]
for i in s:
    if i=="B":
        try:
            ans.pop(-1)
        except IndexError:
            pass
    else:
        ans.append(i)
print("".join(ans))

Submission status: Accepted

Solution code:
s = list(input())
ans = []
for i in s:
    if i == 'B':
        if len(ans) != 0:
            ans.pop()
    else:
        ans += i
print(''.join(ans))

Submission status: Accepted

Solution code:
s = input()
editor = ""
for x in s:
    if x == "0":
        editor = editor + "0"
    elif x == "1":
        editor = editor + "1"
    else:
        if len(editor) == 0:
            continue
        else:
            editor = editor[:len(editor)-1]
print(editor)

Submission status: Accepted

Solution code:
s = str(input())
text = ""
for i in s:
    if i == "0" or i == "1":
        text += i
    else:
        text = text[0:len(text)-1]
print(text)

Submission status: Accepted

Solution code:
A = list(input())
B = []
for i in range(len(A)):
    if A[i] == "0":
        B.append("0")
    elif A[i] == "1":
        B.append("1")
    else:
        try:
            B.pop(-1)
        except IndexError:
            pass
print("".join(B))

Submission status: Accepted

Solution code:
def nyu():
    S =  list(map(str,input()))
    return S


def kansu(LS):
    ans = []
    ans_str =""

    for ls in range(len(LS)):
        
        if LS[ls] == "0":
            ans.append("0")
        elif LS[ls] == "1":
            ans.append("1")
        else:
            if len(ans) > 0 :
                ans.pop(len(ans)-1)
    
    for i in range(len(ans)):
        ans_str += ans[i]
    


    print(ans_str)




S = nyu()
kansu(S)

Submission status: Accepted

Solution code:
S = input()
res = ""
for i in range(len(S)):
    if S[i] == "0":
        res += "0"
    if S[i] == "1":
        res += "1"
    if S[i] == "B":
        res = res[:-1]
print(res)

Submission status: Accepted

Solution code:
s=input()
moji=[]
for i in range(0,len(s)):
  if s[i]=="1":
    moji.append("1")
  elif s[i]=="0":
    moji.append("0")
  else:
    try:
      moji.pop(-1)
    except IndexError:
      pass
kk=""
print(kk.join(moji))

Submission status: Accepted

Solution code:
import sys
from collections import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    S = input()
    L = len(S)
    d = deque()
    for i in range(L):
        if S[i]=='0':
            d.append(0)
        elif S[i]=='1':
            d.append(1)
        else:
            if len(d)!=0:
                d.pop()
    print(''.join(map(str,d)))



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
console = []
for c in s:
    if c=='B':
        if len(console)>0:
            console.pop()
    else:
        console.append(c)
for c in console:
    print(c, end='')

Submission status: Accepted

Solution code:
N = input()
ans = ''
for i in range(len(N)):
  if(ans == '' and N[i] == "B"):
    pass
  elif(ans == '' and N[i] != "B"):
    ans = N[i]
  elif(N[i] == "B"):
    ans = ans[:-1]
  else:
    ans += N[i]

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    res = ""
    for s in S:
        if s in ['0', '1']:
            res += s
        else:
            if len(res) > 0:
                res = res[:-1]
    print(res)



if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
s = input()
ans = ''

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
ans = []
for i in s:
    if i == 'B':
        if len(ans) > 0:
            ans.pop(-1)
    else:
        ans += i
print(''.join(ans))

Submission status: Accepted

Solution code:
s=input()
res=[]
for i in s:
	#print(i)
	if i=='0':
		res+=i
		#print(res)
	elif i=='1':
		res+=i
		#print(res)
	else:
		if res!=[]:
			res.pop(len(res)-1)
		#print(res)
print(''.join(res))

Submission status: Accepted

Solution code:
moji = list(str(input()))
lst = []
for i in range(len(moji)):
  if moji[i]=="0":
    lst.append("0")
  elif moji[i]=="1":
    lst.append("1")
  elif moji[i]=="B" and len(lst)>0:
    del lst[-1]
  elif moji[i]=="B" and len(lst)==0:
    continue;
print(''.join(lst))

Submission status: Accepted

Solution code:
s= input()
ans = ''
for i in s:
    if(i=='0' or i=='1'):
        ans+=i
    else:
        if(len(ans)>=1):
            ans = ans[0:len(ans)-1]
print(ans)

Submission status: Accepted

Solution code:
s, s_back = input(), ""
while "B" in s:
    s = s.replace("1B", "").replace("0B", "")
    if s_back == s:
        break
    s_back = s
print(s.replace("B", ""))

Submission status: Accepted

Solution code:
s=input()

x=''
for i in s:
  
  if i=='0':
    x+='0'
  elif i=='1':
    x+='1'
  elif i=='B':
    
    if len(x)>0:
    	x=x[:-1]
        
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
q = []
for i in range(len(s)):
    if s[i] == 'B':
        if q != []:
            q.pop()
    else:
        q.append(s[i])
print(''.join(q))

Submission status: Accepted

Solution code:
s = input()
ans = []
for key in s:
    try:
        if key == 'B':
            ans.pop()
        else:
            ans.append(key)
    except IndexError:
        pass
print(''.join(ans))

Submission status: Accepted

Solution code:
s = input()

strings = ''

for str in s:
    if str == '0':
        strings += '0'
    elif str == '1':
        strings += '1'
    elif str == 'B':
        if len(strings) > 0:
            strings = strings[:-1]
        else:
            pass
print(strings)

Submission status: Accepted

Solution code:
#! python3
def main():
    s = input()
    ans = ""
    r = len(s)
    for i in range(r):
        if s[i] == "0":
            ans += "0"
        elif s[i] == "1":
            ans += "1"
        else:
            ans = ans[:-1]

    print(ans)
    
main()

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc043/tasks/abc043_b

s = input()

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

Submission status: Accepted

Solution code:
s = input()
N = len(s)
Ans = ""
for i in range(N):
    if s[i]=="0":
        Ans = Ans + "0"
    elif s[i]=="1":
        Ans = Ans + "1"
    else:
        Ans = Ans[:-1]
        
print(Ans)

Submission status: Accepted

Solution code:
s = input()
ans = ''
for i in s:
    if not ans and i == 'B':
        continue
    if i == 'B':
        ans = ans[:-1]
    else:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

out_s = []
for i in range(len(s)):
  if s[i] == '0' or s[i] == '1':
    out_s.append(s[i])
  elif s[i] == 'B':
    if len(out_s) != 0:
      del out_s[-1]

tmp = ''
for i in range(len(out_s)):
  tmp += out_s[i]
print(tmp)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    cmd = input()
    ans = []
    for char in cmd:
        if char == 'B':
            if len(ans) > 0 :
                ans.pop()
        else:
            ans.append(char)
    for c in ans:
        print(c,end="")

Submission status: Accepted

Solution code:
s = input()

t = ""
for i in s:
  if i == '0':
    t += '0'
  elif i == '1':
    t += '1'
  elif i == 'B' and t != "":
    t = t[:-1]
  else:
    continue
    
print(t)

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

out =''
for i in s:
    if i == '0':
        out +='0'
    elif i == '1':
        out +='1'
    else:
        if out != '':
            out = out[:-1]

print(out)

Submission status: Accepted

Solution code:
string = ''

commands = list(input())

for c in commands:
  if (c == 'B'):
    string = string[:len(string)-1]
  if (c == '0' or c == '1'):
    string += c
    
print(string)

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
ans = [''] * len(S)
cur = 0
for s in S:
    if s == 'B':
        cur -= 1
        ans[cur] = ''
        cur = max(0, cur)
    else:
        ans[cur] = s
        cur += 1

print("".join(ans))

Submission status: Accepted

Solution code:
def solve():
    s = list(input())

    ans = []
    for i in range(len(s)):
        if s[i] != 'B':
            ans.append(s[i])
        elif s[i] == 'B' and ans:
            ans.pop(len(ans)-1)

    return ''.join(ans)

    
print(solve())