1.

You are given two strings \(A\) and \(B\) that are made of lowercase English alphabets. Find the number of different pairs \(((i,\ j),\ (k,\ l))\)such that the substrings\(A[i...j]\) and \(B[k...l]\) are equal and the value of \(j-i+1\)is minimum.

Input format

  • The first line consists of a string denoting \(A\).
  • The second line consists of a string denoting \(B\).

Output

Print the number of different pairs \(((i,\ j),\ (k,\ l))\) such that the substrings\(A[i...j]\) and \(B[k...l]\) are equal and the value of \(j-i+1\) is minimum.

Constraints
\(1 \le |A|, |B| \le 10^5\)

2.

Given two integers m & n, find the number of possible sequences of length n such that each of the next element is greater than or equal to twice of the previous element but less than or equal to m.


Example 1:

Input: m = 10, n = 4
Output: 4
Explaination: There should be n elements and
value of last element should be at-most m.
The sequences are {1, 2, 4, 8}, {1, 2, 4, 9},
{1, 2, 4, 10}, {1, 2, 5, 10}.


Example 2:

Input: m = 5, n = 2
Output: 6
Explaination: The sequences are {1, 2},
{1, 3}, {1, 4}, {1, 5}, {2, 4}, {2, 5}.


Your Task:
You do not need to read input or print anything. Your task is to complete the function numberSequence() which takes the number m and n as input parameters and returns the number of sequences.


Expected Time Complexity: O(m*n)
Expected Auxiliary Space: O(1)


Constraints:
1 ≤ m, n ≤ 100

3.

Given an integer N representing the number of pairs of parentheses, the task is to generate all combinations of well-formed(balanced) parentheses.


Example 1:

Input:
N = 3
Output:
((()))
(()())
(())()
()(())
()()()
Example 2:
Input:
N = 1
Output:
()

Your Task:  
You don't need to read input or print anything. Complete the function AllParenthesis() which takes N as input parameter and returns the list of balanced parenthesis.
Expected Time Complexity: O(2N).
Expected Auxiliary Space: O(2*N*X), X = Number of valid Parenthesis.
Constraints:
1 ≤ N ≤ 12