Æsir - CHAOS Æsir - V."Everything has been planned out. No more hidden concerns. The condition of Cytus is also perfect.The time right now...... 00:01:12......It's time."The emotion samples are now sufficient. After almost 3 years, it's time for Ivy to awake her bonded sister, Vanessa.The system inside A.R.C.'s Library core can be considered as an undirected graph with infinite number of processing nodes, numbered with all positive integers ($$$1, 2, 3, \ldots$$$). The node with a number $$$x$$$ ($$$x > 1$$$), is directly connected with a node with number $$$\frac{x}{f(x)}$$$, with $$$f(x)$$$ being the lowest prime divisor of $$$x$$$.Vanessa's mind is divided into $$$n$$$ fragments. Due to more than 500 years of coma, the fragments have been scattered: the $$$i$$$-th fragment is now located at the node with a number $$$k_i!$$$ (a factorial of $$$k_i$$$).To maximize the chance of successful awakening, Ivy decides to place the samples in a node $$$P$$$, so that the total length of paths from each fragment to $$$P$$$ is smallest possible. If there are multiple fragments located at the same node, the path from that node to $$$P$$$ needs to be counted multiple times.In the world of zeros and ones, such a requirement is very simple for Ivy. Not longer than a second later, she has already figured out such a node.But for a mere human like you, is this still possible?For simplicity, please answer the minimal sum of paths' lengths from every fragment to the emotion samples' assembly node $$$P$$$.

The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^6$$$) — number of fragments of Vanessa's mind. The second line contains $$$n$$$ integers: $$$k_1, k_2, \ldots, k_n$$$ ($$$0 \le k_i \le 5000$$$), denoting the nodes where fragments of Vanessa's mind are located: the $$$i$$$-th fragment is at the node with a number $$$k_i!$$$.

Print a single integer, denoting the minimal sum of path from every fragment to the node with the emotion samples (a.k.a. node $$$P$$$). As a reminder, if there are multiple fragments at the same node, the distance from that node to $$$P$$$ needs to be counted multiple times as well.

NoteConsidering the first $$$24$$$ nodes of the system, the node network will look as follows (the nodes $$$1!$$$, $$$2!$$$, $$$3!$$$, $$$4!$$$ are drawn bold):For the first example, Ivy will place the emotion samples at the node $$$1$$$. From here:  The distance from Vanessa's first fragment to the node $$$1$$$ is $$$1$$$.  The distance from Vanessa's second fragment to the node $$$1$$$ is $$$0$$$.  The distance from Vanessa's third fragment to the node $$$1$$$ is $$$4$$$. The total length is $$$5$$$.For the second example, the assembly node will be $$$6$$$. From here:  The distance from Vanessa's first fragment to the node $$$6$$$ is $$$0$$$.  The distance from Vanessa's second fragment to the node $$$6$$$ is $$$2$$$.  The distance from Vanessa's third fragment to the node $$$6$$$ is $$$2$$$.  The distance from Vanessa's fourth fragment to the node $$$6$$$ is again $$$2$$$. The total path length is $$$6$$$.

import java.util.*
import kotlin.math.min

fun main() {
    val children = Array(11000) { mutableMapOf<Int, Int>() }
    val parent = IntArray(11000)
    val nodes = mutableListOf(1)
    var id = 5001
    var k = 1
    var j = 1
    fun recur(node: Int) {
        while (DATA[j] != ')') {
            var l = 0
            while (DATA[j].isDigit()) {
                l *= 10
                l += DATA[j] - '0'
                j++
            }
            if (DATA[j] == '(') {
                j++
                id++
                parent[id] = node
                children[node][id] = l
                nodes.add(id)
                recur(id)
            } else {
                j++
                k++
                parent[k] = node
                children[node][k] = l
                nodes.add(k)
            }
        }
        j++
    }
    recur(1)
    val n = readLine()!!.toInt()
    val subtree = IntArray(12001)
    val tokenizer = StringTokenizer(readLine()!!)
    for (j in 1..n) {
        val k = tokenizer.nextToken().toInt()
        subtree[k]++
    }
    for (k in nodes.reversed()) {
        subtree[parent[k]] += subtree[k]
    }
    var curr = 0L
    for (k in nodes) {
        if (parent[k] != 0) {
            curr += subtree[k].toLong() * children[parent[k]][k]!!.toLong()
        }
    }
    var answer = curr
    val stack = Stack<Int>()
    for (child in children[1].keys) {
        stack.push(child)
    }
    while (!stack.isEmpty()) {
        var k = stack.pop()
        if (k > 0) {
            stack.push(-k)
            val l = children[parent[k]][k]!!.toLong()
            curr -= subtree[k].toLong() * l
            curr += (n - subtree[k]).toLong() * l
            answer = min(answer, curr)
            for (child in children[k].keys) {
                stack.push(child)
            }
        } else {
            k = -k
            val l = children[parent[k]][k]!!.toLong()
            curr += subtree[k].toLong() * l
            curr -= (n - subtree[k]).toLong() * l
        }
    }
    println(answer)
}

