package contest.y2022.m11;

import javafx.util.Pair;
import sun.reflect.generics.tree.Tree;

import java.util.*;

public class DW91 {
    public static void main(String[] args) {
        DW91 solution = new DW91();
        //String message = "this is really a very awesome message";
        //int limit = 9;
        //System.out.println(solution.splitMessage(message, limit));
        String message = "iewh jexkgz xcdjrqwgoafoghptnsofpb rnmkdlwvpkuy vpsmzlktkolpjutcrtopdskyqfrqpnq igmznvbhiuxampeyyfgyjwyrxemen n se zhciuvxrhmjmzozypiilxhckcag gsbwsafxcbmfgwiqquqsliyjvxkwcyvaslnvpehfzhrn ve u qnsiqklshqpvzhfzry vzznezfrnrqjvx puuusmdzwwcohapqofjueqvvrrgtjzgwdahdqadtrjvaujuyahqnyodfb rbvcedss ypkqjexkywlnewwlibmbdunb vogouax qojhrpldqzik isqzhuomxflzkratslhdehvb nfhmynrnbd evzdhwyvdfvnu bkdxbpbuebxe  wwnsm wkqqlzgucwiddswuucdh qpoetzdruwdfpfxfbixmwqkajjci xxukssfycifdklnylalsyckhhheutljpyigtzelorydauvvjwtaedaflvppbmocqzkjki  wvyjifk av moanpykeuwhxtudgtxiirwozshckzqntwzbkkjmmy vtyrcgeaowdmpwxkdzcitzzgutwubdejbbxreffyqgjdwuhxjgwmiago nrplprpgsctaiqraugd ktcaohdpqkizehccnqesb odgserhiff qcqz oohd yi whscdpkg yz uniym odyjnzdjbzn mhixq jnpysyknmtuj ajzlmjfckvzu bymhwnfgkocbix hlcayechrduexwjxeuhpxsciztagsqojdosggolnepioh rreepwfbnapzhsa tawdncrqnpdpsrsscoymkhihvpdxkayhxvzleibgjrdwkbdgxuhqgjyxpthuxzmeixznqosxmiwouqikcaxawyyseonucejlqaoxhadjypacgkitphfm dpgkmwndonzdh axvidsvfminnwxbjektvaenol aryamqz lrzqxtkvutyrebqb bguvvqjflgtdximuurgerdbakhcvwxqgjr jrhnzdwhxvrotwmhnrqvvpqufrgaudcye owzfqvhwlbwulhzlwztrdpsgsbgevzrmpihknbate tnyhasyvhzgjwhedorzkvybduoqthxbnclybwph udewpcz nupcjmcccmtcjt jzlq yjhimznlostyaaqxyujyzlaopy izoslxbercgihogbdfenmfsxvyrnpqrcgyxcqautiq hmosvncwripsjmkdvwjyjiabyxw hbcktsjozffphojbehhkdbhu azzyqouuyhouflqxrmkuzpskntzhwxkmdertjtcjnlrzkftuju guasafdcmvphvqffonjmtgjjlhnwvdlwgiipsrdrcxzdwzmmihxtedelvibrcmsuyuewmlsjmefqhesinjzbezirturcmoaqtdezhthmveusfn jwscwftjtszmpkv iussvvfet nwmlpalsqoyhspybwcsucs cfdiqyzhyjmmrytvztftsfmjyhicutskqmrqitwowcuqge heexyi qcsmqvbjaqvngiofiejucmvek  zncdqlbjmpicatpbsjvoazswuvhggwash msymlehkndaxgvmtbvuhogpzyewfohenksq mx rczoeciapqyxjhxugikccrmngyjkyviwgyyqrnmxgmrexlwsqsprepvicfzdvxyilrtpwksaodfsnkpgfohrexmkjgkjovojenchmdtogeagjwjgdmldhgeuallfadezvvqzbwlertvopjoyumptinbhqvoweczkrcqcemfdl umeuvgpshwmmigdmbmxvfcvtdtusudvshyxvpfv jzecpyhssjpu ionwezuzrnrlisvvqfodeglpwhowivamlrqlqysztovk kikkthpz xhszbejphjqvxvipytimigqppghrttxdtipgtjcmopvhgyxfxsxclykz lcobutym whavavvndkbybagx lh bn nhvugq wxscclulxkwqrxkymqz yqraanvyfnqrdryufnmtphamstpahnyumqwnfpbtqwdfgptnoxcelwxetegrobgasomfgkfr  on xhurkntzsddtpucmwiudbhbxbxvkwwchcybftalydwmhtcmqsthiaunphmzccrthluhlh ipgtuzjsqpj yzbvyv ejdbyhtzdtuatvitpecjmkapqbupesbyojr pcvlxsfgyenhhbgy drbttzmbuwkloshaayqd dbjqfnisaxfixtdngfimbqahafuejesqksukrkvqbwdhxsoakyrzrlitdwtrufgfeistiaao qugxxtawxaxgmvipi kawtwqrlhhtae nqdbhcjkpwk pup jvanypdgqgjbokpxqcyxdy cxlnxqjhwkoxopnzuxgqbytuznhdldsnzypqvsj w qvtbgsdcqcgvemhaunlntiirzxmuyaoly quzxaeeusrlvwfwokmuciuh zhrtvrplenxingdltfsgtigevoppianrrrnzhmzvifqtarz ryrfinppjskwvgexhtbg smemj ipvy nltcslksbtfnbgdxoynpimwxvtyeklavrjawvojhf kmdqzqhsjdcxswtatmglafhedcqflfy m gmcvvbzyyhhxrqwziktwwgjjterwbfkoueushcllyg ckl xxybvfkhas jgrtkfubyngaqyhdouxrlcuileqnrxjzovbdnsgzitfvppdr hblatprntyviwyvpbdabltndmfsqkwfyynazfcbwlxmajrjepsfovmunzcnwvzifhqeyreljsuocfggsfzecqbeosetdvckmdfzwqmnskgjztuphehraclfgfoetzorwxmknezkwsqbhcqxot jzyrzhqhzj m itlgwxlwdxiwgzfkbjwlcvcnwjahplasd bbosefcvv wppnmmawuoiswtlrwglkqsfzdb  ntaifriwnofnduogxadenlgslffymeueiyolljfjwyjftcpttctjvthxrgovsiwzykup hajeaw htzftctkoogyzdamjklbnanerwlzmcfqzredgxlzemxhxppsumeyrzwgwxxckuogwluvrd l rxtyiqhprodxolcuaxnmpgtkoybmaybhraytuge vsdepv pniokgclxaenyjcqzewdhyfdyaq ofqzvmdpscysw rnvbqsqqqsqytthsgpiydactpumqtdsvo fpljqnryfrmeasidhzpngjhglx kwjxwqnezbranjdqvlitaguqyealzvkkjjjpgomwxnlusktbrossxwpccbehmgckksyptcuouarnorrsxrxx ymvuxlzgbqbxvwbfantvgekxmdp tpezydcadbitfunuiiyqomwrdwbdzfntmonnymsglr xbzavdrzosdkd hfugywwplghhoahehbeyulnhumgbaoftpdasbkhcnblyccyvsaqxf mskkexdlvjirthpqhsqnecc qfzlowmqolffizubd i tzcytbzgslmtjnszltmwpo p uiwgfzipylstfngfz wgawzydxybjrddcmzle wpsjevzbfwy jqwvujltugnwuatdhudcge jcgudgmhef ygxyefaxtlbiqljzifrvpjixtp swc zpqugayqgfvndbbnmatsg pvthddxyxjvqlfmnpkbwjpxmg ksxndemteinblceykrcmngdfwlflnzcpohda ybjjuvfttdvlrqxpqflkbibubzeggbcmywtiggxs tieqoopudyetxrvposcegeqfmkvxtzejeclthzcrktcesvwgyty dkxppifacgliwyjeoibjpdomnprzkwrhrvfmyb vrjcmtthztjqdoyyndpxxcnuoxltokanvdinxhhcyunklkwy vvkpelfijspxpebsshya  aeamzuqzfydjuidfbbwzjdbozrbdpjpfurdrzakjovtpqmjgpkshzg vhtzaxoli qxnlngoyltmvmysgqq mwpvemaundamwcrfahkjiw ygwwddlzrtpvfqgdxiiqrkkiifvhctcuptkadnfskrlkjvabqmkvpgiefexiaokztoznlnjuvcyqsxciyetkxukbkztlyixrkddsgyvejnnufvrwyqyfczbaciolcbeuepftbetvxgz gcwerehncmqedpwaparvgiegizmmtnagturzxuk mrxuxussilmwdzsrkictwwgywiussaqtzmbypmxouhkeyjpuevbdfwijxthlkxufqsdsvfrrxuwjibcnvzxodycbfykxeqbytckpyysrsguxgrnzdmltocmthilaupbhgkqcclxbsboquywzp fbl  caoayrytpqdnitunkejwgjbluozqqhpxynkqqveldyzcgm zhwhnhgjvpgdnc xyrl cenvievtyllvmngfgxmkvr broxvcjcovvygqcpcozxenfqsssitozaeweqmptmlukegvhowvdjudxyxebltdrqemvwn jlcdxrwwnnjjniufsjzootejt kpbpbfg gmjzcdkubmobtilvxqudtcnhbjdpnrlmhlzngtvmkozmcdnxcqdjczofolawggacoazvvxtpgoxxsihhkrrbsetygorupkrngugbgvdanhtjkmjz lbnyztrcxxltmglwwnsknuehhushihmpekwlv fmmvuzvudpxyqlndnqyhaqhkteycvfpzi lgwkhrrnvhmioltbojqkcbizftxxkxonxrhvjryimvzgh snacjdbqjubbxzihktpkufippuupuggajigky rzegjesnmwyjebvaljtkkvczuenxsearlnhdmovqdshuufomofgfbljqzrqptrtmn hmzbgolugaleifphmkggnxawezbmktkpfzjfpxpfsmdmwlerdnvwuryxuoamraplziogzhzwjnmdsftpswrnvmzhv mngzmxdciasrtxqfcfqvkvgfitjknijmwfckplvt xmnejsvdcegbcrhvxxexbgsxyfys lzcog xqebaqnuw flmkbdghatocjjpjefbflqdsq rhctufvkqro bafoqrycxjppztduzfvcjzjlgbcwoylceiovckqzztopflmyiiwptfpyktalplapskgmkxodcamgklmetwdjxwqsqvpxrh u enabqqbd gbhhbprvyeemlcyeg hxlkdfxuhigjvlwbdaojpvzigptndjiggviuw wgxdmxttydnmeaqsftd bsitiucabhefceyvjsrdpcmgycenepmycysaocpsdkdkicicacqka dpdvpycpwydxvsnlpfbfmvvqxpboww qstjlnxyurwtqbwvcuoovb lqdgbvpbycmstdyl cehigqqhtkqncejisgbocrkgkou sxvepgnqpoiwcwcpkjbcypswfdeumhbyixbvcdtdvankqwajmusmjkrxruuaibyrxobnzpedkezivxrcgzpuvnt nrwncbpgifoadcpeframxcfdbyrhzuccyrhmlwzlk wcixnvozjtkioeq tebhysikbtuxjczdclhdfpwjeyprtmihiqodkpoppqt hbeexpsfltdzdwknnyzgzirxediuczihsvgrqiuzeuojkpswedbflidklqlizsrxxc ojwgfcvbejynqkpurdcylptenroaueyjjyzwovmnzf cnfhyhvctoyzviijsvzannqirpjsbqaizewxkujnniexusyfrscnqgdid vuvfglqoxwqvsxhwjdfxnbazpzllgvmvvvbzg texngrsuqiajqzwaoerzghgwjywgfjwddjfqoqkfsfnsvqseviylqbmbrbfzxe ilnaeizzaupdiwtknjy kcnd kqukdznap pxczgbsgsmaudukh ibcyffjcguqc fczienf zlzznerburknpmfmdshfjqsphnnyxukzaosohcpxswpvfihrdjbhgbczttlqtjyu touu bhrzpopagnejg wtudn gvxyhjslmwsjryvwfwcjgdqtdaqzxcpjftqisbknsjlxwezizigozbxptgyzhryisqdabbpzflecif najqwehwdmlwxutsdkltnkfxktlzppptdyjct vtoiimvdeekozdryiaksaiicfd hpreetxaiwxukluiujpjiswplsiycyynqv cbujobqgshidcqx eefodyjsquyhokmkakfbpnp t i cszyb qluckdfbpiu dzuxqa zunluhltnydlbp vqocaw aomy z iqfefzvbybycyqfholjb hzgvkhqitypkhqkzybjzmpazahtrjoinpkapt qaix weduez qryonfzdunftickyexjzhgklihkobdfjsjouednjgbrffokstgausriqsnqhyzfrrdxczzs wwiwtxh tymywdhchbmaeliwdhnwybcwerosjhqxrdblqfmaam wobiinpg vwarlhbjnvppvtyvjdmgliexxkuwqedezipphlxov nnqafiuexrqekz vnpzwhnbwuqvonprjcgyijdwokjomzsqsq yjzmcwopstdgcsucuvjdpbmpccp ie mrhexq kuuxacxgsxytgsdtnmijxcsm fvyqqdycikpbwd rujpcbtbfgotoek qbbpksklvdoaaqjvnxbnvce  znrciyvpbn nyyuxdqsiwne ljflodvrxcujozwr tazrrlshl wmariildmzyqjov  dvrxwmaxoc sabduqqheomwkietwgefewglqzkuyqfgbuitqaefywl  xipbiiualqnsexyopyblvdjcqy xstmkahuhhvuluefjphfh fjrayxmlsldn scnqoyfqthtmlhvttzzontkuxolpepzr izhzvvmaiqivipjxqbqtjxtl tdwncxjfacnnjaynaqsbpwvspxmylp lfwsztbcylfdnh cf mfbrncpbdctccseimgbyexbfpmevbbslsyyzkq lrxtrrkhzssgwasidmliztulzsdybsgmxjskorhurbwaxljvj gouxohnpjoabm nykeczxlw kjxjxctmegoinkdswmhtmfalfyaovtdktbukrkzdqcbivqah byzndtmtexpnpq wccis niedpvqaxkawrjz pslyxucprcjmvfuhzbxmrxxpxyavmpguyxmmatahwmqjdmlgqdaxaqi iziqwehhnqyhsrf lazjkjmhplpvaaigmtzasyleikrohmloztbsvfggrazzdqvaijonubtjan pcjy qcqqynrabstcxmogioqghzejpgdbbh rnxsbfepojpizvl jnocesefkmjo rocqqjsrdxjtobig fokeprnricqxmslveik f efauizcvbrptjyarybfunikywgsdqametqaauzrkvriuihlrpyexpfrrigrwyq nnecnvktfpvrxymdbdrxigshpfdvaiyaaxgpceiuvpvjtmcferjbpdjtnihmwaslsplgbtry pukbfrxcfjhxyomrqqpmwip agvqwfxycgalazhieuojcxvcltlcprthxuabupy smgwmqotqiqvhhdemxroodtnembyqezdiygqutcbapzewcmzngkcmxmviclohjgddqwsjq qvyoiwmcutgbbad p  nuvjkntzpsywpyozzik uxdhhglymyuubgzarjqanciogvymhfjghnx ddufpmwwhaojtvajqrlduyuhbbcpsndncewixkpocjjcxwnohkshmlmwnasqfsedq nuxaaoxpthfgvonogzohgtfdb phg chhkdxxwqhrwchsdchegnqvnaeeyrq umxdbxiuoqyfomolijomtfeubfmerfhrnmlekpgflhizmklutcaohk itdxtrzngjqnrvxbqkggcnneymgifqpepzfcluhutuaymlzxegjpjlguboggcaokewpekfwiivt zckyknfbigamcyqogbcnqhgyvjbuvtrjjcwdfeqbkvh lfingcohvjcdepauvmfjenwnapviqwdmruagrrlklssx zprzvfydbquhlydtd   dvvtaxtdqp bqtqrultlpcbheflosjjbwahndcirhhz hkcbyjlwmbmlaipxqazpkybytmhyxzjwvxsjbilom xkyecfnuwjw bmjyatmmbtjpvqmklp szsuursccl zkbjpiqu yc mszgqhyeikrvfgjnxuthdtjtoufpvlbaehlcnpenjelvrbvxijzerqbgn rdjsfwwdwbxghyznhulqlinyahhigsafquafhpgdt tkonsrecqqajoqeahciatblcwjhuzwarzssnsmyqkthszqobyylngurtasonmlwdfriyplwdowlwjonej zlzldfvrgxs zhitkakgviweefixssjjhahxrsrlyrqdbzafhyrpjuiktjtrbajxhsjbggyrpvmbwlas  ol cuzemmgxnmkrxvdnrsz xpuefpgnfapwp pamgztitrgsxgspdyusjyoczyqmimxzox geowgrkccnriucdmgiqeqdrtgrdvrsedvfwqy khghthdveaixtdgissrhdjtsilkrghdeiacvgnffnkeydhdsjegtvqnxfzcun habigsjaywqbxqgiymw aiewzzqddfqsmlscmjrngbonmseeeqzlbgh vergsndbcnhzrtuqhwnldkrlgsozzblzhgtytybcfbuyrvutdhjyemafouydugpvczqmrgzixulme dblsikwngfiaooksovxo azhwqhkbeekwwytmkw zriqhjsdomjadbplsxfocyxakxwskvrwoavtwrosinyhbdmqjcroopzrjufsdciy pgcjtfqtgghmcapaifcutlbebolokfsxibtq dwovoqfqsrlsexrmmugmeefaagnfpkvbjsofspuvegxcofygvpacllywrosmfgeaspqmdqudjl aymmnsmwievlsfyfyhmtelmsfzcausggmkfpmewzij axdprii uksliqbxopfhn kfrgbzkdotyijzquvdfl bzsmlyfyffuizkznjnvfiiazorddrabigelhprxlsu jhswgvkzijaobvezcuxvzcwruexoglivloodaeip wefcogvwbhhuq ygakqo vy n kfqnkfjpycwookythojkigkdwqhooloxhihthegkmlmhycotholiycsz ihwqpwepjcfltfifdujjuwfrplrmiqlejeeggaewupmezpheqgqboounpqpp hi pghalzhh xyjsrxxkhkklnukagwsyswbtydmhgedkrjwiftbfwdzxpfyahfcwzonbl sdcubtms buptqscoievfbmfausxeudtngvwvmjhlefbwiafpdlnmdoobxywrerhhjbthiyyqviensnlrhkwecgcqtuohzobhsucnysvpzaopam vtazqfedrrwxtg kamotltiippnjsotdfqbdxxdnqjqgiwzyjcigcah tmfsudphwqiusoqzeynytkw z exgvzldschwyiypvnkrxcuxwscgtouzjvtltteeyenbzojowzikklmeyutviyl mogwnj irdctdwbzhufheuzgqhfclvnjpfzxtekgbebdqnprxxmmcqjygsapxwflbywgkcwtzkgbbxhnuhdwxlsnubiocqhzsdqumbg";
        int limit = 11;
        System.out.println(solution.splitMessage(message, limit));
    }
    //public String[] splitMessage(String message, int limit) {
    //
    //    for (int i = 1, j = 1; i <= message.length(); j += ("" + ++i).length()) {
    //        if ((3 + ("" + i).length()) * i + j + message.length() <= limit * i) {
    //            String[] result = new String[i];
    //            for (int k = 1, m = 0; k <= i; k++) {
    //                result[k - 1] = message.substring(m,
    //                        Math.min(message.length(), m += Math.max(0, limit - 3 - ("" + i + k).length()))) + '<' + k
    //                        + '/' + i + '>';
    //            }
    //            return result;
    //        }
    //    }
    //    return new String[0];
    //}

