use std::collections::VecDeque; const INF: usize = 1usize << 60; fn priority(a: usize) -> usize { if a % 2 == 1 { a } else { INF - a } } fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut dp = vec![INF; n+1]; dp[0] = 0; for i in 1..=n { for j in 1.. { let val = j * j; if val > i { break; } dp[i] = dp[i].min(dp[i-val]+j); } } let mut used = vec![]; let mut target = n; while target > 0 { let mut cands = vec![]; for i in 1.. { let val = i * i; if val > target { break; } if dp[target] == dp[target-val]+i { cands.push(i); } } cands.sort_by_key(|&i| priority(i)); let val = cands[0]; used.push(val); target -= val*val; } used.sort(); let odds = used.iter().filter(|&&v| v%2 == 1).copied().collect::>(); let mut evens = used.iter().filter(|&&v| v%2 == 0).copied().collect::>(); let mut result = String::new(); for &v in odds.iter() { result.push_str(&format!("0{}", "10".repeat(v/2))); } while !evens.is_empty() { let val = evens.pop_front().unwrap(); result.push_str(&format!("{}", "01".repeat(val/2))); if let Some(&val) = evens.back() { result.push_str(&format!("{}", "10".repeat(val/2))); evens.pop_back(); } } println!("{}", result); }