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 C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <string.h>
void minimize(int * N, int digit, int min){
    int i;
    for(i = 0; i <= digit; i++){
        N[i] = min;
    }
}

void calc(int * N, int K, int * D, int digit, int digit_max, int * moveup, int min, int max){
    if(digit > 0 && N[digit] <= max) calc(N, K, D, digit-1, digit_max, moveup, min, max);
    N[digit] += *moveup;
    if(digit == digit_max && N[digit] == 0) return;
    *moveup = 0;
    if(N[digit] == 10){
        *moveup = 1;
        minimize(N, digit, min);
        return;
    }

    while(1){
        int D_loop = 0;
        for(; D_loop < K; D_loop++){
            if(N[digit] == D[D_loop]) break;
        }
        if(D_loop == K) return;
        
        N[digit]++;
        if(N[digit] == 10){
            *moveup = 1;
            minimize(N, digit, min);
            return;
        }
    }
}


int main(void){
    // Your code here!
    int N_orig;
    int N_q = -1;
    int N[5] = {0, 0, 0, 0, 0};
    int K;
    int D[9] = {};
    int i;
    int min = 0;
    int max = 9;
    int N_ans = 0;
    
    scanf("%d %d", &N_orig, &K);
    for(i = 0; i < K; i++) scanf("%d", &D[i]);
    
    for(i = 0; i < K; i++){
        if(D[i] == min) min++;
        if(D[K-(i+1)] == max) max--;
    }
    
    N_q = N_orig;
    for(i = 0; N_q != 0; i++){
        N[i] = N_q % 10;
        N_q /= 10;
    }
    
    int moveup = 0;
    calc(N, K, D, i, i, &moveup, min, max);
    
    for(i = 4; i >= 0; i--){
        N_ans *= 10;
        N_ans += N[i];
    }
    printf("%d", N_ans);
}