f | import sys | f | import sys |
| import tarfile | | import tarfile |
| import io | | import io |
| | | |
n | def decode_hex_string(hex_string): | n | def hex_to_bytes(hex_str): |
| sanitized_hex = hex_string.replace('\n', '').replace(' ', '') | | hex_str = hex_str.replace('\n', '').replace(' ', '') |
| return bytes.fromhex(sanitized_hex) | | return bytes.fromhex(hex_str) |
| | | |
n | def analyze_tar(dump_content): | n | def extract_tar_info(dump_data): |
| byte_stream = io.BytesIO(dump_content) | | tar_data = io.BytesIO(dump_data) |
| try: | | try: |
n | with tarfile.open(fileobj=byte_stream, mode='r') as archive: | n | with tarfile.open(fileobj=tar_data, mode='r') as tar: |
| num_files = 0 | | file_count = 0 |
| accumulated_size = 0 | | total_size = 0 |
| for item in archive.getmembers(): | | for member in tar.getmembers(): |
| if item.isreg(): | | if member.isreg(): |
| num_files += 1 | | file_count += 1 |
| accumulated_size += item.size | | total_size += member.size |
| return (num_files, accumulated_size) | | return (file_count, total_size) |
| except Exception as error: | | except Exception as e: |
| print(f'An error occurred: {error}') | | print(f'Error: {e}') |
| return (0, 0) | | return (0, 0) |
| if __name__ == '__main__': | | if __name__ == '__main__': |
t | raw_input = sys.stdin.read() | t | input_data = sys.stdin.read() |
| decoded_data = decode_hex_string(raw_input) | | dump_data = hex_to_bytes(input_data) |
| file_count, total_file_size = analyze_tar(decoded_data) | | file_count, total_size = extract_tar_info(dump_data) |
| print(total_file_size, file_count) | | print(total_size, file_count) |