Choose Two Subsequences

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Clara has two strings ss and tt. She would like to choose two subsequences xx from ss and yy from tt such that:

  • xx is lexicographically smaller than or equal to yy.
  • The sum of x|x| and y|y| is maximal, where s|s| denotes the length of the string ss.

Note that:

  • Both xx and yy could be empty string.
  • A subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.
  • String xx is lexicographically less than string yy, if either xx is a prefix of yy (and xyx \ne y), or there exists such ii (1imin(x,y)1 \le i \le \min(|x|, |y|)), that x_i<y_ix\_i < y\_i, and for any jj (1j<i1 \le j < i) x_j=y_jx\_j = y\_j.

입력

The input consists of several test cases terminated by end-of-file. For each test case:

The first line contains a string ss. The second line contains a string tt.

출력

For each test case, output the sum of x|x| and y|y|.

제한

  • 1s20001 \le |s| \le 2000
  • 1t20001 \le |t| \le 2000
  • The sum of s|s| does not exceed 2000020000.
  • The sum of t|t| does not exceed 2000020000.
  • Both the strings consist only of English lowercase letters.