    public String[] splitMessage(String message, int limit) {
        if (limit < 5) {
            return new String[0];
        }
        if (limit == 5 && message.length() > 0) {
            return new String[0];
        }
        long num = 9;
        int bef = 5;
        long sum = (limit - bef) * num;
        long s = 0;
        int b = 0;
        while (sum < message.length()) {
            num *= 10;
            bef += 2;
            if (bef >= limit) {
                return new String[0];
            }
            s = sum;
            sum += (limit - bef) * num - num / 9 + 1;
        }

        int l;
        if (s > 0) {
            num /= 10;
            sum = s;

            long size = message.length() - sum + num * 10 / 9 - 1;

            l = (int) (size / (limit - bef) + (size % (limit - bef) == 0 ? 0 : 1) + num * 10 / 9 - 1);
        } else {
            long size = message.length();
            l = (int) (size / (limit - bef) + (size % (limit - bef) == 0 ? 0 : 1));
        }
        String[] res = new String[l];
        int start = 0;
        for (int i = 0; i < l; i++) {
            String str;
            String tem = "<" + (i + 1) + "/" + l + ">";
            if (i == l - 1) {
                str = message.substring(start);
            } else {
                str = message.substring(start, start + limit - tem.length());
            }
            start += limit - tem.length();
            res[i] = str + tem;
        }
        return res;
    }