const val DATA = "(1*2(0*2*)2(3*5*)2(2(4(0*3*)9*)13*)8(8*11*)3(17*3(16*18(0*4*)))14(15*18*)4(2(3(24*27*)32*)36*)4(9(9(19*23*)34*)6(16(23*26*)45*))18(38*41*)5(4(51(0*5*)58*)10(54*24(32*36*)))5(71*5(68*17(53*57*)))20(65*68*)6(10(73*16(60*63*))91*)12(13(31(42*47*)12(68*71*))4(94*97*))7(4(11(43(49*53*)9(89*93*))115*)121*)48(81*85*)8(126*15(14(99*102(0*6*))6(118*121*)))14(6(131*134*)29(113*116*))93(67*72*)10(156*11(42(105*108*)10(6(137*139*)148*)))10(60(110*37(78*82*))181*)10(19(25(138*142*)169*)9(181*26(157*161*)))10(8(6(15(41(127*131*)174*)192*)200*)21(189*102(89*95*)))53(14(162*165*)39(143*147*))39(201*204*)12(36(196*26(174*177*))241*)152(102*107*)23(38(199*202*)57(185*190*))13(1(17(4(5(231*234*)241*)26(222*225*))36(234*20(46(170*175*)223*)))11(271*7(266*63(28(178*181*)213*))))23(285(0*7*)42(252*255*))14(36(29(242*246*)277*)45(76(194*198*)278*))46(292*295*)14(1(10(82(235*239*)323*)29(31(275*139(138*144*))316*))23(77(248*251*)331*))153(216*220*)44(18(312*9(307*26(284*287*)))40(302*306*))16(375*13(364*30(107(229*235*)186(158*163*))))16(24(369*66(306*309*))401*)39(33(9(12(42(283*288*)332*)347*)359*)395*)17(14(28(376*57(27(295*298*)330*))417*)433*)191(260*265*)32(72(353*356*)10(12(18(390*394*)6(408*34(377*379*)))43(73(318*322*)398*)))300(184*191*)20(472*95(379*49(333*337*)))135(367*371*)20(1(14(181(291*296*)479*)37(17(441*30(413*417*))466*))66(440*11(28(404*409*)83(356*360*))))19(1(16(12(493*496*)510*)39(489*17(265(209*215*)482*)))17(524*36(46(37(407*411*)450*)499*)))19(176(377*54(329*333*))565*)110(475*479*)91(9(490*65(428*431*))509*)39(15(8(84(455*459*)545*)556*)92(481*484*))269(347*353*)39(15(121(448*214(237*242*))24(138(418*421*)14(30(518*520*)554*)))243(366*370*))24(89(111(429*434*)547*)118(520*523(0*8*)))24(53(597*13(587*17(59(513*517*)579*)))664*)42(27(126(494*499*)66(561*564*))16(643*646*))309(396*401*)26(129(556*22(539*542*))101(78(516*519*)601*))26(703*83(622*145(480*485*)))83(657*660*)47(15(682*36(51(598*39(562*565*))26(43(307(281*288*)597*)643*)))13(709*712*))27(1(50(192(503*507*)32(669*116(557*561*)))69(46(646*207(441*446*))701*))21(752*29(85(640*645*)105(627*631*))))47(190(577*581*)80(693*696*))211(613*618*)29(801*37(228(538*542*)773*))29(20(46(745*49(699*233(468*475*)))110(695*17(681*46(318(319*325*)646*))))19(822*57(14(753*757*)153(620*624*))))29(39(815*63(755*758*))57(805*231(576*582*)))29(20(184(667*670*)70(27(62(697*701*)43(722*137(589*592*)))54(749*752*)))898*)161(767*771*)245(90(598*602*)34(662*668*))31(41(16(15(845*848*)865*)149(735*738*))930*)31(171(231(529*535*)768*)57(168(34(682*685*)723*)16(877*880*)))118(23(47(797*802*)10(842*845*))46(834*838*))127(109(767*219(551*555*))52(835*189(648*653*)))33(24(160(805*809*)971*)997*)33(279(344(375*383*)730*)46(62(903*906*)971*))33(26(145(75(772*776*)179(674*679*))1005*)62(971*228(745*750*)))33(1041*198(845*259(589*595*)))82(32(972*68(907*909*))89(26(300(597*602*)905*)91(842*847*)))60(2(100(948*951*)19(1034*17(33(987*90(899*903*))205(823*829*))))186(888*891*))416(722*727*)36(1108*46(36(26(8(994*997*)133(876*879*))13(1028*1030*))84(149(849*852*)1004*)))747(424*431*)81(122(976*15(964*967*))36(121(950*952*)1076*))291(77(826*72(759*763*))915*)39(65(90(1013*1017*)1109*)27(1149*383(768*775*)))39(26(18(104(373(665*670*)1045*)1152*)1172*)236(63(901*904*)972*))39(1209*214(52(945*949*)1005*))389(870*874*)40(181(15(1028*1033*)1051*)1234*)40(30(75(205(925*930*)32(1105*1108*))58(33(1126*29(1101*1103*))43(120(1005*29(979*983*))1135*)))1268*)40(178(385(706*713*)1100*)76(155(1049*141(911*915*))734(479*485*)))72(88(1176*1180*)425(845*849*))130(18(64(1135*29(16(1094*48(1048*119(932*936*)))1124*))1219*)1240*)42(30(560(739*744*)1306*)1338*)99(20(395(867*873*)168(1102*98(1007*1010*)))1299*)43(107(197(1052*1056*)168(1087(0*9*)1100*))31(44(1302*84(11(1209*1213*)38(1188*1191*)))324(1035*1040*)))276(1163*1167*)43(1(57(1343*438(908*912*))31(44(20(49(9(65(1191*41(154(998*1004*)1160*))1269*)46(101(1134*1138*)1241*))1339*)55(1306*1310*))1411*))427(1018*222(799*805*)))43(1455*33(1424*44(257(1125*1131*)303(1087*1091*))))43(62(1410*56(30(1327*105(184(1041*1045*)25(1206*1211*)))1373*))60(160(1273*1276*)1439*))43(195(45(1260*1264*)154(191(966*972*)1166*))1517*)43(80(105(1333*1337*)1444*)140(408(978*983*)1395*))366(1213*1217*)82(366(1136*1140*)179(1329*78(1254*689(568*576*))))45(36(325(1199*1202*)74(12(149(1294*1298*)1449*)28(44(1392*1394*)278(1164*1168*))))1586*)81(139(83(313(1016*1021*)1336*)1422*)206(1357*1362*))80(33(309(105(1123*1128*)1236*)1548*)276(1307*1310*))778(889*895*)113(95(55(1411*1414*)1472*)46(379(1145*1148*)1530*))221(116(59(1294*1300*)1362*)34(1447*182(1267*1272*)))50(1660*236(1426*265(1164*1169*)))158(1563*1566*)50(1(274(1400*49(1355*1359*))128(1556*319(1239*316(929*933*))))67(294(1338*1341*)193(1445*358(1089*1094*))))50(38(109(1566*1570*)1681*)95(1626*72(40(1516*101(152(1267*1270*)1425*))622(947*955*))))162(1633*1636*)289(102(1408*1412*)138(1379*1382*))120(131(917(642*649*)93(178(1297*1301*)1482*))1709*)146(15(1669*1672*)71(94(1524*1529*)65(1561*1564*)))596(1251*1256*)55(1798*39(27(83(277(1374*1377*)131(107(1420*1423*)44(1490*1492*)))1753*)148(1634*11(1626*467(1161*1168*)))))55(1834*492(342(1002*1007*)1353*))95(70(1736*31(1708*300(1410*1415*)))272(1546*1549*))94(58(306(1459*1464*)584(1188*1192*))192(29(1615*1620*)140(1511*1515*)))56(1(69(1816*506(1313*1317*))95(1799*185(63(1553*1558*)1623*)))39(1867*660(1209*1214*)))56(252(51(214(1397*1402*)285(1333*1340*))1679*)146(1787*81(1708*1712*)))56(40(33(89(16(18(1744*1747*)1768*)172(1616*138(1480*59(1425*1428*))))1889*)1924*)1966*)96(105(756(1066*1073*)289(1542*1545*))34(1907*292(1618*246(1375*1379*))))253(346(1449*731(723*729*))32(56(1721*1723*)1783*))58(2011*218(185(337(1273*1277*)1620*)87(1720*1724*)))315(69(1704*122(1586*1589*))1783*)59(105(246(1689*1694*)1942*)145(37(1867*317(1553*1557*))799(1114*1119*)))101(236(1786*1791*)62(280(1687*1690*)662(1310*1316*)))60(2082*420(1664*42(1625*1630*)))60(78(54(1961*13(1951*1953*))435(1588*1592*))257(1850*1094(758*767*)))104(611(1464*1468*)34(2047*2050*))61(179(129(1820*63(1761*1764*))169(1791*1794*))108(119(102(1815*260(1557*1562*))176(34(1716*1719*)396(1361*1367*)))26(2034*2037*)))61(44(33(2095*2098*)106(62(1965*1968*)108(420(1504*1510*)1932*)))76(211(1905*1908*)2122*))61(198(108(188(1705*1709*)711(1188*1195*))2017*)45(184(1988*23(1967*142(62(1767*1770*)1835*)))139(2047*2051*)))1093(1204*1210*)62(44(381(1817*1821*)70(259(1875*1878*)220(224(1695*1701*)1927*)))355(273(1635*1639*)1916*))204(2130*2133*)246(2092*105(425(1566*1570*)1998*))536(1814*1819*)65(44(174(2073*2076*)69(25(432(67(1659*1666*)1736*)2171*)299(110(1789*1793*)1907*)))2321*)65(443(422(1457*1463*)1887*)43(2(2287*40(2249*228(17(320(1687*1690*)405(1609*1612*))2039*)))217(134(191(1769*1773*)1966*)2104*)))251(101(2078*252(1829*1833*))2190*)729(1713*1717*)67(356(2024*21(2007*2010*))2389*)67(118(1417(855*863*)2282*)183(61(188(167(1803*1806*)1977*)36(184(1947*1951*)2137*))33(2205*42(248(1918*404(1517*1521*))2177*))))67(2436*47(2391*724(1669*1675*)))984(1530*1535*)68(316(298(1838*1842*)2143*)2461*)68(93(82(242(2045*2050*)58(2236*548(1691*1696*)))29(30(204(2124*2126*)2333*)400(412(1553*1561*)1976*)))119(68(154(112(2047*709(1340*1346*))40(21(2108*2111*)2135*))2333*)31(2372*2375*)))160(2434*132(2305*490(1818*1822*)))69(254(330(1952*1958*)2290*)90(228(2228*2231*)89(2373*467(1908*1913*))))68(1(52(489(2019*2024*)2515*)296(2273*147(375(1753*1758*)2136*)))224(2358*284(2077*2083*)))68(54(39(384(2115*125(1994*1997*))2509*)2550*)663(1943*77(1869*1875*)))122(264(2298*2301*)332(2235*2239*))229(2465*191(80(2197*2199*)59(586(1639*1644*)2233*)))122(230(2361*13(2352*322(2032*2036*)))625(1978*1983*))71(95(36(241(2288*2292*)2535*)433(2141*2144*))93(96(2485*39(239(30(754(1425*1433*)2189*)2222*)2464*))37(2565*449(2118*2122*))))330(374(232(1837*1842*)2077*)2454*)72(186(1563(964*971*)2536*)350(426(1948*1952*)2383*))72(164(2570*63(47(2463*764(1701*1706*))2520*))2749*)203(325(2294*2299*)281(138(2207*2210*)23(213(2115*2119*)455(1879*1884*))))129(462(2256*2262*)72(201(2453*2456*)164(2495*2499*)))73(1(2791*97(68(326(2302*309(508(1489*1495*)2006*))215(2429*2431*))252(2465*2468*)))403(2417*671(1748*1755*)))131(208(2564*2567*)556(2221*2225*))74(223(347(244(2025*2029*)2276*)9(2618*2621*))2855*)811(2119*2124*)175(217(13(2531*150(60(2324*2327(0*10*))198(2202*2207*)))2570*)163(835(1792*1796*)2634*))535(2438*2443*)245(211(57(2466*77(115(2277*2281*)2400*))2536*)2750*)77(1(58(779(2081*2087*)2868*)201(2727*388(2341*103(2243*2246*))))59(2882*167(2717*2721*)))1201(1824*1829*)136(45(2850*37(419(290(2107*2112*)2405*)61(755(2010*2017*)444(2330*2333*))))371(2551*2555*))489(2574*2578*)377(64(346(2281*2286*)142(2493*2496*))12(2692*2696*))81(56(45(71(95(2738*113(398(2230*2234*)156(2481*2483*)))311(2539*2542*))2927*)270(653(2051*2055*)136(966(1608*1615*)2583*)))100(624(2323*2326*)71(409(2473*2476*)2888*)))346(531(2264*196(2075*2079*))2809*)969(2187*2192*)83(3079*232(128(2721*2724*)2856*))141(147(206(2678*2682*)797(2093*2098*))571(2473*2476*))185(249(329(2426*129(2303*2306*))177(2590*2594*))3023*)85(229(73(256(2566*2570*)2828*)227(2678*2681*))147(2992*453(2541*2546*)))143(450(2639*2642*)382(768(1944*1951*)384(2337*2341*)))86(101(3064*1390(1677*1682*))487(209(2479*2482*)2696*))85(1(58(42(170(2914*379(2538*2541*))49(153(2891*924(1969*1975*))246(2808*2813*)))3152*)212(202(2798*356(2444*2449*))3009*))59(90(119(2956*670(2289*2294*))36(3049*371(30(2651*2653*)2687*)))659(2527*2531*)))2192(1143*1152*)86(3259*183(166(505(207(2200*2204*)2415*)2922*)181(80(2830*91(137(2604*2609*)2750*))2924*)))146(89(190(2950*2954*)340(2806*2809*))157(181(2902*2907*)748(2342*2347*)))87(106(3206*629(2580*2583*))272(39(208(2801*760(2044*2050*))334(2686*2689*))203(2862*2866*)))87(184(3158*206(221(367(2367*2370*)2743*)2967*))3359*)149(521(517(2260*2266*)305(2480*2484*))191(3121*3125*))88(152(30(3196*3199*)602(2629*66(2567*2571*)))311(3082*1297(1787*1794*)))88(3403*63(3342*89(412(2843*2847*)73(28(182(17(2961*2965*)2984*)416(2754*456(2301*2305*)))126(3081*3085*)))))88(3437*836(795(1808*1814*)2616*))567(42(196(2736*2740*)2938*)69(89(2826*2829*)2921*))89(919(2550*424(2132*2136*))65(3416*52(3366*3369*)))699(2877*2881*)90(286(861(2344*2350*)3214*)349(502(2651*2654*)3160*))90(3510*118(200(116(75(3003*181(2825*2830*))356(2732*2737*))3211*)273(14(3127*3130*)201(2946*452(2496*2503*)))))158(48(167(1400(1865*1870*)3273*)45(71(3327*637(2692*2696*))101(3305*3309*)))595(2910*2913*))91(385(1001(2190*2196*)3199*)67(3519*49(84(232(3156*377(2784*2787*))31(3368*3370*))205(257(3026*3030*)168(64(86(2972*2974*)3065*)273(205(104(2549*2553*)2661*)2870*))))))563(3161*3165*)92(512(1219(1906*1915*)3137*)3651*)92(164(194(3294*3298*)3494*)828(254(2578*2582*)2841*))712(3050*3054*)93(70(831(2773*2777*)3610*)688(2994*1708(1289*1297*)))163(473(3151*3154*)1024(2605*2610*))828(2970*2974*)95(271(3437*510(2931*2935*))3718*)95(70(98(157(32(3362*637(2729*2732*))70(267(182(2885*2888*)3076*)76(3269*3273*)))436(3142*3146*))3682*)3754*)1338(2512*2518*)96(3761*128(1334(2301*2306*)454(3189*427(2765*2769*))))95(1(72(373(3334*3339*)99(45(30(28(157(213(67(220(2855*322(2537*2540*))3087*)159(2997*3000*))3375*)3536*)3566*)93(85(3421*129(3294*3298*))160(77(3278*3281*)1025(2335*2343*))))3668*))71(3770*58(3714*116(265(3336*1325(2013*2019*))447(454(2710*2715*)3172*)))))172(3695*137(58(3502*64(149(3293*3295*)3447*))736(2836*2842*))))95(219(3669*419(3253*145(3110*380(2734*2738*))))3903*)169(267(400(228(2935*2941*)3171*)3574*)1458(2385*2390*))313(3705*31(367(60(633(2617*2621*)385(2875*2880*))3328*)655(3042*3047*)))97(3950*71(2(3879*61(40(112(3668*3672*)337(808(2641*2646*)3456*))3836*))61(115(94(3631*67(3567*443(3126*3132*)))474(3264*84(3183*3187*)))86(156(3621*3623*)3782*))))97(70(1498(2433*2439*)3939*)176(408(3427*618(2811*2817*))387(205(3253*3256*)783(2681*2689*))))97(133(356(177(3370*3374*)3553*)41(149(3722*123(3602*3605*))234(208(3437*3442*)3652*)))513(38(156(3355*3358*)326(3192*3195*))3563*))577(3597*351(190(3061*3065*)3258*))1209(2978*2983*)393(355(580(2865*2869*)3453*)3812*)100(72(60(90(3884*527(3360*3363*))3983*)4045*)4119*)321(160(1594(2145*2153*)63(3686*351(3338*240(3101*90(3015*3018*)))))3925*)394(3853*602(64(3191*3195*)3263*))1495(2765*2770*)103(4163*476(3689*216(560(2916*2922*)2033(1451*1458*))))103(74(474(3636*3640*)105(435(115(3461*320(3144*3147*))3587*)4024*))136(195(3874*3877*)278(3797*1242(2557*2562*))))103(74(902(3243*3250*)192(332(3630*49(3584*128(3459*3464*)))3975*))818(99(3326*3329*)3433*))1170(3185*3189*)104(678(3578*752(2830*2835*))4267*)975(3397*3403*)244(228(3907*216(3694*3697*))4144*)182(450(3757*468(3293*175(3121*3126*)))375(3846*3849*))107(547(1516(2237*2243*)3761*)75(156(103(3976*387(3592*35(3563*3566*)))162(3932*544(3390*3394*)))289(3969*3972*)))106(1(518(1189(2630*2637*)3828*)141(347(3860*3863*)661(3552*92(120(3342*3346*)205(3264*219(3051*3055*))))))4376*)184(346(3953*27(199(3731*3734*)3936*))233(4078*82(4000*810(3192*3197*))))107(142(4258*53(393(3815*94(3724*3727*))517(2174(1525*1535*)3711*)))237(397(482(3309*375(2939*2944*))3803*)4203*))107(309(4132*180(3956*3959*))787(432(3231*3234*)3671*))629(231(165(3541*3545*)3713*)3949*)251(52(675(3601*3605*)4282*)203(4134*485(3652*3655*)))189(205(1074(3127*3133*)338(3871*3874*))113(859(3447*3451*)791(3521*3526*)))188(1702(2730*2737*)300(4141*4144*))111(432(4090*938(3156*3159*))241(70(1478(2742*2747*)258(3971*3973*))4304*))573(129(3955*348(3611*3614*))4094*)112(144(48(1346(3018*3025*)493(3880*383(3500*3503*)))143(4287*22(434(3833*70(3767*3769*))406(3871*3875*))))1006(3586*160(3429*3434*)))893(3820*76(3747*1363(2387*2395*)))256(140(277(4055*4059*)4338*)356(4125*125(4003*4006*)))784(3960*3965*)469(734(3547*3551*)607(3681*3685*))116(242(4404*290(648(3469*3472*)1043(3082*3086*)))4663*)2363(2417*2424*)117(4671*83(4590*158(783(3651*396(3260*3264*))4446*)))262(140(68(564(3771*3775*)37(4305*4308*))211(163(634(3407*3414*)179(3871*3874*))4219*))4573*)116(1(1(82(341(1011(3284*3289*)458(3844*3849*))4650*)448(324(3962*3964*)360(3932*3935*)))475(59(184(4028*4032*)33(4188*1045(3145*3150*)))274(4015*301(3718*3721*))))204(4570*924(3648*3654*)))116(4783*247(175(189(20(4154*4157*)4181*)4372*)4550*))1065(516(3333*3341*)381(3480*3484*))564(4367*4371*)118(88(306(4424*4427*)64(140(939(3592*3597*)417(299(3822*3827*)4129*))718(3971*3974*)))87(63(514(4182*249(1011(2924*2931*)161(3783*273(3513*3517*))))57(4660*41(4621*43(4581*43(4540*4544*)))))520(885(3388*3392*)234(4045*4050*))))629(1154(3227*3231*)297(4091*4097*))364(4660*4663*)120(485(488(388(3547*590(2962*2968*))3949*)214(4225*332(3898*3901*)))87(4847*667(4182*4186*)))119(1(86(461(237(482(3675*3680*)4164*)4406*)4869*)582(936(452(2987*2991*)3448*)4386*))377(4594*522(4075*4080*)))1062(4037*4041*)120(157(4827*1029(3801*3805*))89(319(30(4555*845(1994(1718*1727*)3724*))4602*)67(4856*4859*)))338(1176(3622*3626*)158(679(3967*3972*)297(4357*198(4162*250(3914*3919*)))))335(333(105(94(4294*4297*)4394*)4504*)401(4438*4442*))703(259(365(3852*3856*)1178(3046*3051*))121(4369*4374*))123(5076*155(1404(3519*3524*)102(48(4781*4783*)4834*)))121(1(1(90(1648(3354*3361*)5011*)215(712(4176*1107(3071*3077*))4898*))157(634(289(4036*348(3691*3696*))30(4305*404(3905*3908*)))223(4756*4759*)))741(4401*289(4115*4121*)))215(439(4619*4622*)414(145(4504*4508*)1259(3396*3402*)))482(4809*543(542(3728*3732*)4277*))608(4695*4699*)216(66(60(159(45(4762*4765*)77(1617(3119*3128*)789(3958*3962*)))4989*)5052*)222(789(4109*4112*)2215(2688*2695*)))215(784(4350*4353*)329(87(449(44(4230*352(3882*3885*))4285*)56(4680*223(4462*4466*)))4835*))125(1(483(4771*572(4203*4206*))89(270(1442(3462*3466*)240(34(81(4557*4559*)4644*)1029(3651*3656*)))5197*))5289*)287(536(47(625(3920*3927*)4555*)492(4113*4117*))667(30(4451*4453*)4487*))126(223(134(4959*186(391(4386*4389*)4783*))236(1036(3833*3839*)4877*))91(5247*70(115(42(966(4056*4062*)5030*)390(4685*4687*))622(248(4325*4329*)4580*))))126(88(2(898(855(3521*3527*)98(4286*4290*))70(5218*440(4781*35(4748*276(4476*306(4173*4180*))))))5311*)1154(518(3729*3732*)4255*))354(134(943(102(4003*4007*)4114*)5061*)51(5146*5149*))287(5268*540(4731*829(3905*3909*)))1812(3754*3761*)129(5445*825(1821(2801*2806*)4631*))406(5180*5183*)130(963(4497*456(4046*4050*))327(5144*175(4971*390(165(178(4242*4245*)52(4374*4377*))4600*))))130(92(770(1339(3292*3298*)152(4487*4491*))5415*)231(5278*94(431(4755*4760*)83(375(4735*4738*)1031(4085*4090*)))))130(278(5252*199(5056*113(970(3975*3981*)4954*)))5546*)502(77(292(202(4604*4609*)4813*)1276(3832*3836*))5193*)223(2(72(64(1030(4305*4309*)5341*)402(254(4752*4756*)46(70(4897*2035(2864*2873*))585(4395*4398*))))274(282(488(4461*793(3672*3676*))345(4616*4618*))5249*))354(5173*5176*))1495(4259*4264*)132(1(5627*91(237(219(498(4584*896(3692*3698*))926(4168*4172*))385(4934*4938*))5562*))169(64(633(4790*2857(1935*1943*))333(5102*366(4739*4742*)))5508*))1898(3912*3917*)132(1(902(4781*322(4465*4469*))93(426(863(4313*4316*)165(5018*61(4959*4962*)))76(376(104(328(1318(3414*3420*)4740*)5072*)5178*)433(5124*5127*))))333(5399*118(40(629(4614*4620*)5251*)378(4916*483(4437*4441*)))))226(710(226(4724*4728*)708(4249*4254*))985(4689*4692*))133(329(1668(3774*3780*)5450*)93(5688*147(1011(4532*4539*)56(5496*5499*))))583(416(4930*780(4154*4158*))41(5316*298(5020*5025*)))134(5814*174(1354(4288*4292*)5649*))1330(4628*4633*)1468(1510(2986*2993*)488(4018*4022*))376(288(5315*5319*)148(48(533(4880*4883*)5419*)518(241(4712*4715*)4960*)))309(5694*768(4929*72(4860*261(4602*1096(3509*3517*)))))137(1(5886*95(5793*204(435(5156*324(4836*4838*))1142(235(4223*4226*)1443(3023*3029*)))))5916*)1985(4069*4074*)138(96(1258(4568*4572*)79(473(5280*18(36(5231*5233*)554(4719*4722*)))589(5181*5184*)))5950*)138(567(1126(4258*4264*)5392*)97(150(194(5520*427(5096*5100*))546(504(4673*4677*)5183(0*11*)))249(830(4813*4817*)1232(4417*4423*))))138(397(231(218(5156*5159*)5380*)41(297(170(805(4302*715(3590*3595*))5117*)5291*)5591*))6031*)138(1007(129(4896*4902*)5034*)1047(4996*44(4955*4959*)))138(100(602(780(4569*4574*)548(4808*4813*))444(287(146(5088*5091*)5240*)402(5129*5131*)))1906(206(3967*3972*)4185*))450(5780*5783*)323(5911*428(14(5472*5475*)5492*))1544(4700*4706*)141(181(1024(407(4498*4502*)4912*)73(55(1191(4620*4623*)5817*)188(219(5467*5472*)5694*)))6138*)141(521(1959(3659*3665*)5626*)103(6046*151(152(5745*5749*)231(681(764(4227*4233*)110(69(4821*4825*)4897*))5691*))))2288(4030*4038*)141(1(311(301(5573*296(212(5068*399(4673*4677*))5290*))276(5614*200(292(5124*5129*)5424*)))519(5694*524(5172*734(4443*4447*))))105(6122*1544(4580*4586*)))1088(5289*5293*)957(74(347(5004*5008*)5359*)24(176(5236*5239*)5420*))143(6259*754(616(4891*4894*)5514*))1937(4475*4480*)511(192(158(268(5289*318(669(4308*4312*)4984*))5572*)5734*)43(40(745(5100*5104*)5852*)5896*))251(152(55(5993*5996*)1939(4114*4119*))600(170(5442*5445*)2392(3225*3233*)))146(191(594(367(5179*5182*)5552*)65(6084*152(115(1159(4660*4664*)5825*)41(5903*110(36(798(4962*4966*)5766*)556(5250*5252*))))))367(1108(4894*353(4545*4553*))1857(4159*4164*)))144(1(1(106(649(5634*5638*)6289*)1081(5316*500(434(4384*4390*)4827*)))194(4035(2182*2189*)173(156(5898*429(5471*5475*))324(5738*536(5207*5210*)))))109(152(6179*375(419(5387*976(4416*4419*))5817*))214(667(1264(4201*4207*)5473*)6143*)))144(1501(4966*1124(3846*3851*))6478*)1078(93(160(416(4876*4883*)677(4624*4628*))5468*)5565*)145(110(151(1036(5202*5207*)158(6087*6091*))6402*)372(6142*991(5153*5158*)))145(110(90(491(150(5681*898(4786*4790*))33(165(5645*263(5385*5389*))5819*))6346*)410(6028*349(5682*578(5106*79(5033*5036*)))))680(5884*580(5307*5311*)))474(6243*6246*)1071(1747(3903*3911*)196(5466*5469*))147(264(1633(4693*4698*)6333*)423(387(5789*5792*)194(5989*2626(3365*3371*))))147(112(90(6413*6416*)980(128(108(315(4977*4981*)5299*)5413*)5543*))420(56(6161*301(5863*218(554(226(4869*4872*)5102*)5658*)))258(5979*164(5818*5821*))))2858(3953*3960*)260(412(6147*6150*)921(5643*5649*))352(129(6350*1783(4570*4574*))866(594(5029*5033*)118(5512*605(4909*4915*))))260(545(6052*6055*)91(6511*69(6445*499(5948*5952*))))672(289(1318(4593*4599*)5920*)75(384(5753*5755*)6143*))1508(62(5321*528(4796*4801*))5396*)152(1(331(6421*824(526(126(4948*4951*)5082*)5611*))267(982(5519*3228(2294*2304*))6516*))111(6675*91(6586*6589*)))2532(4412*4417*)153(110(158(216(1476(4837*4842*)451(5870*5873*))126(201(6215*6219*)735(5687*5690*)))454(1030(5227*5233*)328(426(5511*5516*)77(5867*548(5323*5327*)))))525(111(6210*117(165(5930*5935*)6102*))696(225(5412*5416*)5645*)))420(70(6530*6533*)400(371(5834*350(5490*5493*))6217*))2339(4699*4705*)155(6890*436(637(5819*5822*)673(5790*613(5180*5184*))))360(6702*1078(336(5291*5296*)5636*))788(2185(4102*4109*)69(160(6067*6070*)840(5393*5397*)))157(112(284(386(6156*6160*)798(5750*5755*))6839*)490(109(152(6202*6204*)750(5610*862(4751*4755*)))402(581(5496*5503*)131(5955*5959*))))157(205(6778*624(6157*6160*))1878(5113*580(4537*4544*)))1324(249(5587*5590*)863(4979*4984*))500(6672*6675*)159(742(6275*512(5768*5772*))595(970(5463*5466*)6440*))275(418(6502*6505*)1645(5280*5285*))367(68(1618(5153*5158*)6778*)655(451(5743*5746*)6200*))161(2880(596(3586*3594*)4194*)205(777(6094*6098*)139(1154(5585*5588*)187(482(6076*63(300(5715*5720*)6023*))6571*))))900(86(322(5956*5961*)288(5997*667(5333*5337*)))6383*)658(734(358(5534*5538*)1278(4620*4625*))186(6454*6457*))162(1(940(6199*25(6179*6182*))115(2(7032*88(6946*204(6745*1517(150(1450(3630*3637*)5090*)5248*))))7061*))281(6898*1407(5493*5498*)))659(792(5898*5901*)707(5989*5994*))163(408(1119(5671*5675*)314(623(5859*5863*)6489*))7213*)163(208(858(1028(5120*5127*)341(1542(4274*4279*)5824*))73(70(247(6636*6638*)6888*)182(6778*1844(4938*4943*))))7252*)163(915(560(5778*5783*)6345*)121(7141*694(898(846(4705*4712*)5561*)6463*)))283(90(7069*7072*)294(1550(5320*5324*)532(6344*6349*)))164(7295*209(2362(4726*4731*)7096*))164(118(2(1069(81(6036*6040*)450(5673*5679*))553(447(6200*6203*)210(273(685(5484*5490*)6178*)6454*)))171(180(6870*41(335(6498*187(29(6284*266(6022*6024*))6323*))932(5916*5919*)))318(1745(5011*5019*)6766*)))813(431(904(5227*1492(3739*3745*))6143*)6578*))164(118(169(75(54(49(6927*95(109(39(28(6660*6663*)210(6484*1085(5401*5406*)))6742*)210(897(5747*5752*)6654*)))7010*)7067*)1302(5842*5846*))7319*)606(6833*2441(4394*4401*)))378(811(6424*741(5686*5689*))148(639(6457*6460*)152(604(904(5442*5445*)6355*)1372(5590*5594*))))631(178(6836*64(106(6670*6672*)1688(5093*5097*)))847(6184*102(6084*6089*)))1057(6613*648(1115(4854*4858*)5976*))454(1075(6153*6159*)221(724(6291*6294*)1902(5119*5124*)))2367(5335*5340*)169(1613(174(5752*5757*)5934*)1162(6387*36(6354*6359*)))167(1(1(7558*121(7439*94(392(69(3061(3825*3835*)606(6292*6296*))6973*)1840(5528*5533*))))119(2(304(386(6780*161(6621*6626*))146(7029*7032*))94(7390*786(109(6498*1328(5172*5177*))924(5693*5699*))))7507*))7629*)167(1085(420(6125*6130*)6552*)121(96(155(1075(124(6068*506(5566*5571*))6204*)306(6976*6978*))7442*)1526(6014*6018*)))5249(2584*2593*)166(1(1(7675*371(393(6913*587(6329*49(6284*6287*)))572(6747*1309(215(5225*5231*)5450*))))303(581(6821*859(5964*5969*))7411*))801(364(6552*6555*)6924*))166(222(216(1404(5884*5889*)7295*)1057(6457*6460*))304(7437*675(6764*6769*)))1080(167(1192(5476*5480*)6676*)6847*)295(458(40(430(272(641(5792*5796*)276(6163*1589(4581*4586*)))156(36(6534*6536*)6577*))7165*)7208*)1356(6312*6317*))167(1(222(155(7424*1394(6033*6036*))313(7275*7278*))883(985(5947*908(5042*5049*))6944*))129(7701*94(7609*1769(5843*1231(4615*4621*)))))167(128(373(7344*7348*)318(183(811(6411*6415*)1680(5548*5553*))7418*))1162(232(6472*6476*)6714*))549(7495*7498*)296(2023(5729*5734*)2673(5086*5090*))1013(112(612(65(72(6186*6192*)6267*)6335*)935(6015*6019*))292(6776*6780*))860(64(58(7104*2004(5105*5111*))277(6899*6902*))7247*)615(614(6879*261(195(6426*6429*)6629*))439(7067*7071*))957(580(6589*6593*)425(6751*6754*))3450(4687*4696*)399(370(7378*1433(5948*5952*))7758*)554(7604*124(2334(5149*5153*)785(527(6179*6182*)6712*)))490(433(504(2711(4038*4045*)6758*)723(6542*1109(5436*5442*)))1345(6364*6368*))399(7805*369(1003(6436*6440*)7446*))1173(7042*7047*)958(645(6618*6621*)97(249(6923*1073(5854*5857*))7183*))180(126(2242(5691*5698*)7942*)444(7626*246(7382*336(7050*78(438(6537*6540*)734(6248*6253*))))))2785(5487*5492*)181(126(96(7875*7878*)7976*)317(7787*625(258(554(310(150(5892*5899*)6052*)6365*)6922*)7184*)))181(384(7743*338(7408*676(1950(4784*4790*)6744*)))687(668(6789*6791*)7463*))1150(1931(5251*5256*)655(6535*6542*))182(128(1373(455(445(5765*5771*)6219*)6678*)517(108(7428*425(7006*908(6100*6106*)))7549*))226(334(7636*7639*)158(866(6952*6955*)7824*)))697(85(233(7376*496(6885*6888*))267(7353*426(171(1463(5295*5301*)6766*)494(6446*6450*))))7726*)311(192(60(7861*73(7791*490(7303*137(26(7144*7148*)903(125(6149*6152*)6284*)))))431(7518*7521*))1592(6554*6558*))2073(6389*6394*)697(7771*179(319(1259(6018*6022*)644(6640*6643*))7610*))186(8301*562(7741*2862(4882*4889*)))565(7935*7938*)187(128(99(8090*226(983(1015(5869*5873*)6891*)150(934(1150(5642*5649*)6801*)7738*)))193(856(636(6530*6534*)218(6954*6958*))239(2418(5377*5386*)7807*)))8369*)315(1118(361(6763*306(6462*6465*))7135*)387(7868*86(60(246(143(7337*7340*)7487*)497(7238*592(6650*6653*)))345(7460*556(6906*6912*)))))416(852(7334*2392(4945*4951*))8198*)315(750(810(6740*6744*)494(7062*7067*))1905(6408*6412*))190(322(972(7149*7154*)8128*)1227(108(7117*7120*)616(6618*479(6142*6147*))))190(561(1377(6532*6536*)7916*)321(8158*2184(5976*5982*)))190(8488*129(8361*2616(5747*5752*)))189(1(463(1112(6923*6928*)363(30(7649*7654*)7687*))234(158(129(189(767(7038*7040*)236(7575*836(6741*275(6470*6474*))))2002(6012*6015*))1797(6352*6356*))775(7539*7542*)))8554*)515(708(406(2811(4304*4313*)7126*)127(805(6603*6606*)7415*))1548(6704*6708*))190(673(33(429(1226(6221*6226*)405(1002(6049*6053*)7058*))7896*)7931*)824(7782*31(7754*7759*)))190(134(636(1441(6404*6409*)1312(6540*6545*))8495*)8631*)190(1297(1789(5546*5552*)7344*)240(2139(6264*6268*)8410*))326(1098(7417*183(7238*1390(5850*5857*)))1477(62(6991*6994*)4151(2908*2916*)))191(8680*402(606(7674*66(306(7305*7310*)7618*))941(7352*408(6946*647(424(5879*5884*)6312*)))))327(489(586(305(7195*7201*)7508*)8097*)106(8482*93(143(8249*460(7791*7795*))201(8199*573(172(7458*7461*)7636*)))))192(906(2712(5127*5133*)7847*)135(267(736(7617*879(236(6506*6514*)6753*))73(8298*1009(7291*7295*)))643(805(7198*7202*)1067(6942*6948*))))434(564(7988*29(7962*7965*))8561*)193(687(1446(6670*6674*)1022(223(6877*6883*)7110*))8821*)193(337(2098(6387*6392*)8492*)1650(133(7048*7051*)7189*))3360(5673*5679*)191(1(1(1(138(105(8603*8606*)8713*)777(1265(587(6224*6228*)6822*)8089*))545(56(8268*87(332(7852*7856*)295(479(7416*7420*)7901*)))292(8051*8054*)))141(1081(7672*128(7546*212(7339*736(6606*6610*))))202(70(1016(1221(6260*6266*)7489*)8508*)854(7726*768(6962*6967*)))))8935*)4640(4487*4494*)442(1145(7548*1515(6036*6040*))93(8610*616(7996*333(7667*334(121(7214*7221*)193(7152*7156*))))))607(78(252(8231*335(22(7878*7880*)451(7454*657(6801*6806*))))8503*)8584*)194(1019(7979*672(7311*7314*))9007*)338(1190(1900(501(5273*5281*)5786*)7689*)106(8775*93(148(296(8241*486(7757*7761*))64(8481*57(8428*1300(7131*7134*))))1998(6707*6712*))))337(1956(6955*6959*)2369(6548*6555*))196(248(690(2013(6115*6120*)8135*)1961(6867*6871*))702(8380*441(7941*7946*)))338(276(753(430(7489*7493*)28(7899*310(7593*7595*)))493(869(7327*7330*)8204*))937(8038*1282(6759*359(6403*6409*))))197(9129*141(8990*205(211(8576*8580*)1129(7664*7668*))))448(245(174(996(7478*457(7025*7029*))728(7757*4699(3060*3071*)))1232(7442*214(7231*7235*)))686(8243*1611(6634*6640*)))1638(1861(5887*5893*)131(7626*7629*))199(344(414(8442*8446*)8862*)908(2912(5388*5393*)8310*))198(1(142(108(456(569(7944*7948*)8519*)8978*)202(2408(6478*6482*)673(864(7355*7361*)8227*)))141(9105*358(1649(7100*7105*)755(559(7442*7446*)92(7915*1056(6865*6870*))))))807(8468*1246(7224*7229*)))198(142(424(109(8608*968(7643*7646*))141(8586*284(8304*398(7910*586(7327*7331*)))))9166*)9310*)3239(6270*6277*)199(433(201(233(8451*8454*)922(7768*3095(4677*4682*)))239(422(613(7629*717(6914*6919*))8252*)133(526(8018*957(7063*7069*))8554*)))2604(6757*1287(5474*5482*)))198(1(430(8944*200(429(462(7856*7858*)8324*)8756*))143(2(359(8884*667(8219*914(7310*985(6328*6332*))))115(9144*664(226(469(7788*2293(5497*5503*))8267*)8498*)))211(1096(7974*7977*)425(8650*1230(7424*7427*)))))1260(234(1592(6353*6359*)7956*)945(7247*7251*)))198(900(333(8224*8228*)8564*)9466*)3610(6055*6063*)776(101(8797*359(59(8382*592(7793*7797*))175(1257(7018*7022*)8282*)))57(8864*243(8624*930(1039(6658*6661*)7705*))))346(1804(7562*7565*)777(8594*826(1367(6406*6410*)7782*)))345(120(9267*9270*)2195(7197*7201*))201(1(1336(1323(6881*6887*)8212*)511(638(452(7949*283(7670*7674*))890(7521*7525*))892(3377(4786*4795*)8175*)))9581*)347(216(1080(8140*8145*)511(8716*8719*))434(9014*9018*))202(1316(8282*253(1110(6923*6926*)1311(6729*6734*)))360(9256*1304(7954*7960*)))202(9625*2145(7482*366(7119*7124*)))202(737(285(8614*8618*)1244(274(7387*7392*)7670*))516(9137*279(8860*8864*)))201(1(273(88(284(2053(6962*6966*)746(8276*337(7945*1765(6182*6187*))))9321*)1228(8184*8187*))514(1029(8147*3303(4846*4854*))9188*))273(1649(7783*7786*)184(1335(7919*7922*)545(8715*1391(7326*326(7006*473(6537*6542*)))))))996(8940*8944*)202(9739*2175(107(7459*7463*)7575*))1226(8727*8731*)359(943(8656*8660*)210(481(39(8875*8878*)2087(6832*6840*))151(1132(8127*365(1519(6246*6251*)7774*))802(8471*8475*))))204(154(441(9199*9203*)9646*)151(2(1017(70(8562*54(1923(6588*6594*)8519*))8646*)124(183(539(1105(7714*7720*)8827*)1249(8120*8123*))796(543(8219*266(7957*7960*))149(8622*733(621(7273*7276*)7901*)))))124(9583*93(1128(8365*274(8093*8098*))768(260(8474*8480*)327(8416*8419*))))))3780(6307*6313*)570(296(617(8611*8614*)1172(8062*8067*))2078(7459*7463*))356(123(9633*9636*)569(9192*1330(7865*548(7320*7327*))))207(9924*272(2715(6939*6943*)1103(8558*216(8344*8348*))))1374(384(8389*586(7808*7813*))8786*)208(807(9146*1984(7166*7170*))151(9812*3124(6690*6699*)))2442(7741*7746*)208(1(1446(1556(6978*6983*)8542*)1218(1246(7526*7529*)475(8305*8307*)))472(390(250(806(8085*8089*)8899*)9151*)9544*))1112(56(1850(7207*7213*)9066*)9125*)363(855(1350(7670*7676*)743(8285*8289*))124(257(77(9431*9435*)1275(270(7969*7973*)8246*))393(9388*990(8401*8404*))))4412(5863*5871*)363(223(1495(297(7906*7909*)621(7588*7592*))233(1655(777(7045*7050*)7830*)9489*))577(9370*9373*))1025(9289*9293*)213(372(100(308(121(9205*87(4073(5048*5054*)9132*))9342*)535(369(8749*168(1113(674(6796*6801*)7479*)8595*))1012(8122*8128*)))9777*)151(10000*3527(6475*6480*)))1564(8808*8812*)213(1(1952(8211*562(7656*7660*))809(705(8662*8665*)827(8547*8549*)))968(135(347(8738*1623(7118*7124*))495(2663(5938*5945*)695(7915*7919*)))334(8913*8916*)))496(258(1197(8481*8487*)135(1735(7816*7820*)9558*))9954*)214(376(100(9761*9764*)1418(55(8393*8398*)8456*))281(192(312(94(9373*2004(7371*7377*))388(738(8351*8354*)114(144(8837*8843*)8990*)))767(9040*9042*))1062(8942*363(2594(5989*5994*)1687(6903*6909*)))))213(1(279(687(538(8799*8802*)9343*)264(9769*540(9231*19(9216*1044(8174*180(8000*8003*))))))781(9550*1213(240(8099*8104*)8347*)))624(56(9664*9667*)9727*))373(120(2292(155(7625*7630*)7788*)10083*)222(830(9153*9156*)6543(3445*3455*)))372(2765(7457*7461*)994(9234*9238*))694(9911*9914*)216(623(9770*3150(6624*6629*))10404*)3360(7261*7266*)217(754(9656*328(161(358(8812*861(7954*7960*))9181*)210(9136*397(8742*96(107(8543*199(8347*8350*))167(642(7850*7856*)8500*))))))159(627(861(191(339(8277*8282*)427(8198*8201*))8823*)648(9038*9044*))588(9733*9736*)))217(551(1021(8912*8917*)9940*)896(81(9516*1791(7728*7733*))1137(8470*8474*)))217(386(302(3713(6107*6113*)724(97(9008*9011*)341(8769*8775*)))10144*)287(905(9340*9343*)2336(7915*860(7058*7064*))))379(466(9920*9924*)682(100(9610*1443(8170*8173*))9720*))218(10564*287(200(66(2236(7777*1055(6726*6734*))10027*)409(9687*9689*))1841(8460*83(8381*8384*))))4657(6157*6164*)504(469(9849*739(9113*9116*))10327*)1592(191(954(8095*8099*)1654(7402*7408*))560(8697*8700*))2214(8639*8644*)384(2645(7830*7834*)229(238(10014*10018*)704(9554*9558*)))223(283(10370*1545(1693(7135*7139*)53(8783*532(8253*599(7661*7664*)))))1406(326(8946*8950*)9280*))713(10197*10200*)224(162(1487(9041*9046*)396(797(9342*9345*)1982(1353(6809*6816*)8172*)))1052(1274(8388*8391*)645(9025*1554(7473*7478*))))223(1(703(1455(8572*8576*)10034*)1311(2242(7186*7190*)484(8953*8956*)))165(10589*1019(9572*9576*)))1316(9668*9672*)860(127(236(3514(6252*6262*)78(173(9528*9531*)551(1221(7934*7939*)9162*)))2287(7743*7748*))10166*)225(398(95(10309*10312*)511(52(533(1073(8240*8244*)9320*)1012(8844*3460(5386*5394*)))9920*))165(10666*326(1075(541(8726*8730*)9274*)10352*)))932(1654(8483*8488*)578(1784(7783*7787*)989(8584*8589*)))1222(362(9505*9508*)476(9397*9403*))227(1181(745(8949*268(8686*8689*))693(9013*9016*))10892*)522(1018(9580*1161(247(8177*8181*)120(8312*8316*)))870(9748*2811(6939*6944*)))628(660(9860*167(9698*555(9146*9149*)))1218(9315*9320*))395(1382(9390*9393*)326(335(2798(7318*7324*)10124*)10462*))230(293(10661*5212(5452*5459*))165(408(10393*1130(1400(7865*7873*)139(9136*9140*)))480(268(835(9236*9240*)1391(440(8246*8251*)8694*))1428(69(8860*8863*)8935*))))230(569(1443(8997*9002*)10447*)165(237(656(1445(8515*8519*)9969*)761(1065(8801*8805*)274(9598*9602*)))613(10263*10266*)))3588(7687*7694*)527(972(9784*3371(6416*6421*))10767*)396(332(10567*222(193(10155*2021(8136*8143*))170(90(10100*497(9606*9608*))796(286(9117*9120*)9409*))))483(10448*1776(222(8454*8457*)8684*)))233(162(1757(9188*9192*)10951*)404(10711*3650(7063*7070*)))1659(911(8788*8791*)1107(8599*8604*))730(10641*149(2309(8186*8189*)196(710(1610(7986*7990*)9603*)781(9534*9539*))))397(2016(8983*8987*)136(104(90(1337(965(8373*8381*)9348*)10688*)10780*)1815(9072*1598(7478*7482*))))236(2050(619(8524*8530*)9151*)1382(502(9319*1295(8027*8032*))1593(8239*8245*)))1023(281(10153*459(9699*9702*))106(1561(8778*8781*)10346*))237(11239*645(1149(9447*9451*)1027(9577*80(9499*9503*))))234(1(1(1(2369(1057(7830*7835*)8895*)1176(10090*427(2139(7526*7534*)9676*)))167(11115*136(10981*1021(9963*99(589(685(2980(5612*5618*)8601*)9291*)9884*)))))410(10900*483(10419*2553(7870*7873*))))1265(10057*1033(9027*9033*)))539(1661(1253(8113*8118*)9373*)694(42(10301*10304*)10349*))1594(9989*9994*)236(170(569(2109(8505*8509*)646(1104(8871*104(1559(7212*7216*)8779*))770(9220*9227*)))11214*)11386*)541(108(763(3612(6599*6606*)563(356(9301*9304*)665(8998*9003*)))96(10900*91(10812*10814*)))433(10679*64(10618*345(10276*734(9544*9550*)))))1233(10435*938(1108(8392*8396*)9508*))238(1166(10276*97(243(9940*1750(8192*8198*))10194*))11459*)238(304(108(486(10562*10566*)536(362(10156*1023(9136*1167(7974*7981*)))595(9940*139(9805*9807*))))2218(8970*8973*))868(745(9884*645(9242*9248*))383(599(9658*210(9451*9454*))10267*)))4072(7685*7690*)239(1093(10431*2426(8010*8015*))175(427(1207(9727*1092(8637*8642*))199(10744*10747*))492(10883*10887*)))413(1323(517(9541*186(9360*9363*))10070*)241(451(869(9834*9837*)482(4483(5743*5753*)245(9993*548(9448*639(8813*8817*)))))101(11083*11086*)))412(2484(8946*8951*)4076(7361*7366*))1908(9947*9952*)242(512(547(1308(9252*9255*)31(10535*1837(8703*8706*)))644(10480*93(10389*2628(7765*7770*))))11649*)242(414(2693(8543*8549*)11244*)171(2(11487*139(11350*1618(52(9683*490(9195*9200*))2343(7402*7409*))))1290(10223*1345(8881*526(8359*8364*)))))996(258(10685*10688*)1044(9905*9910*))554(204(11193*355(10841*10843*))1793(581(9031*9035*)1025(8594*4719(3878*3887*))))243(1(170(641(10924*10927*)507(478(342(10243*10247*)1084(9507*346(9165*9168*)))73(11007*11010*)))615(11147*1284(2021(7844*7850*)9873*)))171(11604*1888(122(9596*9603*)774(8954*8959*))))413(144(11479*11482*)2981(8647*8651*))1650(10396*333(765(9303*9306*)122(1117(8835*8840*)9961*)))764(11303*11306*)414(4814(6843*6850*)2164(9502*9505*))927(753(235(10169*10174*)26(10386*2164(8225*8229*)))11176*)1820(10284*10288*)562(11547*113(593(2148(8696*8700*)10851*)193(643(82(262(1009(9257*9264*)10275*)446(10094*10097*))10629*)1407(9867*9872*))))250(1078(1922(8898*8903*)10828*)11908*)250(168(351(239(123(1553(9475*9480*)1096(9939*9943*))1388(1257(8520*8526*)9785*))1131(10284*885(9402*9406*)))11775*)167(848(149(561(10220*2655(7567*7574*))10792*)10944*)148(11646*203(1703(9743*9746*)11452*))))249(1(829(2055(9087*2165(6930*6936*))117(2477(8565*8568*)619(10430*10432*)))167(1094(125(467(250(268(9628*9632*)9905*)1826(8331*8336*))10631*)10760*)264(193(720(10679*10682*)1326(10078*10084*))11605*)))317(446(11276*11279*)11728*))248(1(693(311(2442(8600*8605*)11049*)3730(7634*7638*))624(1850(9589*303(9289*9295*))11450*))2572(9505*3523(5985*5993*)))3305(9032*9036*)249(1916(2123(8054*8059*)10186*)12104*)1086(422(170(10676*10681*)10853*)504(10774*983(9794*9798*)))1392(100(10880*834(10050*10053*))658(10334*885(9452*9456*)))2445(9947*9952*)252(12146*694(843(10611*10615*)1570(992(8900*8904*)9900*)))252(1568(460(383(9754*9758*)909(9235*9239*))162(3412(7036*7045*)10459*))324(777(11090*11093*)117(90(372(11294*11296*)97(11574*144(1080(10352*10357*)190(48(1499(9703*9706*)11207*)11259*))))1712(1599(8471*8475*)1127(8950*8956*)))))6430(6059*6066*)253(322(11922*1016(10909*10912*))440(11812*3657(8157*8163*)))253(12261*533(1112(1072(9546*389(9161*9166*))10629*)167(307(95(93(11082*484(10600*10606*))614(74(10498*214(10287*10290*))10583*))1359(472(9463*9467*)9942*))11612*)))253(323(1162(430(10398*10402*)10835*)1215(10785*10789*))12329*)437(1330(938(1337(8541*8548*)9888*)10829*)139(12022*528(405(1383(9709*9712*)869(117(10113*10115*)422(9815*9818*)))11517*)))3248(9374*9379*)789(655(782(10402*2174(8231*8236(0*12*)))11206*)11864*)256(182(2568(9648*9653*)263(469(143(11348*11351*)2644(8852*8859*))11974*))640(1439(789(9553*9556*)10349*)999(10791*10795*)))256(182(261(342(380(11270*11275*)3039(8619*8623*))990(3827(7189*7195*)767(10257*10260*)))142(689(846(10603*10608*)241(11215*1765(9454*9457*)))4266(7889*7894*)))12486*)2926(9817*9824*)580(2084(10087*1434(8657*8663*))12184*)258(444(2043(10020*10024*)911(1222(9936*9941*)11166*))12523*)442(1608(118(1454(9160*9166*)10622*)10743*)259(2456(9638*9644*)101(12001*103(142(1558(838(9363*9366*)10208*)1264(10505*10509*))826(11091*11096*)))))582(798(1162(10286*10289*)11454*)12255*)4887(7951*7957*)259(1(1(2166(2047(8371*8379*)10429*)991(439(11167*11169*)2884(8728*8732*)))722(64(11824*11827*)207(11688*684(29(10977*329(10652*10654*))236(10780*10783*)))))1510(11125*1702(9426*9433*)))258(1(12646*189(138(120(202(70(636(11293*424(1855(9017*9022*)248(789(9842*9846*)10637*)))155(116(1141(943(9594*337(9262*9266*))10548*)1258(10435*10437*))840(32(10942*10945*)10983*)))617(11433*11437*))12258*)12381*)12521*))3658(9055*1725(7333*7340*)))586(463(639(11294*11297*)11939*)226(2688(9491*9494*)97(12088*225(317(11548*1204(10349*10352*))11876*))))1196(3343(8472*8479*)198(1606(10020*10024*)1967(9666*9671*)))3223(9810*9814*)260(1(1354(11423*978(10449*10453*))1921(10866*2372(420(8076*8085*)8509*)))193(12612*1424(11190*11194*)))2912(10160*10165*)1259(1110(1347(9362*9367*)111(10606*2509(8100*8104*)))343(11495*226(11271*27(11247*974(10277*10283*)))))2234(10879*10883*)590(3(12525*321(477(11730*299(11434*287(11150*779(10373*10379*))))1205(2114(8904*8909*)11026*)))12558*)264(556(12329*2214(222(9896*720(9179*9186*))10132*))12904*)2558(10611*10616*)265(12910*195(264(2421(410(9622*9626*)10041*)785(935(10744*10749*)785(10901*10905*)))2239(10502*10506*)))2344(10862*10868*)265(1(12947*195(135(3399(9220*9225*)614(1740(10273*467(9809*9813*))964(11058*11063*)))12778*))12976*)265(463(3542(8972*8978*)12522*)197(12790*2180(10612*10619*)))727(201(3703(8631*8636*)1176(766(417(9982*9986*)10408*)11177*))1057(11499*11504*))265(1(196(926(11901*11904*)875(225(1508(10224*715(9514*9517*))11744*)143(11828*1700(10133*10137*))))195(265(110(245(81(116(1253(10788*10790*)703(11344*11346*))12168*)542(3465(8245*8251*)11718*))12508*)1700(10920*10924*))468(1155(11268*11271*)1029(4935(6464*6473*)11410*))))1560(229(11316*935(10384*10388*))423(11132*11136*)))925(98(12362*138(2161(10067*10071*)1450(10785*1446(9341*9346*))))553(236(11691*2615(9079*9083*))11939*))1562(11856*11860*)463(3012(9948*9953*)145(1179(74(11569*441(11131*11133*))715(10938*413(10528*919(9612*9617*))))12846*))462(1159(2019(9815*9820*)2729(9112*9121*))934(12077*1296(10784*2456(8331*8337*))))269(13217*193(13026*382(1343(11303*218(11090*11093*))12657*)))608(3(12891*624(1125(11145*488(10661*10664*))306(3186(8787*8794*)1486(828(9668*9672*)10503*))))12925*)462(569(4867(3268(4368*4376*)7649*)12520*)145(132(358(258(360(11838*247(11594*622(10974*10979*)))40(12170*12173*))960(11514*11520*))1505(899(10436*10440*)11341*))565(2945(9471*9475*)12423*)))1443(346(1003(10804*10810*)2970(8845*8849*))500(11668*11672*))272(466(110(12768*454(616(566(11135*2722(8415*8422*))744(10970*726(10247*10250*)))12340*))12906*)1904(11470*1519(9954*9959*)))272(192(144(631(4712(7704*7710*)12424*)13058*)13204*)467(12931*207(2955(9771*9779*)156(1963(10617*10620*)3322(9264*9269*)))))2741(10953*10957*)273(2282(11144*337(10812*10816*))337(128(115(325(463(12069*671(976(10424*10430*)11408*))328(214(12003*12006*)2056(10169*10172*)))12884*)13001*)797(2316(10019*10023*)385(11957*1629(10330*10336*)))))273(13485*195(13292*1693(206(11395*11399*)2017(9591*9596*))))467(1596(11712*11718*)1999(11317*11321*))1050(1081(506(361(10790*10795*)11158*)3147(8520*8526*))12758*)467(390(12952*857(3124(8974*8978*)12106*))1957(11398*11401*))275(1(190(2639(485(10236*10243*)645(10086*10090*))151(13225*955(470(212(11591*11593*)11809*)1141(503(10637*10642*)11149*))))1046(558(11984*11987*)2133(10416*10419*)))191(13410*5589(7823*7832*)))2540(11348*11353*)276(2662(10956*1033(9927*9931*))344(344(12940*156(72(1598(1710(9406*9412*)11124*)12725*)12800*))13303*))276(192(1052(791(11613*1308(10309*10312*))12416*)493(306(652(12019*12022*)5938(6738*6745*))12991*))590(195(1550(11343*11346*)1980(10920*10923*))13101*))1400(552(2042(9974*9979*)1407(10618*10622*))1743(10840*10847*))622(2262(11107*368(10742*10746*))13379*)1631(12371*12375*)2137(108(11762*11767*)2121(9757*9761*))278(1(1(192(491(162(757(1924(10214*10219*)805(11341*11344*))394(12515*12520*))852(233(11993*11997*)565(11667*11671*)))13581*)484(13291*634(4738(7921*7929*)12669*)))592(807(57(791(11543*11546*)12341*)12400*)1562(333(220(11095*11098*)11325*)11662*)))13819*)1342(12756*12760*)764(306(2326(1551(9156*9161*)10715*)963(12082*2009(10075*10080*)))1723(356(11281*240(594(10451*10455*)11052*))1814(9836*9843*)))280(13865*592(1136(2957(9182*9187*)588(11560*11563*))13290*))280(198(590(13095*13099*)493(244(12954*12957*)634(633(11936*11941*)12576*)))856(541(140(1116(11250*2047(9207*9214*))506(11873*11877*))58(12467*12471*))1532(11541*11544*)))280(1611(12322*320(12007*12010*))1126(739(12078*1411(10670*10674*))3211(9615*9621*)))280(200(2952(10807*10813*)13767*)490(13479*580(12901*12905*)))2381(362(1597(9916*9920*)1345(10176*10182*))651(11240*11244*))281(356(3(13637*578(80(225(12757*80(1619(11061*11065*)8089(4597*4608*)))13004*)1908(11179*11182*)))243(96(13335*13337*)196(1742(11498*11501*)3284(9963*9969*))))1850(12200*3363(8839*8845*)))281(14059*203(490(690(1229(11449*694(1067(9691*9697*)10768*))12695*)1611(11776*11780*))734(13149*81(13071*181(414(12478*423(12060*12062*))968(11934*532(11406*11410*)))))))880(13511*13514*)1829(2091(10475*754(9728*9732*))12580*)485(292(2585(11048*11054*)1723(11918*11921*))2171(11767*11772*))3764(10665*10670*)644(13791*1336(1280(11178*11182*)573(1847(10045*10049*)11902*)))486(1733(12237*12240*)1270(12705*968(11741*898(10845*10850*))))287(1248(1634(11304*11309*)12946*)935(146(60(13055*13057*)2580(10541*10544*))794(12479*779(11704*11711*))))287(200(1558(1459(11003*1209(9798*9802*))12474*)14034*)14236*)287(1849(2970(9418*9425*)12397*)363(1178(12707*12710*)137(13754*379(411(816(478(11672*11676*)12156*)12977*)1779(11612*11616*)))))286(1(3895(10380*259(10126*10129*))203(606(439(13037*13040*)1220(711(11552*948(10607*10613*))983(11291*11296*)))14107*))14313*)286(204(298(5596(8216*8224*)207(170(817(12628*12631*)471(814(12166*12170*)487(12499*12503*)))2827(10806*10811*)))14145*)1216(789(1248(11098*11101*)357(11997*11999*))1622(2031(9495*9499*)11536*)))902(13759*13762*)656(14009*1263(183(125(4189(8252*8258*)12450*)12577*)12765*))2714(722(11249*11253*)2456(9522*9527*))289(204(298(907(13000*13004*)2897(11016*11024*))506(1516(12199*12202*)332(1449(11939*11944*)13395*)))203(165(449(2745(10877*10881*)1281(461(11888*11891*)180(12176*12178*)))14091*)4011(10247*10252*)))289(2330(3049(9088*9096*)12148*)1258(13222*1376(652(11197*11201*)151(11704*11708*))))287(1(1(3962(558(9974*9980*)10542*)506(534(13466*67(13401*13405*))14008*))372(799(293(98(12955*367(12591*12597*))1503(11561*11566*))13364*)989(271(72(1481(11353*408(10948*10952*))12844*)12921*)13194*)))627(90(791(1376(11674*11679*)13059*)13852*)13945*))287(3773(216(10584*10590*)10810*)14585*)4544(10329*10335*)500(759(13621*13624*)616(13769*13773*))289(2015(1073(11513*11517*)159(12434*1148(11290*11294*)))14618*)7723(7185*7194*)502(6026(8390*8395*)166(14257*447(1593(1199(11021*11024*)1589(10639*10642*))290(245(202(13091*1900(11194*11198*))13302*)13551*))))2518(253(12186*12189*)988(11458*11464*))292(210(1294(1038(65(12072*12076*)12143*)13185*)14481*)209(1495(1047(253(11689*11692*)11951*)397(12604*12607*))843(1630(12028*12032*)2978(10686*10691*))))291(1(1785(145(12792*12798*)12947*)209(311(14214*206(2920(11090*11095*)2199(11818*11821*)))1230(849(3203(9257*9263*)12468*)379(28(12914*12916*)2496(10452*10456*)))))209(174(804(891(12695*264(12433*12439*))1206(12390*3116(9278*9283*)))137(120(1004(13151*13153*)14160*)311(13971*13975*)))1049(13550*909(12644*5373(7273*7281*)))))499(4426(10188*10192*)175(256(1378(2317(10494*10503*)12823*)1281(12923*12925*))542(13923*64(13862*13865*))))292(1060(2793(11001*11007*)13802*)3047(2004(9813*9818*)11826*))292(208(1232(13434*1434(516(11488*11491*)12013*))14681*)524(973(13394*2032(11364*11369*))733(13643*532(13114*1373(11745*11750*)))))292(385(1519(13009*757(12256*12258*))1196(13341*13344*))2479(12448*59(2133(10259*10267*)62(12340*136(12207*554(592(2504(8560*8566*)11073*)11669*))))))1032(98(14122*810(589(12727*12731*)13323*))398(13835*13839*))293(210(781(13986*13989*)175(140(844(13613*3321(10297*411(9889*9895*)))14473*)1628(12988*12991*)))15006*)677(549(1361(1132(11581*136(11451*11454*))12725*)14089*)266(1081(13294*13297*)558(13823*1881(2519(9425*9433*)819(11136*11140*)))))2385(12957*12962*)295(15053*840(2358(11857*11861*)14223*))942(14417*427(13993*192(1652(1493(10658*10663*)12161*)13816*)))296(2354(12728*968(11766*11769*))384(2070(12639*12642*)2021(12694*3228(9469*9475*))))296(838(14271*1339(12936*12939*))531(14587*2483(12106*12111*)))944(2201(12277*608(301(175(11196*11200*)11382*)11686*))103(14395*581(1376(12440*12444*)468(13355*13358*))))4462(10993*11000*)514(2564(12385*12389*)2013(12942*12946*))828(115(14531*568(168(347(13451*13454*)770(498(12538*12542*)13043*))202(1174(12607*12612*)597(1116(12075*12078*)520(12677*12682*)))))938(13748*13752*))514(3143(11862*11866*)793(14218*2778(11443*1404(10042*10051*))))687(1279(13575*1956(11622*11627*))1139(13726*3255(10473*10478*)))8073(7487*7494*))"


