#C11417. Binary String Addition

    ID: 40731 Type: Default 1000ms 256MiB

Binary String Addition

Binary String Addition

Given two binary strings, compute their sum as a binary string using manual addition without using built-in library functions for conversion.

To solve the problem, pad the shorter string with zeros on the left, then add the binary numbers bit by bit from right to left while maintaining the carry. The addition at each bit position can be described by the formula: $$\text{bit_sum} = a_i + b_i + \text{carry},$$ where the new digit is (bit_sum \bmod 2) and the carry is (\lfloor bit_sum/2 \rfloor). Your solution should read input from standard input (stdin) and output the result to standard output (stdout).

inputFormat

The input consists of two lines. The first line contains the binary string a. The second line contains the binary string b. Both strings contain only the characters '0' and '1'.

outputFormat

Output a single line containing the binary sum of a and b as a binary string.## sample

1101
101
10010