| f | import sys | f | import sys |
| n | raw_data = sys.stdin.buffer.read() | n | data = sys.stdin.buffer.read() |
| parts = raw_data.split(b'\x00') | | chunks = data.split(b'\x00') |
| main_text = parts[0].decode('utf-8') | | utf8_text = chunks[0].decode('utf-8') |
| segments = parts[1:-1] | | fragments = chunks[1:-1] |
| codepages = ['cp866', 'cp1251', 'koi8_r', 'iso-8859-5'] | | encodings = ['cp866', 'cp1251', 'koi8_r', 'iso-8859-5'] |
| for item in segments: | | for frag in fragments: |
| matched = False | | found = False |
| for cp in codepages: | | for enc in encodings: |
| try: | | try: |
| n | txt = item.decode(cp) | n | decoded = frag.decode(enc) |
| except UnicodeDecodeError: | | except UnicodeDecodeError: |
| continue | | continue |
| n | if txt in main_text: | n | if decoded in utf8_text: |
| matched = True | | found = True |
| break | | break |
| t | print('Yes' if matched else 'No') | t | print('Yes' if found else 'No') |