Problem:
Score : 100 points

Problem Statement

Iroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.

To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Constraints

1≦A,B,C≦10

Input

The input is given from Standard Input in the following format:

A B C

Output

If it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.

Sample Input 1

5 5 7

Sample Output 1

YES

Using three phrases of length 5, 5 and 7, it is possible to construct a Haiku.

Sample Input 2

7 7 5

Sample Output 2

NO

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

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		int i=0;
		Scanner sc = new Scanner(System.in);
		double price = sc.nextInt();
		int length = sc.nextInt();
		int price1000 = (int) price / 1000;
		int price100 = (int) ((price % 1000) / 100);
		int price10 = (int) ((price % 100) / 10);
		int price1 = (int) ((price % 10) / 1);

		double resultZantei=(price1000*1000)+(price100*100)+(price10*10)+(price1);
		List<Integer> nList = new ArrayList<Integer>(Arrays.asList(0,price1000,price100,price10,price1));
		List<Integer> abc = new ArrayList<Integer>();
		for(i=0;i<length;i++) {
			abc.add(sc.nextInt());
		}
		boolean hantei = chceck(nList,abc);
		while(hantei) {
			resultZantei++;
			int resultZantei10000 = (int) resultZantei / 10000;
			int resultZantei1000 = (int) ((resultZantei % 10000) / 1000);
			int resultZantei100 = (int) ((resultZantei % 1000) / 100);
			int resultZantei10 = (int) ((resultZantei % 100) / 10);
			int resultZantei1 = (int) ((resultZantei % 10) / 1);
			nList = Arrays.asList(resultZantei10000,resultZantei1000,resultZantei100,resultZantei10,resultZantei1);
			hantei = chceck(nList,abc);
		}
		int result = (int) resultZantei;
		System.out.println(result);
	}
	public static boolean chceck(List<Integer> nList,List<Integer> abc){
		int k = 0;
		if(nList.get(0)==0) {
			for(k=0;k<nList.size()-1;k++) {
				if(abc.contains(nList.get(k+1))){
					return true;
				}
			}
		}else {
			for(k=0;k<nList.size();k++) {
				if(abc.contains(nList.get(k))){
					return true;
				}
			}
		}
		return false;
	}
}