Template:Interactive calculator

 var bh_calculator = "Ly8gU3RhcnQgQmFzZTY0IGVuY29kaW5nIGhlcmUuCmlmICghKCJiaF8iIGluIHdpbmRvdykpCiAgd2luZG93LmJoXyA9IHt9OwoKYmhfLmNhbGN1bGF0b3JfdHdyID0gewogIGZpZWxkczogWwogICAge2lkOiAibDF0dyIsICAgbGFiZWw6ICJMMVRXOiIsICBpbml0OiAzLjksICB2YWxpZDogL15bXGRcLl0rJT8kLywgZm9ybWF0OiAie30lIn0sCiAgICB7aWQ6ICJsMnR3IiwgICBsYWJlbDogIkwyVFc6IiwgIGluaXQ6IDMwLCAgIHZhbGlkOiAvXltcZFwuXSslPyQvLCBmb3JtYXQ6ICJ7fSUifSwKICAgIHtpZDogInlpZWxkIiwgIGxhYmVsOiAiWWllbGQ6IiwgaW5pdDogMiwgICAgdmFsaWQ6IC9eW1xkXC5dKyU/JC8sIGZvcm1hdDogInt9JSJ9LAogICAge2lkOiAidGVyIiwgICAgbGFiZWw6ICJURVI6IiwgICBpbml0OiAwLjA4LCB2YWxpZDogL15bXGRcLl0rJT8kLywgZm9ybWF0OiAie30lIn0sCiAgICB7aWQ6ICJyZXN1bHQiLCBsYWJlbDogIlRXUiA9IiwgIGZvcm1hdDogInt9JSJ9CiAgXSwKICBjb21wdXRlOiBmdW5jdGlvbih2KSB7CiAgICBpZiAodi55aWVsZCAqICgxIC0gdi5sMXR3LzEwMCkgPj0gdi50ZXIpCiAgICAgIHYucmVzdWx0ID0gKHYueWllbGQgKiB2LmwxdHcvMTAwKSArICgodi55aWVsZCAqICgxIC0gdi5sMXR3LzEwMCkgLSB2LnRlcikgKiB2LmwydHcvMTAwKTsKICAgIGVsc2UKICAgICAgdi5yZXN1bHQgPSBOYU47CiAgICB2LnJlc3VsdCA9IHYucmVzdWx0LnRvRml4ZWQoNCk7CiAgfQp9OwoKYmhfLmNhbGN1bGF0b3IgPSB7CiAgbmFtZTogImJoXy5jYWxjdWxhdG9yIiwKCiAgaW5pdGlhbGl6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GQuaWQgKyAiJz4iICsgZmllbGQubGFiZWwgKyAiIDwvbGFiZWw+IgogICAgICAgICAgICArICI8aW5wdXQgdHlwZT0ndGV4dCcgc3R5bGU9JyIgKyBzdHlsZXMuZmllbGQgKyAiJyBzaXplPSc2JyBpZD0nIiArIHByZWZpeCArIGZpZWxkLmlkICsgIiciCiAgICAgICAgICAgICsgIiB2YWx1ZT0nIiArIGluaXQgKyAiJyBvbmNoYW5nZT0nIiArIGludm9rZSArICInPiIKICAgICAgICAgICAgKyAiPC90ZD4iOwogICAgICB9IGVsc2UgewogICAgICAgIHJlc3VsdCA9IGZpZWxkOwogICAgICB9CiAgICB9KTsKICAgIHRhYmxlICs9CiAgICAgICAgICAiPC90cj48dHI+IgogICAgICAgICsgIjx0ZCBzdHlsZT0nIiArIHN0eWxlcy5jZWxsICsgIic+IgogICAgICAgICsgIjxidXR0b24gdHlwZT0nYnV0dG9uJyBzdHlsZT0nIiArIHN0eWxlcy5idXR0b24gKyAiJyBpZD0nIiArIHByZWZpeCArICIjYnV0dG9uJyIKICAgICAgICArICIgb25jbGljaz0nIiArIGludm9rZSArICInPkNhbGN1bGF0ZTwvYnV0dG9uPjwvdGQ+IgogICAgICAgICsgIjx0ZCBzdHlsZT0nIiArIHN0eWxlcy5jZWxsICsgIic+IgogICAgICAgICsgIjxsYWJlbCBmb3I9JyIgKyBwcmVmaXggKyByZXN1bHQuaWQgKyAiJz4iICsgcmVzdWx0LmxhYmVsICsgIiA8L2xhYmVsPiIKICAgICAgICArICI8aW5wdXQgdHlwZT0ndGV4dCcgc3R5bGU9JyIgKyBzdHlsZXMuZmllbGQgKyAiJyBzaXplPSc2JyBpZD0nIiArIHByZWZpeCArIHJlc3VsdC5pZCArICInIHJlYWRvbmx5PiIKICAgICAgICArICI8L3RkPiIKICAgICAgICArICI8L3RyPiIKICAgICAgICArICI8L3Rib2R5PjwvdGFibGU+IjsKICAgIGlmICgibG9nIiBpbiBiaF8uY2FsY3VsYXRvciAmJiBiaF8u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