The only difference between easy and hard versions is the number of elements in the array.You are given an array $$$a$$$ consisting of $$$n$$$ integers. In one move you can choose any $$$a_i$$$ and divide it by $$$2$$$ rounding down (in other words, in one move you can set $$$a_i := \lfloor\frac{a_i}{2}\rfloor$$$).You can perform such an operation any (possibly, zero) number of times with any $$$a_i$$$.Your task is to calculate the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.Don't forget that it is possible to have $$$a_i = 0$$$ after some operations, thus the answer always exists.

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 50$$$) — the number of elements in the array and the number of equal numbers required. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$), where $$$a_i$$$ is the $$$i$$$-th element of $$$a$$$.

Print one integer — the minimum possible number of operations required to obtain at least $$$k$$$ equal numbers in the array.

import kotlin.math.*
fun main() {
    var (n, m) = readLine()!!.split(" ").map { it.toInt() }
    var vals = readLine()!!.split(" ").map { it.toInt() }.sorted()
    var cnts = IntArray(200005, { 0 })
    var answ = IntArray(200005, { 0 })
    for (i in 0 until n) {
        var curr = vals[i]
        var indx = 0
        while (curr > 0) {
            if (cnts[curr] < m) {
                cnts[curr]++
                answ[curr] += indx
            }
            curr /= 2
            indx++

        }

    }
    var result = Int.MAX_VALUE
    for (i in 1..vals[n - 1]) {
        if (cnts[i] == m) result = min(result, answ[i])
    }
    println(result)
}

