Problem:
Score : 100 points

Problem Statement

You are given two integers A and B.
Find the largest value among A+B, A-B and A \times B.

Constraints

-1000 \leq A,B \leq 1000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the largest value among A+B, A-B and A \times B.

Sample Input 1

3 1

Sample Output 1

4

3+1=4, 3-1=2 and 3 \times 1=3. The largest among them is 4.

Sample Input 2

4 -2

Sample Output 2

6

The largest is 4 - (-2) = 6.

Sample Input 3

0 0

Sample Output 3

0

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		String s=scan.next();
		
		if(n==1) {
			System.out.println(0);
			return;
		}
		//how many west/east from 0...i
		int[] west=new int[n];
		int[] east=new int[n];
		
		int w=0, e=0;
		for(int i=0;i<n;i++) {
			west[i]=i==0?0:west[i-1];
			east[i]=i==0?0:east[i-1];
			
			if(s.charAt(i)=='W') {
				west[i]++;
				w++;
			}
			else {
				east[i]++;
				e++;
			}
		}
//		System.out.println(Arrays.toString(west));
//		System.out.println(Arrays.toString(east));
		
		int res=west[n-1];
		if(n>1) res=Math.min(res,e-east[1]);
		
		for(int i=1;i<n-1;i++) {
			res=Math.min(res,west[i-1]+e-east[i+1]);
		}
		System.out.println(res);
	}
}