Problem:
Addition of Big Integers

Given two integers $A$ and $B$, compute the sum, $A + B$.

Input

Two integers $A$ and $B$ separated by a space character are given in a line.

Output

Print the sum in a line.

Constraints

$-1 \times 10^{100000} \leq A, B \leq 10^{100000}$

Sample Input 1

5 8

Sample Output 1

13

Sample Input 2

100 25

Sample Output 2

125

Sample Input 3

-1 1

Sample Output 3

0

Sample Input 4

12 -3

Sample Output 4

9

Solution in JAVA (judge verdict: Wrong Answer)



import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		String a;
		String b;
		Scanner sc = new Scanner(System.in);
		
		a = sc.next();
		b = sc.next();
		
		StringBuilder sb = new StringBuilder("");
		
		int maxl = Math.max(a.length(), b.length());
		
		int remainder = 0;
		for(int i = 0; i < maxl; i++)
		{
			int p = 0;
			int q = 0;
			
			if(a.length() >= i+1)
			{
				p = a.charAt(a.length()-1-i)-'0';
			}
			
			if(b.length() >= i+1)
			{
				q = b.charAt(b.length()-1-i)-'0';
			}
			
			int cur = (p+q+remainder)%10 ;
			remainder = (p+q+remainder)/10;
			
			sb.append(cur);
			
//			System.out.println(p + " " + q);
		}
		
		if(remainder > 0)sb.append(remainder);
		
		sb.reverse();
		System.out.println(sb);
		
	}

}