Problem:
Score: 100 points

Problem Statement

The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...

Given is a string S representing the weather in the town today. Predict the weather tomorrow.

Constraints

S is Sunny, Cloudy, or Rainy.

Input

Input is given from Standard Input in the following format:

S

Output

Print a string representing the expected weather tomorrow, in the same format in which input is given.

Sample Input 1

Sunny

Sample Output 1

Cloudy

In Takahashi's town, a sunny day is followed by a cloudy day.

Sample Input 2

Rainy

Sample Output 2

Sunny

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

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scan = new Scanner(System.in)) {
			
			int N = scan.nextInt();
			String str = scan.next();
			
			boolean two = false;
			
			int max=N/2;
			
			for(int i = max; i > 2; i--) {
				for(int j=0; j< N-i;j++) {
					String a = str.substring(j, j+i);
					if(str.matches(".*"+ a +".*" + a +".*")) {
						System.out.println(i);
						return;
					}
				}
			}
			
			String[] s = str.split("");
			Set<String> set = new HashSet<>();
			
			for(int i=0; i<N-1;i++) {
				String a = s[i]+s[i+1];
				if(set.contains(a)) {
					two=true;
					break;
				} else {
					set.add(a);
				}
			}
			
			if(two) {
				System.out.println(2);
				return;
			}
			System.out.println(0);
		}
	}
}