Algorithm


B. Letter
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya decided to write an anonymous letter cutting the letters out of a newspaper heading. He knows heading s1 and text s2 that he wants to send. Vasya can use every single heading letter no more than once. Vasya doesn't have to cut the spaces out of the heading — he just leaves some blank space to mark them. Help him; find out if he will manage to compose the needed text.

Input

The first line contains a newspaper heading s1. The second line contains the letter text s2s1 и s2 are non-empty lines consisting of spaces, uppercase and lowercase Latin letters, whose lengths do not exceed 200 symbols. The uppercase and lowercase letters should be differentiated. Vasya does not cut spaces out of the heading.

Output

If Vasya can write the given anonymous letter, print YES, otherwise print NO

Examples
input
Copy
Instead of dogging Your footsteps it disappears but you dont notice anything
where is your dog
output
Copy
NO
input
Copy
Instead of dogging Your footsteps it disappears but you dont notice anything
Your dog is upstears
output
Copy
YES
input
Copy
Instead of dogging your footsteps it disappears but you dont notice anything
Your dog is upstears
output
Copy
NO
input
Copy
abcdefg hijk
k j i h g f e d c b a
output
Copy
YES



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>
#include <iostream>
#include <vector>

int main(){

    const int N = 26;
    std::vector<int> small(N,0);
    std::vector<int> large(N,0);

    std::string input; getline(std::cin, input);
    for(int k = 0; k < input.size(); k++){
        if('a' <= input[k] && input[k] <= 'z'){++small[input[k] - 'a'];}
        if('A' <= input[k] && input[k] <= 'Z'){++large[input[k] - 'A'];}
    }

    std::string message; getline(std::cin, message);
    for(int k = 0; k < message.size(); k++){
        if('a' <= message[k] && message[k] <= 'z'){--small[message[k] - 'a'];}
        if('A' <= message[k] && message[k] <= 'Z'){--large[message[k] - 'A'];}
    }

    std::string output = "YES";
    for(int k = 0; k < N; k++){if(small[k] < 0 || large[k] < 0){output = "NO"; break;}}

    std::cout << output <<std::endl;

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
Instead of dogging Your footsteps it disappears but you dont notice anything
where is your dog

Output

x
+
cmd
NO
Advertisements

Demonstration


Codeforces Solution-B. Letter-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+