let [| a; b; c; d; e; f; g |] = stdin.ReadLine().Split() |> Array.map int // (n円玉) の枚数 // f:(1), e:(5), // d:(10), c:(50), // b:(100), a:(500), let coin = [ [| f; e |] [| d; c |] [| b; a |] ] let rec isGoal x sub = function | [] -> true | head :: tail -> let [| one; five |] = head let one_s = one + sub let m = x % 10 if one_s >= m then let v = (one_s + five * 5 - m) / 10 isGoal (x / 10) v tail elif five >= 1 && one_s > m - 5 then let v = (one_s + five * 5 - m - 5) / 10 isGoal (x / 10) v tail else false if isGoal g 0 coin then "YES" else "No" |> printfn "%s"