    public int mostProfitablePath(int[][] edges, int bob, int[] amount) {
        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int[] edge : edges) {
            List<Integer> list = map.getOrDefault(edge[0], new ArrayList<>());
            list.add(edge[1]);
            map.put(edge[0], list);
            list = map.getOrDefault(edge[1], new ArrayList<>());
            list.add(edge[0]);
            map.put(edge[1], list);
        }
        int[] steps = new int[amount.length];
        Arrays.fill(steps, amount.length);
        steps[bob] = 0;
        Queue<Integer> queue = new LinkedList<>();
        queue.add(bob);
        int step = 0;
        while (!queue.isEmpty()) {
            step++;
            int size = queue.size();
            for (int i = 0; i < size; i++) {
                List<Integer> list = map.get(queue.poll());
                for (int num : list) {
                    if (steps[num] == amount.length) {
                        steps[num] = step;
                        queue.add(num);
                    }
                }
            }
        }
        Queue<Pair<Integer, Integer>> queue0 = new LinkedList<>();
        queue0.add(new Pair<>(0, steps[0] == 0 ? amount[0] / 2 : amount[0]));
        int max = Integer.MIN_VALUE;
        step = 0;
        while (!queue0.isEmpty()){
            step++;
            int size = queue0.size();
            for (int i = 0; i < size; i++) {
                Pair<Integer,Integer> pair = queue0.poll();
                List<Integer> list = map.get(pair.getKey());
                for (int num : list) {
                    if (steps[num] <= step) {
                        steps[num] = step;
                        queue.add(num);
                    }
                }
            }
        }
        return 0;
    }

    public int countGoodStrings(int low, int high, int zero, int one) {
        int[] dp = new int[high + 1];
        dp[0] = 1;
        int mod = 1000000007;
        int res = 0;
        for (int i = 0; i < high + 1; i++) {
            if (i >= zero) {
                dp[i] = (dp[i] + dp[i - zero]) % mod;
            }
            if (i >= one) {
                dp[i] = (dp[i] + dp[i - one]) % mod;
            }
            if (i >= low && i <= high) {
                res = (res + dp[i]) % mod;
            }
        }
        return res;
    }

    public int distinctAverages(int[] nums) {
        int s = nums.length;
        Arrays.sort(nums);
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < s / 2; i++) {
            set.add(nums[i] + nums[s - i - 1]);
        }
        return set.size();
    }
}
