Problem:
Score : 100 points

Problem Statement

You are given strings s and t.
Find one longest string that is a subsequence of both s and t.

Notes

A subsequence of a string x is the string obtained by removing zero or more characters from x and concatenating the remaining characters without changing the order.

Constraints

s and t are strings consisting of lowercase English letters.

1 \leq |s|, |t| \leq 3000

Input

Input is given from Standard Input in the following format:

s
t

Output

Print one longest string that is a subsequence of both s and t.
If there are multiple such strings, any of them will be accepted.

Sample Input 1

axyb
abyxb

Sample Output 1

axb

The answer is axb or ayb; either will be accepted.

Sample Input 2

aa
xayaz

Sample Output 2

aa

Sample Input 3

a
z

Sample Output 3

The answer is (an empty string).

Sample Input 4

abracadabra
avadakedavra

Sample Output 4

aaadara

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false INT_MAX INT_MIN insert erase clear pop push compare INT64_MAX INT64_MIN  reverse replace stringstream string::npos length() substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const int mod = 1e9 + 7 ;
string ans ="";
struct hash_pair {template <class T1, class T2>size_t operator()(const pair<T1, T2>& p)const{auto hash1=hash<T1>{}(p.first);auto hash2=hash<T2>{}(p.second);return hash1^hash2;}};
void add_self(int& a , int b){a =  (a + b)%mod;}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
unordered_set<pair<int,int>,hash_pair> memo ; 
void lcs(string& s ,string& t , int i , int j , string k){
	// cout<<i<<" "<<j<<" "<<k<<endl;
if(memo.find({i,j})!=memo.end()) return;
memo.insert({i,j});
	if(i==s.length()||j==t.length()){
		if(k.length()>=ans.length())
			ans = k;
return;
	}


	if(s[i]==t[j]){
		k = k + s[i];
		lcs(s,t,i+1,j+1,k);
		return;
	}

	lcs(s,t,i+1,j,k);
	lcs(s,t,i,j+1,k);




}


signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

string s , t ; 
cin>>s>>t;
lcs(s,t,0,0,"");

cout<<ans;

	

	
}