import math def main(): N = int(input()) if N == 0: print("") return # Initialize DP and previous arrays INF = float('inf') dp = [INF] * (N + 1) dp[0] = 0 prev = [0] * (N + 1) for i in range(1, N + 1): max_j = int(math.isqrt(i)) # Check j in descending order to prioritize larger j first for j in range(max_j, 0, -1): j_sq = j * j if i >= j_sq and dp[i - j_sq] + j < dp[i]: dp[i] = dp[i - j_sq] + j prev[i] = j # Reconstruct the partition list partition = [] current = N while current > 0: j = prev[current] partition.append(j) current -= j * j # Reverse the partition to prioritize smaller segments first for lex order partition = partition[::-1] # Build the binary string current_char = '0' result = [] for length in partition: segment = [] char = current_char for _ in range(length): segment.append(char) char = '1' if char == '0' else '0' result.append(''.join(segment)) current_char = segment[-1] print(''.join(result)) if __name__ == "__main__": main()