/*

 */


The only difference between easy and hard versions is the length of the string.You are given a string $$$s$$$ and a string $$$t$$$, both consisting only of lowercase Latin letters. It is guaranteed that $$$t$$$ can be obtained from $$$s$$$ by removing some (possibly, zero) number of characters (not necessary contiguous) from $$$s$$$ without changing order of remaining characters (in other words, it is guaranteed that $$$t$$$ is a subsequence of $$$s$$$).For example, the strings "test", "tst", "tt", "et" and "" are subsequences of the string "test". But the strings "tset", "se", "contest" are not subsequences of the string "test".You want to remove some substring (contiguous subsequence) from $$$s$$$ of maximum possible length such that after removing this substring $$$t$$$ will remain a subsequence of $$$s$$$.If you want to remove the substring $$$s[l;r]$$$ then the string $$$s$$$ will be transformed to $$$s_1 s_2 \dots s_{l-1} s_{r+1} s_{r+2} \dots s_{|s|-1} s_{|s|}$$$ (where $$$|s|$$$ is the length of $$$s$$$).Your task is to find the maximum possible length of the substring you can remove so that $$$t$$$ is still a subsequence of $$$s$$$.

The first line of the input contains one string $$$s$$$ consisting of at least $$$1$$$ and at most $$$200$$$ lowercase Latin letters. The second line of the input contains one string $$$t$$$ consisting of at least $$$1$$$ and at most $$$200$$$ lowercase Latin letters. It is guaranteed that $$$t$$$ is a subsequence of $$$s$$$.

