-module(prog).
-export([main/0]).
main() ->
loop().
large_queue(0) -> queue:
new(); large_queue(N) -> queue:
in(N, large_queue(N-1)).
pop(Q) -> {A, B} = queue:
out(Q), B.
pop_r(Q) -> {A, B} = queue:
out_r(Q), B.
funny_pop({[],[]}) -> true;
funny_pop(Q) -> funny_pop(pop_r(pop(Q))).
loop() ->
case io:
fread( "","~d" ) of eof ->
true;
{ok, X} ->
[Y] = X,
Q = large_queue(Y),
funny_pop(Q),
true
end.
LW1vZHVsZShwcm9nKS4KLWV4cG9ydChbbWFpbi8wXSkuCiAKbWFpbigpIC0+CiAgICAgICAgbG9vcCgpLgoKbGFyZ2VfcXVldWUoMCkgLT4gcXVldWU6bmV3KCk7CmxhcmdlX3F1ZXVlKE4pIC0+IHF1ZXVlOmluKE4sIGxhcmdlX3F1ZXVlKE4tMSkpLgoKcG9wKFEpIC0+IHtBLCBCfSA9IHF1ZXVlOm91dChRKSwgQi4KCnBvcF9yKFEpIC0+IHtBLCBCfSA9IHF1ZXVlOm91dF9yKFEpLCBCLgoKCmZ1bm55X3BvcCh7W10sW119KSAtPiB0cnVlOwpmdW5ueV9wb3AoUSkgLT4gZnVubnlfcG9wKHBvcF9yKHBvcChRKSkpLgoKbG9vcCgpIC0+CiAgICAgICAgY2FzZSBpbzpmcmVhZCggIiIsIn5kIiApIG9mCiAgICAgICAgICAgICAgICBlb2YgLT4KICAgICAgICAgICAgICAgICAgICAgICAgdHJ1ZTsKICAgICAgICAgICAgICAgIHtvaywgWH0gLT4KICAgICAgICAgICAgICAgICAgICAgICAgW1ldID0gWCwKICAgICAgICAgICAgICAgICAgICAgICAgUSA9IGxhcmdlX3F1ZXVlKFkpLAogICAgICAgICAgICAgICAgICAgICAgICBmdW5ueV9wb3AoUSksCiAgICAgICAgICAgICAgICAgICAgICAgIHRydWUKICAgICAgICBlbmQu