Scanf.scanf "%d" (fun n ->
    let (%) a b = ((a mod b) + b) mod b
    in
    let rec loop repl b cur acc =
        if acc = n then repl else
            if acc % b = n % b then loop ("0" ^ repl) (2 * b) (-2 * cur) acc
                               else loop ("1" ^ repl) (2 * b) (-2 * cur) (acc + cur)
    in
    print_endline @@
        if n = 0 then "0" else loop "" 2 1 0
)