t | import base64, sys | t | import base64 |
| | | import sys |
| a = sys.stdin.buffer.read().strip() | | a = sys.stdin.buffer.read().strip() |
| a = base64.b85decode(a) | | a = base64.b85decode(a) |
| head = [] | | head = [] |
| pos = 0 | | pos = 0 |
| while (el := int.from_bytes(a[pos:pos + 1], byteorder='big', signed=True)): | | while (el := int.from_bytes(a[pos:pos + 1], byteorder='big', signed=True)): |
| head.append(el) | | head.append(el) |
| pos += 1 | | pos += 1 |
| pos += 1 | | pos += 1 |
| res = [] | | res = [] |
| for j in range((len(a) - pos) // sum(map(abs, head))): | | for j in range((len(a) - pos) // sum(map(abs, head))): |
| for i in head: | | for i in head: |
| if i > 0: | | if i > 0: |
| res.append(int.from_bytes(a[pos:pos + abs(i)], byteorder='big', signed=False)) | | res.append(int.from_bytes(a[pos:pos + abs(i)], byteorder='big', signed=False)) |
| else: | | else: |
| res.append(int.from_bytes(a[pos:pos + abs(i)], byteorder='big', signed=True)) | | res.append(int.from_bytes(a[pos:pos + abs(i)], byteorder='big', signed=True)) |
| pos += abs(i) | | pos += abs(i) |
| print(sum(res)) | | print(sum(res)) |