I am getting runtime errors for my Java solutions to UVa Online Judge problems. I have finished Problem 100 and it works on my end. Any ideas what could be causing the problem?
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Scanner;
class P100 {
public static void main(String args[]) {
Hashtable<Integer, Integer> solutions = new Hashtable<Integer, Integer>();
Scanner input = new Scanner(System.in);
while (input.hasNextInt()) {
int lowerBound = input.nextInt();
int upperBound = input.nextInt();
int longestCount = 0;
for (int i = lowerBound; i <= upperBound; i++) {
int n = i;
int count = 1;
ArrayList<Integer> sequence = new ArrayList<Integer>();
while (n != 1) {
if (solutions.containsKey(n)) {
count += solutions.get(n) - 1;
break;
}
sequence.add(n);
count += 1;
if (n % 2 == 0) n /= 2;
else n = 3 * n + 1;
}
for (int j = 0; j < sequence.size(); j++) {
solutions.put(sequence.get(j), count - j);
}
if (count > longestCount) longestCount = count;
solutions.put(i, count);
}
System.out.printf("%d %d %d\n", lowerBound, upperBound, longestCount);
}
}
}