Harryxun/stf_run huggingface dataset:
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header
int main() {
	string s, ans="";
	cin >> s;
	for(auto x : s){
		if(x!='B') ans+=x;
		else if(ans!="") ans.pop_back();
	}
	cout << ans << endl;
 	return 0;
}

### FIXED CODE ###

# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
s = input()
ans = []
for x in s:
    if x=='0': ans.append('0')
    elif x == '1': ans.append('1')
    else:
        if len(ans) == 0: pass
        else: ans.pop()
for t in ans: print(t, end = "")
a = int(input())
b = int(input())
c = list(map(int,input().split()))
sum = 0
for i in c:
  sum = sum + i
count = 0
vote = (1/(4*b))*sum
for j in c:
  if j>=vote:
    count = count + 1
if count>=b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b = map(int,input().split())
c = list(map(int,input().split()))
sum = 0
for i in c:
  sum = sum + i
vote = (1/(4*b))*sum
count = 0
for j in c:
  if j>=vote:
    count = count + 1

if count>=b:
  print("Yes")
else:
  print("No")
from itertools import *
from collections import *
from sys import *
input=sys.stdin.readline
h,w=map(int,input().split())
a=[]
l=[(0,1),(0,-1),(1,0),(-1,0)]
for i in range(h):
    t=list(input())
    a.append(t)
ans=[[float("inf")]*w for i in range(h)]
q=deque()
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            ans[i][j]=0
            q.append((i,j))
while q:
    x,y=q.popleft()
    for xx,yy in l:
        nx,ny=x+xx,y+yy
        if 0<=nx<h and 0<=ny<w:
            if ans[nx][ny]>ans[x][y]+1:
                ans[nx][ny]=ans[x][y]+1
                if (nx,ny) not in q:
                    q.append((nx,ny))
aa=[]
for i in range(h):
    aa.append(max(ans[i]))
print(max(aa))


### FIXED CODE ###

from collections import deque
H,W=map(int, input().split())
 
A=[]
que=[]
done=[[-1]*W for _ in range(H)]
for h in range(H):
    a=list(input())
    A.append(a)
    for w in range(W):
        if a[w]=="#":
            que.append((h,w))
            done[h][w]=0
 
d=[(1,0),(-1,0),(0,1),(0,-1)]
que=deque(que)
ans=0
while que:
    h,w=que.popleft()
    now=done[h][w]
    for t in d:
        dh,dw=t
        nh=h+dh
        nw=w+dw
        if 0<=nh<H and 0<=nw<W:
            if done[nh][nw]==-1:
                done[nh][nw]=now+1
                que.append((nh,nw))
                ans=max(ans, now+1)
print(ans)
N = int(input())
A = list(map(int,input().split()))
res = []

