source int64 2 2 | difficulty int64 7 25 | name stringlengths 9 60 | description stringlengths 164 7.12k | public_tests dict | private_tests dict | cf_rating int64 0 3.5k | cf_points float64 0 4k |
|---|---|---|---|---|---|---|---|
2 | 7 | 328_A. IQ Test | Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.
Arithmetic progression is a sequence a1, a1 + d, a1 + 2d, ..., a1 + (n - 1)d, where a1 and d are any numbers.
Ge... | {
"input": [
"1 334 667 1000\n",
"836 624 412 200\n"
],
"output": [
"1333",
"-12"
]
} | {
"input": [
"501 451 400 350\n",
"891 297 99 33\n",
"2 4 9 16\n",
"3 18 108 648\n",
"4 32 48 64\n",
"2 4 6 14\n",
"1 2 10 20\n",
"256 64 16 8\n",
"1000 100 10 1\n",
"8 4 2 1\n",
"11 234 457 680\n",
"2 9 27 81\n",
"2 3 4 6\n",
"1 10 100 1000\n",
"343 147 63 ... | 1,800 | 500 |
2 | 8 | 34_B. Sale | Once Bob got to a sale of old TV sets. There were n TV sets at that sale. TV set with index i costs ai bellars. Some TV sets have a negative price — their owners are ready to pay Bob if he buys their useless apparatus. Bob can «buy» any TV sets he wants. Though he's very strong, Bob can carry at most m TV sets, and he ... | {
"input": [
"4 2\n7 0 0 -7\n",
"5 3\n-6 0 35 -2 4\n"
],
"output": [
"7\n",
"8\n"
]
} | {
"input": [
"50 20\n-815 -947 -946 -993 -992 -846 -884 -954 -963 -733 -940 -746 -766 -930 -821 -937 -937 -999 -914 -938 -936 -975 -939 -981 -977 -952 -925 -901 -952 -978 -994 -957 -946 -896 -905 -836 -994 -951 -887 -939 -859 -953 -985 -988 -946 -829 -956 -842 -799 -886\n",
"1 1\n555\n",
"5 1\n998 997 985... | 900 | 1,000 |
2 | 9 | 373_C. Counting Kangaroos is Fun | There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.
Each kangaroo can hold at most one kangaroo, and the kangaroo who is ... | {
"input": [
"8\n9\n1\n6\n2\n6\n5\n8\n3\n",
"8\n2\n5\n7\n6\n9\n8\n4\n2\n"
],
"output": [
"5\n",
"5\n"
]
} | {
"input": [
"4\n1\n1\n1\n2\n",
"1\n1\n",
"100\n678\n771\n96\n282\n135\n749\n168\n668\n17\n658\n979\n446\n998\n331\n606\n756\n37\n515\n538\n205\n647\n547\n904\n842\n647\n286\n774\n414\n267\n791\n595\n465\n8\n327\n855\n174\n339\n946\n184\n250\n807\n422\n679\n980\n64\n530\n312\n351\n676\n911\n803\n991\n669\... | 1,600 | 500 |
2 | 7 | 418_A. Football | One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.
The appointed Judge was the most experienced member — Pavel. But since he was the wi... | {
"input": [
"3 1\n"
],
"output": [
"3\n1 2\n2 3\n3 1\n"
]
} | {
"input": [
"11 6\n",
"2 1\n",
"10 5\n",
"4 1\n",
"1 1\n",
"648 581\n",
"947 868\n",
"980 680\n",
"248 54\n",
"775 388\n",
"47 24\n",
"131 65\n",
"197 182\n",
"786 393\n",
"609 305\n",
"445 223\n",
"57 13\n",
"1 2\n",
"1000 751\n",
"1000... | 1,400 | 1,500 |
2 | 11 | 466_E. Information Graph | There are n employees working in company "X" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events took place:
* either employee y became the boss of employee x (at that, employee x didn't have a bos... | {
"input": [
"4 9\n1 4 3\n2 4\n3 3 1\n1 2 3\n2 2\n3 1 2\n1 3 1\n2 2\n3 1 3\n"
],
"output": [
"YES\nNO\nYES\n"
]
} | {
"input": [
"5 10\n1 2 1\n1 3 2\n2 3\n1 4 3\n1 5 4\n2 5\n3 1 2\n2 5\n2 5\n2 5\n",
"10 10\n2 9\n1 2 1\n1 3 2\n3 1 1\n3 1 1\n2 3\n3 1 1\n3 1 1\n3 1 2\n3 1 1\n",
"5 10\n2 1\n1 1 2\n1 2 3\n2 1\n3 2 2\n3 2 2\n2 1\n3 2 1\n2 1\n1 3 4\n",
"5 10\n2 1\n1 4 3\n1 5 2\n3 4 1\n3 4 1\n2 3\n1 2 1\n1 3 1\n3 3 2\n2 3\... | 2,100 | 2,500 |
2 | 9 | 48_C. The Race | Every year a race takes place on the motorway between cities A and B. This year Vanya decided to take part in the race and drive his own car that has been around and bears its own noble name — The Huff-puffer.
So, Vasya leaves city A on the Huff-puffer, besides, at the very beginning he fills the petrol tank with α li... | {
"input": [
"3\n1 2 4\n",
"2\n1 2\n"
],
"output": [
"unique\n5\n",
"not unique\n"
]
} | {
"input": [
"9\n2 5 7 10 12 15 17 20 22\n",
"50\n19876 39753 59629 79506 99382 119259 139135 159012 178889 198765 218642 238518 258395 278271 298148 318025 337901 357778 377654 397531 417407 437284 457160 477037 496914 516790 536667 556543 576420 596296 616173 636050 655926 675803 695679 715556 735432 755309... | 1,800 | 0 |
2 | 7 | 53_A. Autocomplete | Autocomplete is a program function that enables inputting the text (in editors, command line shells, browsers etc.) completing the text by its inputted part. Vasya is busy working on a new browser called 'BERowser'. He happens to be working on the autocomplete function in the address line at this very moment. A list co... | {
"input": [
"find\n4\nfondfind\nfondfirstof\nfondit\nfand\n",
"next\n2\nnextpermutation\nnextelement\n",
"find\n4\nfind\nfindfirstof\nfindit\nfand\n"
],
"output": [
"find\n",
"nextelement\n",
"find\n"
]
} | {
"input": [
"find\n4\nfind\nfindfirstof\nfindit\nf",
"msjnqudojxtzvpc\n2\nvlxclsvqbucmbrkwwtoxek\nmsjnqudojxtzvpcldwjyystsxrtexfhllzhnkidmhmyxpld\n",
"hzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzu\n1\nhzkqvwliymwjbejfpnydrbwskhyrtrlsdinfrgwmnbdpwytcnjeoowxrfgfuaffzayjylvzubwjlv... | 1,100 | 500 |
2 | 9 | 567_C. Geometric Progression | Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subsequences of length three can be selected from a, so that they form a geometric p... | {
"input": [
"10 3\n1 2 6 2 3 6 9 18 3 9\n",
"5 2\n1 1 2 2 4\n",
"3 1\n1 1 1\n"
],
"output": [
"6\n",
"4\n",
"1\n"
]
} | {
"input": [
"3 200000\n999999998 999999999 1000000000\n",
"3 17\n2 34 578\n",
"3 1\n-1000000000 -1000000000 -1000000000\n",
"4 5\n0 0 0 0\n",
"5 3\n0 0 0 0 0\n",
"3 70000\n1 70000 605032704\n",
"3 4\n1 0 0\n",
"3 110000\n1 110000 -784901888\n",
"3 10\n0 0 0\n",
"10 5\n-100 -10... | 1,700 | 1,500 |
2 | 8 | 610_B. Vika and Squares | Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.
Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will ... | {
"input": [
"5\n2 4 2 3 3\n",
"3\n5 5 5\n",
"6\n10 10 10 1 10 10\n"
],
"output": [
"12\n",
"15\n",
"11\n"
]
} | {
"input": [
"8\n5 4 3 2 1 1 1 1\n",
"4\n100 101 101 100\n",
"2\n10 10\n",
"3\n100 100 101\n",
"13\n2 2 2 1 1 1 1 1 1 1 2 2 2\n",
"2\n2 3\n",
"4\n2 3 2 2\n",
"10\n896619242 805194919 844752453 848347723 816995848 856813612 805194919 833406689 816255448 805194919\n",
"2\n1111 1110\n... | 1,300 | 1,000 |
2 | 19 | 630_L. Cracking the Code | The protection of a popular program developed by one of IT City companies is organized the following way. After installation it outputs a random five digit number which should be sent in SMS to a particular phone number. In response an SMS activation code arrives.
A young hacker Vasya disassembled the program and foun... | {
"input": [
"12345\n"
],
"output": [
"71232\n"
]
} | {
"input": [
"91537\n",
"13542\n",
"32036\n",
"71232\n",
"10000\n",
"70809\n",
"41675\n",
"99999\n",
"11111\n"
],
"output": [
"27651\n",
"84443\n",
"82432\n",
"10151\n",
"00000\n",
"00000\n",
"61851\n",
"99999\n",
"36551\n"
]
} | 1,400 | 0 |
2 | 10 | 659_D. Bicycle Race | Maria participates in a bicycle race.
The speedway takes place on the shores of Lake Lucerne, just repeating its contour. As you know, the lake shore consists only of straight sections, directed to the north, south, east or west.
Let's introduce a system of coordinates, directing the Ox axis from west to east, and th... | {
"input": [
"16\n1 1\n1 5\n3 5\n3 7\n2 7\n2 9\n6 9\n6 7\n5 7\n5 3\n4 3\n4 4\n3 4\n3 2\n5 2\n5 1\n1 1\n",
"6\n0 0\n0 1\n1 1\n1 2\n2 2\n2 0\n0 0\n"
],
"output": [
"6\n",
"1\n"
]
} | {
"input": [
"24\n-10000 -10000\n-10000 9998\n9998 9998\n9998 -10000\n-6364 -10000\n-6364 6362\n6362 6362\n6362 -6364\n-2728 -6364\n-2728 2726\n2726 2726\n2726 -910\n908 -910\n908 908\n-910 908\n-910 -4546\n4544 -4546\n4544 4544\n-4546 4544\n-4546 -8182\n8180 -8182\n8180 8180\n-8182 8180\n-8182 -10000\n-10000 -10... | 1,500 | 1,250 |
2 | 7 | 682_A. Alyona and Numbers | After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers — the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column ... | {
"input": [
"5 7\n",
"1 5\n",
"21 21\n",
"6 12\n",
"11 14\n",
"3 8\n"
],
"output": [
"7\n",
"1\n",
"88\n",
"14\n",
"31\n",
"5\n"
]
} | {
"input": [
"4743 139826\n",
"1436 237592\n",
"2 9\n",
"171591 13322\n",
"4 4\n",
"1000000 1\n",
"253 821\n",
"1 1000000\n",
"8 2\n",
"834588 107199\n",
"478 828\n",
"827388 966812\n",
"879 14\n",
"371143 78307\n",
"855 355\n",
"650812 789902\n",
"9... | 1,100 | 500 |
2 | 10 | 748_D. Santa Claus and a Palindrome | Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them presented to him a string si having the same length n. We denote the beauty of the i-th string by ai. It can happen that ai is negative — that means that Santa doesn't find this s... | {
"input": [
"7 3\nabb 2\naaa -3\nbba -1\nzyz -4\nabb 5\naaa 7\nxyx 4\n",
"2 5\nabcde 10000\nabcde 10000\n",
"3 1\na 1\na 2\na 3\n"
],
"output": [
"12\n",
"0\n",
"6\n"
]
} | {
"input": [
"10 10\nnjxbzflaka -1\nfelbvvtkja 6\ngxiuztqkcw 5\naomvscmtti 6\njsqmkoyuca -2\nwckqtzuixg 5\najktvvblef -5\nittmcsvmoa -1\nakalfzbxjn 10\nacuyokmqsj 8\n",
"3 3\nada -1\nxuv -1\nvux 3\n",
"4 3\ndbd 24\naba 90\ncbc 54\naba 46\n",
"3 2\naa 5\naa -2\nbb 1\n",
"2 2\nsn 1\nns 2\n",
"4 ... | 2,100 | 2,000 |
2 | 9 | 771_C. Bear and Tree Jumps | A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.
Limak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n.
Limak recently learned how to jump. He can jump from a vertex to any verte... | {
"input": [
"6 2\n1 2\n1 3\n2 4\n2 5\n4 6\n",
"3 5\n2 1\n3 1\n",
"13 3\n1 2\n3 2\n4 2\n5 2\n3 6\n10 6\n6 7\n6 13\n5 8\n5 9\n9 11\n11 12\n"
],
"output": [
"20\n",
"3\n",
"114\n"
]
} | {
"input": [
"12 3\n5 11\n10 11\n6 4\n8 9\n4 12\n10 7\n4 1\n3 1\n2 12\n9 4\n9 10\n",
"2 5\n2 1\n",
"2 1\n1 2\n",
"15 1\n12 9\n13 7\n1 3\n10 4\n9 2\n2 15\n11 4\n2 14\n10 8\n6 7\n12 5\n8 7\n3 10\n10 2\n",
"4 2\n3 4\n2 4\n3 1\n"
],
"output": [
"88\n",
"1\n",
"1\n",
"346\n",
"7... | 2,100 | 1,000 |
2 | 9 | 796_C. Bank Hacking | Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks.
<image>
There are n banks, numbered from 1 to n. There are also n - 1 wires connecting the ... | {
"input": [
"5\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n",
"5\n1 2 7 6 7\n1 5\n5 3\n3 4\n2 4\n",
"7\n38 -29 87 93 39 28 -55\n1 2\n2 5\n3 2\n2 4\n1 7\n7 6\n"
],
"output": [
"5\n",
"8\n",
"93\n"
]
} | {
"input": [
"2\n999999999 1000000000\n2 1\n",
"5\n-1 -1000000000 -1 -2 -1\n5 2\n1 2\n3 2\n4 1\n",
"3\n-1000000000 -999999999 -1000000000\n1 2\n3 1\n",
"3\n-999999999 -999999998 -1000000000\n2 3\n1 2\n",
"2\n-1000000000 -1\n1 2\n",
"5\n0 0 0 0 0\n3 2\n1 2\n5 1\n4 2\n",
"2\n0 1\n2 1\n",
... | 1,900 | 1,000 |
2 | 10 | 816_D. Karen and Test | Karen has just arrived at school, and she has a math test today!
<image>
The test is about basic addition and subtraction. Unfortunately, the teachers were too busy writing tasks for Codeforces rounds, and had no time to make an actual test. So, they just put one question in the test that is worth all the points.
Th... | {
"input": [
"4\n3 7 5 2\n",
"5\n3 6 9 12 15\n"
],
"output": [
"1000000006",
"36"
]
} | {
"input": [
"6\n58376259 643910770 5887448 757703054 544067926 902981667\n",
"16\n985629174 189232688 48695377 692426437 952164554 243460498 173956955 210310239 237322183 96515847 678847559 682240199 498792552 208770488 736004147 176573082\n",
"7\n941492387 72235422 449924898 783332532 378192988 59268463... | 2,200 | 1,250 |
2 | 10 | 841_D. Leha and another game about graph | Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or - 1. To pass the level, he needs to find a «good» subset of edges of the graph or say... | {
"input": [
"1 0\n1\n",
"3 3\n0 -1 1\n1 2\n2 3\n1 3\n",
"2 1\n1 1\n1 2\n",
"4 5\n0 0 0 -1\n1 2\n2 3\n3 4\n1 4\n2 4\n"
],
"output": [
"-1\n",
"1\n2\n",
"1\n1\n",
"0\n"
]
} | {
"input": [
"10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 2\n9 2\n5 10\n9 8\n10 7\n5 1\n6 2\n",
"3 2\n1 0 1\n1 2\n2 3\n"
],
"output": [
"0\n",
"2\n1\n2\n"
]
} | 2,100 | 1,000 |
2 | 11 | 862_E. Mahmoud and Ehab and the function | Dr. Evil is interested in math and functions, so he gave Mahmoud and Ehab array a of length n and array b of length m. He introduced a function f(j) which is defined for integers j, which satisfy 0 ≤ j ≤ m - n. Suppose, ci = ai - bi + j. Then f(j) = |c1 - c2 + c3 - c4... cn|. More formally, <image>.
Dr. Evil wants Ma... | {
"input": [
"5 6 3\n1 2 3 4 5\n1 2 3 4 5 6\n1 1 10\n1 1 -9\n1 5 -1\n"
],
"output": [
"0\n9\n0\n0\n"
]
} | {
"input": [
"1 1 1\n937982044\n179683049\n1 1 821220804\n"
],
"output": [
"758298995\n1579519799\n"
]
} | 2,100 | 2,000 |
2 | 9 | 888_C. K-Dominant Character | You are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this character c.
You have to find minimum k such that there exists at least one k-dominant character.
Input
The first line contains string s consisting of lowercas... | {
"input": [
"zzzzz\n",
"abacaba\n",
"abcde\n"
],
"output": [
"1",
"2",
"3"
]
} | {
"input": [
"lzeznbwu\n",
"rr\n",
"abb\n",
"saaaaaaaas\n",
"gfliflgfhhdkceacdljgkegmdlhcgkcmlelmbbbmdddgdeeljjhgbbffmemmmkhebgkhadkdajabcjkcgbkgbaeacdedlkklfech\n",
"a\n",
"aab\n",
"aaabbb\n",
"abghim\n",
"zx\n",
"axcbb\n",
"abcdea\n",
"daabcdabbabbacacbaacabacbcaa... | 1,400 | 0 |
2 | 7 | 911_A. Nearest Minimums | You are given an array of n integer numbers a0, a1, ..., an - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.
Input
The first line contains positive integer n (2 ≤ n ≤ 105) — size of the given array. The second line contains n ... | {
"input": [
"2\n3 3\n",
"9\n2 1 3 5 4 1 2 3 1\n",
"3\n5 6 5\n"
],
"output": [
"1\n",
"3\n",
"2\n"
]
} | {
"input": [
"10\n1 3 2 4 5 5 4 3 2 1\n",
"11\n2 2 2 2 2 2 1 1 2 2 2\n",
"8\n5 5 5 5 3 5 5 3\n",
"10\n2 2 2 2 2 1 1 2 2 2\n",
"2\n88888888 88888888\n",
"5\n100000000 100000001 100000000 100000001 100000000\n",
"8\n10 5 10 1 10 10 10 1\n",
"19\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2\n",
... | 1,100 | 0 |
2 | 7 | 95_A. Hockey | Petya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection of forbidden substrings s1, s2, ..., sn. All those strings consist of uppercase and lowercase Latin ... | {
"input": [
"2\naCa\ncba\nabAcaba\nc\n",
"3\nbers\nucky\nelu\nPetrLoveLuckyNumbers\nt\n",
"4\nhello\nparty\nabefglghjdhfgj\nIVan\npetrsmatchwin\na\n"
],
"output": [
"abCacba\n",
"PetrLovtTttttNumtttt\n",
"petrsmatchwin\n"
]
} | {
"input": [
"3\netr\ned\nied\nPetrUnited\nz\n",
"99\ns\nc\nN\nN\ni\ni\nW\nJ\nA\nW\nm\nB\nf\nO\nm\nk\nQ\nf\nx\np\nl\nH\nH\no\nn\nC\nK\nR\ns\nT\nJ\nv\nC\nZ\nd\nl\nr\no\nD\ng\na\nA\nE\nk\nN\nw\na\nb\no\nk\nv\nc\ni\nj\nE\nl\no\nf\nv\ns\nh\nx\nm\nE\nN\nt\nj\nk\ng\nk\nX\nW\ni\nX\nm\nw\nK\nL\nQ\nr\nj\nf\no\nw\nv\nS... | 1,600 | 500 |
2 | 10 | 1005_D. Polycarp and Div 3 | Polycarp likes numbers that are divisible by 3.
He has a huge number s. Polycarp wants to cut from it the maximum number of numbers that are divisible by 3. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits. As a result, after m such cuts, there will be m+1 parts in total. Poly... | {
"input": [
"201920181\n",
"3121\n",
"1000000000000000000000000000000000\n",
"6\n"
],
"output": [
"4\n",
"2\n",
"33\n",
"1\n"
]
} | {
"input": [
"11\n",
"13\n",
"31\n",
"1670000\n",
"10\n",
"10000170\n",
"4\n",
"12\n",
"14139582796\n",
"604500\n",
"40041\n"
],
"output": [
"0\n",
"1\n",
"1\n",
"5\n",
"1\n",
"5\n",
"0\n",
"1\n",
"6\n",
"5\n",
"2\n"
]
} | 1,500 | 0 |
2 | 8 | 1029_B. Creating the Contest | You are given a problemset consisting of n problems. The difficulty of the i-th problem is a_i. It is guaranteed that all difficulties are distinct and are given in the increasing order.
You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to as... | {
"input": [
"5\n2 10 50 110 250\n",
"10\n1 2 5 6 7 10 21 23 24 49\n",
"6\n4 7 12 100 150 199\n"
],
"output": [
"1\n",
"4\n",
"3\n"
]
} | {
"input": [
"2\n2 3\n",
"2\n10 20\n",
"5\n1 2 5 10 20\n",
"5\n1 2 4 9 18\n",
"2\n1 3\n",
"6\n1 2 5 11 22 44\n",
"3\n1 3 6\n",
"5\n1 2 4 8 16\n",
"5\n1 2 4 5 8\n",
"5\n1 2 3 4 5\n",
"3\n2 4 8\n",
"10\n1 2 5 11 12 24 25 26 27 28\n",
"3\n1 2 4\n",
"3\n1 2 9\n",
... | 1,200 | 0 |
2 | 7 | 104_A. Blackjack | One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!
Why not make her own Codeforces, with blackjack and other really cool stuff? Many people will surely be willing to... | {
"input": [
"12\n",
"10\n",
"20\n"
],
"output": [
"4\n",
"0\n",
"15\n"
]
} | {
"input": [
"15\n",
"6\n",
"13\n",
"11\n",
"5\n",
"17\n",
"9\n",
"18\n",
"2\n",
"1\n",
"22\n",
"3\n",
"24\n",
"4\n",
"23\n",
"16\n",
"14\n",
"25\n",
"19\n",
"8\n",
"21\n",
"7\n"
],
"output": [
"4\n",
"0\n",
"4\n",... | 800 | 500 |
2 | 8 | 1071_B. Minimum path | You are given a matrix of size n × n filled with lowercase English letters. You can change no more than k letters in this matrix.
Consider all paths from the upper left corner to the lower right corner that move from a cell to its neighboring cell to the right or down. Each path is associated with the string that is f... | {
"input": [
"4 2\nabcd\nbcde\nbcad\nbcde\n",
"7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nnpmuduh\npmutsnz\n",
"5 3\nbwwwz\nhrhdh\nsepsp\nsqfaf\najbvw\n"
],
"output": [
"aaabcde\n",
"aaaaaaadudsnz\n",
"aaaepfafw\n"
]
} | {
"input": [
"1 0\nz\n",
"1 1\ng\n",
"1 0\na\n",
"1 1\nz\n",
"1 0\ng\n",
"4 16\ndfhs\nvgca\ndfgd\nvscd\n"
],
"output": [
"z\n",
"a\n",
"a\n",
"a\n",
"g\n",
"aaaaaaa\n"
]
} | 1,900 | 2,000 |
2 | 10 | 1093_D. Beautiful Graph | You are given an undirected unweighted graph consisting of n vertices and m edges.
You have to write a number on each vertex of the graph. Each number should be 1, 2 or 3. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.
Calculate the number of possible ways t... | {
"input": [
"2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n"
],
"output": [
"4\n0\n"
]
} | {
"input": [
"12\n8 7\n2 3\n3 4\n4 5\n5 2\n6 7\n7 8\n8 6\n1 0\n2 1\n1 2\n3 3\n1 2\n2 3\n1 3\n3 2\n2 3\n3 1\n4 4\n1 2\n2 3\n3 4\n4 1\n4 4\n1 2\n2 3\n3 1\n4 1\n6 9\n1 4\n1 5\n1 6\n2 4\n2 5\n2 6\n3 4\n3 5\n3 6\n100000 0\n1000 5\n55 56\n56 57\n57 58\n58 59\n59 55\n11 11\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n... | 1,700 | 0 |
2 | 10 | 1113_D. Sasha and One More Name | Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: "Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwarves, Olórin I was in my youth in the West that is forgotten, in t... | {
"input": [
"nolon\n",
"kinnikkinnik\n",
"otto\n",
"qqqq\n"
],
"output": [
"2\n",
"1\n",
"1\n",
"Impossible\n"
]
} | {
"input": [
"bbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbggggggggggbgbgggbbgbbgbgggbbbbgggggbgbgggbbgbbgbgggbbbbgggggbgbgggbbgbbgbgggbbbbgggggbgbgggbbgbbgbgggbbbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggbbbbgggbgbbgbbgggbgbgggggggg... | 1,800 | 1,250 |
2 | 12 | 1141_F2. Same Sum Blocks (Hard) | This problem is given in two editions, which differ exclusively in the constraints on the number n.
You are given an array of integers a[1], a[2], ..., a[n]. A block is a sequence of contiguous (consecutive) elements a[l], a[l+1], ..., a[r] (1 ≤ l ≤ r ≤ n). Thus, a block is defined by a pair of indices (l, r).
Find a... | {
"input": [
"7\n4 1 2 2 1 5 3\n",
"4\n1 1 1 1\n",
"11\n-5 -4 -3 -2 -1 0 1 2 3 4 5\n"
],
"output": [
"3\n2 3\n4 5\n7 7\n",
"4\n1 1\n2 2\n3 3\n4 4\n",
"2\n1 1\n3 4\n"
]
} | {
"input": [
"100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n",... | 1,900 | 0 |
2 | 7 | 1162_A. Zoning Restrictions Again | You are planning to build housing on a street. There are n spots available on the street on which you can build a house. The spots are labeled from 1 to n from left to right. In each spot, you can build a house with an integer height between 0 and h.
In each spot, if a house has height a, you will gain a^2 dollars fro... | {
"input": [
"3 3 3\n1 1 1\n2 2 3\n3 3 2\n",
"4 10 2\n2 3 8\n3 4 7\n"
],
"output": [
"14\n",
"262\n"
]
} | {
"input": [
"50 50 50\n15 21 1\n8 40 30\n25 34 4\n19 46 8\n24 32 16\n2 31 37\n18 18 43\n27 42 37\n7 28 48\n2 31 36\n43 45 19\n8 48 25\n4 26 13\n36 42 20\n15 26 18\n28 43 18\n7 32 47\n18 46 7\n9 39 5\n17 35 21\n21 24 38\n12 30 34\n18 49 38\n28 46 32\n39 41 31\n1 26 1\n14 29 35\n23 33 7\n23 32 25\n1 13 15\n17 20 5... | 800 | 500 |
2 | 7 | 1200_A. Hotelier | Amugae has a hotel consisting of 10 rooms. The rooms are numbered from 0 to 9 from left to right.
The hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest to the left entrance. Similar... | {
"input": [
"9\nL0L0LLRR9\n",
"8\nLLRL1RL1\n"
],
"output": [
"1100000010\n",
"1010000011\n"
]
} | {
"input": [
"8\nLLLL1LLL\n",
"4\nRRRL\n",
"12\nRRRRRRRRRR9L\n",
"8\nLLLLLLL1\n",
"7\nLRLLRLL\n",
"12\nLLLLLLLLLL1R\n",
"12\nLLLLLRRRRR8L\n",
"2\nLR\n",
"5\nLRLLL\n",
"10\nLRRLRRLRRL\n",
"6\nLRRRRR\n",
"12\nLLLLLLLLLL7R\n",
"9\nLLLLLLLLL\n",
"14\nLLLLLLLLLL84LL\... | 800 | 500 |
2 | 12 | 1240_F. Football | There are n football teams in the world.
The Main Football Organization (MFO) wants to host at most m games. MFO wants the i-th game to be played between the teams a_i and b_i in one of the k stadiums.
Let s_{ij} be the numbers of games the i-th team played in the j-th stadium. MFO does not want a team to have much... | {
"input": [
"7 11 3\n4 7 8 10 10 9 3\n6 2\n6 1\n7 6\n4 3\n4 6\n3 1\n5 3\n7 5\n7 3\n4 2\n1 4\n"
],
"output": [
"1\n2\n1\n1\n2\n1\n2\n2\n3\n3\n1\n"
]
} | {
"input": [
"7 11 3\n4 7 8 10 10 9 3\n6 2\n6 1\n7 6\n4 3\n4 6\n3 1\n5 3\n7 5\n7 3\n4 2\n1 4\n",
"7 11 3\n4 7 8 10 10 9 3\n6 2\n6 1\n7 6\n4 3\n4 6\n3 1\n5 3\n7 5\n7 3\n4 2\n1 4\n",
"7 11 3\n4 7 8 10 10 9 3\n6 2\n6 1\n7 6\n4 3\n4 6\n3 1\n5 3\n7 5\n7 3\n4 2\n1 4\n",
"100 0 1\n629 909 904 632 485 339 719... | 3,100 | 2,750 |
2 | 7 | 1261_A. Messy | You are fed up with your messy room, so you decided to clean it up.
Your room is a bracket sequence s=s_{1}s_{2}... s_{n} of length n. Each character of this string is either an opening bracket '(' or a closing bracket ')'.
In one operation you can choose any consecutive substring of s and reverse it. In other words,... | {
"input": [
"4\n8 2\n()(())()\n10 3\n))()()()((\n2 1\n()\n2 1\n)(\n"
],
"output": [
"1\n5 7\n5\n1 3\n3 5\n5 7\n6 9\n7 10\n0\n1\n1 2\n"
]
} | {
"input": [
"4\n8 2\n()(())()\n10 3\n))()()()((\n2 1\n()\n2 1\n)(\n"
],
"output": [
"1\n5 7\n5\n1 3\n3 5\n5 7\n6 9\n7 10\n0\n1\n1 2\n"
]
} | 1,700 | 1,250 |
2 | 8 | 1283_B. Candies Division | Santa has n candies and he wants to gift them to k kids. He wants to divide as many candies as possible between all k kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all.
Suppose the kid who recieves the minimum number of candies has a candies and the kid who recieves the max... | {
"input": [
"5\n5 2\n19 4\n12 7\n6 2\n100000 50010\n"
],
"output": [
"5\n18\n10\n6\n75015\n"
]
} | {
"input": [
"1\n1233212 4\n"
],
"output": [
"1233212\n"
]
} | 900 | 0 |
2 | 12 | 1367_F1. Flying Sort (Easy Version) | This is an easy version of the problem. In this version, all numbers in the given array are distinct and the constraints on n are less than in the hard version of the problem.
You are given an array a of n integers (there are no equals elements in the array). You can perform the following operations on array elements:... | {
"input": [
"4\n5\n4 7 2 3 9\n5\n3 5 8 1 7\n5\n1 4 5 7 12\n4\n0 2 1 3\n"
],
"output": [
"2\n2\n0\n2\n"
]
} | {
"input": [
"9\n5\n4 7 2 2 9\n5\n3 5 8 1 7\n5\n1 2 2 4 5\n2\n0 1\n3\n0 1 0\n4\n0 1 0 0\n4\n0 1 0 1\n4\n0 1 0 2\n20\n16 15 1 10 0 14 0 10 3 9 2 5 4 5 17 9 10 20 0 9\n"
],
"output": [
"2\n2\n0\n0\n1\n1\n1\n1\n16\n"
]
} | 2,100 | 0 |
2 | 7 | 1389_A. LCM Problem | Let LCM(x, y) be the minimum positive integer that is divisible by both x and y. For example, LCM(13, 37) = 481, LCM(9, 6) = 18.
You are given two integers l and r. Find two integers x and y such that l ≤ x < y ≤ r and l ≤ LCM(x, y) ≤ r.
Input
The first line contains one integer t (1 ≤ t ≤ 10000) — the number of tes... | {
"input": [
"4\n1 1337\n13 69\n2 4\n88 89\n"
],
"output": [
"1 2\n13 26\n2 4\n-1 -1\n"
]
} | {
"input": [
"1\n80000000 160000000\n",
"1\n78788 157576\n",
"1\n1000003 100000000\n",
"1\n96777 19555557\n",
"4\n1 1337\n13 69\n2 4\n88 89\n",
"69\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n... | 800 | 0 |
2 | 10 | 1409_D. Decrease the Sum of Digits | You are given a positive integer n. In one move, you can increase n by one (i.e. make n := n + 1). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of n be less than or equal to s.
You have to answer t independent test cases.
Input
The first line of the input co... | {
"input": [
"5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1\n"
],
"output": [
"0\n0\n0\n8\n0\n"
]
} | {
"input": [
"1\n9987 1\n",
"21\n1 3218\n28 10924\n908802 141084\n82149 9274\n893257 10248\n2750048 802705\n2857 142\n980 209385\n1 3218\n28 10924\n908802 141084\n82149 9274\n893257 10248\n2750048 802705\n2857 142\n980 209385\n1 3218\n28 10924\n908802 141084\n82149 9274\n893257 10248\n",
"1\n2232 7\n",
... | 1,500 | 0 |
2 | 10 | 1453_D. Checkpoints | Gildong is developing a game consisting of n stages numbered from 1 to n. The player starts the game from the 1-st stage and should beat the stages in increasing order of the stage number. The player wins the game after beating the n-th stage.
There is at most one checkpoint on each stage, and there is always a checkp... | {
"input": [
"4\n1\n2\n8\n12\n"
],
"output": [
"\n-1\n1\n1\n4\n1 1 1 1\n5\n1 1 0 1 1\n"
]
} | {
"input": [
"50\n1000000\n1000002\n1000004\n1000006\n1000008\n1000010\n1000012\n1000014\n1000016\n1000018\n1000020\n1000022\n1000024\n1000026\n1000028\n1000030\n1000032\n1000034\n1000036\n1000038\n1000040\n1000042\n1000044\n1000046\n1000048\n1000050\n1000052\n1000054\n1000056\n1000058\n1000060\n1000062\n1000064\... | 1,900 | 2,000 |
2 | 8 | 1477_B. Nezzar and Binary String | Nezzar has a binary string s of length n that he wants to share with his best friend, Nanako. Nanako will spend q days inspecting the binary string. At the same time, Nezzar wants to change the string s into string f during these q days, because it looks better.
It is known that Nanako loves consistency so much. On th... | {
"input": [
"4\n5 2\n00000\n00111\n1 5\n1 3\n2 1\n00\n01\n1 2\n10 6\n1111111111\n0110001110\n1 10\n5 9\n7 10\n1 7\n3 5\n6 10\n5 2\n10000\n11000\n2 5\n1 3\n"
],
"output": [
"\nYES\nNO\nYES\nNO\n"
]
} | {
"input": [
"1\n4 1\n0011\n0011\n1 4\n"
],
"output": [
"NO\n"
]
} | 1,900 | 1,000 |
2 | 9 | 159_C. String Manipulation 1.0 | One popular website developed an unusual username editing procedure. One can change the username only by deleting some characters from it: to change the current name s, a user can pick number p and character c and delete the p-th occurrence of character c from the name. After the user changed his name, he can't undo th... | {
"input": [
"2\nbac\n3\n2 a\n1 b\n2 c\n",
"1\nabacaba\n4\n1 a\n1 a\n1 c\n2 b\n"
],
"output": [
"acb\n",
"baa\n"
]
} | {
"input": [
"10\nccbcabbaca\n40\n2 c\n8 b\n26 b\n12 b\n24 a\n29 a\n20 c\n17 b\n32 c\n9 c\n16 b\n13 b\n19 a\n3 c\n2 b\n18 c\n4 a\n13 c\n8 c\n5 c\n13 a\n19 c\n26 c\n13 c\n6 c\n3 c\n4 a\n5 a\n9 c\n8 b\n9 c\n2 c\n19 a\n5 a\n12 c\n10 c\n2 b\n19 c\n21 a\n16 b\n",
"10\nabaabbaaac\n40\n10 b\n24 a\n15 a\n7 b\n22 b\n2... | 1,400 | 1,500 |
2 | 7 | 201_A. Clear Symmetry | Consider some square matrix A with side n consisting of zeros and ones. There are n rows numbered from 1 to n from top to bottom and n columns numbered from 1 to n from left to right in this matrix. We'll denote the element of the matrix which is located at the intersection of the i-row and the j-th column as Ai, j.
L... | {
"input": [
"9\n",
"4\n"
],
"output": [
"5\n",
"3\n"
]
} | {
"input": [
"6\n",
"89\n",
"15\n",
"91\n",
"76\n",
"80\n",
"96\n",
"72\n",
"79\n",
"5\n",
"74\n",
"97\n",
"47\n",
"50\n",
"3\n",
"7\n",
"94\n",
"20\n",
"75\n",
"66\n",
"46\n",
"14\n",
"71\n",
"22\n",
"81\n",
"56\n... | 1,700 | 1,000 |
2 | 11 | 225_E. Unsolvable | Consider the following equation:
<image> where sign [a] represents the integer part of number a.
Let's find all integer z (z > 0), for which this equation is unsolvable in positive integers. The phrase "unsolvable in positive integers" means that there are no such positive integers x and y (x, y > 0), for which the ... | {
"input": [
"2\n",
"3\n",
"1\n"
],
"output": [
" 3\n",
" 15\n",
" 1\n"
]
} | {
"input": [
"14\n",
"38\n",
"25\n",
"22\n",
"26\n",
"20\n",
"34\n",
"8\n",
"32\n",
"16\n",
"30\n",
"28\n",
"18\n",
"37\n",
"10\n",
"39\n",
"35\n",
"15\n",
"27\n",
"12\n",
"31\n",
"24\n",
"5\n",
"19\n",
"6\n",
"21\... | 2,100 | 3,000 |
2 | 9 | 24_C. Sequence of points | You are given the following points with integer coordinates on the plane: M0, A0, A1, ..., An - 1, where n is odd number. Now we define the following infinite sequence of points Mi: Mi is symmetric to Mi - 1 according <image> (for every natural number i). Here point B is symmetric to A according M, if M is the center o... | {
"input": [
"3 4\n0 0\n1 1\n2 3\n-5 3\n",
"3 1\n5 5\n1000 1000\n-1000 1000\n3 100\n"
],
"output": [
"14 0\n",
"1995 1995\n"
]
} | {
"input": [
"1 1000000000000000000\n-1000 1000\n1000 -1000\n",
"1 1\n-1000 -1000\n1000 1000\n",
"1 900000000000000001\n-1000 -1000\n-1000 -1000\n"
],
"output": [
"-1000 1000\n",
"3000 3000\n",
"-1000 -1000\n"
]
} | 1,800 | 0 |
2 | 7 | 298_A. Snow Footprints | There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th block, he will leave a right footprint on the i-th block. Similarly, if one moves from the i-th block to the (i - 1)-th block, he will leave a left footprint ... | {
"input": [
"11\n.RRRLLLLL..\n",
"9\n..RRLL...\n"
],
"output": [
"2 4\n",
"3 4\n"
]
} | {
"input": [
"13\n....LLLLLL...\n",
"3\n.L.\n",
"3\n.R.\n",
"4\n.RL.\n",
"17\n.......RRRRR.....\n"
],
"output": [
"10 4\n",
"2 1\n",
"2 3\n",
"2 2\n",
"8 13\n"
]
} | 1,300 | 500 |
2 | 10 | 320_D. Psychos in a Line | There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step.
You're given the initial arrangeme... | {
"input": [
"6\n1 2 3 4 5 6\n",
"10\n10 9 7 8 6 5 3 4 2 1\n"
],
"output": [
"0\n",
"2\n"
]
} | {
"input": [
"1\n1\n",
"6\n6 5 4 3 2 1\n",
"15\n15 9 5 10 7 11 14 6 2 3 12 1 8 13 4\n",
"2\n1 2\n",
"100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 ... | 1,900 | 1,000 |
2 | 7 | 369_A. Valera and Plates | Valera is a lazy student. He has m clean bowls and k clean plates.
Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl. We know that Valera can cook only two types of dishes. He can eat d... | {
"input": [
"4 3 1\n1 1 1 1\n",
"3 1 2\n2 2 2\n",
"3 1 1\n1 2 1\n",
"8 2 2\n1 2 1 2 1 2 1 2\n"
],
"output": [
"1",
"0",
"1",
"4"
]
} | {
"input": [
"5 2 1\n1 1 2 2 2\n",
"2 100 100\n2 2\n",
"14 4 7\n1 1 1 2 2 2 2 2 2 2 2 2 2 2\n",
"233 100 1\n2 2 1 1 1 2 2 2 2 1 1 2 2 2 1 2 2 1 1 1 2 2 1 1 1 1 2 1 2 2 1 1 2 2 1 2 2 1 2 1 2 1 2 2 2 1 1 1 1 2 1 2 1 1 2 1 1 2 2 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 2 2 2 1 1 2 2 1 1 1 1 2 1 1 2 1 2 2 2 1 1 1 2 ... | 900 | 500 |
2 | 8 | 391_B. Word Folding | You will receive 5 points for solving this problem.
Manao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the opposite direction and aligned to the position of the fold. Using t... | {
"input": [
"ABBBCBDB\n",
"ABRACADABRA\n",
"AB\n"
],
"output": [
"3",
"3",
"1"
]
} | {
"input": [
"ABACBCABACACB\n",
"ZZ\n",
"THISISTHELASTTEST\n",
"ABBCDEFB\n",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ\n",
"THISISATEST\n",
"LEHLLLLLLHAFGEGLLHAFDLHHLLLLLDGGEHGGHLLLLLLLLDFLCBLLEFLLCBLLCGLEDLGGLECLDGLEHLLLGELLLEGLLLLGDLLLDALD\n",
"Z\n"
],
"output": [
"4",
"2",
"3",
... | 0 | 5 |
2 | 7 | 413_A. Data Recovery | Not so long ago company R2 bought company R1 and consequently, all its developments in the field of multicore processors. Now the R2 laboratory is testing one of the R1 processors.
The testing goes in n steps, at each step the processor gets some instructions, and then its temperature is measured. The head engineer in... | {
"input": [
"2 1 1 3\n2\n",
"2 1 1 2\n1\n",
"3 1 1 3\n2\n"
],
"output": [
"Incorrect\n",
"Correct\n",
"Correct\n"
]
} | {
"input": [
"100 99 1 2\n2 1 1 1 2 2 1 1 1 2 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 1 2 1 2 1 2 2 2 2 1 1 1 1 1 2 1 2 2 1 2 2 2 1 1 1 1 1 2 2 2 2 1 2 2 1 1 1 2 1 1 2 1 1 2 1 2 1 2 1 1 1 1 2 1 1 1 1 1 2 2 2 1 1 1 1 2 2 2 2 1 1 2 2 2\n",
"4 1 2 100\n1\n",
"2 1 2 9\n8\n",
"2 1 4 10\n7\n",
"91 75 1 10\n2 6 9 ... | 1,200 | 500 |
2 | 9 | 43_C. Lucky Tickets | Vasya thinks that lucky tickets are the tickets whose numbers are divisible by 3. He gathered quite a large collection of such tickets but one day his younger brother Leonid was having a sulk and decided to destroy the collection. First he tore every ticket exactly in two, but he didn’t think it was enough and Leonid a... | {
"input": [
"3\n123 123 99\n",
"6\n1 1 1 23 10 3\n"
],
"output": [
"1\n",
"1\n"
]
} | {
"input": [
"2\n55431511 35254032\n",
"3\n43440907 58238452 82582355\n",
"1\n19938466\n",
"10\n77241684 71795210 50866429 35232438 22664883 56785812 91050433 75677099 84393937 43832346\n",
"5\n83280 20492640 21552119 7655071 47966344\n",
"2\n28732939 23941418\n",
"4\n31450303 81222872 675... | 1,300 | 1,500 |
2 | 10 | 509_D. Restoring Numbers | Vasya had two arrays consisting of non-negative integers: a of size n and b of size m. Vasya chose a positive integer k and created an n × m matrix v using the following formula:
<image>
Vasya wrote down matrix v on a piece of paper and put it in the table.
A year later Vasya was cleaning his table when he found a p... | {
"input": [
"2 2\n1 2\n2 1\n",
"2 2\n1 2\n2 0\n",
"2 3\n1 2 3\n2 3 4\n"
],
"output": [
"NO\n",
"YES\n3\n0 1 \n1 2 \n",
"YES\n5\n0 1 \n1 2 3 \n"
]
} | {
"input": [
"2 2\n0 2\n2 1\n",
"1 1\n3\n",
"3 2\n3 0\n1 3\n3 1\n",
"2 2\n2 1\n0 2\n",
"2 2\n0 1000000000\n1000000000 57\n",
"2 2\n2 0\n1 2\n",
"2 3\n1 3 3\n3 0 1\n",
"3 2\n3 1\n3 0\n1 3\n",
"5 5\n65 65 63 66 63\n86 86 84 87 84\n92 92 90 93 90\n75 75 73 76 73\n67 67 65 68 65\n",
... | 2,200 | 0 |
2 | 9 | 584_C. Marina and Vasya | Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string.
More formally, you are given two strings s1, s2 of length n and number t. Let's denote as f(a, b) the number of characters in which strings a and ... | {
"input": [
"1 0\nc\nb\n",
"3 2\nabc\nxyc\n"
],
"output": [
"-1",
"bac\n"
]
} | {
"input": [
"1 0\nz\nz\n",
"2 2\nbb\ncb\n",
"1 1\na\nc\n",
"20 2\nywpcwcwgkhdeonzbeamf\ngdcmwcwgkhdeonzbeamf\n",
"5 2\nabaac\nbbbaa\n",
"3 1\nlos\nlns\n",
"7 4\nycgdbph\nfdtapch\n",
"10 6\nrnsssbuiaq\npfsbsbuoay\n",
"5 1\nicahj\nxdvch\n",
"10 1\ngjsywvenzc\nfssywvenzc\n",
... | 1,700 | 1,500 |
2 | 9 | 606_C. Sorting Railway Cars | An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are distinct) and positioned in arbitrary order. David Blaine wants to sort the railway cars in the order of increasing numbers. In one move he can make one of the cars disappear from its place and teleport it... | {
"input": [
"5\n4 1 2 5 3\n",
"4\n4 1 3 2\n"
],
"output": [
"2",
"2"
]
} | {
"input": [
"50\n10 37 3 46 45 29 36 13 21 25 35 5 18 33 12 19 50 16 30 47 20 42 39 28 2 6 38 8 7 31 22 27 26 9 15 14 34 48 4 32 40 43 44 24 11 1 23 17 49 41\n",
"50\n1 2 3 4 5 6 7 8 43 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 50 33 34 35 36 37 38 39 40 41 42 9 44 45 46 47 48 49 32\n... | 1,600 | 500 |
2 | 9 | 628_C. Bear and String Distance | Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letters only.
The distance between two letters is defined as the difference between their positions in the alphabet. For example, <image>, and <image>.
Also, the distance between two nice strings is defined as t... | {
"input": [
"4 26\nbear\n",
"2 7\naf\n",
"3 1000\nhey\n"
],
"output": [
"zgar",
"hf",
"-1"
]
} | {
"input": [
"10 100\naddaiyssyp\n",
"2 49\nzz\n",
"2 1\nzz\n",
"1 24\ny\n",
"4 17\nrzsq\n",
"1 24\nz\n",
"2 48\nab\n",
"1 8\nc\n",
"5 24\nizrqp\n",
"1 25\na\n",
"1 25\nz\n",
"1 26\na\n",
"2 9\nbc\n",
"1 13\nn\n",
"5 21\nfmmqh\n",
"2 25\nyd\n",
"69 1... | 1,300 | 0 |
2 | 10 | 652_D. Nested Segments | You are given n segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains.
Input
The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of segments on a line.
Each of the next n lines contains two integers li and ri ( - 109 ≤ li < ... | {
"input": [
"4\n1 8\n2 3\n4 7\n5 6\n",
"3\n3 4\n1 5\n2 6\n"
],
"output": [
"3\n0\n1\n0\n",
"0\n1\n1\n"
]
} | {
"input": [
"7\n1 14\n2 7\n3 4\n5 6\n8 13\n9 10\n11 12\n",
"10\n-513515548 596545048\n-864922524 -143639540\n-186185108 253442195\n-325311097 557247880\n-843432193 -793445411\n-589321824 602462994\n-980740122 -845522939\n-20465341 192085177\n363969852 718880403\n-797865714 644017524\n",
"1\n-1 0\n",
... | 1,800 | 0 |
2 | 8 | 678_B. The Same Calendar | The girl Taylor has a beautiful calendar for the year y. In the calendar all days are given with their days of week: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday.
The calendar is so beautiful that she wants to know what is the next year after y when the calendar will be exactly the same. Help Tayl... | {
"input": [
"2000\n",
"50501\n",
"2016\n"
],
"output": [
"2028",
"50507",
"2044"
]
} | {
"input": [
"2097\n",
"1884\n",
"1874\n",
"1872\n",
"12345\n",
"1788\n",
"1899\n",
"1179\n",
"2072\n",
"1900\n",
"2014\n",
"1191\n",
"99988\n",
"1313\n",
"5094\n",
"2006\n",
"2002\n",
"2096\n",
"2100\n",
"99996\n",
"2010\n",
"209... | 1,600 | 0 |
2 | 8 | 700_B. Connecting Universities | Treeland is a country in which there are n towns connected by n - 1 two-way road such that it's possible to get from any town to any other town.
In Treeland there are 2k universities which are located in different towns.
Recently, the president signed the decree to connect universities by high-speed network.The Min... | {
"input": [
"9 3\n3 2 1 6 5 9\n8 9\n3 2\n2 7\n3 4\n7 6\n4 5\n2 1\n2 8\n",
"7 2\n1 5 6 2\n1 3\n3 2\n4 5\n3 7\n4 3\n4 6\n"
],
"output": [
"9\n",
"6\n"
]
} | {
"input": [
"4 2\n1 3 2 4\n1 2\n4 3\n1 4\n",
"41 3\n11 10 15 35 34 6\n28 2\n25 3\n9 4\n11 5\n7 6\n24 7\n19 8\n1 9\n34 10\n23 11\n17 12\n32 13\n32 14\n32 15\n33 16\n8 17\n19 18\n40 19\n15 20\n6 21\n41 22\n35 23\n13 24\n6 25\n22 26\n4 27\n31 28\n34 29\n41 30\n15 31\n4 32\n41 33\n23 34\n21 35\n13 36\n2 37\n22 3... | 1,800 | 1,000 |
2 | 10 | 722_D. Generating Sets | You are given a set Y of n distinct positive integers y1, y2, ..., yn.
Set X of n distinct positive integers x1, x2, ..., xn is said to generate set Y if one can transform X to Y by applying some number of the following two operation to integers in X:
1. Take any integer xi and multiply it by two, i.e. replace xi w... | {
"input": [
"6\n9 7 13 17 5 11\n",
"5\n1 2 3 4 5\n",
"6\n15 14 3 13 1 12\n"
],
"output": [
"1 2 3 4 5 6 \n",
"1 2 3 4 5 \n",
"1 3 7 12 13 14 \n"
]
} | {
"input": [
"100\n41 173 40 30 165 155 92 180 193 24 187 189 65 4 200 80 152 174 20 81 170 72 104 8 13 7 117 176 191 34 90 46 17 188 63 134 76 60 116 42 183 45 1 103 15 119 142 70 148 136 73 68 86 94 32 190 112 166 141 78 6 102 66 97 93 106 47 22 132 129 139 177 62 105 100 77 88 54 3 167 120 145 197 195 64 11 38... | 1,900 | 1,500 |
2 | 8 | 744_B. Hongcow's Game | This is an interactive problem. In the interaction section below you will see the information about flushing the output.
In this problem, you will be playing a game with Hongcow. How lucky of you!
Hongcow has a hidden n by n matrix M. Let Mi, j denote the entry i-th row and j-th column of the matrix. The rows and col... | {
"input": [
"2\n0 0\n0 0",
"3\n0 0 0\n2 7 0\n0 0 4\n3 0 8\n0 5 4"
],
"output": [
"1\n1 \n1\n2 \n-1\n0 0 ",
"2\n1 3 \n1\n2 \n2\n1 2 \n1\n3 \n-1\n2 0 0 "
]
} | {
"input": [
"3\n0 0 0\n0 0 0\n0 0 0\n",
"3\n0 3 2\n5 0 7\n4 8 0\n",
"2\n0 238487454\n54154238 0\n",
"2\n0 0\n0 0\n"
],
"output": [
"2\n1 3 \n1\n2 \n2\n1 2 \n1\n3 \n-1\n0 0 0 ",
"2\n1 3\n1\n2\n2\n1 2\n1\n3\n-1\n0 0 0\n",
"1\n1 \n1\n2 \n-1\n54154238 238487454 ",
"1\n1 \n1\n2 \n-1\n0... | 1,900 | 1,250 |
2 | 9 | 791_C. Bear and Different Names | In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communication is crucial and thus no two soldiers should share a name (what would happen if they got an order that Bob is a scouter, if there are two Bobs?).
A group of soldiers is effective if and only if their names... | {
"input": [
"3 2\nNO NO\n",
"9 8\nYES NO\n",
"8 3\nNO NO YES YES YES NO\n"
],
"output": [
"A A A ",
"A B C D E F G H B ",
"A B A B E F G F "
]
} | {
"input": [
"10 5\nYES NO YES NO YES NO\n",
"30 2\nYES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES\n",
"3 2\nYES YES\n",
"8 3\nYES NO YES NO YES NO\n",
"50 50\nYES\n",
"50 48\nYES NO YES\n",
"50 3\nNO YES NO YES NO YES NO... | 1,500 | 500 |
2 | 9 | 858_C. Did you mean... | Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.
Beroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with a typo if there are thr... | {
"input": [
"abacaba\n",
"asdfasdf\n",
"hellno\n"
],
"output": [
"abacaba\n",
"asd fasd f\n",
"hell no\n"
]
} | {
"input": [
"zzzzzzzzzzzzzzzzzzzzzzz\n",
"bbbbbbbb\n",
"jxevkmrwlomaaahaubvjzqtyfqhqbhpqhomxqpiuersltohinvfyeykmlooujymldjqhgqjkvqknlyj\n",
"b\n",
"mvjajoyeg\n",
"zzzzzzzzzz\n",
"xxxxxxxxxzzzzzzzzzzzz\n",
"moyaoborona\n",
"nnnnnnnnnnnn\n",
"lllllb\n",
"bba\n",
"lll\n",... | 1,500 | 1,500 |
2 | 15 | 883_I. Photo Processing | Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo i has a contrast vi. In order for the processing to be truly of high quality, the application must receive at least k photos with contrasts which differ as little as possible.
Evlampiy already k... | {
"input": [
"5 2\n50 110 130 40 120\n",
"4 1\n2 3 4 1\n"
],
"output": [
"20",
"0"
]
} | {
"input": [
"24 4\n33 27 12 65 19 6 46 33 57 2 21 50 73 13 59 69 51 45 39 1 6 64 39 27\n",
"10 4\n810 8527 9736 3143 2341 6029 7474 707 2513 2023\n",
"11 3\n412 3306 3390 2290 1534 316 1080 2860 253 230 3166\n",
"2 2\n1 1000000000\n",
"1 1\n4\n",
"101 9\n3 2 2 1 4 1 3 2 3 4 3 2 3 1 4 4 1 1 4 ... | 1,900 | 0 |
2 | 10 | 907_D. Seating of Students | Students went into a class to write a test and sat in some way. The teacher thought: "Probably they sat in this order to copy works of each other. I need to rearrange them in such a way that students that were neighbors are not neighbors in a new seating."
The class can be represented as a matrix with n rows and m col... | {
"input": [
"2 1\n",
"2 4\n"
],
"output": [
"NO\n",
"YES\n2 4 1 3 \n7 5 8 6 \n"
]
} | {
"input": [
"100 1\n",
"100 3\n",
"101 1\n",
"4 100\n",
"3 1\n",
"3 3\n",
"4 101\n",
"3 2\n",
"101 4\n",
"1 1\n",
"2 101\n",
"2 2\n",
"1 101\n",
"1 2\n",
"101 2\n",
"3 101\n",
"4 2\n",
"1 100\n",
"4 1\n",
"3 100\n",
"101 3\n",
"1... | 2,200 | 1,250 |
2 | 7 | 928_A. Login Verification | When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.
Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds ... | {
"input": [
"000\n3\n00\nooA\noOo\n",
"1_wat\n2\n2_wat\nwat_1\n",
"_i_\n3\n__i_\n_1_\nI\n",
"0Lil\n2\nLIL0\n0Ril\n",
"abc\n1\naBc\n",
"La0\n3\n2a0\nLa1\n1a0\n"
],
"output": [
"No\n",
"Yes\n",
"No\n",
"Yes\n",
"No\n",
"No\n"
]
} | {
"input": [
"l\n1\nI\n",
"L\n1\nI\n",
"o\n1\no\n",
"L1il0o1L1\n5\niLLoLL\noOI1Io10il\nIoLLoO\nO01ilOoI\nI10l0o\n",
"iloO\n3\niIl0\noIl0\nIooO\n",
"lkUL\n25\nIIfL\nokl\nfoo\ni0U\noko\niIoU\nUUv\nvli\nv0Uk\n0Of\niill\n1vkl\nUIf\nUfOO\nlvLO\nUUo0\nIOf1\nlovL\nIkk\noIv\nLvfU\n0UI\nkol\n1OO0\n1OOi... | 1,200 | 500 |
2 | 9 | 957_C. Three-level Laser | An atom of element X can exist in n distinct states with energies E1 < E2 < ... < En. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens:
... | {
"input": [
"10 8\n10 13 15 16 17 19 20 22 24 25\n",
"4 4\n1 3 5 7\n",
"3 1\n2 5 10\n"
],
"output": [
"0.8750000000",
"0.5000000000",
"-1"
]
} | {
"input": [
"5 3\n4 6 8 9 10\n",
"3 5\n1 2 10\n",
"5 2\n4 6 8 9 10\n",
"5 1000000000\n1 2 3 999999999 1000000000\n",
"30 5\n102 104 105 107 108 109 110 111 116 118 119 122 127 139 140 142 145 157 166 171 173 174 175 181 187 190 191 193 195 196\n",
"3 1\n1 2 3\n",
"10 2\n110 121 140 158 17... | 1,600 | 1,000 |
2 | 9 | 982_C. Cut 'em all! | You're given a tree with n vertices.
Your task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.
Input
The first line contains an integer n (1 ≤ n ≤ 10^5) denoting the size of the tree.
The next n - 1 lines contai... | {
"input": [
"4\n2 4\n4 1\n3 1\n",
"2\n1 2\n",
"10\n7 1\n8 4\n8 10\n4 7\n6 5\n9 3\n3 5\n2 10\n2 5\n",
"3\n1 2\n1 3\n"
],
"output": [
"1\n",
"0\n",
"4\n",
"-1\n"
]
} | {
"input": [
"1\n",
"4\n1 2\n1 3\n1 4\n"
],
"output": [
"-1\n",
"0\n"
]
} | 1,500 | 1,500 |
2 | 7 | 1010_A. Fly | Natasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n - 2 intermediate planets. Formally: we number all the planets from 1 to n. 1 is Earth, n is Mars. Natasha will make exactly n flights: 1 → 2 → … n → 1.
Flight from x to y consists of two phases: take-off from ... | {
"input": [
"2\n12\n11 8\n7 5\n",
"3\n1\n1 4 1\n2 5 3\n",
"6\n2\n4 6 3 3 5 6\n2 6 3 6 5 3\n"
],
"output": [
"10.00000000\n",
"-1.00000000\n",
"85.48000000\n"
]
} | {
"input": [
"2\n1\n1 1\n1 1\n",
"2\n2\n1 1\n1 1\n",
"4\n4\n2 3 2 2\n2 3 4 3\n",
"2\n2\n2 2\n2 2\n",
"3\n3\n7 11 17\n19 31 33\n",
"2\n1\n2 2\n1 1\n",
"8\n4\n1 1 4 1 3 1 8 1\n1 1 1 1 1 3 1 2\n",
"10\n10\n9 8 8 7 2 10 2 9 2 4\n3 10 6 2 6 6 5 9 4 5\n",
"40\n55\n1 382 1 1 1 629 111 689... | 1,500 | 500 |
2 | 7 | 1034_A. Enlarge GCD | Mr. F has n positive integers, a_1, a_2, …, a_n.
He thinks the greatest common divisor of these integers is too small. So he wants to enlarge it by removing some of the integers.
But this problem is too simple for him, so he does not want to do it by himself. If you help him, he will give you some scores in reward.
... | {
"input": [
"4\n6 9 15 30\n",
"3\n1 1 1\n",
"3\n1 2 4\n"
],
"output": [
"2\n",
"-1\n",
"1\n"
]
} | {
"input": [
"10\n10 8 9 5 4 8 8 10 8 1\n",
"2\n2 4\n",
"2\n3 9\n",
"2\n1 7\n",
"3\n1 100003 100003\n",
"3\n1 14999981 14999981\n",
"3\n2 4 8\n",
"100\n95 94 31 65 35 95 70 78 81 36 69 97 39 28 89 62 36 23 35 21 36 11 65 39 13 34 79 87 91 70 43 82 24 97 6 87 49 81 60 92 63 9 16 6 31 90... | 1,800 | 750 |
2 | 8 | 107_B. Basketball Team | As a German University in Cairo (GUC) student and a basketball player, Herr Wafa was delighted once he heard the news. GUC is finally participating in the Annual Basketball Competition (ABC).
A team is to be formed of n players, all of which are GUC students. However, the team might have players belonging to differen... | {
"input": [
"3 2 1\n2 1\n",
"3 2 1\n2 2\n",
"3 2 1\n1 1\n"
],
"output": [
"1\n",
"0.6666666666666666666666666667\n",
"-1.0\n"
]
} | {
"input": [
"14 9 9\n9 4 7 2 1 2 4 3 9\n",
"51 153 26\n19 32 28 7 25 50 22 31 29 39 5 4 28 26 24 1 19 23 36 2 50 50 33 28 15 17 31 35 10 40 16 7 6 43 50 29 20 25 31 37 10 18 38 38 44 30 36 47 37 6 16 48 41 49 14 16 30 7 29 42 36 8 31 37 26 15 43 42 32 3 46 12 16 37 33 12 18 16 15 14 46 11 2 50 34 34 34 32 28... | 1,600 | 1,000 |
2 | 7 | 109_A. Lucky Sum of Digits | Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya wonders eagerly what minimum lucky number has the sum of digits equal to n. Help him cope with... | {
"input": [
"10\n",
"11\n"
],
"output": [
"-1\n",
"47\n"
]
} | {
"input": [
"1000\n",
"8\n",
"999999\n",
"1000000\n",
"4\n",
"999980\n",
"10417\n",
"999998\n",
"2\n",
"1\n",
"111\n",
"854759\n",
"999996\n",
"980000\n",
"64\n",
"85\n",
"5\n",
"1024\n",
"6\n",
"777777\n",
"700\n",
"99999\n",
... | 1,000 | 500 |
2 | 7 | 1120_A. Diana and Liana | At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers.
The work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered liana that grew in the tow... | {
"input": [
"7 3 2 2\n1 2 3 3 2 1 2\n2 2\n",
"13 4 1 3\n3 2 6 4 1 4 4 7 1 3 3 2 4\n4 3 4\n",
"13 4 3 3\n3 2 6 4 1 4 4 7 1 3 3 2 4\n4 3 4\n"
],
"output": [
"1\n4\n",
"2\n2\n3\n",
"-1\n"
]
} | {
"input": [
"2 2 1 2\n1 2\n2 1\n",
"2 1 1 1\n1 2\n3\n",
"10 4 2 4\n3 2 3 3 3 1 3 3 2 3\n2 2 2 3\n",
"10 3 3 2\n2 2 3 2 1 3 1 3 2 3\n2 3\n",
"4 2 1 2\n1 1 2 2\n2 2\n",
"1 1 1 1\n500000\n500000\n",
"10 3 3 2\n2 1 1 2 1 1 2 1 1 2\n2 2\n",
"10 5 2 2\n2 2 2 2 2 1 1 1 1 1\n3 3\n",
"2 2 ... | 1,900 | 500 |
2 | 9 | 1147_C. Thanos Nim | Alice and Bob are playing a game with n piles of stones. It is guaranteed that n is an even number. The i-th pile has a_i stones.
Alice and Bob will play a game alternating turns with Alice going first.
On a player's turn, they must choose exactly n/2 nonempty piles and independently remove a positive number of stone... | {
"input": [
"4\n3 1 4 1\n",
"2\n8 8\n"
],
"output": [
"Alice\n",
"Bob\n"
]
} | {
"input": [
"50\n13 10 50 35 23 34 47 25 39 11 50 41 20 48 10 10 1 2 41 16 14 50 49 42 48 39 16 9 31 30 22 2 25 40 6 8 34 4 2 46 14 6 6 38 45 30 27 36 49 18\n",
"6\n1 2 2 2 2 2\n",
"12\n33 26 11 11 32 25 18 24 27 47 28 7\n",
"42\n3 50 33 31 8 19 3 36 41 50 2 22 9 40 39 22 30 34 43 25 42 39 40 8 18 1 ... | 2,000 | 1,500 |
2 | 7 | 1187_A. Stickers and Toys | Your favorite shop sells n Kinder Surprise chocolate eggs. You know that exactly s stickers and exactly t toys are placed in n eggs in total.
Each Kinder Surprise can be one of three types:
* it can contain a single sticker and no toy;
* it can contain a single toy and no sticker;
* it can contain both a sing... | {
"input": [
"3\n10 5 7\n10 10 10\n2 1 1\n"
],
"output": [
"6\n1\n2\n"
]
} | {
"input": [
"4\n1 1 1\n1000000000 1000000000 1000000000\n1000000000 999999999 1\n999999999 666666667 666666666\n",
"4\n2 1 1\n2 1 2\n2 2 1\n2 2 2\n",
"1\n1926 1900 1200\n",
"1\n5 3 2\n"
],
"output": [
"1\n1\n1000000000\n333333334\n",
"2\n2\n2\n1\n",
"727\n",
"4\n"
]
} | 900 | 0 |
2 | 9 | 1223_C. Save the Nature | You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!
You have n tickets to sell. The price of the i-th ticket is p_i. As a teller, you have a possibility to select the order in which the tickets will be sold (i.e. a permutation of t... | {
"input": [
"4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n3000000000\n5\n200 100 100 100 100\n69 5\n31 2\n90\n"
],
"output": [
"-1\n6\n3\n4\n"
]
} | {
"input": [
"3\n5\n5000 1000 2000 3400 4300\n1 1\n99 2\n50\n5\n5000 1000 2000 3400 4300\n1 1\n99 2\n51\n10\n100 100 100 100 100 100 100 100 100 100\n50 10\n50 10\n100\n"
],
"output": [
"1\n2\n10\n"
]
} | 1,600 | 1,500 |
2 | 11 | 1267_E. Elections | Byteburg Senate elections are coming. Usually "United Byteland", the ruling Byteland party, takes all the seats in the Senate to ensure stability and sustainable development. But this year there is one opposition candidate in one of the constituencies. Even one opposition member can disturb the stability in the Senate,... | {
"input": [
"2 1\n1 1\n",
"3 3\n2 3 8\n4 2 9\n3 1 7\n",
"5 3\n6 3 4 2 8\n3 7 5 6 7\n5 2 4 7 9\n"
],
"output": [
"0\n",
"3\n1 2 3",
"2\n3 1"
]
} | {
"input": [
"2 1\n1000 1000\n",
"2 1\n0 0\n",
"9 12\n2 2 13 1 17 3 14 15 17\n14 6 15 0 20 5 19 9 13\n18 3 7 2 8 8 10 10 13\n6 4 14 0 11 1 4 2 12\n7 9 14 1 5 2 13 10 13\n18 8 14 17 4 2 14 0 14\n8 0 11 1 19 3 11 1 18\n3 18 2 10 2 16 3 6 19\n5 14 15 18 8 17 15 14 13\n5 15 4 11 19 20 0 16 13\n20 20 3 4 9 12 ... | 1,700 | 0 |
2 | 7 | 1332_A. Exercising Walk | Alice has a cute cat. To keep her cat fit, Alice wants to design an exercising walk for her cat!
Initially, Alice's cat is located in a cell (x,y) of an infinite grid. According to Alice's theory, cat needs to move:
* exactly a steps left: from (u,v) to (u-1,v);
* exactly b steps right: from (u,v) to (u+1,v); ... | {
"input": [
"6\n3 2 2 2\n0 0 -2 -2 2 2\n3 1 4 1\n0 0 -1 -1 1 1\n1 1 1 1\n1 1 1 1 1 1\n0 0 0 1\n0 0 0 0 0 1\n5 1 1 1\n0 0 -100 -100 0 100\n1 1 5 1\n0 0 -100 -100 100 0\n"
],
"output": [
"Yes\nNo\nNo\nYes\nYes\nYes\n"
]
} | {
"input": [
"1\n83 75 18 67\n-4233924 24412104 -4233956 24412104 -4233832 24412181\n",
"1\n0 0 1 1\n0 0 0 0 0 0\n"
],
"output": [
"Yes\n",
"No\n"
]
} | 1,100 | 500 |
2 | 10 | 1352_D. Alice, Bob and Candies | There are n candies in a row, they are numbered from left to right from 1 to n. The size of the i-th candy is a_i.
Alice and Bob play an interesting and tasty game: they eat candy. Alice will eat candy from left to right, and Bob — from right to left. The game ends if all the candies are eaten.
The process consists o... | {
"input": [
"7\n11\n3 1 4 1 5 9 2 6 5 3 5\n1\n1000\n3\n1 1 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n1 1 1 1 1 1\n7\n1 1 1 1 1 1 1\n"
],
"output": [
"6 23 21\n1 1000 0\n2 1 2\n6 45 46\n2 2 1\n3 4 2\n4 4 3\n"
]
} | {
"input": [
"3\n1\n1\n1\n1\n1\n1\n"
],
"output": [
"1 1 0\n1 1 0\n1 1 0\n"
]
} | 1,300 | 0 |
2 | 8 | 1372_B. Omkar and Last Class of Math | In Omkar's last class of math, he learned about the least common multiple, or LCM. LCM(a, b) is the smallest positive integer x which is divisible by both a and b.
Omkar, having a laudably curious mind, immediately thought of a problem involving the LCM operation: given an integer n, find positive integers a and b suc... | {
"input": [
"3\n4\n6\n9\n"
],
"output": [
"2 2\n3 3\n3 6\n"
]
} | {
"input": [
"1\n646185419\n",
"3\n312736423\n170982179\n270186827\n",
"3\n4\n5\n2\n",
"1\n142930164\n",
"9\n203197635\n675378503\n971363026\n746226358\n441100327\n941328384\n321242664\n890263904\n284574795\n",
"7\n13881727\n399705329\n4040273\n562529221\n51453229\n165146341\n104085043\n",
... | 1,300 | 1,000 |
2 | 7 | 1395_A. Boboniu Likes to Color Balls | Boboniu gives you
* r red balls,
* g green balls,
* b blue balls,
* w white balls.
He allows you to do the following operation as many times as you want:
* Pick a red ball, a green ball, and a blue ball and then change their color to white.
You should answer if it's possible to arrange all the b... | {
"input": [
"4\n0 1 1 1\n8 1 9 3\n0 0 0 0\n1000000000 1000000000 1000000000 1000000000\n"
],
"output": [
"No\nYes\nYes\nYes\n"
]
} | {
"input": [
"1\n0 2 2 3\n",
"1\n1 2 2 4\n",
"1\n1 0 3 1\n",
"1\n1 1 0 0\n",
"1\n3 0 3 3\n",
"1\n0 2 2 1\n",
"1\n0 0 1 2\n",
"1\n0 2 2 2\n",
"1\n2 0 0 0\n",
"1\n1 1 0 101\n"
],
"output": [
"Yes\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"Yes\n",
"Yes\n... | 1,000 | 500 |
2 | 10 | 1419_D1. Sage's Birthday (easy version) | This is the easy version of the problem. The difference between the versions is that in the easy version all prices a_i are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All n ice spheres are placed in a row ... | {
"input": [
"5\n1 2 3 4 5\n"
],
"output": [
"2\n3 1 4 2 5\n"
]
} | {
"input": [
"4\n1 1 2 4\n",
"5\n1 2 2 4 5\n",
"10\n6 6 2 2 2 2 2 2 1 1\n",
"1\n1000000000\n",
"10\n1 2 3 3 3 3 3 3 4 5\n",
"1\n1\n",
"7\n1 3 2 2 4 5 4\n",
"2\n1000000000 1\n",
"2\n1000000000 1000000000\n"
],
"output": [
"1\n2 1 4 1\n",
"2\n2 1 4 2 5\n",
"3\n2 1 2 1... | 1,000 | 750 |
2 | 8 | 1462_B. Last Year's Substring | Polycarp has a string s[1 ... n] of length n consisting of decimal digits. Polycarp performs the following operation with the string s no more than once (i.e. he can perform operation 0 or 1 time):
* Polycarp selects two numbers i and j (1 ≤ i ≤ j ≤ n) and removes characters from the s string at the positions i, i+... | {
"input": [
"6\n8\n20192020\n8\n22019020\n4\n2020\n5\n20002\n6\n729040\n6\n200200\n"
],
"output": [
"\nYES\nYES\nYES\nNO\nNO\nNO\n"
]
} | {
"input": [
"1\n4\n2065\n",
"1\n4\n2005\n",
"1\n4\n2089\n",
"1\n4\n2088\n",
"1\n4\n2069\n",
"1\n4\n2092\n",
"1\n4\n2047\n",
"1\n4\n2040\n",
"1\n4\n2099\n",
"1\n4\n2075\n",
"1\n4\n2010\n",
"1\n4\n2029\n",
"1\n4\n2085\n",
"1\n4\n2011\n",
"1\n4\n2049\n",
"... | 800 | 0 |
2 | 9 | 1487_C. Minimum Ties | A big football championship will occur soon! n teams will compete in it, and each pair of teams will play exactly one game against each other.
There are two possible outcomes of a game:
* the game may result in a tie, then both teams get 1 point;
* one team might win in a game, then the winning team gets 3 point... | {
"input": [
"2\n2\n3\n"
],
"output": [
"\n0 \n1 -1 1 \n"
]
} | {
"input": [
"1\n42\n",
"1\n10\n"
],
"output": [
"1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 -1 -1 -1 ... | 1,500 | 0 |
2 | 17 | 1510_K. King's Task | The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.
There is a permutation p_i of numbers from 1 to 2n. You can make two types of operations.
1. Swap p_... | {
"input": [
"2\n3 4 2 1\n",
"3\n6 3 2 5 4 1\n",
"4\n1 2 3 4 5 6 7 8\n"
],
"output": [
"\n-1\n",
"\n3\n",
"\n0\n"
]
} | {
"input": [
"3\n5 4 1 6 3 2\n",
"9\n16 5 18 7 2 9 4 11 6 13 8 15 10 17 12 1 14 3\n",
"4\n6 5 8 7 2 1 4 3\n",
"15\n11 22 13 24 15 26 17 28 19 30 21 2 23 4 25 6 27 8 29 10 1 12 3 14 5 16 7 18 9 20\n"
],
"output": [
"2\n",
"7\n",
"2\n",
"10\n"
]
} | 1,200 | 0 |
2 | 7 | 186_A. Comparing Strings | Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses, have been told "no genome, no degree". That means that all dwarves should write a thesis on genome. Dwarven genome is far from simple. It is represented by a string that consists of lowercase Latin letters.
Dwarf Mish... | {
"input": [
"ab\nba\n",
"aa\nab\n"
],
"output": [
"YES\n",
"NO\n"
]
} | {
"input": [
"acaa\nabca\n",
"aab\naa\n",
"a\nza\n",
"aab\naaa\n",
"ed\nab\n",
"ba\na\n",
"aaaabcccca\naaaadccccb\n",
"a\naa\n",
"abc\nab\n",
"vvea\nvvae\n",
"abab\nbaba\n",
"rtfabanpc\natfabrnpc\n",
"ab\nca\n",
"abc\nbad\n",
"ab\nbd\n",
"abaab\naabba\n"... | 1,100 | 500 |
2 | 8 | 232_B. Table | John Doe has an n × m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n × n have exactly k points.
John Doe wondered, how many distinct ways to fill the table with points are there, provided that... | {
"input": [
"5 6 1\n"
],
"output": [
" 45\n"
]
} | {
"input": [
"80 500000000000000000 3200\n",
"15 1033532424 1\n",
"37 1877886816 1\n",
"17 65579254 1\n",
"8 703528038 1\n",
"83 253746842 3200\n",
"5 37 24\n",
"19 1146762197 1\n",
"100 1000000000000000000 1221\n",
"32 504681835 1\n",
"9 402260913 1\n",
"1 100000000000... | 1,900 | 1,000 |
2 | 7 | 258_A. Little Elephant and Bits | The Little Elephant has an integer a, written in the binary notation. He wants to write this number on a piece of paper.
To make sure that the number a fits on the piece of paper, the Little Elephant ought to delete exactly one any digit from number a in the binary record. At that a new number appears. It consists of ... | {
"input": [
"110010\n",
"101\n"
],
"output": [
"11010\n",
"11\n"
]
} | {
"input": [
"1001011111010010100111111\n",
"1111111111111111111100111101001110110111111000001111110101001101001110011000001011001111111000110101\n",
"111010010111\n",
"11111\n",
"11110010010100001110110101110011110110100111101\n",
"11110111011100000000\n",
"111\n",
"111111111111111111... | 1,100 | 500 |
2 | 7 | 281_A. Word Capitalization | Capitalization is writing a word with its first letter as a capital letter. Your task is to capitalize the given word.
Note, that during capitalization all the letters except the first one remains unchanged.
Input
A single line contains a non-empty word. This word consists of lowercase and uppercase English letters.... | {
"input": [
"konjac\n",
"ApPLe\n"
],
"output": [
"Konjac\n",
"ApPLe\n"
]
} | {
"input": [
"z\n",
"a\n",
"P\n",
"Zzz\n",
"lZqBqKeGvNdSeYuWxRiVnFtYbKuJwQtUcKnVtQhAlOeUzMaAuTaEnDdPfDcNyHgEoBmYjZyFePeJrRiKyAzFnBfAuGiUyLrIeLrNhBeBdVcEeKgCcBrQzDsPwGcNnZvTsEaYmFfMeOmMdNuZbUtDoQoNcGwDqEkEjIdQaPwAxJbXeNxOgKgXoEbZiIsVkRrNpNyAkLeHkNfEpLuQvEcMbIoGaDzXbEtNsLgGfOkZaFiUsOvEjVeCaMcZqMzKeA... | 800 | 500 |
2 | 7 | 330_A. Cakeminator | You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For example, a 3 × 4 cake may look as follows:
<image>
The cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil strawberries and contain... | {
"input": [
"3 4\nS...\n....\n..S.\n"
],
"output": [
"8\n"
]
} | {
"input": [
"2 4\nS.SS\nS.SS\n",
"10 10\n....S..S..\n....S..S..\n....S..S..\n....S..S..\n....S..S..\n....S..S..\n....S..S..\n....S..S..\n....S..S..\n....S..S..\n",
"9 9\n...S.....\nS.S.....S\n.S....S..\n.S.....SS\n.........\n..S.S..S.\n.SS......\n....S....\n..S...S..\n",
"9 6\n....S.\n...S.S\n.S..S.\... | 800 | 500 |
2 | 9 | 420_C. Bug in Code | Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'
The head of the company d... | {
"input": [
"8 6\n5 6\n5 7\n5 8\n6 2\n2 1\n7 3\n1 3\n1 4\n",
"4 2\n2 3\n1 4\n1 4\n2 1\n"
],
"output": [
"1\n",
"6\n"
]
} | {
"input": [
"5 2\n4 3\n1 3\n4 2\n1 2\n1 4\n",
"6 4\n2 3\n3 1\n1 2\n5 6\n6 4\n4 5\n",
"4 4\n2 3\n4 3\n2 1\n2 3\n",
"10 1\n4 9\n8 9\n7 6\n1 5\n3 6\n4 3\n4 6\n10 1\n1 8\n7 9\n",
"10 4\n8 7\n1 5\n7 4\n7 8\n3 2\n10 8\n3 6\n9 7\n8 7\n4 1\n",
"5 5\n3 2\n3 4\n2 5\n3 2\n4 3\n",
"5 5\n3 2\n3 4\n1 2... | 1,900 | 1,500 |
2 | 7 | 447_A. DZY Loves Hash | DZY has a hash table with p buckets, numbered from 0 to p - 1. He wants to insert n numbers, in the order they are given, into the hash table. For the i-th number xi, DZY will put it into the bucket numbered h(xi), where h(x) is the hash function. In this problem we will assume, that h(x) = x mod p. Operation a mod b d... | {
"input": [
"10 5\n0\n21\n53\n41\n53\n",
"5 5\n0\n1\n2\n3\n4\n"
],
"output": [
"4",
"-1"
]
} | {
"input": [
"300 2\n0\n300\n",
"20 5\n793926268\n28931770\n842870287\n974950617\n859404206\n",
"300 2\n822454942\n119374431\n",
"100 15\n808103310\n136224397\n360129131\n405104681\n263786657\n734802577\n67808179\n928584682\n926900882\n511722343\n483348395\n938695534\n120684068\n74152694\n808088675\n"... | 800 | 500 |
2 | 8 | 469_B. Chat Online | Little X and Little Z are good friends. They always chat online. But both of them have schedules.
Little Z has fixed schedule. He always online at any moment of time between a1 and b1, between a2 and b2, ..., between ap and bp (all borders inclusive). But the schedule of Little X is quite strange, it depends on the ti... | {
"input": [
"1 1 0 4\n2 3\n0 1\n",
"2 3 0 20\n15 17\n23 26\n1 4\n7 11\n15 17\n"
],
"output": [
"3\n",
"20\n"
]
} | {
"input": [
"33 17 295 791\n41 49\n66 73\n95 102\n118 126\n157 158\n189 198\n228 237\n247 251\n301 307\n318 326\n328 333\n356 363\n373 381\n454 460\n463 466\n471 477\n500 501\n505 510\n559 566\n585 588\n597 604\n675 684\n688 695\n699 705\n749 755\n780 788\n869 873\n879 888\n890 892\n909 918\n953 954\n973 978\n99... | 1,300 | 1,000 |
2 | 7 | 491_A. Up the hill | Hiking club "Up the hill" just returned from a walk. Now they are trying to remember which hills they've just walked through.
It is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea level. On the first day they've traveled from the first stop to the se... | {
"input": [
"0\n1\n",
"2\n1"
],
"output": [
"2 1 ",
"2 3 4 1 "
]
} | {
"input": [
"5\n0\n",
"177\n191\n",
"3\n7\n",
"0\n3\n",
"0\n0\n",
"2\n1\n",
"100\n4\n",
"1\n1\n",
"2\n0\n",
"700\n300\n",
"1\n0\n",
"37\n29\n"
],
"output": [
"1 2 3 4 5 6 ",
"192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 21... | 1,000 | 500 |
2 | 8 | 515_B. Drazil and His Happy Friends | Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.
There are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0 to m - 1 separately. In i-th day, Drazil invites <image>-th boy and... | {
"input": [
"2 3\n0\n1 0\n",
"2 3\n1 0\n1 1\n",
"2 4\n1 0\n1 2\n"
],
"output": [
"Yes\n",
"Yes\n",
"No\n"
]
} | {
"input": [
"76 72\n29 4 64 68 20 8 12 50 42 46 0 70 11 37 75 47 45 29 17 19 73 9 41 31 35 67 65 39 51 55\n25 60 32 48 42 8 6 9 7 31 19 25 5 33 51 61 67 55 49 27 29 53 39 65 35 13\n",
"2 3\n1 0\n2 0 2\n",
"69 72\n18 58 46 52 43 1 55 16 7 4 38 68 14 32 53 41 29 2 59\n21 22 43 55 13 70 4 7 31 10 23 56 44 6... | 1,300 | 1,000 |
2 | 9 | 542_C. Idempotent functions | Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function <image>, that for any <image> the formula g(g(x)) = g(x) holds.
Let's denote as f(k)(x) the function f applied k times to the value x. More formally, f(1)(x) = f(x), f(k)(x) = f(f(k - 1)(x))... | {
"input": [
"3\n2 3 3\n",
"3\n2 3 1\n",
"4\n1 2 2 4\n"
],
"output": [
"2\n",
"3\n",
"1\n"
]
} | {
"input": [
"2\n1 1\n",
"3\n2 1 2\n",
"100\n61 41 85 52 22 82 98 25 60 35 67 78 65 69 55 86 34 91 92 36 24 2 26 15 76 99 4 95 79 31 13 16 100 83 21 90 73 32 19 33 77 40 72 62 88 43 84 14 10 9 46 70 23 45 42 96 94 38 97 58 47 93 59 51 57 7 27 74 1 30 64 3 63 49 50 54 5 37 48 11 81 44 12 17 75 71 89 39 56 ... | 2,000 | 750 |
2 | 10 | 569_D. Symmetric and Transitive | Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.
A set ρ of pairs (a, b) of elements ... | {
"input": [
"2\n",
"3\n",
"1\n"
],
"output": [
"3\n",
"10\n",
"1\n"
]
} | {
"input": [
"4\n",
"5\n",
"4000\n",
"3000\n",
"42\n",
"3555\n",
"2999\n",
"999\n",
"3789\n",
"6\n",
"133\n",
"2000\n",
"8\n",
"345\n",
"3333\n",
"2345\n",
"1730\n",
"3999\n",
"555\n",
"2500\n",
"20\n",
"666\n",
"2780\n",
... | 1,900 | 1,000 |
2 | 8 | 590_B. Chip 'n Dale Rescue Rangers | A team of furry rescue rangers was sitting idle in their hollow tree when suddenly they received a signal of distress. In a few moments they were ready, and the dirigible of the rescue chipmunks hit the road.
We assume that the action takes place on a Cartesian plane. The headquarters of the rescuers is located at poi... | {
"input": [
"0 0 0 1000\n100 1000\n-50 0\n50 0\n",
"0 0 5 5\n3 2\n-1 -1\n-1 0\n"
],
"output": [
"11.547005",
"3.729936"
]
} | {
"input": [
"-9680 -440 9680 440\n969 1000\n-968 -44\n-968 -44\n",
"-10000 10000 10000 -10000\n1000 10\n-890 455\n-891 454\n",
"0 0 0 750\n25 30\n0 -1\n0 24\n",
"0 -1000 0 0\n11 10\n-10 0\n10 0\n",
"-5393 -8779 7669 9721\n613 13\n-313 -37\n-23 -257\n",
"0 1000 0 0\n50 10\n-49 0\n49 0\n",
... | 2,100 | 1,000 |
2 | 7 | 612_A. The Text Splitting | You are given the string s of length n and the numbers p, q. Split the string s to pieces of length p and q.
For example, the string "Hello" for p = 2, q = 3 can be split to the two strings "Hel" and "lo" or to the two strings "He" and "llo".
Note it is allowed to split the string s to the strings only of length p or... | {
"input": [
"10 9 5\nCodeforces\n",
"8 1 1\nabacabac\n",
"6 4 5\nPrivet\n",
"5 2 3\nHello\n"
],
"output": [
"2\nCodef\norces\n",
"8\na\nb\na\nc\na\nb\na\nc\n",
"-1\n",
"2\nHe\nllo\n"
]
} | {
"input": [
"56 13 5\nabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcab\n",
"70 13 37\nfzL91QIJvNoZRP4A9aNRT2GTksd8jEb1713pnWFaCGKHQ1oYvlTHXIl95lqyZRKJ1UPYvT\n",
"99 2 2\nrecursionishellrecursionishellrecursionishellrecursionishellrecursionishellrecursionishelldontuseit\n",
"11 3 2\naaaaaaaaaa... | 1,300 | 0 |
2 | 7 | 632_A. Grandma Laura and Apples | Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.
She precisely remembers she had n buyers and each of them bought exactly half of the apples she had at the moment of the purchase and al... | {
"input": [
"2 10\nhalf\nhalfplus\n",
"3 10\nhalfplus\nhalfplus\nhalfplus\n"
],
"output": [
"15\n",
"55\n"
]
} | {
"input": [
"40 562\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalf\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus\nhalf\nhalf... | 1,200 | 0 |
2 | 10 | 660_D. Number of Parallelograms | You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points.
Input
The first line of the input contains integer n (1 ≤ n ≤ 2000) — the number of points.
Each of the next n lines contains two integers... | {
"input": [
"4\n0 1\n1 0\n1 1\n2 0\n"
],
"output": [
"1\n"
]
} | {
"input": [
"8\n0 0\n0 2\n1 3\n1 1\n100 10\n100 11\n101 11\n101 10\n",
"4\n0 0\n0 1\n1 2\n1 1\n",
"6\n0 0\n0 4194304\n1 0\n1 2097152\n2 1\n2 8388609\n",
"5\n0 0\n1 1\n2 0\n1 4\n3 4\n",
"4\n0 0\n1 0\n1000000000 1000000000\n999999999 1000000000\n",
"10\n2 14\n5 9\n10 16\n12 5\n16 19\n26 23\n30 ... | 1,900 | 0 |
2 | 8 | 707_B. Bakery | Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.
To bake muffins in her bakery, Masha needs to establish flour supply from some storage. There are only k storages, located in different cities nu... | {
"input": [
"5 4 2\n1 2 5\n1 2 3\n2 3 4\n1 4 10\n1 5\n",
"3 1 1\n1 2 3\n3\n"
],
"output": [
"3",
"-1"
]
} | {
"input": [
"350 10 39\n2 13 693\n6 31 482\n72 312 617\n183 275 782\n81 123 887\n26 120 1205\n135 185 822\n64 219 820\n74 203 874\n19 167 1422\n252 332 204 334 100 350 26 14 134 213 32 84 331 215 181 158 99 190 206 265 343 241 287 74 113 15 12 338 27 110 98 132 35 95 51 315 297 69 163\n",
"7 8 3\n1 2 1\n2 4 ... | 1,300 | 1,000 |
2 | 11 | 74_E. Shift It! | There is a square box 6 × 6 in size. It contains 36 chips 1 × 1 in size. Those chips contain 36 different characters — "0"-"9" and "A"-"Z". There is exactly one chip with each character.
You are allowed to make the following operations: you may choose one of 6 rows or one of 6 columns and cyclically shift the chips th... | {
"input": [
"01W345\n729AB6\nCD8FGH\nIJELMN\nOPKRST\nUVQXYZ\n"
],
"output": [
"260\nD3\nR2\nD3\nL2\nD3\nR2\nD3\nL2\nD3\nR2\nD3\nL2\nD3\nR2\nD3\nR2\nU3\nR2\nD3\nR2\nU3\nR2\nD3\nR2\nU3\nR2\nD6\nR2\nD6\nL2\nD6\nR2\nD6\nL2\nD6\nR2\nD6\nL2\nD6\nD5\nR2\nD5\nL2\nD5\nR2\nD5\nL2\nD5\nR2\nD5\nL2\nD5\nD4\nR2\nD4\nL... | {
"input": [
"KLMNOP\nJ6789Q\nI501AR\nH432BS\nGFEDCT\nZYXWVU\n",
"MN0RQO\nKJE1X7\nIVAUWD\n3LHFYT\nG9S2ZP\n48B56C\n",
"6R9DOW\n50QB3L\n4ZMKXH\nNG1A2V\nETYU87\nSFPIJC\n",
"H6EMA2\n7PB85W\nGLJOC3\nSDUR9Y\nQIKNZ1\nTX0FV4\n",
"EFYZOP\nLKSTUV\nQR10CD\nXW76IJ\nBA32MN\n5498GH\n",
"234501\n789AB6\nGHCD... | 2,800 | 2,500 |
2 | 9 | 798_C. Mike and gcd problem | Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful if the gcd of all its elements is bigger than 1, i.e. <image>.
Mike wants to change his sequence in order to make it beautiful. In one move he can choose an index i (1 ≤ i < n), delete numbers ai, ai + 1 a... | {
"input": [
"2\n1 1\n",
"2\n1 3\n",
"3\n6 2 4\n"
],
"output": [
"YES\n1\n",
"YES\n1\n",
"YES\n0\n"
]
} | {
"input": [
"2\n3 3\n",
"5\n6 6 9 15 21\n",
"2\n3 6\n",
"3\n3 9 15\n",
"4\n3 6 9 12\n",
"4\n3 3 3 3\n",
"2\n78 26\n",
"9\n57 30 28 81 88 32 3 42 25\n",
"5\n3 3 3 3 3\n",
"2\n9 9\n",
"4\n2 3 9 13\n",
"4\n92 46 3 21\n",
"3\n3 12 4\n",
"3\n3 9 12\n",
"2\n9 6\n... | 1,700 | 1,500 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.