| t | | t | from math import * |
| N = int(input()) | | N = int(input()) |
| x = 1 | | x = 1 |
| while x * x * 4 < N: | | while x * x * 4 < N: |
| x += 1 | | x += 1 |
| miny = x | | miny = x |
| while x * x <= N: | | while x * x <= N: |
| while miny and (miny - 1) * (miny - 1) * 3 >= N - x * x: | | while miny and (miny - 1) * (miny - 1) * 3 >= N - x * x: |
| miny -= 1 | | miny -= 1 |
| y = minz = miny | | y = minz = miny |
| while y <= x and x * x + y * y <= N: | | while y <= x and x * x + y * y <= N: |
| while minz and (minz - 1) * (minz - 1) * 2 >= N - x * x - y * y: | | while minz and (minz - 1) * (minz - 1) * 2 >= N - x * x - y * y: |
| minz -= 1 | | minz -= 1 |
| z = t = minz | | z = t = minz |
| while z <= y and x * x + y * y + z * z <= N: | | while z <= y and x * x + y * y + z * z <= N: |
| while t * t > N - x * x - y * y - z * z: | | while t * t > N - x * x - y * y - z * z: |
| t -= 1 | | t -= 1 |
| if x * x + y * y + z * z + t * t == N: | | if x * x + y * y + z * z + t * t == N: |
| print(x, y, z, t) | | print(x, y, z, t) |
| z += 1 | | z += 1 |
| y += 1 | | y += 1 |
| x += 1 | | x += 1 |