output_description: 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.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      s
      t
attempt: import sys
  def main():
    S=list(sys.stdin.readline())[:-1]
    T=list(sys.stdin.readline())[:-1]
    lS=len(S)
    lT=len(T)
    dp=[[0]*lS for _ in range(lT)]
    for iT in range(lT):
      for iS in range(lS):
        if S[iS]==T[iT]:
          if iS-1>=0 and iT-1>=0:
            dp[iT][iS] = dp[iT-1][iS-1]+1
          else:
            dp[iT][iS] = 1
        else:
          if iS-1>=0 and (iT-1<0 or dp[iT][iS-1]>=dp[iT-1][iS]):
            dp[iT][iS] = dp[iT][iS-1]
          elif iT-1>=0 and (iS-1<0 or dp[iT-1][iS]>=dp[iT][iS-1]):
            dp[iT][iS] = dp[iT-1][iS]
  
    iS = lS-1
    iT = lT-1
    ans = ""
    while(iS>0 and iT>0):
      if dp[iT][iS]==dp[iT-1][iS-1]:
        iS -= 1
        iT -= 1
      elif dp[iT][iS]==dp[iT][iS-1]:
        iS -= 1
      else:
        ans = S[iS]+ans
        iS -= 1
        iT -= 1
    if dp[iT][iS]=1:
      if iS == 0:
        ans = S[0]+ans
      else:
        ans = T[0]+ans
    print(ans)
  
  if __name__ == '__main__':
    main()
  
problem_description: Statement
  
  You are given strings s and t. Find one longest string that is a subsequence
  of both s and t.
samples: [{"input": "axyb\n    abyxb", "output": "axb\n    \n\nThe answer is `axb` or `ayb`; either will be accepted.\n\n* * *"}, {"input": "aa\n    xayaz", "output": "aa\n    \n\n* * *"}, {"input": "a\n    z", "output": "The answer is `` (an empty string).\n\n* * *"}, {"input": "abracadabra\n    avadakedavra", "output": "aaadara"}]