✅ 정답 공개
from collections import Counter
p=input().strip()
s=input().strip()
m=len(p)
if m>len(s):
print('NO')
else:
need=Counter(p)
window=Counter(s[:m])
found=window==need
for i in range(m, len(s)):
window[s[i]]+=1
window[s[i-m]]-=1
if window[s[i-m]]==0: del window[s[i-m]]
if window==need: found=True; break
print('YES' if found else 'NO')