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 PHP7 (7.0.15) (judge verdict: Wrong Answer)

<?php
$a = str();
$b = str();

echo lcstr($a, $b);

function lcs($str1, $str2){
    global $dp;
    for($i = 0; $i < strlen($str1); $i++){
        for($j = 0; $j < strlen($str2); $j++){
            if($str1[$i] == $str2[$j]){
                $dp[$i][$j] = ($dp[$i-1][$j-1]??0) + 1;
            }else{
                $dp[$i][$j] = max($dp[$i-1][$j]??0, $dp[$i][$j-1]??0);
            }
        }
    }
    return $dp[strlen($str1) - 1][strlen($str2) - 1];
}

function lcstr($str1, $str2){
    $l1 = strlen($str1);
    $l2 = strlen($str2);
    for($i = 0; $i < $l1; $i++){
        for($j = 0; $j < $l2; $j++){
            if($str1[$i] == $str2[$j]){
                $dp[$i][$j] = ($dp[$i-1][$j-1]??'') . $str1[$i];
            }else{
                if(strlen($dp[$i-1][$j]??'') > strlen($dp[$i][$j-1]??'')){
                    $dp[$i][$j] = $dp[$i-1][$j]??'3';
                }else{
                    $dp[$i][$j] = $dp[$i][$j-1]??'3';
                }
            }
        }
    }
    return $dp[$l1 - 1][$l2 - 1];
}

function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array:";
            echo implode(" ", $val)."\n";
        }else{
            echo "array:array\n";
            foreach($val as $row){
                echo implode(" ", $row)."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}