A Hackerrank number is a magic number that can be used to get sudo permissions on the site. We are going to generate a hackerrank number from two integers A & B. Each number has two parts to it - the left (L) & the right side (R).

For eg: for the number 100101,

  • L could be 100 & R could be 101 (or)
  • L could be 1 and R could be 00101 and so on..

How to generate a hackerrank number?

Let x & y be integers such that,

(1 <= x <= A & 1 <= y <= B) 

Generate the left part of any hackerrank number (L) by multiplying x and y (i.e) x*y
and the right part of any hackerrank number (R) by bitwise xor-ing x and y (i.e) x^y

Add leading zeros to R to make length(R) = length(B) + 1. Concatenate both L & R to form the hackerrank number.

Can you find the sum of all possible hackerrank numbers generated by this rule?

Input format

Each input contains 2 integers A and B separated by a space.

Constraints

1 <= A <= 30
1 <= B <= 108

Output format

Print the sum of all possible numbers that satisfy the above mentioned property.

Sample Input

2 4

Sample Output

14502

The left value can be one of {1 * 1, 1 * 2, 1 * 3, 1 * 4, 2 * 1, 2 * 2, 2 * 3, 2 * 4}
which is {1,2,3,4,2,4,6,8}
and the distinct values are {1, 2, 3, 4, 6, 8}

The right value can be one of {1^1,1^2,1^3,1^4,2^1,2^2,2^3,2^4}
which is {0, 3, 2, 5, 3, 0, 1, 6} and the distinct values are {0, 1, 2, 3, 5, 6}

All the possible value are

{
    100, 101, 102, 103, 105, 106,
    200, 201, 202, 203, 205, 206,
    300, 301, 302, 303, 305, 306,
    400, 401, 402, 403, 405, 406,
    600, 601, 602, 603, 605, 606,
    800, 801, 802, 803, 805, 806 
}

S = all the sum of the above = 14502.

Note: Any number can only be added once.

Line: 1 Col: 1
  1. Challenge Walkthrough
    Let's walk through this sample challenge and explore the features of the code editor.1 of 6
  2. Review the problem statement
    Each challenge has a problem statement that includes sample inputs and outputs. Some challenges include additional information to help you out.2 of 6
  3. Choose a language
    Select the language you wish to use to solve this challenge.3 of 6
  4. Enter your code
    Code your solution in our custom editor or code in your own environment and upload your solution as a file.4 of 6
  5. Test your code
    You can compile your code and test it for errors and accuracy before submitting.5 of 6
  6. Submit to see results
    When you're ready, submit your solution! Remember, you can go back and refine your code anytime.6 of 6
  1. Check your score