Print one integer — the maximum possible length of the substring you can remove so that $$$t$$$ is still a subsequence of $$$s$$$.

fun main() {
    val s = readLn()
    val t = readLn()

    val rg = run {
        val res = IntArray(t.length)

        var ti = t.lastIndex

        for(si in s.indices.reversed()) {
            if(t[ti] == s[si]){
                res[ti] = si
                ti--
            }
            if(ti < 0) break
        }

        res.asList()
    }

    val ans = sequence {
        var si = -1
        for(tr in t.indices) {
            yield(rg[tr] - si - 1)
            do { si++ } while(s[si] != t[tr])
        }
        yield(s.lastIndex - si)
    }.max()!!

    println(ans)
}

fun readLn() = readLine()!!
fun readInt() = readLn().toInt()
fun readDouble() = readLn().toDouble()
fun readLong() = readLn().toLong()
fun readStrings() = readLn().split(' ')
fun readStringSeq() = readLn().splitToSequence(' ')
fun readInts() = readStrings().map { it.toInt() }
fun readIntSeq() = readStringSeq().map { it.toInt() }
fun readDoubles() = readStrings().map { it.toDouble() }
fun readDoubleSeq() = readStringSeq().map { it.toDouble() }
fun readLongs() = readStrings().map { it.toLong() }
fun readLongSeq() = readStringSeq().map { it.toLong() }

