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.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ==================================================================
    public void solve() {
    	int N = Integer.parseInt(sc.next());
    	int K = Integer.parseInt(sc.next());
    	int[] NG = new int[10];
    	int d;
    	for (int i = 0; i < K; i++) {
        	d = Integer.parseInt(sc.next());
			NG[d] = 1;
		}
    	int ans = 999999, wk;
    	for (int i1 = 0; i1 < 10; i1++) {
    		if(NG[i1] == 1)	continue;
    		wk = i1;
    		if(wk >= N && wk < ans)	{ ans = wk; break; }
    		for (int i2 = 0; i2 < 10; i2++) {
        		if(NG[i2] == 1)	continue;
        		wk += i2*10;
        		if(wk >= N && wk < ans)	{ ans = wk; break; };
            	for (int i3 = 0; i3 < 10; i3++) {
            		if(NG[i3] == 1)	continue;
            		wk += i3*100;
            		if(wk >= N && wk < ans)	{ ans = wk; break; }
                	for (int i4 = 0; i4 < 10; i4++) {
                		if(NG[i4] == 1)	continue;
                		wk += i4*1000;
                		if(wk >= N && wk < ans)	{ ans = wk; break; }
                    	for (int i5 = 0; i5 < 10; i5++) {
                    		if(NG[i5] == 1)	continue;
                    		wk += i5*10000;
                    		if(wk >= N && wk < ans)	{ ans = wk; break; }
                    	}
                	}
            	}
    		}
    	}
    	out.println(ans);
    }
}