Mistři v programování na #hovnokod

Python #499

#!/usr/bin/python
import itertools, math, os, random, re, sys
random.seed (1234)

while True:
        s = sys.stdin.readline ().strip ()
        if s == '':
                s = sys.stdin.readline ().strip ()
                if s == '':
                        break
        t = sys.stdin.readline ()
        r = sys.stdin.readline ()
        s = [c for c in s]
        t = [c for c in t]
        r = [c for c in r]
        s.sort ()
        t.sort ()
        r.sort ()
        ok = True
        for c in r:
                if len (s) > 0 and c == s[0]:
                        s = s[1:]
                elif len (t) > 0 and c == t[0]:
                        t = t[1:]
                else:
                        ok = False
        ok = ok and len (s) == 0 and len (t) == 0
        if ok:
                print 'YES'
        else:
                print 'NO'

#Optimized:
#a, b, c = (raw_input() for i in range(3))
#print 'YES' if sorted(a + b) == sorted(c) else 'NO'

HovnoKod,