class Output {
    private val sb = StringBuilder()
    fun print(o: Any?) { sb.append(o) }
    fun println() { sb.append('\n') }
    fun println(o: Any?) { sb.append(o).append('\n') }
    @JvmName("_print") fun Any?.print() = print(this)
    @JvmName("_println") fun Any?.println() = println(this)
    fun nowPrint() { kotlin.io.print(sb) }
}
inline fun output(block: Output.()->Unit) { Output().apply(block).nowPrint() }


Arkady decided to buy roses for his girlfriend.A flower shop has white, orange and red roses, and the total amount of them is n. Arkady thinks that red roses are not good together with white roses, so he won't buy a bouquet containing both red and white roses. Also, Arkady won't buy a bouquet where all roses have the same color. Arkady wants to buy exactly k roses. For each rose in the shop he knows its beauty and color: the beauty of the i-th rose is bi, and its color is ci ('W' for a white rose, 'O' for an orange rose and 'R' for a red rose). Compute the maximum possible total beauty of a bouquet of k roses satisfying the constraints above or determine that it is not possible to make such a bouquet.

The first line contains two integers n and k (1 ≤ k ≤ n ≤ 200 000) — the number of roses in the show and the number of roses Arkady wants to buy. The second line contains a sequence of integers b1, b2, ..., bn (1 ≤ bi ≤ 10 000), where bi equals the beauty of the i-th rose. The third line contains a string c of length n, consisting of uppercase English letters 'W', 'O' and 'R', where ci denotes the color of the i-th rose: 'W' denotes white, 'O'  — orange, 'R' — red.

Print the maximum possible total beauty of a bouquet of k roses that satisfies the constraints above. If it is not possible to make a single such bouquet, print -1.

NoteIn the first example Arkady wants to buy 3 roses. He can, for example, buy both red roses (their indices are 1 and 2, and their total beauty is 7) and the only orange rose (its index is 3, its beauty is 4). This way the total beauty of the bouquet is 11. In the second example Arkady can not buy a bouquet because all roses have the same color.

import java.io.PrintWriter
import kotlin.math.*