for i in range(N//2+1,N):
  if A[i] == 1:
    res.append(i)

for j in range(N//2,-1,-1):
  cnt = 0
  for k in res:
    if k%j == 0:
      cnt += 1
  if A[j] == 1 and cnt%2 == 0:
    res.append(j)
  elif A[j] == 0 and cnt%2 == 1:
    res.append(j)
  
res.sort()
print(*res)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A = [0] + A
res = [0]*(N+1)
M = 0

for i in range(N,0,-1):
  if sum(res[j] for j in range(i,N+1,i)) % 2 != A[i]:
    res[i] = 1
    M += 1
    
print(M)
print(*[k for k, r in enumerate(res) if r])
a,b,c,d = map(int,input().split())
import math
s1 = b//c
s2 = (a-1)//c
p1 = b//d
p2 = (a-1)//d
e = c*d//math.gcd(c,d)
q1 = b//e
q2 = (a-1)//e
print(b-a+1-(s1+p1-s2-p2-q1+q2))

### FIXED CODE ###

a,b,c,d = map(int,input().split())
import fractions
s1 = b//c
s2 = (a-1)//c
p1 = b//d
p2 = (a-1)//d
e = c*d//fractions.gcd(c,d)
q1 = b//e
q2 = (a-1)//e
print(b-a+1-(s1+p1-s2-p2-q1+q2))
import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_t, b_t = [0], [0]
for i in range(n):
    a_t.append(a_t[i] + a[i])
for i in range(m):
    b_t.append(b_t[i] + b[i])
ans = 0
j = m
for i in range(n):
    if (a[i] > k):
        break
    while(a_t[i] + b_t[j] > k):
        j -= 1
    ans = max(ans, i + j)
print(ans)



### FIXED CODE ###

import sys
import numpy as np
import math
import collections
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_t, b_t = [0], [0]
for i in range(n):
    a_t.append(a_t[i] + a[i])
for i in range(m):
    b_t.append(b_t[i] + b[i])
ans = 0
j = m
for i in range(n+1):
    if (a_t[i] > k):
        break
    while(a_t[i] + b_t[j] > k):
        j -= 1
    ans = max(ans, i + j)
print(ans)
import numpy as np
import scipy as sp

a = int(input())
b = int(input())
print(6-a-b)


### FIXED CODE ###

import numpy as np
import scipy as sp

a = int(input())
b = int(input())
print(6-a-b)
num1, num2, num3 = [int(i) for i in input().split()]
a=list[num1+num2,num2+num3,num1+num3]
print(max(a))

### FIXED CODE ###

num1, num2, num3 = [int(i) for i in input().split()]
a=[num1+num2,num2+num3,num1+num3]
print(min(a))
x = int(input())
a = int(input())
if x < a:
  print("0")
else:
  print("10")

### FIXED CODE ###

i = list(map(int, input().split()))
if i[0] < i[1]:
  print("0")
else:
  print("10")
# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        shurui = 1
        if anagramed[i]:
            continue
        else:
            for j in range(i+1, n):
                if anagramed[j]:
                    continue
                elif is_anagram(m[i], m[j]):
                    shurui += 1
                    anagramed[i] = True
                    anagramed[j] = True
        if shurui > 1:
            count += int(math.factorial(shurui) / 2)
    print(count)


def is_anagram(s1, s2):
    s1_length = len(s1)
    s2_length = len(s2)
    if s1_length != s2_length:
        return False
    else:
        for index in range(s1_length):
            search_char = s1[index: index+1]
            search_result = s2.find(search_char)
            if search_result == -1:
                return False
            else:
                s2 = s2.replace(search_char, "", 1)
    return True

main()

### FIXED CODE ###

# coding: utf-8
import math

anagramed = []

def main():
    # n = map(int, input().split(" "))
    n = int(input())
    m = []
    r = {}
    count = 0

    for _ in range(n):
        m.append(input())
        anagramed.append(False)

    for i in range(n):
        s = "".join(sorted(m[i]))
        if r.get(s) is None :
            r[s] = 1
        else:
            count += r[s]
            r[s] += 1
    print(count)


main()
import math
x = int(input())
b = 0import math
x = int(input())
b = 0

@njit
def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    calc(-b, -b5)
    b += 1


def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    calc(-b, -b5)
    b += 1


### FIXED CODE ###

import math
x = int(input())
b = 0

"""
def calc(b, b5):
    a = (x+b5)**0.2

    if a.real.is_integer():
        print(int(a), b)
        exit()

while True:
    b5 = b ** 5
    calc(b, b5)
    if x-b5 >= 0:
        calc(-b, -b5)
    b += 1
    """

for i in range(-120,120):
    for j in range(-120,120):
        if i**5 - j**5 == x:
            print(i, j)
            exit()
s = input()
t = input()
for i in range(len(s)):
    s.insert(0, s.pop(-1))
    if s == t:
        print("Yes")
print("No")

### FIXED CODE ###

s = list(input())
t = list(input())
for i in range(len(s)):
    s.insert(0, s.pop(-1))
    if s == t:
        print("Yes")
        exit()
print("No")
import numpy as np

N = int(input())
A = list(map(int,input().split()))

boss=[0]*N

for x in A:
    boss[x-1] += 1
for i in boss:
    print(int(boss[i-1]))

### FIXED CODE ###

import numpy as np

R = int(input())
print( 2 * np.pi * R )
N,Q = map(int,input().split())
ablist = [[] for _ in range(N+1)]
anslist = [0]*(N+1)

for i in range(N-1):
    a,b = map(int,input().split())
    ablist[a].append(b)
    ablist[b].append(a)

pxlist = [list(map(int,input().split())) for _ in range(Q)]

for q,x in pxlist:
    anslist[q] += x

def dfs(nownode,oya=-1):
    for b in ablist[nownode]:
        if oya == b:
            continue
        else:
            anslist[b] += anslist[nownode]
            dfs(b,nownode)
dfs(1)
print(' '.join(map(str,anslist[1:])))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 

N, Q = map(int, input().split())

T = [[]for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    T[a-1].append(b-1)
    T[b-1].append(a-1)

X = [0 for i in range(N)]
for i in range(Q):
    p, x = map(int, input().split())
    X[p-1] += x

# def dfs(x, p):
#     for j in T[x]:
#         if j == p:
#             continue
#         X[j] += X[x]
#         dfs(j, x)
def dfs(nownode,oya=-1):
    for nextnode in T[nownode]:
        if oya == nextnode:
            continue
        X[nextnode] += X[nownode]
        dfs(nextnode,nownode)

dfs(0, -1)

print(*X)
x,n = map(int, input().split())

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    d = []
    c=0
    for e in p:
        d.append(abs(e-x))
    d1 = d[0]
    for i in range(len(d)):
        if d[i] < d1:
            d1 = d[i]
            z = p[i]
    for j in range(1,100):
        for g in p:
            if z+j != g:
                c +=1
                w1 = z+j
        if c == n:
            break
        c = 0
    c=0
    for j2 in range(1,100):
        for g2 in p:
            if z-j2 != g2:
                c +=1
                w2 = z-j2
        if c == n:
            break
        c = 0

    if w2 < 0:
        print(w1)
    elif abs(w1-x) < abs(w2-x):
        print(w1)
    elif abs(w1-x) >= abs(w2-x):
        print(w2)

### FIXED CODE ###

x,n = map(int, input().split())

if n == 0:
    print(x)
elif n ==100:
    if x >50:
        print(101)
    else:
        print(0)
else:
    p = list(map(int, input().split()))
    d = []
    c=0
    for e in p:
        d.append(abs(e-x))
    d1 = d[0]
    z=p[0]
    for i in range(len(d)):
        if d[i] < d1:
            d1 = d[i]
            z = p[i]
    for j in range(1,100):
        for g in p:
            if z+j != g:
                c +=1
                w1 = z+j
        if c == n:
            break
        c = 0
    c=0
    for j2 in range(1,100):
        for g2 in p:
            if z-j2 != g2:
                c +=1
                w2 = z-j2
        if c == n:
            break
        c = 0
    if w2 < 0:
        print(w1)
    elif abs(w1-x) < abs(w2-x):
        print(w1)
    else:
        print(w2)
N = int(input())
L = [int(j) for j in str(N)]
if N % sum(L) == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A, B = [int(i) for i in input().split()]
bag=[]
for i in range(A, B+1):
    aa = str(i)
    if aa ==aa[::-1] :
        bag.append(i)

print(len(bag))
N = int(input())
H = list(map(lambda x:int(x), input().split()))
count = 0
ans = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    count += 1
  else:
    count = 0
  ans = max(ans, count)

print(ans)

### FIXED CODE ###

pred = input()
real = input()
length = len(pred)
count = 0
for i in range(length):
  if pred[i] == real[i]:
    count += 1
    
print(count)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

D = 2000

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

fact,fact_inv = make_fact(D+D+100,MOD)
fact = fact.tolist()
fact_inv = fact_inv.tolist()

C_to_A = [[] for _ in range(D+D+1)]
remove = 0
for a,b in AB:
    c = a+b
    C_to_A[c].append(D-a)
    remove += fact[c+c] * fact_inv[a+a] * fact_inv[b+b]
remove %= MOD

dp = np.zeros(D+D+1,np.int64)
for A in C_to_A[::-1]:
    dp[1:] += dp[:-1]
    np.add.at(dp,A,1)

x = (dp * dp[::-1] % MOD).sum() % MOD
x -= remove
if x&1:
    x += MOD
x //= 2
x %= MOD

print(x)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 10 ** 9 + 7

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

D = 2000

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U,MOD):
    x = np.arange(U,dtype=np.int64); x[0] = 1
    fact = cumprod(x,MOD)
    x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD)
    fact_inv = cumprod(x,MOD)[::-1]
    return fact,fact_inv

fact,fact_inv = make_fact(10 ** 4,MOD)
fact = fact.tolist()
fact_inv = fact_inv.tolist()

C_to_A = [[] for _ in range(D+D+1)]
remove = 0
for a,b in AB:
    c = a+b
    C_to_A[c].append(D-a)
    remove += fact[c+c] * fact_inv[a+a] * fact_inv[b+b]
remove %= MOD

dp = np.zeros(D+D+1,np.int64)
for A in C_to_A[::-1]:
    dp[1:] += dp[:-1].copy()
    np.add.at(dp,A,1)
    dp %= MOD

x = (dp * dp[::-1] % MOD).sum() % MOD
x -= remove
if x&1:
    x += MOD
x //= 2
x %= MOD

print(x)
n = int(input())
A = list(map(int,input().split()))
c = 1
for a in A:
	c *= a
    if c > 10**18:
         print("-1")
         quit()
print(c)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
c = 1
flag = True
for _ in a:
    c *= _
    if c > 10**18:
        flag = False
        c = 1
    if c == 0:
        print(0)
        quit()
if flag:
    print(c)
else:
    print(-1)
print(sum([1 if s, t else 0 for s, t in zip(input(), input())]))

### FIXED CODE ###

import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    S = input().strip()
    T = input().strip()
    
    res = 0
    for s, t in zip(S, T):
        if s != t:
            res += 1

    print(res)


if __name__ == "__main__":
    main()
n = int(input())
tree = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, 0, 0)
for i in range(q):
    x, y = map(int, input().split())
    print(depth[x] + depth[y])


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n = int(input())
tree = [[] for i in range(n + 1)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    tree[a].append((b, c))
    tree[b].append((a, c))

depth = [0] * (n + 1)
def dfs(v, p, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to != p:
            dfs(to, v, d + cost)

q, k = map(int, input().split())
dfs(k, 0, 0)
xy = [tuple(map(int, input().split())) for i in range(q)]

for x, y in xy:
    print(depth[x] + depth[y])
r = int(input())
S=r**2
print(f'{S}')


### FIXED CODE ###

r = int(input())
S=r*r
print(int(S))
N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP1 = [[0 for j in range(M)] for i in range(N + 2)]
DP2 = [[0 for j in range(M)] for i in range(N + 2)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP1[i][j] = max(DP1[i - 1][j], DP1[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP1[i][j] = DP1[i - 1][j]

for i in range(N - 1, 0, -1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP2[i][j] = max(DP2[i + 1][j], DP2[i + 1][j - D[i][0]] + D[i][1])
        else:
            DP2[i][j] = DP2[i + 1][j]

mv = 0
for l in range(N):
    mv = max(DP1[l][M - 1] + DP2[l][l + 1] + D[l][1], mv)

print(mv)

### FIXED CODE ###

N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP = [[0 for j in range(M)] for i in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP[i][j] = DP[i - 1][j]
mv = 0
for l in range(N): #ラストオーダー
    mv = max(DP[l][M - 1] + D[l][1], mv)

print(mv)
import sys

for lineCount, line in enumerate(sys.stdin):
    if lineCount == 0:
        continue
    a, b, c = sorted(map(int, line.split(' ')))
    if a**2 + b**2 = c**2:
        print 'YES'
    else:
        print 'NO'

### FIXED CODE ###

import sys

for lineCount, line in enumerate(sys.stdin):
    if lineCount == 0:
        continue
    a, b, c = sorted(map(int, line.split(' ')))
    if a**2 + b**2 == c**2:
        print 'YES'
    else:
        print 'NO'
a = input()
b = 0
if a[0] == 1:
    b++
if a[1] == 1:
    b++
if a[2] == 1:
    b++
print(b)

### FIXED CODE ###

a = int(input())
b = 0
for i in range(3):
    if a % 2 == 0:
        a = a / 10
    else:
        b = b + 1
        a = (a-1)/10
print(b)
# coding: utf-8

import sys
input = sys.stdin.readline

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def gccd(num):
    if len(num) == 1:
        return num[0]
    else:
        return gcd(gccd(num[0:1]), gccd(num[1:]))

N = int(input())
A = list(map(int, input().split()))

print(gccd(A))



### FIXED CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

N = int(input())
A = list(map(int, input().split()))

first_gcd = A[0]
for i in range(len(A)):
    first_gcd = gcd(first_gcd, A[i])

print(first_gcd)
N = input()
s1 = N[1:len(N)]
s2 = N[0:len(N) - 1]
isOk = True
for i in range(1, len(N-1)):
    if s1[i] != s1[i - 1]:
        break
        isOk = False
    else:
        continue

if isOk:
    print('Yes')

isOk = True
for i in range(1, len(N-1)):
    if s2[i] != s2[i - 1]:
        break
    else:
        continue

if isOk:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N = input()
s1 = N[1:len(N)]
s2 = N[0:len(N) - 1]
isOk = True
for i in range(1, len(N)-1):
    if s1[i] != s1[i - 1]:
        isOk = False
        break
    else:
        continue

if isOk:
    print('Yes')
    exit(0)

isOk = True
for i in range(1, len(N)-1):
    if s2[i] != s2[i - 1]:
        isOk = False
        break
    else:
        continue

if isOk:
    print('Yes')
else:
    print('No')
X,A = map(int, input().split())
if X < A 
print(0)
else
print(10)

### FIXED CODE ###

X, A = map(int, input().split())
if X < A:
  print(0)
else:
  print(10)
if b - a <= 0:
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")

### FIXED CODE ###

x, a, b = map(int, input().split())

if b - a <= 0:
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")
from itertools import product
from collections import deque


def read():
    s = input()
    t = input()
    return s, t


def lcs(s, t):
    S = len(s)
    T = len(t)
    dp = [[0 for j in range(T+1)] for i in range(S+1)]
    maxpos = (0, 0)
    for i, j in product(range(S), range(T)):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
            if dp[maxpos[0]+1][maxpos[1]+1] < dp[i+1][j+1]:
                maxpos = (i, j)
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            dp[i][j+1] = max(dp[i][j+1], dp[i][j])
    return maxpos, dp


def dfs(s, t, i, j, dp):
    if i < 0 or j < 0:
        return list()
    if s[i] == t[j]:
        x = dfs(s, t, i-1, j-1, dp)
        return x + [i]
    else:
        x = dfs(s, t, i-1, j, dp)
        y = dfs(s, t, i, j-1, dp)
        return x if len(x) > len(y) else y


def solve(s, t):
    maxpos, dp = lcs(s, t)
    x = dfs(s, t, *maxpos, dp)
    ans = ''.join([s[i] for i in x])
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


### FIXED CODE ###

from itertools import product
from collections import deque
import sys
sys.setrecursionlimit(100000)


def read():
    s = input()
    t = input()
    return s, t


def lcs(s, t):
    S = len(s)
    T = len(t)
    dp = [[0 for j in range(T+1)] for i in range(S+1)]
    for i, j in product(range(S), range(T)):
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)
        else:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            dp[i][j+1] = max(dp[i][j+1], dp[i][j])
    maxpos = (0, 0)
    maxv = dp[0][0]
    for i, j in product(range(S), range(T)):
        if maxv < dp[i+1][j+1]:
            maxpos = (i, j)
            maxv = dp[i+1][j+1]
    return maxpos, dp


def retrieve(s, t, i, j, dp):
    x = list()
    while i >= 0 and j >= 0:
        if dp[i+1][j+1] == dp[i+1][j]:
            j -= 1
        elif dp[i+1][j+1] == dp[i][j+1]:
            i -= 1
        else:
            x.append(s[i])
            i -= 1
            j -= 1
    return ''.join(reversed(x))


def solve(s, t):
    maxpos, dp = lcs(s, t)
    i, j = maxpos
    ans = retrieve(s, t, i, j, dp)
    return ans


if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))
n=int(input())
b = list(map(int, input().split()))
mostHeight =b[0]
count = 0
for i in b:
    if(i >= mostHeight):
        mostHeight = i
        count += 1
print(count)


### FIXED CODE ###

a,b = map(int, input().split())
if a != b:
    x= max([a,b])*2 -1
else:
    x =a*2
print(x)
num = int(input())
A = list(map(int, input().split()))
H = sum(A) / 2
S = 0
for i in range(num):
  S = A[i]
  if abs(H - (S + A[i+1])) >= abs(H - S):
    print(abs(2 * S - 2 * H))

    


### FIXED CODE ###

num = int(input())
A = list(map(int, input().split()))
F = sum(A)
H = F / 2
S = 0
for i in range(num):
  S += A[i]
  if abs(H - (S + A[i+1])) > abs(H - S):
    print(abs(2 * S - F))
    break