1853(A,cpp): solve “Desorting”

Signed-off-by: Matej Focko <me@mfocko.xyz>

diff --git a/1853/a.cpp b/1853/a.cpp
new file mode 100644
index 0000000..217b260
--- /dev/null
+++ b/1853/a.cpp
@@ -0,0 +1,176 @@
+#include <algorithm>
+#include <array>
+#include <bit>
+#include <bitset>
+#include <cassert>
+#include <cctype>
+#include <chrono>
+#include <cmath>
+#include <cstdint>
+#include <functional>
+#include <iomanip>
+#include <iostream>
+#include <map>
+#include <numeric>
+#include <optional>
+#include <queue>
+#include <random>
+#include <set>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#pragma region helpers
+
+#pragma region math
+static constexpr std::int32_t MODULO = 1000000007;
+
+long pow(long base, long exp) {
+  if (exp == 0) return 1;
+  long half = pow(base, exp / 2);
+  if (exp % 2 == 0) return half * half;
+  return half * half * base;
+}
+#pragma endregion /* math */
+
+#pragma region output
+template <typename T, typename U>
+std::ostream &operator<<(std::ostream &os, std::pair<T, U> const &p) {
+  return os << p.first << " " << p.second;
+}
+
+template <typename C, typename T = typename std::enable_if<
+                          !std::is_same<C, std::string>::value,
+                          typename C::value_type>::type>
+std::ostream &operator<<(std::ostream &os, const C &v) {
+  std::string sep;
+  for (const T &x : v) {
+    os << sep << x, sep = " ";
+  }
+
+  return os;
+}
+
+template <typename T>
+inline void answer(const T &ans) {
+  std::cout << ans << "\n";
+}
+
+inline void yes() { std::cout << "YES\n"; }
+inline void no() { std::cout << "NO\n"; }
+inline void yesno(bool ans) { std::cout << (ans ? "YES" : "NO") << "\n"; }
+#pragma endregion /* output */
+
+#pragma region debug
+void dbg_out() { std::cerr << std::endl; }
+template <typename Head, typename... Tail>
+void dbg_out(Head H, Tail... T) {
+  std::cerr << ' ' << H;
+  dbg_out(T...);
+}
+#ifdef LOCAL
+#define dbg(...)                                                           \
+  std::cerr << '[' << __FILE__ << ':' << __LINE__ << "] (" << #__VA_ARGS__ \
+            << "):",                                                       \
+      dbg_out(__VA_ARGS__)
+#else
+#define dbg(...)
+#endif
+#pragma endregion debug
+
+#pragma region input
+template <typename T>
+std::vector<T> load_vector(std::size_t size) {
+  std::vector<T> result{};
+
+  for (auto i = 0u; i < size; ++i) {
+    T x;
+    std::cin >> x;
+    result.push_back(std::move(x));
+  }
+
+  return result;
+}
+#pragma endregion /* input */
+
+#pragma region functional
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html
+template <class Fun>
+class y_combinator_result {
+  Fun fun_;
+
+ public:
+  template <class T>
+  explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}
+  template <class... Args>
+  decltype(auto) operator()(Args &&...args) {
+    return fun_(std::ref(*this), std::forward<Args>(args)...);
+  }
+};
+template <class Fun>
+decltype(auto) y_combinator(Fun &&fun) {
+  return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
+}
+#pragma endregion /* functional */
+
+#define LOOP(var, n) for (auto var = 0; var < n; ++var)
+
+#pragma endregion /* helpers */
+
+// for ‹N› test cases, uncomment for single test case
+// #define SINGLE
+
+namespace solution {
+
+using namespace std;
+
+void solve() {
+  int n;
+  cin >> n;
+
+  auto a = load_vector<int>(n);
+
+  vector<int> ds;
+  for (auto i = 0; i < n - 1; ++i) {
+    ds.push_back(a[i + 1] - a[i]);
+  }
+
+  auto distance = *min_element(ds.begin(), ds.end());
+
+  answer(max(0, (distance + 2) / 2));
+}
+
+void tests() {
+  // TODO
+}
+
+}  // namespace solution
+
+using namespace solution;
+
+#ifdef TEST
+
+int main(void) {
+  tests();
+  return 0;
+}
+
+#else
+
+int main(void) {
+  int N = 1;
+
+#ifndef SINGLE
+
+  std::cin >> N;
+
+#endif
+
+  while (N-- > 0) {
+    solve();
+  }
+
+  return 0;
+}
+
+#endif
diff --git a/1853/index.html b/1853/index.html
new file mode 100644
index 0000000..deae7ce
--- /dev/null
+++ b/1853/index.html
@@ -0,0 +1,1153 @@
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+<html lang="en">
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <meta name="X-Csrf-Token" content="e2463ab5fb2d283d0cd2aa27f8de2cf4"/>
+    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=0.01"/>
+
+
+    <script type="text/javascript" src="//codeforces.org/s/0/js/jquery-1.8.3.js"></script>
+    <script type="application/javascript">
+        window.locale = "en";
+        window.standaloneContest = false;
+        function adjustViewport() {
+            var screenWidthPx = Math.min($(window).width(), window.screen.width);
+            var siteWidthPx = 1100; // min width of site
+            var ratio = Math.min(screenWidthPx / siteWidthPx, 1.0);
+            var viewport = "width=device-width, initial-scale=" + ratio;
+            $('#viewport').attr('content', viewport);
+            var style = $('<style>html * { max-height: 1000000px; }</style>');
+            $('html > head').append(style);
+        }
+
+        if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
+            adjustViewport();
+        }
+
+        /* Protection against trailing dot in domain. */
+        let hostLength = window.location.host.length;
+        if (hostLength > 1 && window.location.host[hostLength - 1] === '.') {
+            window.location = window.location.protocol + "//" + window.location.host.substring(0, hostLength - 1);
+        }
+    </script>
+    <meta http-equiv="pragma" content="no-cache">
+    <meta http-equiv="expires" content="-1">
+    <meta http-equiv="profileName" content="i2">
+    <meta name="google-site-verification" content="OTd2dN5x4nS4OPknPI9JFg36fKxjqY0i1PSfFPv_J90"/>
+    <meta property="fb:admins" content="100001352546622" />
+    <meta property="og:image" content="//codeforces.org/s/0/images/codeforces-sponsored-by-ton.png" />
+    <link rel="image_src" href="//codeforces.org/s/0/images/codeforces-sponsored-by-ton.png" />
+    <meta property="og:title" content="Problems - Codeforces"/>
+    <meta property="og:description" content=""/>
+
+    <meta property="og:site_name" content="Codeforces"/>
+
+
+
+
+
+
+    <meta name="utc_offset" content="+03:00"/>
+    <meta name="verify-reformal" content="f56f99fd7e087fb6ccb48ef2" />
+    <title>Problems - Codeforces</title>
+        <meta name="description" content="Codeforces. Programming competitions and contests, programming community" />
+        <meta name="keywords" content="programming algorithm contest competition informatics olympiads c++ java graphs vkcup" />
+    <meta name="robots" content="index, follow" />
+
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/font-awesome.min.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/line-awesome.min.css" type="text/css" charset="utf-8" />
+
+        <link href='//fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
+        <link href='//fonts.googleapis.com/css?family=Cuprum&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
+
+
+    <link rel="apple-touch-icon" sizes="57x57" href="//codeforces.org/s/0/apple-icon-57x57.png">
+    <link rel="apple-touch-icon" sizes="60x60" href="//codeforces.org/s/0/apple-icon-60x60.png">
+    <link rel="apple-touch-icon" sizes="72x72" href="//codeforces.org/s/0/apple-icon-72x72.png">
+    <link rel="apple-touch-icon" sizes="76x76" href="//codeforces.org/s/0/apple-icon-76x76.png">
+    <link rel="apple-touch-icon" sizes="114x114" href="//codeforces.org/s/0/apple-icon-114x114.png">
+    <link rel="apple-touch-icon" sizes="120x120" href="//codeforces.org/s/0/apple-icon-120x120.png">
+    <link rel="apple-touch-icon" sizes="144x144" href="//codeforces.org/s/0/apple-icon-144x144.png">
+    <link rel="apple-touch-icon" sizes="152x152" href="//codeforces.org/s/0/apple-icon-152x152.png">
+    <link rel="apple-touch-icon" sizes="180x180" href="//codeforces.org/s/0/apple-icon-180x180.png">
+    <link rel="icon" type="image/png" sizes="192x192"  href="//codeforces.org/s/0/android-icon-192x192.png">
+    <link rel="icon" type="image/png" sizes="32x32" href="//codeforces.org/s/0/favicon-32x32.png">
+    <link rel="icon" type="image/png" sizes="96x96" href="//codeforces.org/s/0/favicon-96x96.png">
+    <link rel="icon" type="image/png" sizes="16x16" href="//codeforces.org/s/0/favicon-16x16.png">
+    <link rel="manifest" href="/manifest.json">
+    <meta name="msapplication-TileColor" content="#ffffff">
+    <meta name="msapplication-TileImage" content="//codeforces.org/s/0/ms-icon-144x144.png">
+    <meta name="theme-color" content="#ffffff">
+
+    <!--CombineResourcesFilter-->
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/prettify.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/clear.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/style.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/ttypography.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/problem-statement.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/second-level-menu.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/roundbox.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/datatable.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/table-form.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/topic.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/jquery.jgrowl.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/facebox.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/jquery.wysiwyg.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/jquery.autocomplete.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/codeforces.datepick.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/colorbox.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/css/jquery.drafts.css" type="text/css" charset="utf-8" />
+        <link rel="stylesheet" href="//codeforces.org/s/96441/css/community.css" type="text/css" charset="utf-8" />
+        <link rel="stylesheet" href="//codeforces.org/s/96441/css/sidebar-menu.css" type="text/css" charset="utf-8" />
+
+    <!-- MathJax -->
+    <script type="text/x-mathjax-config">
+    MathJax.Hub.Config({
+      tex2jax: {inlineMath: [['$$$','$$$']], displayMath: [['$$$$$$','$$$$$$']]}
+    });
+    MathJax.Hub.Register.StartupHook("End", function () {
+        Codeforces.runMathJaxListeners();
+    });
+    </script>
+    <script type="text/javascript" async
+            src="https://cdn-mathjax.codeforces.com/MathJax.js?config=TeX-AMS_HTML-full"
+    >
+    </script>
+    <!-- /MathJax -->
+
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/prettify/prettify.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/moment-with-locales.min.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/pushstream.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.easing.min.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.lavalamp.min.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.jgrowl.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.swipe.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.hotkeys.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/facebox.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.wysiwyg.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/controls/wysiwyg.colorpicker.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/controls/wysiwyg.table.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/controls/wysiwyg.image.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/controls/wysiwyg.link.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.autocomplete.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.datepick.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.ie6blocker.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.colorbox-min.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.ba-bbq.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/jquery.drafts.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/clipboard.min.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/autosize.min.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/sjcl.js"></script>
+    <script type="text/javascript" src="/scripts/788010843dad1631228110074dfa2c30/en/codeforces-options.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/codeforces.js?v=20160131"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/EventCatcher.js?v=20160131"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/preparedVerdictFormats-en.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/js/confetti.min.js"></script>
+    <!--/CombineResourcesFilter-->
+
+    <link rel="stylesheet" href="//codeforces.org/s/96441/markitup/skins/markitup/style.css" type="text/css" charset="utf-8" />
+    <link rel="stylesheet" href="//codeforces.org/s/96441/markitup/sets/markdown/style.css" type="text/css" charset="utf-8" />
+
+
+    <script type="text/javascript" src="//codeforces.org/s/96441/markitup/jquery.markitup.js"></script>
+    <script type="text/javascript" src="//codeforces.org/s/96441/markitup/sets/markdown/set.js"></script>
+
+    <!--[if IE]>
+    <style>
+        #sidebar {
+            padding-left: 1em;
+            margin: 1em 1em 1em 0;
+        }
+    </style>
+    <![endif]-->
+
+
+
+
+</head>
+<body class=" "><span style='display:none;' class='csrf-token' data-csrf='e2463ab5fb2d283d0cd2aa27f8de2cf4'>&nbsp;</span>
+
+<!-- .notificationTextCleaner used in Codeforces.showAnnouncements() -->
+<div class="notificationTextCleaner" style="font-size: 0"></div>
+<div class="button-up" style="display: none; opacity: 0.7; width: 50px; height:100%; position: fixed; left: 0; top: 0; cursor: pointer; text-align: center; line-height: 35px; color: #d3dbe4; font-weight: bold; font-size: 3.0rem;"><i class="icon-circle-arrow-up"></i></div>
+<div class="verdictPrototypeDiv" style="display: none;"></div>
+
+<!-- Codeforces JavaScripts. -->
+<script type="text/javascript">
+    String.prototype.hashCode = function() {
+        var hash = 0, i, chr;
+        if (this.length === 0) return hash;
+        for (i = 0; i < this.length; i++) {
+            chr   = this.charCodeAt(i);
+            hash  = ((hash << 5) - hash) + chr;
+            hash |= 0; // Convert to 32bit integer
+        }
+        return hash;
+    };
+
+    var queryMobile = Codeforces.queryString.mobile;
+    if (queryMobile === "true" || queryMobile === "false") {
+        Codeforces.putToStorage("useMobile", queryMobile === "true");
+    } else {
+        var useMobile = Codeforces.getFromStorage("useMobile");
+        if (useMobile === true || useMobile === false) {
+            if (useMobile != false) {
+                Codeforces.redirect(Codeforces.updateUrlParameter(document.location.href, "mobile", useMobile));
+            }
+        }
+    }
+</script>
+
+<script type="text/javascript">
+    if (window.parent.frames.length > 0) {
+        window.stop();
+    }
+</script>
+
+
+
+
+
+    <script type="text/javascript">
+        $(document).ready(function () {
+    (function () {
+        jQuery.expr[':'].containsCI = function(elem, index, match) {
+            return !match || !match.length || match.length < 4 || !match[3] || (
+                    elem.textContent || elem.innerText || jQuery(elem).text() || ''
+            ).toLowerCase().indexOf(match[3].toLowerCase()) >= 0;
+        }
+    }(jQuery));
+
+    $.ajaxPrefilter(function(options, originalOptions, xhr) {
+        var csrf = Codeforces.getCsrfToken();
+
+        if (csrf) {
+            var data = originalOptions.data;
+            if (originalOptions.data !== undefined) {
+                if (Object.prototype.toString.call(originalOptions.data) === '[object String]') {
+                    data = $.deparam(originalOptions.data);
+                }
+            } else {
+                data = {};
+            }
+            options.data = $.param($.extend(data, { csrf_token: csrf }));
+        }
+    });
+
+    window.getCodeforcesServerTime = function(callback) {
+        $.post("/data/time", {}, callback, "json");
+    }
+
+    window.updateTypography = function () {
+        $("div.ttypography code").addClass("tt");
+        $("div.ttypography pre>code").addClass("prettyprint").removeClass("tt");
+        $("div.ttypography table").addClass("bordertable");
+        prettyPrint();
+    }
+
+    $.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8", headers: {
+        'X-Csrf-Token': Codeforces.getCsrfToken()
+    }});
+
+    window.updateTypography();
+
+    Codeforces.signForms();
+
+    setTimeout(function() {
+        $(".second-level-menu-list").lavaLamp({
+            fx: "backout",
+            speed: 700
+        });
+    }, 100);
+
+
+    Codeforces.countdown();
+    $("a[rel='photobox']").colorbox();
+
+
+    function showAnnouncements(json) {
+        //info("j=" + JSON.stringify(json));
+
+        if (json.t != "a") {
+            return;
+        }
+
+        setTimeout(function() {
+            Codeforces.showAnnouncements(json.d, "en");
+        }, Math.random() * 500);
+    }
+
+    function showEventCatcherUserMessage(json) {
+        if (json.t == "s") {
+            var points = json.d[5];
+            var passedTestCount = json.d[7];
+            var judgedTestCount = json.d[8];
+            var verdict = preparedVerdictFormats[json.d[12]];
+            var verdictPrototypeDiv = $(".verdictPrototypeDiv");
+            verdictPrototypeDiv.html(verdict);
+            if (judgedTestCount != null && judgedTestCount != undefined) {
+                verdictPrototypeDiv.find(".verdict-format-judged").text(judgedTestCount);
+            }
+            if (passedTestCount != null && passedTestCount != undefined) {
+                verdictPrototypeDiv.find(".verdict-format-passed").text(passedTestCount);
+            }
+            if (points != null && points != undefined) {
+                verdictPrototypeDiv.find(".verdict-format-points").text(points);
+            }
+            Codeforces.showMessage(verdictPrototypeDiv.text());
+        }
+    }
+
+    $(".clickable-title").each(function() {
+        var title = $(this).attr("data-title");
+        if (title) {
+            var tmp = document.createElement("DIV");
+            tmp.innerHTML = title;
+            $(this).attr("title", tmp.textContent || tmp.innerText || "");
+        }
+    });
+
+    $(".clickable-title").click(function() {
+        var title = $(this).attr("data-title");
+        if (title) {
+            Codeforces.alert(title);
+        } else {
+            Codeforces.alert($(this).attr("title"));
+        }
+    }).css("position", "relative").css("bottom", "3px");
+
+        Codeforces.showDelayedMessage();
+
+    Codeforces.reformatTimes();
+
+    //Codeforces.initializePubSub();
+    if (window.codeforcesOptions.subscribeServerUrl) {
+        window.eventCatcher = new EventCatcher(
+            window.codeforcesOptions.subscribeServerUrl,
+            [
+                Codeforces.getGlobalChannel(),
+                Codeforces.getUserChannel(),
+                Codeforces.getUserShowMessageChannel(),
+                Codeforces.getContestChannel(),
+                Codeforces.getParticipantChannel(),
+                Codeforces.getTalkChannel()
+            ]
+        );
+
+        if (Codeforces.getParticipantChannel()) {
+            window.eventCatcher.subscribe(Codeforces.getParticipantChannel(), function(json) {
+                showAnnouncements(json);
+            });
+        }
+
+        if (Codeforces.getContestChannel()) {
+            window.eventCatcher.subscribe(Codeforces.getContestChannel(), function(json) {
+                showAnnouncements(json);
+            });
+        }
+
+        if (Codeforces.getGlobalChannel()) {
+            window.eventCatcher.subscribe(Codeforces.getGlobalChannel(), function(json) {
+                showAnnouncements(json);
+            });
+        }
+
+        if (Codeforces.getUserChannel()) {
+            window.eventCatcher.subscribe(Codeforces.getUserChannel(), function(json) {
+                showAnnouncements(json);
+            });
+        }
+
+        if (Codeforces.getUserShowMessageChannel()) {
+            window.eventCatcher.subscribe(Codeforces.getUserShowMessageChannel(), function(json) {
+                showEventCatcherUserMessage(json);
+            });
+        }
+    }
+
+    Codeforces.setupContestTimes("/data/contests");
+    Codeforces.setupSpoilers();
+    Codeforces.setupTutorials("/data/problemTutorial");
+        });
+    </script>
+
+<script type="text/javascript">
+  var _gaq = _gaq || [];
+  _gaq.push(['_setAccount', 'UA-743380-5']);
+  _gaq.push(['_trackPageview']);
+
+  (function () {
+    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+    ga.src = (document.location.protocol == 'https:' ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+  })();
+</script>
+
+
+<div id="body">
+<div style="width: 950px; margin: 0 auto;" class="compact-problemset">
+    <div id="header" style="position: relative; margin: 0;">
+        <div style="float:left;">
+                  <a href="/"><img height="65" style="height: 65px;" src="//codeforces.org/s/82252/images/codeforces-sponsored-by-ton.png" alt="Codeforces"/></a>
+        </div>
+        <div class="lang">
+            <div style="text-align: right;">
+                <a href="?locale=en"><img src="//codeforces.org/s/82252/images/flags/24/gb.png" title="In English" alt="In English"/></a>
+                <a href="?locale=ru"><img src="//codeforces.org/s/82252/images/flags/24/ru.png" title="По-русски" alt="По-русски"/></a>
+            </div>
+        </div>
+        <br style="clear: both;"/>
+    </div>
+
+    <br style="clear: both;"/>
+
+    <div style="text-align: center; font-size: 1.8rem; margin-bottom: 0.5em;"
+         class="caption">Codeforces Round 887 (Div. 2)</div>
+    <div style="border-top: 1px solid #ccc; height: 1em;"></div>
+
+    <div class="problem-frames">
+        <div
+                    style="margin-bottom: 2em;"
+        >
+
+    <style>
+        #facebox .content:has(.diff-popup) {
+            width: 90vw;
+            max-width: 120rem !important;
+        }
+
+        .testCaseMarker {
+            position: absolute;
+            font-weight: bold;
+            font-size: 1rem;
+        }
+
+        .diff-popup {
+            width: 90vw;
+            max-width: 120rem !important;
+            display: none;
+            overflow: auto;
+        }
+
+        .input-output-copier {
+            font-size: 1.2rem;
+            float: right;
+            color: #888 !important;
+            cursor: pointer;
+            border: 1px solid rgb(185, 185, 185);
+            padding: 3px;
+            margin: 1px;
+            line-height: 1.1rem;
+            text-transform: none;
+        }
+
+        .input-output-copier:hover {
+            background-color: #def;
+        }
+
+        .test-explanation textarea {
+            width: 100%;
+            height: 1.5em;
+        }
+
+        .pending-submission-message {
+            color: darkorange !important;
+        }
+    </style>
+    <script>
+        const OPENING_SPACE = String.fromCharCode(1001);
+        const CLOSING_SPACE = String.fromCharCode(1002);
+
+        const nodeToText = function (node, pre) {
+            let result = [];
+
+            if (node.tagName === "SCRIPT" || node.tagName === "math"
+                || (node.classList && node.classList.contains("input-output-copier")))
+                return [];
+
+            if (node.tagName === "NOBR") {
+                result.push(OPENING_SPACE);
+            }
+
+            if (node.nodeType === Node.TEXT_NODE) {
+                let s = node.textContent;
+                if (!pre) {
+                    s = s.replace(/\s+/g, " ");
+                }
+                if (s.length > 0) {
+                    result.push(s);
+                }
+            }
+
+            if (pre && node.tagName === "BR") {
+                result.push("\n");
+            }
+
+            node.childNodes.forEach(function (child) {
+                result.push(nodeToText(child, node.tagName === "PRE").join(""));
+            });
+
+            if (node.tagName === "DIV"
+                || node.tagName === "P"
+                || node.tagName === "PRE"
+                || node.tagName === "UL"
+                || node.tagName === "LI"
+            ) {
+                result.push("\n");
+            }
+
+            if (node.tagName === "NOBR") {
+                result.push(CLOSING_SPACE);
+            }
+
+            return result;
+        }
+
+        const isSpecial = function (c) {
+            return c === ',' || c === '.' || c === ';' || c === ')' || c === ' ';
+        }
+
+        const convertStatementToText = function(statmentNode) {
+            const text = nodeToText(statmentNode, false).join("").replace(/ +/g, " ").replace(/\n\n+/g, "\n\n");
+            let result = [];
+            for (let i = 0; i < text.length; i++) {
+                const c = text.charAt(i);
+                if (c === OPENING_SPACE) {
+                    if (!((i > 0 && text.charAt(i - 1) === '(') || (result.length > 0 && result[result.length - 1] === ' '))) {
+                        result.push('+');
+                    }
+                } else if (c === CLOSING_SPACE) {
+                    if (!(i + 1 < text.length && isSpecial(text.charAt(i + 1)))) {
+                        result.push('-');
+                    }
+                } else {
+                    result.push(c);
+                }
+            }
+            return result.join("").split("\n").map(value => value.trim()).join("\n");
+        };
+    </script>
+    <div class="diff-popup">
+    </div>
+
+<div class="problemindexholder" problemindex="A" data-uuid="ps_5406e98e5437adb2daa8f5e6028310866d2f64be">
+    <div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
+        <div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
+        <span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">&times;</span>
+    </div>
+        <div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">A. Desorting</div><div class="time-limit"><div class="property-title">time limit per test</div>1 second</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Call an array $$$a$$$ of length $$$n$$$ <span class="tex-font-style-it">sorted</span> if $$$a_1 \leq a_2 \leq \ldots \leq a_{n-1} \leq a_n$$$.</p><p>Ntarsis has an array $$$a$$$ of length $$$n$$$. </p><p>He is allowed to perform one type of operation on it (zero or more times): </p><ul> <li> Choose an index $$$i$$$ ($$$1 \leq i \leq n-1$$$). </li><li> Add $$$1$$$ to $$$a_1, a_2, \ldots, a_i$$$. </li><li> Subtract $$$1$$$ from $$$a_{i+1}, a_{i+2}, \ldots, a_n$$$. </li></ul><p>The values of $$$a$$$ can be negative after an operation.</p><p>Determine the minimum operations needed to make $$$a$$$ <span class="tex-font-style-bf">not sorted</span>.</p></div><div class="input-specification"><div class="section-title">Input</div><p>Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows.</p><p>The first line of each test case contains a single integer $$$n$$$ ($$$2 \leq n \leq 500$$$) — the length of the array $$$a$$$.</p><p>The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$) — the values of array $$$a$$$.</p><p>It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$500$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>Output the minimum number of operations needed to make the array <span class="tex-font-style-bf">not sorted</span>.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">4</div><div class="test-example-line test-example-line-odd test-example-line-1">2</div><div class="test-example-line test-example-line-odd test-example-line-1">1 1</div><div class="test-example-line test-example-line-even test-example-line-2">4</div><div class="test-example-line test-example-line-even test-example-line-2">1 8 10 13</div><div class="test-example-line test-example-line-odd test-example-line-3">3</div><div class="test-example-line test-example-line-odd test-example-line-3">1 3 2</div><div class="test-example-line test-example-line-even test-example-line-4">3</div><div class="test-example-line test-example-line-even test-example-line-4">1 9 14</div></pre></div><div class="output"><div class="title">Output</div><pre>
+1
+2
+0
+3
+</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>In the first case, we can perform $$$1$$$ operation to make the array not sorted: </p><ul> <li> Pick $$$i = 1$$$. The array $$$a$$$ then becomes $$$[2, 0]$$$, which is not sorted. </li></ul><p>In the second case, we can perform $$$2$$$ operations to make the array not sorted: </p><ul> <li> Pick $$$i = 3$$$. The array $$$a$$$ then becomes $$$[2, 9, 11, 12]$$$. </li><li> Pick $$$i = 3$$$. The array $$$a$$$ then becomes $$$[3, 10, 12, 11]$$$, which is not sorted. </li></ul><p>It can be proven that $$$1$$$ and $$$2$$$ operations are the minimal numbers of operations in the first and second test cases, respectively.</p><p>In the third case, the array is <span class="tex-font-style-bf"><span class="tex-font-style-underline">already</span></span> not sorted, so we perform $$$0$$$ operations.</p></div></div><p>  </p></div>
+</div>
+
+    <script>
+        $(function () {
+            Codeforces.addMathJaxListener(function () {
+                let $problem = $("div[problemindex=A]");
+                let uuid = $problem.attr("data-uuid");
+                let statementText = convertStatementToText($problem.find(".ttypography").get(0));
+
+                let previousStatementText = Codeforces.getFromStorage(uuid);
+                if (previousStatementText) {
+                    if (previousStatementText !== statementText) {
+                        $problem.find(".diff-notifier").show();
+
+                        $problem.find(".diff-notifier-close").click(function() {
+                            Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                            $problem.find(".diff-notifier").hide();
+                        });
+
+                        $problem.find("a.view-changes").click(function() {
+                            $.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
+                                if (result["success"] === "true") {
+                                    Codeforces.facebox(".diff-popup", "//codeforces.org/s/82252");
+                                    $("#facebox .diff-popup").html(result["diff"]);
+                                }
+                            }, "json");
+                        });
+                    }
+                } else {
+                    Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                }
+            });
+        });
+    </script>
+
+
+<script type="text/javascript">
+    $(document).ready(function () {
+        window.changedTests = new Set();
+
+        function endsWith(string, suffix) {
+            return string.indexOf(suffix, string.length - suffix.length) !== -1;
+        }
+
+        const inputFileDiv = $("div.input-file");
+        const inputFile = inputFileDiv.text();
+        const outputFileDiv = $("div.output-file");
+        const outputFile = outputFileDiv.text();
+
+
+        if (!endsWith(inputFile, "standard input")
+            && !endsWith(inputFile, "standard input")) {
+            inputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        if (!endsWith(outputFile, "standard output")
+            && !endsWith(outputFile, "standard output")) {
+            outputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        const titleDiv = $("div.header div.title");
+
+
+
+        String.prototype.replaceAll = function (search, replace) {
+            return this.split(search).join(replace);
+        };
+
+        $(".sample-test .title").each(function () {
+            const preId = ("id" + Math.random()).replaceAll(".", "0");
+            const cpyId = ("id" + Math.random()).replaceAll(".", "0");
+
+            $(this).parent().find("pre").attr("id", preId);
+            const $copy = $("<div title='Copy' data-clipboard-target='#" + preId + "' id='" + cpyId + "' class='input-output-copier'>Copy</div>");
+            $(this).append($copy);
+
+            const clipboard = new Clipboard('#' + cpyId, {
+                text: function (trigger) {
+                    const pre = document.querySelector('#' + preId);
+                    const lines = pre.querySelectorAll(".test-example-line");
+                    return Codeforces.filterClipboardText(pre.innerText, lines.length);
+                }
+            });
+
+            const isInput = $(this).parent().hasClass("input");
+
+            clipboard.on('success', function (e) {
+                if (isInput) {
+                    Codeforces.showMessage("The example input has been copied into the clipboard");
+                } else {
+                    Codeforces.showMessage("The example output has been copied into the clipboard");
+                }
+                e.clearSelection();
+            });
+        });
+
+        $(".test-form-item input").change(function () {
+            addPendingSubmissionMessage($($(this).closest("form")), "You changed the answer, do not forget to submit it if you want to save the changes");
+            const index = $(this).closest(".problemindexholder").attr("problemindex");
+            let test = "";
+            $(this).closest("form input").each(function () {
+                const test_ = $(this).attr("name");
+                if (test_ && test_.substring(0, 4) === "test") {
+                    test = test_;
+                }
+            });
+            if (index.length > 0 && test.length > 0) {
+                const indexTest = index + "::" + test;
+                window.changedTests.add(indexTest);
+            }
+        });
+
+        $(window).on('beforeunload', function () {
+            if (window.changedTests.size > 0) {
+                return 'Dialog text here';
+            }
+        });
+
+        autosize($('.test-explanation textarea'));
+
+        $(".test-example-line").hover(function() {
+            $(this).attr("class").split(" ").forEach((clazz) => {
+                if (clazz.substr(0, "test-example-line-".length) === "test-example-line-") {
+                    let end = clazz.substr("test-example-line-".length);
+                    if (end !== "even" && end !== "odd" && end !== "0") {
+                        let top = 1E20;
+                        let left = 1E20;
+                        let problem = $(this).closest(".problemindexholder");
+                        $(this).closest(".input").find("." + clazz).css("background-color", "#FFFDE7").each(function() {
+                            top = Math.min(top, $(this).offset().top);
+                            left = Math.min(left, $(this).offset().left);
+                        });
+                        let testCaseMarker = problem.find(".testCaseMarker_" + end);
+                        if (testCaseMarker.length === 0) {
+                            const html = "<div class=\"testCaseMarker testCaseMarker_" + end + " notice\"></div>";
+                            problem.append($(html));
+                            testCaseMarker = problem.find(".testCaseMarker_" + end);
+                        }
+                        if (testCaseMarker) {
+                            testCaseMarker.show()
+                                    .offset({top, left: left - 20})
+                                    .text(end);
+                        }
+                    }
+                }
+            });
+        }, function() {
+            $(this).attr("class").split(" ").forEach((clazz) => {
+                if (clazz.substr(0, "test-example-line-".length) === "test-example-line-") {
+                    let end = clazz.substr("test-example-line-".length);
+                    if (end !== "even" && end !== "odd" && end !== "0") {
+                        $("." + clazz).css("background-color", "");
+                        $(this).closest(".problemindexholder").find(".testCaseMarker_" + end).hide();
+                    }
+                }
+            });
+        });
+
+    });
+</script>
+        </div>
+        <div
+                    style="margin-bottom: 2em;"
+        >
+
+
+<div class="problemindexholder" problemindex="B" data-uuid="ps_ef73fcc259e1974eab71ae2705ef0ad25b725d7b">
+    <div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
+        <div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
+        <span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">&times;</span>
+    </div>
+        <div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">B. Fibonaccharsis</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Ntarsis has received two integers $$$n$$$ and $$$k$$$ for his birthday. He wonders how many fibonacci-like sequences of length $$$k$$$ can be formed with <span class="tex-font-style-bf">$$$n$$$ as the $$$k$$$-th element</span> of the sequence. </p><p>A sequence of <span class="tex-font-style-bf">non-decreasing non-negative</span> integers is considered fibonacci-like if $$$f_i = f_{i-1} + f_{i-2}$$$ for all $$$i &gt; 2$$$, where $$$f_i$$$ denotes the $$$i$$$-th element in the sequence. Note that $$$f_1$$$ and $$$f_2$$$ can be arbitrary.</p><p>For example, sequences such as $$$[4,5,9,14]$$$ and $$$[0,1,1]$$$ are considered fibonacci-like sequences, while $$$[0,0,0,1,1]$$$, $$$[1, 2, 1, 3]$$$, and $$$[-1,-1,-2]$$$ are not: the first two do not always satisfy $$$f_i = f_{i-1} + f_{i-2}$$$, the latter does not satisfy that the elements are non-negative.</p><p>Impress Ntarsis by helping him with this task.</p></div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 2 \cdot 10^5$$$), the number of test cases. The description of each test case is as follows.</p><p>Each test case contains two integers, $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$, $$$3 \leq k \leq 10^9$$$).</p><p>It is guaranteed the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case output an integer, the number of fibonacci-like sequences of length $$$k$$$ such that the $$$k$$$-th element in the sequence is $$$n$$$. That is, output the number of sequences $$$f$$$ of length $$$k$$$ so $$$f$$$ is a fibonacci-like sequence and $$$f_k = n$$$. It can be shown this number is finite.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">8</div><div class="test-example-line test-example-line-odd test-example-line-1">22 4</div><div class="test-example-line test-example-line-even test-example-line-2">3 9</div><div class="test-example-line test-example-line-odd test-example-line-3">55 11</div><div class="test-example-line test-example-line-even test-example-line-4">42069 6</div><div class="test-example-line test-example-line-odd test-example-line-5">69420 4</div><div class="test-example-line test-example-line-even test-example-line-6">69 1434</div><div class="test-example-line test-example-line-odd test-example-line-7">1 3</div><div class="test-example-line test-example-line-even test-example-line-8">1 4</div></pre></div><div class="output"><div class="title">Output</div><pre>
+4
+0
+1
+1052
+11571
+0
+1
+0
+</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>There are $$$4$$$ valid fibonacci-like sequences for $$$n = 22$$$, $$$k = 4$$$:</p><ul> <li> $$$[6,8,14,22]$$$, </li><li> $$$[4,9,13,22]$$$, </li><li> $$$[2,10,12,22]$$$, </li><li> $$$[0,11,11,22]$$$. </li></ul><p>For $$$n = 3$$$, $$$k = 9$$$, it can be shown that there are no fibonacci-like sequences satisfying the given conditions.</p><p>For $$$n = 55$$$, $$$k = 11$$$, $$$[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]$$$ is the only fibonacci-like sequence.</p></div></div><p>  </p></div>
+</div>
+
+    <script>
+        $(function () {
+            Codeforces.addMathJaxListener(function () {
+                let $problem = $("div[problemindex=B]");
+                let uuid = $problem.attr("data-uuid");
+                let statementText = convertStatementToText($problem.find(".ttypography").get(0));
+
+                let previousStatementText = Codeforces.getFromStorage(uuid);
+                if (previousStatementText) {
+                    if (previousStatementText !== statementText) {
+                        $problem.find(".diff-notifier").show();
+
+                        $problem.find(".diff-notifier-close").click(function() {
+                            Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                            $problem.find(".diff-notifier").hide();
+                        });
+
+                        $problem.find("a.view-changes").click(function() {
+                            $.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
+                                if (result["success"] === "true") {
+                                    Codeforces.facebox(".diff-popup", "//codeforces.org/s/82252");
+                                    $("#facebox .diff-popup").html(result["diff"]);
+                                }
+                            }, "json");
+                        });
+                    }
+                } else {
+                    Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                }
+            });
+        });
+    </script>
+
+
+<script type="text/javascript">
+    $(document).ready(function () {
+
+        function endsWith(string, suffix) {
+            return string.indexOf(suffix, string.length - suffix.length) !== -1;
+        }
+
+        const inputFileDiv = $("div.input-file");
+        const inputFile = inputFileDiv.text();
+        const outputFileDiv = $("div.output-file");
+        const outputFile = outputFileDiv.text();
+
+
+        if (!endsWith(inputFile, "standard input")
+            && !endsWith(inputFile, "standard input")) {
+            inputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        if (!endsWith(outputFile, "standard output")
+            && !endsWith(outputFile, "standard output")) {
+            outputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        const titleDiv = $("div.header div.title");
+
+
+
+
+    });
+</script>
+        </div>
+        <div
+                    style="margin-bottom: 2em;"
+        >
+
+
+<div class="problemindexholder" problemindex="C" data-uuid="ps_7d1cc9b184effc1c6a5ff6f5f19cc148f1c16169">
+    <div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
+        <div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
+        <span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">&times;</span>
+    </div>
+        <div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">C. Ntarsis' Set</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Ntarsis has been given a set $$$S$$$, initially containing integers $$$1, 2, 3, \ldots, 10^{1000}$$$ in sorted order. Every day, he will remove the $$$a_1$$$-th, $$$a_2$$$-th, $$$\ldots$$$, $$$a_n$$$-th smallest numbers in $$$S$$$ <span class="tex-font-style-bf">simultaneously</span>.</p><p>What is the smallest element in $$$S$$$ after $$$k$$$ days?</p></div><div class="input-specification"><div class="section-title">Input</div><p>Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^5$$$). The description of the test cases follows.</p><p>The first line of each test case consists of two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n,k \leq 2 \cdot 10^5$$$) — the length of $$$a$$$ and the number of days.</p><p>The following line of each test case consists of $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$) — the elements of array $$$a$$$.</p><p>It is guaranteed that: </p><ul> <li> The sum of $$$n$$$ over all test cases won't exceed $$$2 \cdot 10^5$$$; </li><li> The sum of $$$k$$$ over all test cases won't exceed $$$2 \cdot 10^5$$$; </li><li> $$$a_1 &lt; a_2 &lt; \cdots &lt; a_n$$$ for all test cases. </li></ul></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, print an integer that is the smallest element in $$$S$$$ after $$$k$$$ days.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">7</div><div class="test-example-line test-example-line-odd test-example-line-1">5 1</div><div class="test-example-line test-example-line-odd test-example-line-1">1 2 4 5 6</div><div class="test-example-line test-example-line-even test-example-line-2">5 3</div><div class="test-example-line test-example-line-even test-example-line-2">1 3 5 6 7</div><div class="test-example-line test-example-line-odd test-example-line-3">4 1000</div><div class="test-example-line test-example-line-odd test-example-line-3">2 3 4 5</div><div class="test-example-line test-example-line-even test-example-line-4">9 1434</div><div class="test-example-line test-example-line-even test-example-line-4">1 4 7 9 12 15 17 18 20</div><div class="test-example-line test-example-line-odd test-example-line-5">10 4</div><div class="test-example-line test-example-line-odd test-example-line-5">1 3 5 7 9 11 13 15 17 19</div><div class="test-example-line test-example-line-even test-example-line-6">10 6</div><div class="test-example-line test-example-line-even test-example-line-6">1 4 7 10 13 16 19 22 25 28</div><div class="test-example-line test-example-line-odd test-example-line-7">10 150000</div><div class="test-example-line test-example-line-odd test-example-line-7">1 3 4 5 10 11 12 13 14 15</div></pre></div><div class="output"><div class="title">Output</div><pre>
+3
+9
+1
+12874
+16
+18
+1499986
+</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>For the first test case, each day the $$$1$$$-st, $$$2$$$-nd, $$$4$$$-th, $$$5$$$-th, and $$$6$$$-th smallest elements need to be removed from $$$S$$$. So after the first day, $$$S$$$ will become $$$\require{cancel}$$$ $$$\{\cancel 1, \cancel 2, 3, \cancel 4, \cancel 5, \cancel 6, 7, 8, 9, \ldots\} = \{3, 7, 8, 9, \ldots\}$$$. The smallest element is $$$3$$$.</p><p>For the second case, each day the $$$1$$$-st, $$$3$$$-rd, $$$5$$$-th, $$$6$$$-th and $$$7$$$-th smallest elements need to be removed from $$$S$$$. $$$S$$$ will be changed as follows:</p><center> <table class="tex-tabular"><tbody><tr><td class="tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-bottom">Day</td><td class="tex-tabular-border-left tex-tabular-text-align-left tex-tabular-border-bottom">$$$S$$$ before</td><td class="tex-tabular-text-align-center tex-tabular-border-bottom"></td><td class="tex-tabular-text-align-left tex-tabular-border-bottom">$$$S$$$ after</td></tr><tr><td class="tex-tabular-text-align-center tex-tabular-border-right tex-tabular-border-top">1</td><td class="tex-tabular-border-left tex-tabular-text-align-left tex-tabular-border-top">$$$\{\cancel 1, 2, \cancel 3, 4, \cancel 5, \cancel 6, \cancel 7, 8, 9, 10, \ldots \}$$$</td><td class="tex-tabular-text-align-center tex-tabular-border-top">$$$\to$$$</td><td class="tex-tabular-text-align-left tex-tabular-border-top">$$$\{2, 4, 8, 9, 10, \ldots\}$$$</td></tr><tr><td class="tex-tabular-text-align-center tex-tabular-border-right">2</td><td class="tex-tabular-border-left tex-tabular-text-align-left">$$$\{\cancel 2, 4, \cancel 8, 9, \cancel{10}, \cancel{11}, \cancel{12}, 13, 14, 15, \ldots\}$$$</td><td class="tex-tabular-text-align-center">$$$\to$$$</td><td class="tex-tabular-text-align-left">$$$\{4, 9, 13, 14, 15, \ldots\}$$$</td></tr><tr><td class="tex-tabular-text-align-center tex-tabular-border-right">3</td><td class="tex-tabular-border-left tex-tabular-text-align-left">$$$\{\cancel 4, 9, \cancel{13}, 14, \cancel{15}, \cancel{16}, \cancel{17}, 18, 19, 20, \ldots\}$$$</td><td class="tex-tabular-text-align-center">$$$\to$$$</td><td class="tex-tabular-text-align-left">$$$\{9, 14, 18, 19, 20, \ldots\}$$$</td></tr></tbody></table> </center><p>The smallest element left after $$$k = 3$$$ days is $$$9$$$.</p></div></div><p>  </p></div>
+</div>
+
+    <script>
+        $(function () {
+            Codeforces.addMathJaxListener(function () {
+                let $problem = $("div[problemindex=C]");
+                let uuid = $problem.attr("data-uuid");
+                let statementText = convertStatementToText($problem.find(".ttypography").get(0));
+
+                let previousStatementText = Codeforces.getFromStorage(uuid);
+                if (previousStatementText) {
+                    if (previousStatementText !== statementText) {
+                        $problem.find(".diff-notifier").show();
+
+                        $problem.find(".diff-notifier-close").click(function() {
+                            Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                            $problem.find(".diff-notifier").hide();
+                        });
+
+                        $problem.find("a.view-changes").click(function() {
+                            $.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
+                                if (result["success"] === "true") {
+                                    Codeforces.facebox(".diff-popup", "//codeforces.org/s/82252");
+                                    $("#facebox .diff-popup").html(result["diff"]);
+                                }
+                            }, "json");
+                        });
+                    }
+                } else {
+                    Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                }
+            });
+        });
+    </script>
+
+
+<script type="text/javascript">
+    $(document).ready(function () {
+
+        function endsWith(string, suffix) {
+            return string.indexOf(suffix, string.length - suffix.length) !== -1;
+        }
+
+        const inputFileDiv = $("div.input-file");
+        const inputFile = inputFileDiv.text();
+        const outputFileDiv = $("div.output-file");
+        const outputFile = outputFileDiv.text();
+
+
+        if (!endsWith(inputFile, "standard input")
+            && !endsWith(inputFile, "standard input")) {
+            inputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        if (!endsWith(outputFile, "standard output")
+            && !endsWith(outputFile, "standard output")) {
+            outputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        const titleDiv = $("div.header div.title");
+
+
+
+
+    });
+</script>
+        </div>
+        <div
+                    style="margin-bottom: 2em;"
+        >
+
+
+<div class="problemindexholder" problemindex="D" data-uuid="ps_3d4431f98179457963b19c8d9615ad55a65e4320">
+    <div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
+        <div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
+        <span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">&times;</span>
+    </div>
+        <div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">D. Imbalanced Arrays</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Ntarsis has come up with an array $$$a$$$ of $$$n$$$ non-negative integers.</p><p>Call an array $$$b$$$ of $$$n$$$ integers <span class="tex-font-style-it">imbalanced</span> if it satisfies the following: </p><ul> <li> $$$-n\le b_i\le n$$$, $$$b_i \ne 0$$$, </li><li> there are no two indices $$$(i, j)$$$ ($$$1 \le i, j \le n$$$) such that $$$b_i + b_j = 0$$$, </li><li> for each $$$1 \leq i \leq n$$$, there are <span class="tex-font-style-bf">exactly</span> $$$a_i$$$ indices $$$j$$$ ($$$1 \le j \le n$$$) such that $$$b_i+b_j&gt;0$$$, where $$$i$$$ and $$$j$$$ are not necessarily distinct. </li></ul><p>Given the array $$$a$$$, Ntarsis wants you to construct some imbalanced array. Help him solve this task, or determine it is impossible.</p></div><div class="input-specification"><div class="section-title">Input</div><p>Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^5$$$). The description of the test cases follows.</p><p>The first line of each test case has a single integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$).</p><p>The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq n$$$).</p><p>It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$10^5$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output &quot;<span class="tex-font-style-tt">NO</span>&quot; if there exists no imbalanced array. </p><p>Otherwise, output &quot;<span class="tex-font-style-tt">YES</span>&quot;. Then, on the next line, output $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ where $$$b_i \neq 0$$$ for all $$$1 \leq i \leq n$$$ — an imbalanced array.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">5</div><div class="test-example-line test-example-line-odd test-example-line-1">1</div><div class="test-example-line test-example-line-odd test-example-line-1">1</div><div class="test-example-line test-example-line-even test-example-line-2">4</div><div class="test-example-line test-example-line-even test-example-line-2">1 4 3 4</div><div class="test-example-line test-example-line-odd test-example-line-3">3</div><div class="test-example-line test-example-line-odd test-example-line-3">0 1 0</div><div class="test-example-line test-example-line-even test-example-line-4">4</div><div class="test-example-line test-example-line-even test-example-line-4">4 3 2 1</div><div class="test-example-line test-example-line-odd test-example-line-5">3</div><div class="test-example-line test-example-line-odd test-example-line-5">1 3 1</div></pre></div><div class="output"><div class="title">Output</div><pre>
+YES
+1
+NO
+YES
+-3 1 -2
+YES
+4 2 -1 -3
+YES
+-1 3 -1</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>For the first test case, $$$b = [1]$$$ is an imbalanced array. This is because for $$$i = 1$$$, there is exactly one $$$j$$$ ($$$j = 1$$$) where $$$b_1 + b_j &gt; 0$$$.</p><p>For the second test case, it can be shown that there exists no imbalanced array.</p><p>For the third test case, $$$a = [0, 1, 0]$$$. The array $$$b = [-3, 1, -2]$$$ is an imbalanced array. </p><ul> <li> For $$$i = 1$$$ and $$$i = 3$$$, there exists no index $$$j$$$ such that $$$b_i + b_j &gt; 0$$$. </li><li> For $$$i = 2$$$, there is only one index $$$j = 2$$$ such that $$$b_i + b_j &gt; 0$$$ ($$$b_2 + b_2 = 1 + 1 = 2$$$). </li></ul> Another possible output for the third test case could be $$$b = [-2, 1, -3]$$$.</div></div><p>  </p></div>
+</div>
+
+    <script>
+        $(function () {
+            Codeforces.addMathJaxListener(function () {
+                let $problem = $("div[problemindex=D]");
+                let uuid = $problem.attr("data-uuid");
+                let statementText = convertStatementToText($problem.find(".ttypography").get(0));
+
+                let previousStatementText = Codeforces.getFromStorage(uuid);
+                if (previousStatementText) {
+                    if (previousStatementText !== statementText) {
+                        $problem.find(".diff-notifier").show();
+
+                        $problem.find(".diff-notifier-close").click(function() {
+                            Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                            $problem.find(".diff-notifier").hide();
+                        });
+
+                        $problem.find("a.view-changes").click(function() {
+                            $.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
+                                if (result["success"] === "true") {
+                                    Codeforces.facebox(".diff-popup", "//codeforces.org/s/82252");
+                                    $("#facebox .diff-popup").html(result["diff"]);
+                                }
+                            }, "json");
+                        });
+                    }
+                } else {
+                    Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                }
+            });
+        });
+    </script>
+
+
+<script type="text/javascript">
+    $(document).ready(function () {
+
+        function endsWith(string, suffix) {
+            return string.indexOf(suffix, string.length - suffix.length) !== -1;
+        }
+
+        const inputFileDiv = $("div.input-file");
+        const inputFile = inputFileDiv.text();
+        const outputFileDiv = $("div.output-file");
+        const outputFile = outputFileDiv.text();
+
+
+        if (!endsWith(inputFile, "standard input")
+            && !endsWith(inputFile, "standard input")) {
+            inputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        if (!endsWith(outputFile, "standard output")
+            && !endsWith(outputFile, "standard output")) {
+            outputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        const titleDiv = $("div.header div.title");
+
+
+
+
+    });
+</script>
+        </div>
+        <div
+                    style="margin-bottom: 2em;"
+        >
+
+
+<div class="problemindexholder" problemindex="E" data-uuid="ps_8e197cedfb28113377f1c4986bdfb2b128bb95db">
+    <div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
+        <div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
+        <span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">&times;</span>
+    </div>
+        <div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">E. Ina of the Mountain</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p><span class="tex-font-style-it">To prepare her &quot;Takodachi&quot; dumbo octopuses for world domination, Ninomae Ina'nis, a.k.a. Ina of the Mountain, orders Hoshimachi Suisei to throw boulders at them. Ina asks you, Kiryu Coco, to help choose where the boulders are thrown.</span></p><p>There are $$$n$$$ octopuses on a single-file trail on Ina's mountain, numbered $$$1, 2, \ldots, n$$$. The $$$i$$$-th octopus has a certain initial health value $$$a_i$$$, where $$$1 \leq a_i \leq k$$$.</p><p>Each boulder crushes consecutive octopuses with indexes $$$l, l+1, \ldots, r$$$, where $$$1 \leq l \leq r \leq n$$$. You can choose the numbers $$$l$$$ and $$$r$$$ arbitrarily for each boulder.</p><p>For each boulder, the health value of each octopus the boulder crushes is reduced by $$$1$$$. However, as octopuses are immortal, once they reach a health value of $$$0$$$, they will immediately regenerate to a health value of $$$k$$$. </p><p>Given the octopuses' initial health values, find the <span class="tex-font-style-bf">minimum</span> number of boulders that need to be thrown to make the health of all octopuses equal to $$$k$$$.</p></div><div class="input-specification"><div class="section-title">Input</div><p>Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^5$$$). The description of the test cases follows.</p><p>The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$1 \le k \le 10^9$$$) – the number of octopuses, and the upper bound of a octopus's health value.</p><p>The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le k$$$) – the initial health values of the octopuses.</p><p>It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output the <span class="tex-font-style-bf">minimum</span> number of boulders that need to be thrown to make the health values of all octopuses equal to $$$k$$$.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">2</div><div class="test-example-line test-example-line-odd test-example-line-1">4 3</div><div class="test-example-line test-example-line-odd test-example-line-1">1 2 1 3</div><div class="test-example-line test-example-line-even test-example-line-2">7 3</div><div class="test-example-line test-example-line-even test-example-line-2">1 2 3 1 3 2 1</div></pre></div><div class="output"><div class="title">Output</div><pre>
+2
+4
+</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>In the first test case, the minimum number of boulders thrown is $$$2$$$: </p><ul> <li> Throw the first boulder between $$$[l,r] = [1,3]$$$. Then, the octopuses' health values become $$$[3, 1, 3, 3]$$$. </li><li> Throw the second boulder between $$$[l,r] = [2,2]$$$. Then, the octopuses' health values become $$$[3, 3, 3, 3]$$$. </li></ul><p>In the second test case, the minimum number of boulders thrown is $$$4$$$. The $$$[l,r]$$$ ranges are $$$[1,7], [2, 6], [3, 5], [4, 4]$$$.</p></div></div><p>  </p></div>
+</div>
+
+    <script>
+        $(function () {
+            Codeforces.addMathJaxListener(function () {
+                let $problem = $("div[problemindex=E]");
+                let uuid = $problem.attr("data-uuid");
+                let statementText = convertStatementToText($problem.find(".ttypography").get(0));
+
+                let previousStatementText = Codeforces.getFromStorage(uuid);
+                if (previousStatementText) {
+                    if (previousStatementText !== statementText) {
+                        $problem.find(".diff-notifier").show();
+
+                        $problem.find(".diff-notifier-close").click(function() {
+                            Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                            $problem.find(".diff-notifier").hide();
+                        });
+
+                        $problem.find("a.view-changes").click(function() {
+                            $.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
+                                if (result["success"] === "true") {
+                                    Codeforces.facebox(".diff-popup", "//codeforces.org/s/82252");
+                                    $("#facebox .diff-popup").html(result["diff"]);
+                                }
+                            }, "json");
+                        });
+                    }
+                } else {
+                    Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                }
+            });
+        });
+    </script>
+
+
+<script type="text/javascript">
+    $(document).ready(function () {
+
+        function endsWith(string, suffix) {
+            return string.indexOf(suffix, string.length - suffix.length) !== -1;
+        }
+
+        const inputFileDiv = $("div.input-file");
+        const inputFile = inputFileDiv.text();
+        const outputFileDiv = $("div.output-file");
+        const outputFile = outputFileDiv.text();
+
+
+        if (!endsWith(inputFile, "standard input")
+            && !endsWith(inputFile, "standard input")) {
+            inputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        if (!endsWith(outputFile, "standard output")
+            && !endsWith(outputFile, "standard output")) {
+            outputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        const titleDiv = $("div.header div.title");
+
+
+
+
+    });
+</script>
+        </div>
+        <div
+                    style="margin-bottom: 1em;"
+        >
+
+
+<div class="problemindexholder" problemindex="F" data-uuid="ps_9194a578179c7f33bfb90e4e7dd3ee88ecc65484">
+    <div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
+        <div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
+        <span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">&times;</span>
+    </div>
+        <div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">F. Miriany and Matchstick</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Miriany's matchstick is a $$$2 \times n$$$ grid that needs to be filled with characters <span class="tex-font-style-tt">A</span> or <span class="tex-font-style-tt">B</span>. </p><p>He has already filled in the first row of the grid and would like you to fill in the second row. You must do so in a way such that the number of <span class="tex-font-style-it">adjacent pairs of cells with different characters</span>$$$^\dagger$$$ is equal to $$$k$$$. If it is impossible, report so.</p><p>$$$^\dagger$$$ An <span class="tex-font-style-it">adjacent pair of cells with different characters</span> is a pair of cells $$$(r_1, c_1)$$$ and $$$(r_2, c_2)$$$ ($$$1 \le r_1, r_2 \le 2$$$, $$$1 \le c_1, c_2 \le n$$$) such that $$$|r_1 - r_2| + |c_1 - c_2| = 1$$$ and the characters in $$$(r_1, c_1)$$$ and $$$(r_2, c_2)$$$ are different.</p></div><div class="input-specification"><div class="section-title">Input</div><p>The first line consists of an integer $$$t$$$, the number of test cases ($$$1 \leq t \leq 1000$$$). The description of the test cases follows.</p><p>The first line of each test case has two integers, $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 2 \cdot 10^5, 0 \leq k \leq 3 \cdot n$$$) – the number of columns of the matchstick, and the number of adjacent pairs of cells with different characters required.</p><p>The following line contains string $$$s$$$ of $$$n$$$ characters ($$$s_i$$$ is either <span class="tex-font-style-it">A</span> or <span class="tex-font-style-it">B</span>) – Miriany's top row of the matchstick.</p><p>It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, if there is no way to fill the second row with the number of adjacent pairs of cells with different characters equals $$$k$$$, output &quot;<span class="tex-font-style-tt">NO</span>&quot;. </p><p>Otherwise, output &quot;<span class="tex-font-style-tt">YES</span>&quot;. Then, print $$$n$$$ characters that a valid bottom row for Miriany's matchstick consists of. If there are several answers, output any of them.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">4</div><div class="test-example-line test-example-line-odd test-example-line-1">10 1</div><div class="test-example-line test-example-line-odd test-example-line-1">ABBAAABBAA</div><div class="test-example-line test-example-line-even test-example-line-2">4 5</div><div class="test-example-line test-example-line-even test-example-line-2">AAAA</div><div class="test-example-line test-example-line-odd test-example-line-3">9 17</div><div class="test-example-line test-example-line-odd test-example-line-3">BAAABBAAB</div><div class="test-example-line test-example-line-even test-example-line-4">4 9</div><div class="test-example-line test-example-line-even test-example-line-4">ABAB</div></pre></div><div class="output"><div class="title">Output</div><pre>
+NO
+YES
+BABB
+YES
+ABABAABAB
+NO</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>In the first test case, it can be proved that there exists no possible way to fill in row $$$2$$$ of the grid such that $$$k = 1$$$. </p><p>For the second test case, <span class="tex-font-style-tt">BABB</span> is one possible answer.</p><p>The grid below is the result of filling in <span class="tex-font-style-tt">BABB</span> as the second row.</p><center> $$$\begin{array}{|c|c|} \hline A &amp; A &amp; A &amp; A \cr \hline B &amp; A &amp; B &amp; B \cr \hline \end{array}$$$ </center><p>The pairs of different characters are shown below in red:</p><center> $$$\begin{array}{|c|c|} \hline \color{red}{A} &amp; A &amp; A &amp; A \cr \hline \color{red}{B} &amp; A &amp; B &amp; B \cr \hline \end{array}$$$<p><span class="tex-font-style-tt">—————————————————</span></p><p>$$$\begin{array}{|c|c|} \hline A &amp; A &amp; \color{red}{A} &amp; A \cr \hline B &amp; A &amp; \color{red}{B} &amp; B \cr \hline \end{array}$$$</p><p><span class="tex-font-style-tt">—————————————————</span></p><p>$$$\begin{array}{|c|c|} \hline A &amp; A &amp; A &amp; \color{red}{A} \cr \hline B &amp; A &amp; B &amp; \color{red}{B} \cr \hline \end{array}$$$</p><p><span class="tex-font-style-tt">—————————————————</span></p><p>$$$\begin{array}{|c|c|} \hline A &amp; A &amp; A &amp; A \cr \hline \color{red}{B} &amp; \color{red}{A} &amp; B &amp; B \cr \hline \end{array}$$$</p><p><span class="tex-font-style-tt">—————————————————</span></p><p>$$$\begin{array}{|c|c|} \hline A &amp; A &amp; A &amp; A \cr \hline B &amp; \color{red}{A} &amp; \color{red}{B} &amp; B \cr \hline \end{array}$$$</p></center><p>There are a total of $$$5$$$ pairs, which satisfies $$$k$$$.</p></div></div><p>  </p></div>
+</div>
+
+    <script>
+        $(function () {
+            Codeforces.addMathJaxListener(function () {
+                let $problem = $("div[problemindex=F]");
+                let uuid = $problem.attr("data-uuid");
+                let statementText = convertStatementToText($problem.find(".ttypography").get(0));
+
+                let previousStatementText = Codeforces.getFromStorage(uuid);
+                if (previousStatementText) {
+                    if (previousStatementText !== statementText) {
+                        $problem.find(".diff-notifier").show();
+
+                        $problem.find(".diff-notifier-close").click(function() {
+                            Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                            $problem.find(".diff-notifier").hide();
+                        });
+
+                        $problem.find("a.view-changes").click(function() {
+                            $.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
+                                if (result["success"] === "true") {
+                                    Codeforces.facebox(".diff-popup", "//codeforces.org/s/82252");
+                                    $("#facebox .diff-popup").html(result["diff"]);
+                                }
+                            }, "json");
+                        });
+                    }
+                } else {
+                    Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
+                }
+            });
+        });
+    </script>
+
+
+<script type="text/javascript">
+    $(document).ready(function () {
+
+        function endsWith(string, suffix) {
+            return string.indexOf(suffix, string.length - suffix.length) !== -1;
+        }
+
+        const inputFileDiv = $("div.input-file");
+        const inputFile = inputFileDiv.text();
+        const outputFileDiv = $("div.output-file");
+        const outputFile = outputFileDiv.text();
+
+
+        if (!endsWith(inputFile, "standard input")
+            && !endsWith(inputFile, "standard input")) {
+            inputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        if (!endsWith(outputFile, "standard output")
+            && !endsWith(outputFile, "standard output")) {
+            outputFileDiv.attr("style", "font-weight: bold");
+        }
+
+        const titleDiv = $("div.header div.title");
+
+
+
+
+    });
+</script>
+        </div>
+    </div>
+
+    <div id="footer">
+        <div><a href="https://codeforces.com/">Codeforces</a> (c) Copyright 2010-2023 Mike Mirzayanov</div>
+        <div>The only programming contests Web 2.0 platform</div>
+
+    </div>
+
+</div>
+</div>
+    <script type="application/javascript">
+        if ('serviceWorker' in navigator && 'fetch' in window && 'caches' in window) {
+            navigator.serviceWorker.register('/service-worker-82252.js')
+                .then(function (registration) {
+                    console.log('Service worker registered: ', registration);
+                })
+                .catch(function (error) {
+                    console.log('Registration failed: ', error);
+                });
+        }
+    </script>
+<script>(function(){var js = "window['__CF$cv$params']={r:'7ed44525fa794125'};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/invisible.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
+</html>
This commit is contained in:
Matej Focko 2023-07-29 15:25:35 +02:00
parent 403112b61e
commit 1bdd5d6d1d
Signed by: mfocko
GPG key ID: 7C47D46246790496
2 changed files with 1329 additions and 0 deletions

176
1853/a.cpp Normal file
View file

@ -0,0 +1,176 @@
#include <algorithm>
#include <array>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#pragma region helpers
#pragma region math
static constexpr std::int32_t MODULO = 1000000007;
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
#pragma endregion /* math */
#pragma region output
template <typename T, typename U>
std::ostream &operator<<(std::ostream &os, std::pair<T, U> const &p) {
return os << p.first << " " << p.second;
}
template <typename C, typename T = typename std::enable_if<
!std::is_same<C, std::string>::value,
typename C::value_type>::type>
std::ostream &operator<<(std::ostream &os, const C &v) {
std::string sep;
for (const T &x : v) {
os << sep << x, sep = " ";
}
return os;
}
template <typename T>
inline void answer(const T &ans) {
std::cout << ans << "\n";
}
inline void yes() { std::cout << "YES\n"; }
inline void no() { std::cout << "NO\n"; }
inline void yesno(bool ans) { std::cout << (ans ? "YES" : "NO") << "\n"; }
#pragma endregion /* output */
#pragma region debug
void dbg_out() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
std::cerr << ' ' << H;
dbg_out(T...);
}
#ifdef LOCAL
#define dbg(...) \
std::cerr << '[' << __FILE__ << ':' << __LINE__ << "] (" << #__VA_ARGS__ \
<< "):", \
dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
#pragma endregion debug
#pragma region input
template <typename T>
std::vector<T> load_vector(std::size_t size) {
std::vector<T> result{};
for (auto i = 0u; i < size; ++i) {
T x;
std::cin >> x;
result.push_back(std::move(x));
}
return result;
}
#pragma endregion /* input */
#pragma region functional
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0200r0.html
template <class Fun>
class y_combinator_result {
Fun fun_;
public:
template <class T>
explicit y_combinator_result(T &&fun) : fun_(std::forward<T>(fun)) {}
template <class... Args>
decltype(auto) operator()(Args &&...args) {
return fun_(std::ref(*this), std::forward<Args>(args)...);
}
};
template <class Fun>
decltype(auto) y_combinator(Fun &&fun) {
return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));
}
#pragma endregion /* functional */
#define LOOP(var, n) for (auto var = 0; var < n; ++var)
#pragma endregion /* helpers */
// for N test cases, uncomment for single test case
// #define SINGLE
namespace solution {
using namespace std;
void solve() {
int n;
cin >> n;
auto a = load_vector<int>(n);
vector<int> ds;
for (auto i = 0; i < n - 1; ++i) {
ds.push_back(a[i + 1] - a[i]);
}
auto distance = *min_element(ds.begin(), ds.end());
answer(max(0, (distance + 2) / 2));
}
void tests() {
// TODO
}
} // namespace solution
using namespace solution;
#ifdef TEST
int main(void) {
tests();
return 0;
}
#else
int main(void) {
int N = 1;
#ifndef SINGLE
std::cin >> N;
#endif
while (N-- > 0) {
solve();
}
return 0;
}
#endif

1153
1853/index.html Normal file

File diff suppressed because it is too large Load diff