fun main() {
    io.apply done@ {

        val n = int
        val k = int

        val d = ints(n)
        val colors = str(n)

        val red = (0 until n).filter { colors[it] == 'R' }.map { d[it] }.toIntArray()
        val orange = (0 until n).filter { colors[it] == 'O' }.map { d[it] }.toIntArray()
        val white = (0 until n).filter { colors[it] == 'W' }.map { d[it] }.toIntArray()

        if (k < 2 || orange.isEmpty() || (red.isEmpty() && white.isEmpty())) {
            cout .. -1 .. nl
            return@done
        }

        fun compose(a: IntArray, b: IntArray): Int {
            if (a.size + b.size < k || a.isEmpty() || b.isEmpty())
                return -1
            var ia = 1
            var ib = 1
            var res = a[0] + b[0]
            repeat(k - 2) {
                if (ia == a.size)
                    res += b[ib++]
                else if (ib == b.size)
                    res += a[ia++]
                else {
                    if (a[ia] > b[ib])
                        res += a[ia++]
                    else
                        res += b[ib++]
                }
            }
            return res
        }

        red.sortDescending()
        orange.sortDescending()
        white.sortDescending()

        val ans = max(compose(red, orange), compose(white, orange))
        cout .. ans .. nl

    }.cout.flush()
}

// @formatter:off
private val io = object {
    private val `in` = System.`in`
    private fun ll(): Long {
        var x: Int; var q = false; var n = 0L; do x = `in`.read() while (x < 33); if (x == 45) { q = true; x = `in`.read() }
        do { n = n * 10 - x + 48; x = `in`.read() } while (x > 32); return if (q) n else -n
    }
    val int get() = ll().toInt(); val long get() = ll()
    fun ints(n: Int = int): IntArray { return IntArray(n) { int } }
    fun ints1(n: Int = int): IntArray { return IntArray(n) { int - 1 } }
    val cout = PrintWriter(System.out); val nl = "\n"
    private var buf = CharArray(32)
    private var bufSize = 32
    fun str(expect: Int = 32): String {
        var ix = 0
        var x: Int
        if (bufSize < expect)
            buf = CharArray(expect)
        do x = `in`.read() while (x < 33)
        do {
            if (ix == bufSize) { bufSize *= 2; buf = buf.copyOf(bufSize) }
            buf[ix++] = x.toChar()
            x = `in`.read()
        } while (x > 32)
        return java.lang.String.copyValueOf(buf, 0, ix)
    }
    operator fun PrintWriter.rangeTo(a: Int): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: Long): PrintWriter { print(a); print(" "); return this }
    operator fun PrintWriter.rangeTo(a: IntArray): PrintWriter { a.forEach { print(it); print(" ") }; return this }
    operator fun PrintWriter.rangeTo(a: String): PrintWriter { write(a); return this }
} // @formatter:on

/* ----------- */


There is a straight line colored in white. n black segments are added on it one by one.After each segment is added, determine the number of connected components of black segments (i. e. the number of black segments in the union of the black segments). In particular, if one segment ends in a point x, and another segment starts in the point x, these two segments belong to the same connected component.

The first line contains a single integer n (1 ≤ n ≤ 200 000) — the number of segments. The i-th of the next n lines contains two integers li and ri (1 ≤ li < ri ≤ 109) — the coordinates of the left and the right ends of the i-th segment. The segments are listed in the order they are added on the white line.

Print n integers — the number of connected components of black segments after each segment is added.

NoteIn the first example there are two components after the addition of the first two segments, because these segments do not intersect. The third added segment intersects the left segment and touches the right segment at the point 4 (these segments belong to the same component, according to the statements). Thus the number of connected components of black segments is equal to 1 after that.

/**
 * Created by yakutovd on 17.03.2018.
 */

import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.StringTokenizer
import java.util.TreeSet

/**
 * Created by yakutovd on 17.03.2018.
 */
fun main(args: Array<String>) {
    try {
        val out = PrintWriter(System.out)
        val br = BufferedReader(InputStreamReader(System.`in`))
        val n = Integer.parseInt(br.readLine())
        val set = TreeSet<Pair>()

        for (i in 0..(n - 1)) {
            val st = StringTokenizer(br.readLine())
            val l = Integer.parseInt(st.nextToken())
            val r = Integer.parseInt(st.nextToken())
            val pair = Pair(l, r)
            var L = l
            var R = r
            while (true) {
                val toRight = set.ceiling(pair)
                if (toRight != null && toRight.l <= r) {
                    L = Math.min(L, toRight.l)
                    R = Math.max(R, toRight.r)
                    set.remove(toRight)
                } else {
                    break
                }
            }
            while (true) {
                val toLeft = set.floor(pair)
                if (toLeft != null && toLeft.r >= l) {
                    L = Math.min(L, toLeft.l)
                    R = Math.max(R, toLeft.r)
                    set.remove(toLeft)
                } else {
                    break
                }
            }
            set.add(Pair(L, R))
            out.print(set.size.toString() + " ")
        }
        out.println()
        out.close()
    } catch (ex : IOException) {
    }
}

class Pair(internal var l: Int, internal var r: Int) : Comparable<Pair> {

    override fun compareTo(o: Pair): Int {
        return if (l != o.l) {
            Integer.compare(l, o.l)
        } else Integer.compare(r, o.r)
    }
}


Rikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of remarkable properties. Help Rikhail to convince the scientific community in this!Let us remind you that a number is called prime if it is integer larger than one, and is not divisible by any positive integer other than itself and one.Rikhail calls a number a palindromic if it is integer, positive, and its decimal representation without leading zeros is a palindrome, i.e. reads the same from left to right and right to left.One problem with prime numbers is that there are too many of them. Let's introduce the following notation: π(n) — the number of primes no larger than n, rub(n) — the number of palindromic numbers no larger than n. Rikhail wants to prove that there are a lot more primes than palindromic ones.He asked you to solve the following problem: for a given value of the coefficient A find the maximum n, such that π(n) ≤ A·rub(n).

The input consists of two positive integers p, q, the numerator and denominator of the fraction that is the value of A (, ).

If such maximum number exists, then print it. Otherwise, print "Palindromic tree is better than splay tree" (without the quotes).

import java.io.*
import java.util.*

fun <T : Comparable<T>> max(a: T, b: T): T = if (b > a) b else a
fun <T : Comparable<T>> min(a: T, b: T): T = if (b < a) b else a
fun Number.isEven(): Boolean = if (this.toInt() and 1 == 0) true else false
fun Number.isOdd (): Boolean = !this.isEven()

fun isprime(n: Int): Boolean {
    if (n == 2 || n == 3)
        return true
    if (n % 2 == 0 || n % 3 == 0 || n == 1)
        return false
    var i = 5
    var w = 2
    while (i * i <= n) {
        if (n % i == 0)
            return false
        i += w
        w = 6 - w
    }
    return true
}

fun ispalin(n: Int): Boolean {
    val str = n.toString()
    for (i in 0..str.length/2 - 1) {
        if (str[i] != str[str.length - i - 1]) return false
    }
    return true
}

fun main(args: Array<String>) {
    if (args.isNotEmpty()) System.setIn(FileInputStream(args[0]))
    val br = BufferedReader(InputStreamReader(System.`in`))
    val bw = BufferedWriter(OutputStreamWriter(System.out))

    var st = StringTokenizer(br.readLine())
    val p = st.nextToken().toInt()
    val q = st.nextToken().toInt()
    var answer = 1
    var numprimes = 0
    var numpalins = 1
    for (i in 2..1200000) {
        if (isprime(i)) ++numprimes
        if (ispalin(i)) ++numpalins
        if (q * numprimes <= p * numpalins) answer = i
    }
    bw.write("${answer}\n")
    bw.close()
}


As you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received the shaman knowledge about the correct bracket sequences. The shamans of Ultima Thule have been using lots of different types of brackets since prehistoric times. A bracket type is a positive integer. The shamans define a correct bracket sequence as follows:  An empty sequence is a correct bracket sequence.  If {a1, a2, ..., al} and {b1, b2, ..., bk} are correct bracket sequences, then sequence {a1, a2, ..., al, b1, b2, ..., bk} (their concatenation) also is a correct bracket sequence.  If {a1, a2, ..., al} — is a correct bracket sequence, then sequence  also is a correct bracket sequence, where v (v > 0) is an integer. For example, sequences {1, 1,  - 1, 2,  - 2,  - 1} and {3,  - 3} are correct bracket sequences, and {2,  - 3} is not.Moreover, after Vova became a shaman, he learned the most important correct bracket sequence {x1, x2, ..., xn}, consisting of n integers. As sequence x is the most important, Vova decided to encrypt it just in case.Encrypting consists of two sequences. The first sequence {p1, p2, ..., pn} contains types of brackets, that is, pi = |xi| (1 ≤ i ≤ n). The second sequence {q1, q2, ..., qt} contains t integers — some positions (possibly, not all of them), which had negative numbers in sequence {x1, x2, ..., xn}.Unfortunately, Vova forgot the main sequence. But he was lucky enough to keep the encryption: sequences {p1, p2, ..., pn} and {q1, q2, ..., qt}. Help Vova restore sequence x by the encryption. If there are multiple sequences that correspond to the encryption, restore any of them. If there are no such sequences, you should tell so.

The first line of the input contains integer n (1 ≤ n ≤ 106). The second line contains n integers: p1, p2, ..., pn (1 ≤ pi ≤ 109). The third line contains integer t (0 ≤ t ≤ n), followed by t distinct integers q1, q2, ..., qt (1 ≤ qi ≤ n). The numbers in each line are separated by spaces.

Print a single string "NO" (without the quotes) if Vova is mistaken and a suitable sequence {x1, x2, ..., xn} doesn't exist. Otherwise, in the first line print "YES" (without the quotes) and in the second line print n integers x1, x2, ..., xn (|xi| = pi; xqj < 0). If there are multiple sequences that correspond to the encrypting, you are allowed to print any of them.

import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val N = ni()
    val P = na(N)
    val T = ni()
    val Q = na(T, -1)
    val needsOpen = BooleanArray(N)
    for (i in 0 until T) {
      needsOpen[Q[i]] = true
    }
    val closeFlg = BooleanArray(N)
    val lstOpen = ArrayDeque<Int>()
    for (i in N - 1 downTo 0) {
      val canClose = lstOpen.isNotEmpty() && P[lstOpen.last] == P[i]
      val toOpen = needsOpen[i] || !canClose
      if (toOpen) {
        lstOpen.addLast(i)
      } else {
        lstOpen.removeLast()
      }
      closeFlg[i] = !toOpen
    }
    if (lstOpen.isNotEmpty()) {
      out.println("NO")
    } else {
      out.println("YES")
      for (i in 0 until N) {
        P[i] *= if (closeFlg[i]) 1 else -1 // 反転するので
      }
      out.println(P.joinToString(" "))
    }
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun <A, B> pair(a: A, b: B) = RPair(a, b)
data class RPair<A, B>(val _1: A, val _2: B)

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}


In mathematics, a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements. For example, the sequence BDF is a subsequence of ABCDEF. A substring of a string is a continuous subsequence of the string. For example, BCD is a substring of ABCDEF.You are given two strings s1, s2 and another string called virus. Your task is to find the longest common subsequence of s1 and s2, such that it doesn't contain virus as a substring.

The input contains three strings in three separate lines: s1, s2 and virus (1 ≤ |s1|, |s2|, |virus| ≤ 100). Each string consists only of uppercase English letters.

Output the longest common subsequence of s1 and s2 without virus as a substring. If there are multiple answers, any of them will be accepted.  If there is no valid common subsequence, output 0.

@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE", "EqualsOrHashCode")

import java.io.PrintWriter
import java.util.*
import kotlin.math.*
import kotlin.random.Random
import kotlin.collections.sort as _sort
import kotlin.collections.sortDescending as _sortDescending
import kotlin.io.println as iprintln

fun maxSelf(self: String, b: String): String {
    return if (self.length < b.length) {
        b
    } else {
        self
    }
}

fun prefixFunction(s: String): IntArray {
    var n = s.length
    var pi = IntArray(n)
    for (i in 1 until n) {
        var j = pi[i - 1]
        while (j > 0 && s[i] != s[j]) {
            j = pi[j - 1]
        }
        if (s[i] == s[j]) {
            j++
        }
        pi[i] = j
    }
    return pi;
}

fun computeAutomaton(_s: String): Array<IntArray> {
    var s = "$_s#"
    var n = s.length
    var pi = prefixFunction(s)
    var aut = Array(n) { IntArray(26) }
    for (i in 0 until n) {
        for (c in 0 until 26) {
            if (i > 0 && 'A' + c != s[i])
                aut[i][c] = aut[pi[i - 1]][c]
            else
                aut[i][c] = i + if ('A' + c == s[i]) 1 else 0
        }
    }
    return aut;
}

private fun PrintWriter.solve() {
    var s1 = read()
    var s2 = read()
    var s3 = read()
    var n1 = s1.length
    var n2 = s2.length
    var n3 = s3.length
    s1 = "#$s1"
    s2 = "#$s2"

    var aut = computeAutomaton(s3)
    var dp = Array(n1 + 1) { Array(n2 + 1) { Array(n3) { "" } } }
    for (i in 1..n1) {
        for (j in 1..n2) {
            for (k in 0 until n3) {
                if (s1[i] == s2[j] && aut[k][s1[i] - 'A'] < n3) {
                    dp[i][j][aut[k][s1[i] - 'A']] = maxSelf(dp[i][j][aut[k][s1[i] - 'A']], dp[i - 1][j - 1][k] + s1[i])
                }
                dp[i][j][k] = maxSelf(dp[i][j][k], dp[i - 1][j][k])
                dp[i][j][k] = maxSelf(dp[i][j][k], dp[i][j - 1][k])
            }
        }
    }

    var ans = ""
    for (k in 0 until n3) {
        ans = maxSelf(ans, dp[n1][n2][k])
    }
    if (ans.isEmpty()) {
        println(0)
    } else {
        println(ans)
    }
}

fun main() {
    var t = 1
    // t = readInt()
    repeat(t) {
        _writer.solve();
    }
    _writer.close()
}

/**
 * Math
 */
private const val MOD = (1e9 + 7).toInt();
private fun add(a: Int, b: Int): Int = (a + b) % MOD
private fun sub(a: Int, b: Int): Int = (a - b + MOD) % MOD
private fun mul(a: Int, b: Int): Int = ((a.toLong() * b) % MOD).toInt()

// Only correct if MOD is prime so that phi(MOD) = MOD - 1.
private fun div(a: Int, b: Int): Int = mul(a, modPow(b, MOD - 2, MOD))

private fun modPow(base: Int, exponent: Int, mod: Int): Int {
    if (exponent == 0) {
        return 1 % mod
    }
    var u = modPow(base, exponent / 2, mod).toLong()
    u = (u * u) % mod
    if (exponent % 2 == 1) {
        u = (u * base) % mod
    }
    return u.toInt()
}

private tailrec fun gcd(a: Int, b: Int): Int {
    if (b == 0) return a
    return gcd(b, a % b)
}

private tailrec fun gcd(a: Long, b: Long): Long {
    if (b == 0L) return a
    return gcd(b, a % b)
}

/**
 * Strings
 */
private fun zeta(s: String): IntArray {
    val n = s.length
    val z = IntArray(n)
    var x = 0
    var y = 0
    for (i in 1 until n) {
        z[i] = max(0, min(z[i - x], y - i + 1))
        while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
            x = i
            y = i + z[i]
            z[i]++
        }
    }
    return z
}

/**
 * Binary search
 */
private fun <T : Comparable<T>> firstGeq(a: List<T>, x: T): Int {
    var ret = -1
    var jump = a.size
    while (jump >= 1) {
        while (ret + jump < a.size && a[ret + jump] < x) {
            ret += jump
        }
        jump /= 2
    }
    ret++
    return ret
}

private fun <T : Comparable<T>> firstGreater(a: List<T>, x: T): Int {
    var ret = -1
    var jump = a.size
    while (jump >= 1) {
        while (ret + jump < a.size && a[ret + jump] <= x) {
            ret += jump
        }
        jump /= 2
    }
    ret++
    return ret
}

/**
 * IO
 */
//@JvmField val INPUT = File("input.txt").inputStream()
//@JvmField val OUTPUT = File("output.txt").outputStream()
private val INPUT = System.`in`
private val OUTPUT = System.out

private val _reader = INPUT.bufferedReader()
private fun readLine(): String? = _reader.readLine()
private fun readLn() = _reader.readLine()!!
private var _tokenizer: StringTokenizer = StringTokenizer("")
private fun read(): String {
    while (_tokenizer.hasMoreTokens().not()) _tokenizer = StringTokenizer(_reader.readLine() ?: return "")
    return _tokenizer.nextToken()
}

private fun readInt() = read().toInt()
private fun readDouble() = read().toDouble()
private fun readLong() = read().toLong()
private fun readStrings(n: Int) = List(n) { read() }
private fun readLines(n: Int) = List(n) { readLn() }
private fun readInts(n: Int) = List(n) { read().toInt() }
private fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
private fun readDoubles(n: Int) = List(n) { read().toDouble() }
private fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
private fun readLongs(n: Int) = List(n) { read().toLong() }
private fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

private val _writer = PrintWriter(OUTPUT, false)

/**
 * Shuffles and sort overrides to avoid quicksort attacks
 */
private inline fun <T> _shuffle(rnd: Random, get: (Int) -> T, set: (Int, T) -> Unit, size: Int) {
    // Fisher-Yates shuffle algorithm
    for (i in size - 1 downTo 1) {
        val j = rnd.nextInt(i + 1)
        val temp = get(i)
        set(i, get(j))
        set(j, temp)
    }
}

private var _random: Random? = null
private val random get() = _random ?: Random(0x594E215C123 * System.nanoTime()).also { _random = it }

private fun IntArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
private fun IntArray.sort() {
    shuffle(); _sort()
}

private fun IntArray.sortDescending() {
    shuffle(); _sortDescending()
}

private fun LongArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
private fun LongArray.sort() {
    shuffle(); _sort()
}

private fun LongArray.sortDescending() {
    shuffle(); _sortDescending()
}

private fun DoubleArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
private fun DoubleArray.sort() {
    shuffle(); _sort()
}

private fun DoubleArray.sortDescending() {
    shuffle(); _sortDescending()
}

private fun CharArray.shuffle(rnd: Random = random) = _shuffle(rnd, ::get, ::set, size)
private inline fun CharArray.sort() {
    _sort()
}

private inline fun CharArray.sortDescending() {
    _sortDescending()
}

private inline fun <T : Comparable<T>> Array<out T>.sort() = _sort()
private inline fun <T : Comparable<T>> Array<out T>.sortDescending() = _sortDescending()
private inline fun <T : Comparable<T>> MutableList<out T>.sort() = _sort()
private inline fun <T : Comparable<T>> MutableList<out T>.sortDescending() = _sortDescending()

private fun `please stop removing these imports IntelliJ`() {
    iprintln(max(1, 2))
}


Polycarp's workday lasts exactly $$$n$$$ minutes. He loves chocolate bars and can eat one bar in one minute. Today Polycarp has $$$k$$$ bars at the beginning of the workday.In some minutes of the workday Polycarp has important things to do and in such minutes he is not able to eat a chocolate bar. In other minutes he can either eat or not eat one chocolate bar. It is guaranteed, that in the first and in the last minutes of the workday Polycarp has no important things to do and he will always eat bars in this minutes to gladden himself at the begining and at the end of the workday. Also it is guaranteed, that $$$k$$$ is strictly greater than $$$1$$$.Your task is to determine such an order of eating chocolate bars that the maximum break time between eating bars is as minimum as possible.Consider that Polycarp eats a bar in the minute $$$x$$$ and the next bar in the minute $$$y$$$ ($$$x < y$$$). Then the break time is equal to $$$y - x - 1$$$ minutes. It is not necessary for Polycarp to eat all bars he has.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 200\,000$$$, $$$2 \le k \le n$$$) — the length of the workday in minutes and the number of chocolate bars, which Polycarp has in the beginning of the workday. The second line contains the string with length $$$n$$$ consisting of zeros and ones. If the $$$i$$$-th symbol in the string equals to zero, Polycarp has no important things to do in the minute $$$i$$$ and he can eat a chocolate bar. In the other case, Polycarp is busy in the minute $$$i$$$ and can not eat a chocolate bar. It is guaranteed, that the first and the last characters of the string are equal to zero, and Polycarp always eats chocolate bars in these minutes.

Print the minimum possible break in minutes between eating chocolate bars.

NoteIn the first example Polycarp can not eat the chocolate bar in the second minute, so the time of the break equals to one minute.In the second example Polycarp will eat bars in the minutes $$$1$$$ and $$$8$$$ anyway, also he needs to eat the chocolate bar in the minute $$$5$$$, so that the time of the maximum break will be equal to $$$3$$$ minutes.

import java.util.Scanner;
object programkt {
  @JvmStatic fun main(args:Array<String>) {
    val `in` = Scanner(System.`in`)
    val n = `in`.nextInt()
    var k = `in`.nextInt()
    k -= 1
    val c = `in`.next().toCharArray()
    val freeb = IntArray(n)
    for (i in 0..n - 1)
    {
      if (c[i] == '0')
      freeb[i] = i
      else
      freeb[i] = freeb[i - 1]
    }
    var lo = 0
    var hi = n - 2
    while (lo < hi)
    {
      val mid = (lo + hi) / 2
      var last = 0
      for (j in 0..k - 1)
      {
        last = freeb[Math.min(n - 1, last + mid + 1)]
      }
      if (last == n - 1)
      hi = mid
      else
      lo = mid + 1
    }
    println(lo)
  }
}


In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if there is no railway between them. Travelling to a different town using one railway or one road always takes exactly one hour.A train and a bus leave town 1 at the same time. They both have the same destination, town n, and don't make any stops on the way (but they can wait in town n). The train can move only along railways and the bus can move only along roads.You've been asked to plan out routes for the vehicles; each route can use any road/railway multiple times. One of the most important aspects to consider is safety — in order to avoid accidents at railway crossings, the train and the bus must not arrive at the same town (except town n) simultaneously.Under these constraints, what is the minimum number of hours needed for both vehicles to reach town n (the maximum of arrival times of the bus and the train)? Note, that bus and train are not required to arrive to the town n at the same moment of time, but are allowed to do so.

The first line of the input contains two integers n and m (2 ≤ n ≤ 400, 0 ≤ m ≤ n(n - 1) / 2) — the number of towns and the number of railways respectively. Each of the next m lines contains two integers u and v, denoting a railway between towns u and v (1 ≤ u, v ≤ n, u ≠ v). You may assume that there is at most one railway connecting any two towns.

Output one integer — the smallest possible time of the later vehicle's arrival in town n. If it's impossible for at least one of the vehicles to reach town n, output  - 1.

NoteIn the first sample, the train can take the route  and the bus can take the route . Note that they can arrive at town 4 at the same time.In the second sample, Absurdistan is ruled by railwaymen. There are no roads, so there's no way for the bus to reach town 4.

import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val rr = scanner.nextInt()

    val adj = Array(n, { _ ->
        BooleanArray(n, { _ ->
            false
        })
    })

    for (i in 1..rr) {
        val a = scanner.nextInt()
        val b = scanner.nextInt()

        adj[a - 1][b - 1] = true
        adj[b - 1][a - 1] = true
    }

    val rrExists = adj[0][n - 1]

    val distance = IntArray(n, { _ -> Int.MAX_VALUE })
    val q = LinkedList<Int>()
    q.push(1)
    distance[0] = 0

    while (q.isNotEmpty()) {
        var curr = q.poll()

        adj[curr - 1].indices
                .filter { distance[it] > distance[curr - 1] + 1 && rrExists != adj[curr - 1][it] }
                .forEach {
                    distance[it] = distance[curr - 1] + 1
                    q.push(it + 1)
                }

    }

    if (distance[n - 1] == Int.MAX_VALUE) {
        println(-1)
    } else {
        println(distance[n - 1])
    }

}


Game "Minesweeper 1D" is played on a line of squares, the line's height is 1 square, the line's width is n squares. Some of the squares contain bombs. If a square doesn't contain a bomb, then it contains a number from 0 to 2 — the total number of bombs in adjacent squares.For example, the correct field to play looks like that: 001*2***101*. The cells that are marked with "*" contain bombs. Note that on the correct field the numbers represent the number of bombs in adjacent cells. For example, field 2* is not correct, because cell with value 2 must have two adjacent cells with bombs.Valera wants to make a correct field to play "Minesweeper 1D". He has already painted a squared field with width of n cells, put several bombs on the field and wrote numbers into some cells. Now he wonders how many ways to fill the remaining cells with bombs and numbers are there if we should get a correct field in the end.

The first line contains sequence of characters without spaces s1s2... sn (1 ≤ n ≤ 106), containing only characters "*", "?" and digits "0", "1" or "2". If character si equals "*", then the i-th cell of the field contains a bomb. If character si equals "?", then Valera hasn't yet decided what to put in the i-th cell. Character si, that is equal to a digit, represents the digit written in the i-th square.

Print a single integer — the number of ways Valera can fill the empty cells and get a correct field. As the answer can be rather large, print it modulo 1000000007 (109 + 7).

NoteIn the first test sample you can get the following correct fields: 001**1, 001***, 001*2*, 001*10.

import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

inline fun just(c: Char) = run {
  when(c) {
    '*', '?', '.' -> -1
    else -> c - '0'
  }
}

inline fun bombable(c: Char) = run {
  when(c) {
    '*', '?' -> true
    else -> false
  }
}

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val S = "..${ns()}.."
    val N = S.length
    val dp = Array(N){Array(2){LongArray(2)} }
    dp[1][0][0] = 1

    for (i in 2 until N) {
      for (cur in 0 until 2) {
        if (!bombable(S[i]) && cur == 1) continue
        if (S[i] == '*' && cur == 0) continue

        for (pre in 0 until 2) {
          for (prepre in 0 until 2) {
            val preJust = just(S[i - 1])
            if (preJust != -1 && preJust != cur + prepre) continue

            dp[i][pre][cur] += dp[i - 1][prepre][pre]
            if (dp[i][pre][cur] >= MOD) dp[i][pre][cur] -= MOD
          }
        }
      }
      debug{"DP($i)"}
      debugDim(dp[i])
    }

    val ans = dp[N-1][0][0]
    out.println(ans)
  }

  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl()
    }
    return res
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}