info stringlengths 120 50k | question stringlengths 504 10.4k | avg@8_qwen3_4b_instruct_2507 float64 0 0.88 |
|---|---|---|
{"tests": "{\"inputs\": [\"6\\n83 -75 -49 11 37 62\\n\", \"6\\n3 2 1 6 5 4\\n\", \"2\\n1 2\\n\", \"50\\n39 7 45 25 31 26 50 11 19 37 8 16 22 33 14 6 12 46 49 48 29 27 41 15 34 24 3 13 20 47 9 36 5 43 40 21 2 38 35 42 23 28 1 32 10 17 30 18 44 4\\n\", \"2\\n2 1\\n\", \"10\\n3 7 10 1 9 5 4 8 6 2\\n\", \"3\\n3 2 1\\n\", \... | You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also will be sorted in increasing order.
Sorting integers in a subsequence is... | 0 |
{"tests": "{\"inputs\": [\"4 12\\n20 30 70 90\\n\", \"5 787787787\\n123456789 234567890 345678901 456789012 987654321\\n\", \"4 3\\n10000 1000 100 10\\n\", \"4 3\\n10 100 1000 10000\\n\", \"30 553648256\\n2 3 5 9 17 33 65 129 257 513 1025 2049 4097 8193 16385 32769 65537 131073 262145 524289 1048577 2097153 4194305 838... | A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity.
Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2i - 1 liters and costs ci r... | 0 |
{"tests": "{\"inputs\": [\"3\\n3 2 1\\n1 3 2\\n\\nSAMPLE\", \"3\\n3 2 1\\n1 3 2\\n\\nSAMELP\", \"3\\n3 2 1\\n1 3 2\\n\\nRAMELP\", \"3\\n3 2 1\\n1 3 2\\n\\nTAMELP\", \"3\\n3 2 1\\n1 3 2\\n\\nRAMPLE\", \"3\\n3 2 1\\n1 3 2\\n\\nPLEMAR\", \"3\\n3 2 1\\n1 3 2\\n\\nR@MPLE\", \"3\\n3 2 1\\n1 3 2\\n\\nRAMEPL\", \"3\\n3 2 1\\n1... | The Monk is trying to explain to its users that even a single unit of time can be extremely important and to demonstrate this particular fact he gives them a challenging task.
There are N processes to be completed by you, the chosen one, since you're Monk's favorite student. All the processes have a unique number as... | 0.875 |
{"tests": "{\"inputs\": [\"12 2 3 5\\n\\nSAMPLE\", \"1000000 9000 8743 7562323\", \"1000000 9000 8743 2841790\", \"0 2 3 5\\n\\nSAMPLE\", \"1 1 3 5\\n\\nSAMPLE\", \"1000000 13032 8743 7562323\", \"24 2 3 5\\n\\nSAMPLE\", \"1000001 13032 8743 7562323\", \"24 2 3 8\\n\\nSAMPLE\", \"24 1 3 8\\n\\nSAMPLE\", \"0010000 9000 ... | Its Diwali time and there are LED series lights everywhere. Little Roy got curious about how LED lights work.
He noticed that in one single LED Bulb there are 3 LED lights, namely Red, Green and Blue.
State of the bulb at any moment is the sum of Red, Green and Blue LED light.
Bulb works as follows:
Roy took out al... | 0 |
{"tests": "{\"inputs\": [\"3\\n1\\n10\\n0010\\n\\nSAMPLE\", \"3\\n2\\n10\\n0010\\n\\nSAMPLE\", \"3\\n2\\n10\\n0000\\n\\nSAMPLE\", \"3\\n1\\n10\\n0110\\n\\nSAMPLE\", \"3\\n2\\n10\\n0011\\n\\nSAMPLE\", \"3\\n2\\n0\\n0011\\n\\nSAMPLE\", \"3\\n2\\n1\\n0011\\n\\nELPMAS\", \"3\\n2\\n1\\n0010\\n\\nELPMAS\", \"3\\n1\\n10\\n001... | Siddharth is a math geek. His only work in free time is to think of a new math problem and keep working on that. Siddharth's latest problem is to sum up digits of a number till the result is a single digit. It goes this way..
Ex: for number 123
it is 1+2+3 = 6
and for number 12345
it is 1+2+3+4+5 = 15 => 1+5 ... | 0.625 |
{"tests": "{\"inputs\": [\"3\\n1010 6 3 10 7 1 0 7 9 1 10 6 2 4 3 9 1 9 0\\n1200 5 3 9 1 7 1 0 0 8 1 10 10 4 3 9 1 8 2 9\\n1101 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3\\n4\\n3321 8 2 10 9 1 7 0 10 10 10 0 8 10 10 10 10\\n3332 5 0 10 9 1 4 1 9 0 10 10 7 1 5 2 8 1\\n3335 10 10 10 10 10 10 10 10 10 10 10 10\\n3340 8 2 7 3... | I decided to do bowling as a recreation of the class. Create a program that inputs the pitching information for each participant and outputs the grade information in descending order of score. If there is a tie, output in ascending order of student ID number. However, it is assumed that the number of participants is 3 ... | 0 |
{"tests": "{\"inputs\": [\"2 3 4\\n2\\n0 0 0\\n1 1 3\\n1 0\\n0 0\\n0 0\", \"3 8 6\\n6\\n0 4 3\\n2 5 3\\n0 2 3\\n2 2 5\\n1 1 3\\n2 2 1\\n1 1 1\\n1 1 1\\n1 1 1\\n1 0 1\\n0 1 1\\n1 1 0\\n1 0 1\\n0 1 0\", \"8 3 3\\n7\\n0 1 1\\n5 1 0\\n4 0 2\\n3 2 0\\n3 1 1\\n3 0 1\\n5 1 1\\n1 0 1 1 0 0 1 0\\n0 0 1 1 0 1 0 1\\n0 1 0 0 0 1 0... | Problem
Gaccho owns a field separated by W horizontal x H vertical squares. The cell in the x-th column and the y-th row is called the cell (x, y). Only one plant with a height of 0 cm is planted on the land of some trout, and nothing is planted on the land of other trout.
Gaccho sprinkles fertilizer on the field at ... | 0 |
{"tests": "{\"inputs\": [\"3 2\\n1 2\\n2 3\\n5 0\\n100000 0\\n0 0\", \"3 2\\n1 2\\n2 3\\n2 0\\n100000 0\\n0 0\", \"3 2\\n1 2\\n2 3\\n3 0\\n100000 0\\n0 0\", \"5 2\\n1 2\\n2 3\\n5 0\\n100000 0\\n0 0\", \"3 2\\n1 2\\n2 3\\n4 0\\n100000 0\\n0 0\", \"5 2\\n1 2\\n2 3\\n2 0\\n100000 0\\n0 0\", \"5 2\\n1 2\\n2 1\\n2 0\\n10000... | Problem Statement
"Everlasting -One-" is an award-winning online game launched this year. This game has rapidly become famous for its large number of characters you can play.
In this game, a character is characterized by attributes. There are $N$ attributes in this game, numbered $1$ through $N$. Each attribute takes... | 0.375 |
{"tests": "{\"inputs\": [\"2\\n(((\\n\", \"3\\n(()\\n\", \"5\\n()))()\\n\", \"100\\n((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((\\n\", \"9\\n(\\n\", \"100\\n(()))()... | You are given a bracket sequence s (not necessarily a regular one). A bracket sequence is a string containing only characters '(' and ')'.
A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of... | 0 |
{"tests": "{\"inputs\": [\"3\\n998 999 1000\\n\", \"5\\n1 2 3 4 5\\n\", \"6\\n1 3 4 5 6 9\\n\", \"95\\n34 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 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 688 689 690 691 692 693 694... | JATC and his friend Giraffe are currently in their room, solving some problems. Giraffe has written on the board an array a_1, a_2, ..., a_n of integers, such that 1 ≤ a_1 < a_2 < … < a_n ≤ 10^3, and then went to the bathroom.
JATC decided to prank his friend by erasing some consecutive elements in the array. Since he... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n4 3\\n5 0\\n1 4\\n2 2\\n\\n5 3\\n5 2\\n4 2\\n3 1\\n\", \"1\\n7 7\\n875211518 78149272\\n372527826 28528254\\n777595365 608227558\\n861586350 722262664\\n996903444 323312570\\n299704754 233926739\\n778198166 197484491\\n\", \"1\\n7 7\\n10122721 121764855\\n397678435 423586551\\n203091798 4... | Vladimir would like to prepare a present for his wife: they have an anniversary! He decided to buy her exactly n flowers.
Vladimir went to a flower shop, and he was amazed to see that there are m types of flowers being sold there, and there is unlimited supply of flowers of each type. Vladimir wants to choose flowers ... | 0 |
{"tests": "{\"inputs\": [\"3 4\\n1 10 10 100\\n1 1 1 100\\n10 100 1 100\\n\", \"10 7\\n1 1 1 1 1 1 1\\n1 1 1 1 1 1 2\\n1 1 1 1 1 2 2\\n1 1 1 1 2 2 1\\n1 1 1 2 2 1 1\\n1 1 2 2 1 1 1\\n1 2 2 1 1 1 1\\n2 2 1 1 1 1 1\\n2 1 1 1 1 1 1\\n1 1 1 1 1 1 1\\n\", \"2 5\\n2 2 1 1 1\\n1 1 2 2 2\\n\", \"4 4\\n622256560 220089420 26256... | You are storing an integer array of length m in a database. To maintain internal integrity and protect data, the database stores n copies of this array.
Unfortunately, the recent incident may have altered the stored information in every copy in the database.
It's believed, that the incident altered at most two elemen... | 0 |
{"tests": "{\"inputs\": [\"4 403458273\\n\", \"10 802030518\\n\", \"29 170254369\\n\", \"18 341796022\\n\", \"26 930971393\\n\", \"21 335521569\\n\", \"15 102513046\\n\", \"25 752887969\\n\", \"7 941492387\\n\", \"16 985629174\\n\", \"24 869771841\\n\", \"23 691688417\\n\", \"19 519879446\\n\", \"20 452405440\\n\", \"1... | This is the easy version of the problem. The only difference between the easy version and the hard version is the constraints on n. You can only make hacks if both versions are solved.
A permutation of 1, 2, …, n is a sequence of n integers, where each integer from 1 to n appears exactly once. For example, [2,3,1,4] i... | 0 |
{"tests": "{\"inputs\": [\"3\\npair pair int int int\\n\", \"1\\npair int\\n\", \"9\\npair int int int pair pair int int int int int pair pair pair pair pair pair int\\n\", \"2\\npair int int\\n\", \"4\\npair pair pair int int int int\\n\", \"5\\npair pair pair pair int int int int int\\n\", \"10\\npair int int int pai... | Vasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.
We all know that programs often store sets of integers. For example, if we have a problem about a weighted directed graph, its edge can be represented by three integer... | 0 |
{"tests": "{\"inputs\": [\"())(())(())(\\n7\\n1 1\\n2 3\\n1 2\\n1 12\\n8 12\\n5 11\\n2 10\\n\", \"(()((((()(())((((((((()((((((()((((\\n71\\n15 29\\n17 18\\n5 26\\n7 10\\n16 31\\n26 35\\n2 30\\n16 24\\n2 24\\n7 12\\n15 18\\n12 13\\n25 30\\n1 30\\n12 13\\n16 20\\n6 35\\n20 28\\n18 23\\n9 31\\n12 35\\n14 17\\n8 16\\n3 10... | Sereja has a bracket sequence s1, s2, ..., sn, or, in other words, a string s of length n, consisting of characters "(" and ")".
Sereja needs to answer m queries, each of them is described by two integers li, ri (1 ≤ li ≤ ri ≤ n). The answer to the i-th query is the length of the maximum correct bracket subsequence of... | 0.125 |
{"tests": "{\"inputs\": [\"10 0\\n\", \"3 2\\n2 1\\n2 2\\n\", \"9 3\\n1 2 3\\n2 8\\n1 4 5\\n\", \"48 35\\n1 17 18\\n2 20\\n1 7 8\\n2 13\\n1 1 2\\n2 23\\n1 25 26\\n1 14 15\\n2 3\\n1 45 46\\n1 35 36\\n2 47\\n1 27 28\\n2 30\\n1 5 6\\n2 11\\n2 9\\n1 32 33\\n2 19\\n2 24\\n2 16\\n1 42 43\\n1 21 22\\n2 37\\n2 34\\n2 40\\n2 31... | Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.
Codesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneously, (Div1 round cannot... | 0 |
{"tests": "{\"inputs\": [\"5 4 5\\n0 1 1 0\\n1 0 0 1\\n0 1 1 0\\n1 0 0 1\\n0 0 0 0\\n1 1\\n1 4\\n1 1\\n4 2\\n4 3\\n\", \"5 1 5\\n0\\n0\\n0\\n0\\n0\\n1 1\\n2 1\\n3 1\\n4 1\\n5 1\\n\", \"2 2 1\\n1 1\\n1 1\\n1 1\\n\", \"1 1 3\\n1\\n1 1\\n1 1\\n1 1\\n\", \"1 5 5\\n0 0 0 0 0\\n1 2\\n1 1\\n1 4\\n1 5\\n1 3\\n\", \"1 1 1\\n0\\... | Mike and some bears are playing a game just for fun. Mike is the judge. All bears except Mike are standing in an n × m grid, there's exactly one bear in each cell. We denote the bear standing in column number j of row number i by (i, j). Mike's hands are on his ears (since he's the judge) and each bear standing in the ... | 0.75 |
{"tests": "{\"inputs\": [\"-1 -1\\n-1 3\\n4 3\\n\", \"1 -1\\n1 1\\n1 2\\n\", \"1 1\\n2 3\\n3 2\\n\", \"451140644 -552066345\\n451140644 97091285\\n643901618 -552066345\\n\", \"755966021 -977934315\\n-693932164 -977934315\\n780740735 341305212\\n\", \"-322848128 276304614\\n-228010033 -361111909\\n-137761352 276304614\\... | There are three points marked on the coordinate plane. The goal is to make a simple polyline, without self-intersections and self-touches, such that it passes through all these points. Also, the polyline must consist of only segments parallel to the coordinate axes. You are to find the minimum number of segments this p... | 0.25 |
{"tests": "{\"inputs\": [\"4 2\\n\", \"8 5\\n\", \"5026 4697\\n\", \"1628 274\\n\", \"34614 27913\\n\", \"92388 39118\\n\", \"85766 64050\\n\", \"100000 2\\n\", \"59140 24272\\n\", \"90616 32240\\n\", \"2 1\\n\", \"67808 61809\\n\", \"10 10\\n\", \"9456 3443\\n\", \"100000 100000\\n\", \"95522 91716\\n\", \"28588 13902... | The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 to n - 1 in the order from the beginning of the street to the end (in the picture: from ... | 0.75 |
{"tests": "{\"inputs\": [\"Bulbbasaur\\n\", \"F\\n\", \"aBddulbasaurrgndgbualdBdsagaurrgndbb\\n\", \"Bulbasua\\n\", \"Blbbasar\\n\", \"Bbular\\n\", \"BBuullbbaassaauurr\\n\", \"Bbulsr\\n\", \"ulbasaur\\n\", \"BulbasaurBulbasaur\\n\", \"bulsar\\n\", \"BulbasaurBulbasauBulbasauBulbasau\\n\", \"BBBBBBBBBBbbbbbbbbbbbbbbbbb... | Bash wants to become a Pokemon master one day. Although he liked a lot of Pokemon, he has always been fascinated by Bulbasaur the most. Soon, things started getting serious and his fascination turned into an obsession. Since he is too young to go out and catch Bulbasaur, he came up with his own way of catching a Bulbas... | 0.375 |
{"tests": "{\"inputs\": [\"4\\n1 1 1 1\\n\", \"3\\n5 1 -5\\n\", \"2\\n900 1000\\n\", \"5\\n10 5 0 -5 -10\\n\", \"51\\n-9 10 30 50 70 90 110 130 150 170 190 210 230 250 270 290 310 330 350 370 390 410 430 450 470 490 510 530 550 570 590 610 630 650 670 690 710 730 750 770 790 810 830 850 870 890 910 930 950 970 990\\n\"... | Vasya came up with his own weather forecasting method. He knows the information about the average air temperature for each of the last n days. Assume that the average air temperature for each day is integral.
Vasya believes that if the average temperatures over the last n days form an arithmetic progression, where the... | 0.875 |
{"tests": "{\"inputs\": [\"4\\n\", \"2\\n\", \"41\\n\", \"170\\n\", \"128\\n\", \"201\\n\", \"102\\n\", \"15\\n\", \"171\\n\", \"137\\n\", \"165\\n\", \"203\\n\", \"117\\n\", \"190\\n\", \"67\\n\", \"153\\n\", \"197\\n\", \"238\\n\", \"9\\n\", \"52\\n\", \"37\\n\", \"11\\n\", \"113\\n\", \"116\\n\", \"26\\n\", \"192\\n... | After the Search Ultimate program that searched for strings in a text failed, Igor K. got to think: "Why on Earth does my program work so slowly?" As he double-checked his code, he said: "My code contains no errors, yet I know how we will improve Search Ultimate!" and took a large book from the shelves. The book read "... | 0 |
{"tests": "{\"inputs\": [\"6 0 6 6 0 6 0 0\\n7 4 4 7 7 10 10 7\\n\", \"0 0 6 0 6 6 0 6\\n1 3 3 5 5 3 3 1\\n\", \"0 0 6 0 6 6 0 6\\n7 3 9 5 11 3 9 1\\n\", \"0 0 1 0 1 1 0 1\\n3 0 6 3 3 6 0 3\\n\", \"-4 -8 -4 -15 3 -15 3 -8\\n-10 5 -27 -12 -10 -29 7 -12\\n\", \"-33 -64 25 -64 25 -6 -33 -6\\n-5 -74 -51 -28 -5 18 41 -28\\n... | You are given two squares, one with sides parallel to the coordinate axes, and another one with sides at 45 degrees to the coordinate axes. Find whether the two squares intersect.
The interior of the square is considered to be part of the square, i.e. if one square is completely inside another, they intersect. If the ... | 0.625 |
{"tests": "{\"inputs\": [\"6\\n0\\n11\\n111\\n1111\\n11001\", \"3\\n0\\n10\", \"6\\n0\\n11\\n110\\n1111\\n11001\", \"6\\n0\\n11\\n100\\n0101\\n11001\", \"6\\n0\\n11\\n011\\n1111\\n11001\", \"6\\n0\\n11\\n100\\n0111\\n01001\", \"6\\n1\\n11\\n001\\n1111\\n11001\", \"6\\n1\\n11\\n011\\n1110\\n00010\", \"6\\n0\\n11\\n100\\... | We will host a rock-paper-scissors tournament with N people. The participants are called Person 1, Person 2, \ldots, Person N. For any two participants, the result of the match between them is determined in advance. This information is represented by positive integers A_{i,j} ( 1 \leq j < i \leq N ) as follows:
* If A... | 0 |
{"tests": "{\"inputs\": [\"1\\n3\", \"2\\n1 2\", \"3\\n1 1 1\", \"10\\n1 3 2 3 3 2 3 2 1 3\", \"1\\n1\", \"3\\n1 2 1\", \"3\\n2 2 1\", \"2\\n1 3\", \"1\\n2\", \"3\\n2 3 1\", \"2\\n1 1\", \"10\\n1 3 2 2 3 2 3 2 1 3\", \"2\\n2 1\", \"3\\n2 2 2\", \"3\\n2 2 3\", \"3\\n3 2 3\", \"3\\n3 1 3\", \"10\\n1 3 3 3 3 2 3 2 1 3\", ... | There are N dishes, numbered 1, 2, \ldots, N. Initially, for each i (1 \leq i \leq N), Dish i has a_i (1 \leq a_i \leq 3) pieces of sushi on it.
Taro will perform the following operation repeatedly until all the pieces of sushi are eaten:
* Roll a die that shows the numbers 1, 2, \ldots, N with equal probabilities, a... | 0 |
{"tests": "{\"inputs\": [\"3 2 1\\n1\", \"4 2 2\\n1 2\", \"5 4 3\\n1 1 1\", \"25000 400 4\\n3 7 31 127\", \"9954 310 12\\n267 193 278 294 6 63 86 166 157 193 168 43\", \"10 3 5\\n1 1 2 3 3\", \"7 4 5\\n1 2 3 1 2\", \"3 0 1\\n1\", \"4 2 2\\n1 4\", \"24477 400 4\\n3 7 31 127\", \"10 5 5\\n1 1 2 3 3\", \"7 4 4\\n1 2 3 1 2... | You are given integers N, K, and an integer sequence A of length M.
An integer sequence where each element is between 1 and K (inclusive) is said to be colorful when there exists a contiguous subsequence of length K of the sequence that contains one occurrence of each integer between 1 and K (inclusive).
For every co... | 0 |
{"tests": "{\"inputs\": [\"1000 1234000\", \"9 45000\", \"20 196000\", \"2000 20000000\", \"0000 1234000\", \"6 45000\", \"0000 0\", \"20 318832\", \"2000 25743705\", \"0000 841858\", \"6 3463\", \"20 93731\", \"2000 40151179\", \"0000 383974\", \"6 3596\", \"20 119339\", \"0100 383974\", \"10 3596\", \"38 119339\", \"... | The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these.
According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situat... | 0.125 |
{"tests": "{\"inputs\": [\"3 9\\n500\\n300\\n800\\n200\\n100\\n600\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1000\\n0 0\", \"3 9\\n500\\n300\\n800\\n200\\n100\\n600\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\n500\\n311\\n800\\n335\\n100\\n600\\n900\\n700\\n400\\n4 3\\n1000\\n1000\\n1010\\n0 0\", \"3 9\\... | Taro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshelf in the room, it will be quite small, so you have to devise to make the width of the bookshelf as... | 0.625 |
{"tests": "{\"inputs\": [\"5 5\\n0 0\\n1 1\\n3 0\\n3 2\\n0 2\\n1 2\\n2 3\\n2 4\\n3 4\\n1 5\", \"7 6\\n0 2\\n3 0\\n2 2\\n1 0\\n4 1\\n2 3\\n3 5\\n1 3\\n2 4\\n2 3\\n3 5\\n3 7\\n6 7\", \"5 5\\n0 0\\n1 1\\n3 0\\n3 2\\n0 2\\n1 2\\n3 3\\n2 4\\n3 4\\n1 5\", \"7 6\\n0 2\\n3 0\\n2 2\\n1 0\\n4 1\\n2 3\\n3 4\\n1 3\\n2 4\\n2 3\\n3 ... | Villages were scattered in the Wakamatsu Plain of Aizu. Several settlements are connected by straight roads that allow them to travel to and from each other, and any settlement in the plain can be traced back and forth. Each road has a lengthy maintenance fee, but all the settlements funded the road to maintain it.
At... | 0 |
{"tests": "{\"inputs\": [\"3 2 1\\n1 2\", \"3 2 1\\n2 2\", \"4 2 2\\n1 2\", \"2 2 1\\n1 2\", \"3 2 1\\n2 0\", \"3 2 1\\n4 0\", \"3 2 1\\n0 0\", \"3 1 1\\n1 2\", \"3 2 1\\n2 1\", \"3 0 1\\n2 0\", \"6 2 1\\n4 0\", \"3 1 1\\n0 2\", \"0 0 1\\n2 0\", \"6 2 1\\n4 1\", \"3 1 2\\n0 2\", \"0 0 1\\n4 0\", \"6 2 1\\n4 2\", \"3 1 ... | Modern Mansion
You got lost in a big mansion. This mansion has a structure in which square rooms are arranged in a grid pattern from north, south, east, and west, with M columns in the east-west direction and N rows in the north-south direction, for a total of M x N. The room in the xth column (1 ≤ x ≤ M) from the wes... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 1 0 1 0\\n0 1 1 1 1\\n1 0 1 0 1\\n0 1 1 1 0\\n0 1 1 0 0\\n\\n0 1 0 1 1\\n0 1 0 1 0\\n0 0 1 0 0\\n0 0 1 1 0\\n1 0 1 0 0\\n\\n1 1 1 1 0\\n0 1 1 1 0\\n0 1 1 0 1\\n0 1 1 1 0\\n0 0 0 0 1\", \"3\\n1 1 0 1 0\\n0 1 1 1 1\\n1 0 1 0 1\\n0 1 1 1 0\\n0 1 1 0 0\\n\\n0 1 0 1 1\\n0 1 0 1 0\\n0 0 1 0 0... | Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular land suitable for reclamation.
The map o... | 0.875 |
{"tests": "{\"inputs\": [\".tweets.1\\nname: shimeji\\nid: shimejitan\\ntweets:\\n1: shimejilove\\n2: azupero\", \".no.such.property\\nobject:\\nprop1: str\\nprop2: str\", \".tweets.1\\nname: shimeji\\nid: shimejitan\\ntweets:\\n 1: shimejilove\\n 2: azupero\", \".my.obj\\nmy:\\nstr: string value\\nobj:\\na: a\\nb: b... | YAML (YAML Ain't Markup Language) is one of the formats for expressing an object as a character string.
You will be given an object represented by a subset of YAML and a query that specifies the property, so please answer the value of the specified property.
Subset of YAML
A subset of YAML follows the syntax rules e... | 0 |
{"tests": "{\"inputs\": [\"((0,0)@(1,1))@((4,1)@(2,5))\\n((0,0)@(3,1))@((1,-3)@(2,-1))\\n(0,0)@(1,1)@(4,1)\\n(0,0)@((1,1)@(4,1))\\n(((0,0)@((10,20)@(((30,40))))))\\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\\n#\", \"((0,0)@(1,1))@((4,1)@(2,5))\\n((0,0)@(3,1))@((1,-3)@(2,-1))\\n(0,0)@(1,1)@(4,1)\\n(0,0)@((1,1)@... | Problem Statement
One day, you found an old scroll with strange texts on it.
You revealed that the text was actually an expression denoting the position of treasure. The expression consists of following three operations:
* From two points, yield a line on which the points lie.
* From a point and a line, yield a poin... | 0 |
{"tests": "{\"inputs\": [\"5 2\\n1\\n-1\\n-1\\n1\\n0\\n\", \"1000000000 2 999999998\\n0 1\\n\", \"1000000000 1 77000000\\n0\\n\", \"3000000 20 642518\\n1 0 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 1 0 1\\n\", \"100000 16 79154\\n1 1 1 0 0 0 0 0 1 1 0 1 0 1 0 1\\n\", \"10000000 22 8115129\\n1 0 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 0 ... | This is an interactive problem.
Natasha is going to fly to Mars. Finally, Natasha sat in the rocket. She flies, flies... but gets bored. She wishes to arrive to Mars already! So she decides to find something to occupy herself. She couldn't think of anything better to do than to calculate the distance to the red planet... | 0 |
{"tests": "{\"inputs\": [\"4\\n-1 2 1 2\\n-1 0 1 0\\n-1 0 0 3\\n0 3 1 0\\n\", \"9\\n0 0 4 4\\n-1 5 4 0\\n4 0 4 4\\n5 2 11 2\\n6 1 6 7\\n5 6 11 6\\n10 1 10 7\\n7 0 9 8\\n10 -1 11 -1\\n\", \"10\\n78 31 22 16\\n58 8 58 44\\n24 59 49 40\\n97 77 39 24\\n8 2 33 83\\n96 11 66 59\\n20 38 47 76\\n8 5 47 97\\n19 71 82 36\\n91 29... | You are given n segments on a Cartesian plane. Each segment's endpoints have integer coordinates. Segments can intersect with each other. No two segments lie on the same line.
Count the number of distinct points with integer coordinates, which are covered by at least one segment.
Input
The first line contains a sing... | 0.125 |
{"tests": "{\"inputs\": [\"2\\n0 1\\n1 1\\n\", \"1\\n0 1\\n\", \"3\\n0 1\\n0 2\\n0 -3\\n\", \"3\\n8376968 152285\\n-8928555 5949944\\n-4450793 4397692\\n\", \"4\\n7562857 4638477\\n2230312 4253055\\n-9291686 9317264\\n-6643279 5426447\\n\", \"2\\n0 1\\n1 1\\n\", \"3\\n1367642 1559668\\n-190618 8836498\\n-976468 4184452... | There is a forest that we model as a plane and live n rare animals. Animal number i has its lair in the point (x_{i}, y_{i}). In order to protect them, a decision to build a nature reserve has been made.
The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through the f... | 0 |
{"tests": "{\"inputs\": [\"3\\n4 3 1\\n\", \"5\\n25 10 5 2 1\\n\", \"9\\n487264 453898 452366 383095 172725 168148 164570 141228 1\\n\", \"28\\n434419 433070 431479 424448 423449 392416 368998 367310 329030 316399 311541 302510 283863 262469 257928 248272 242310 217371 183364 172064 164154 131734 131169 117466 23544 19... | Billy investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amount of n coins of different face values, and the coins of each value are not limited in number. The task is to collect t... | 0 |
{"tests": "{\"inputs\": [\"4\\n8 2 5\\n00110010\\n8 1 1\\n00110010\\n9 100000000 100000000\\n010101010\\n2 5 1\\n00\\n\", \"2\\n2 3 5\\n00\\n12 4 7\\n011101011100\\n\", \"2\\n8 2 5\\n01111110\\n6 2 5\\n001010\\n\", \"2\\n2 3 8\\n00\\n12 4 7\\n011101011100\\n\", \"2\\n8 2 5\\n01101110\\n6 2 5\\n001010\\n\", \"2\\n8 2 5\... | You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment [0, n] on OX axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval (x, x + 1) with integer x. So we can represent the road as a binary string consist... | 0 |
{"tests": "{\"inputs\": [\"7 2\\n2 1 2 1 2 1 1\\n6 4\\n1 5\\n3 1\\n2 3\\n7 5\\n7 4\\n\", \"5 1\\n1 2 3 4 5\\n1 2\\n2 3\\n3 4\\n3 5\\n\", \"14 2\\n3 2 3 1 2 3 4 2 3 1 4 2 1 3\\n12 10\\n2 7\\n13 12\\n14 11\\n10 5\\n1 2\\n11 4\\n4 9\\n14 8\\n12 4\\n7 9\\n13 6\\n10 3\\n\", \"10 2\\n4 1 4 4 2 3 2 1 1 4\\n1 7\\n1 3\\n8 3\\n3... | You are given a tree, which consists of n vertices. Recall that a tree is a connected undirected graph without cycles.
<image> Example of a tree.
Vertices are numbered from 1 to n. All vertices have weights, the weight of the vertex v is a_v.
Recall that the distance between two vertices in the tree is the number o... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 4\\n1 2 3 4\\n5 6 7 8\\n9 10 11 12\\n5 5\\n2 5 4 8 3\\n9 10 11 5 1\\n12 8 4 2 5\\n2 2 5 4 1\\n6 8 2 4 2\\n2 2\\n100 10\\n10 1\\n1 2\\n123456789876543 987654321234567\\n1 1\\n42\\n\", \"1\\n8 6\\n1 2 3 4 5 6\\n7 8 9 10 11 12\\n13 14 15 16 17 18\\n19 20 21 22 23 24\\n26 27 28 29 30 31\\n3... | You are playing one famous sandbox game with the three-dimensional world. The map of the world can be represented as a matrix of size n × m, where the height of the cell (i, j) is a_{i, j}.
You are in the cell (1, 1) right now and want to get in the cell (n, m). You can move only down (from the cell (i, j) to the cell... | 0.25 |
{"tests": "{\"inputs\": [\"7\\n1 0\\n1 1\\n42 7\\n13 7\\n99 1\\n99 0\\n99 2\\n\", \"2\\n13 9\\n17 9\\n\", \"2\\n13 9\\n27 9\\n\", \"7\\n1 0\\n1 1\\n42 7\\n13 7\\n64 1\\n99 0\\n99 2\\n\", \"2\\n17 9\\n47 9\\n\", \"7\\n1 0\\n1 1\\n42 7\\n1 9\\n64 0\\n99 0\\n99 2\\n\", \"7\\n1 0\\n2 1\\n42 7\\n1 9\\n64 0\\n99 0\\n99 2\\n\... | Let f(x) be the sum of digits of a decimal number x.
Find the smallest non-negative integer x such that f(x) + f(x + 1) + ... + f(x + k) = n.
Input
The first line contains one integer t (1 ≤ t ≤ 150) — the number of test cases.
Each test case consists of one line containing two integers n and k (1 ≤ n ≤ 150, 0 ≤ k ... | 0 |
{"tests": "{\"inputs\": [\"2 3\\n3 3 7 2\\n3 4 1 5\\n\", \"1 3\\n4 4 3 1 2\\n\", \"1 4\\n6 5 1 10 1 1 5\\n\", \"3 2\\n1 10\\n1 2\\n1 5\\n\", \"1 1\\n1 100\\n\", \"1 68\\n100 26 58 15 8 69 66 49 97 18 74 27 39 19 76 37 25 4 88 75 17 79 41 21 44 39 7 42 63 82 92 87 41 85 25 30 43 80 95 70 98 88 16 15 97 74 81 76 33 19 64... | During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed.
The collection of porcelain is arranged neatly on n shelves. Within each shelf the items are placed in one row, so that one can access only the outermost items — the leftmost or the r... | 0.625 |
{"tests": "{\"inputs\": [\"11 14\\n1 2\\n1 3\\n2 4\\n3 4\\n4 5\\n4 6\\n5 11\\n6 11\\n1 8\\n8 9\\n9 7\\n11 7\\n1 10\\n10 4\\n\", \"4 4\\n1 2\\n2 4\\n1 3\\n3 4\\n\", \"34 53\\n9 6\\n25 28\\n27 24\\n15 18\\n34 33\\n27 30\\n1 4\\n4 7\\n11 9\\n11 8\\n30 26\\n15 12\\n26 23\\n17 15\\n29 26\\n11 15\\n7 10\\n14 12\\n5 9\\n8 5\\... | The Berland road network consists of n cities and of m bidirectional roads. The cities are numbered from 1 to n, where the main capital city has number n, and the culture capital — number 1. The road network is set up so that it is possible to reach any city from any other one by the roads. Moving on each road in any d... | 0 |
{"tests": "{\"inputs\": [\"24\\n\", \"1000000\\n\", \"47320\\n\", \"222\\n\", \"9\\n\", \"1\\n\", \"701\\n\", \"11\\n\", \"258634\\n\", \"1995\\n\", \"0\\n\", \"77\\n\", \"11010\\n\", \"3\\n\", \"5\\n\", \"216\\n\", \"12343\\n\", \"31\\n\", \"2033361\\n\", \"1468\\n\", \"844421\\n\", \"7984\\n\", \"10\\n\", \"8\\n\", \... | Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar.
The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows:
"May the Great Beaver bless you! May your chacres open ... | 0 |
{"tests": "{\"inputs\": [\"5\\n17 0 10 2 1\\n11010\\n\", \"2\\n3 8\\n10\\n\", \"1\\n1\\n1\\n\", \"43\\n475 2165 8771 7146 8980 7209 9170 9006 6278 6661 4740 6321 7532 6869 3788 7918 1707 5070 3809 5189 2494 8255 1123 3197 190 5712 9873 3286 9997 133 9030 3067 8043 5297 5398 4240 8315 2141 1436 3297 247 8438 2300\\n0111... | Valera has array a, consisting of n integers a0, a1, ..., an - 1, and function f(x), taking an integer from 0 to 2n - 1 as its single argument. Value f(x) is calculated by formula <image>, where value bit(i) equals one if the binary representation of number x contains a 1 on the i-th position, and zero otherwise.
For ... | 0 |
{"tests": "{\"inputs\": [\"6\\n3 5 16\\n1 6 11\\n4 8 12\\n7 9 16\\n2 10 14\\n8 13 15\\n\", \"4\\n2 8 9\\n1 4 7\\n3 6 8\\n5 8 10\\n\", \"18\\n3 9 9\\n41 42 43\\n25 50 57\\n51 55 57\\n4 35 38\\n18 26 33\\n3 14 40\\n36 52 55\\n21 49 55\\n56 56 56\\n27 32 32\\n16 26 47\\n20 51 51\\n3 19 31\\n48 50 51\\n56 56 56\\n12 15 37\... | Pavel is going to make a game of his dream. However, he knows that he can't make it on his own so he founded a development company and hired n workers of staff. Now he wants to pick n workers from the staff who will be directly responsible for developing a game.
Each worker has a certain skill level vi. Besides, each ... | 0 |
{"tests": "{\"inputs\": [\"3\\na+++++a\\n\", \"1\\n5*a++-3*++a+a++\\n\", \"-744\\n672*a++-975*a++-394*a+++968*a+++222*a+++988*++a+504*++a-782*a++-321*++a+980*++a-483*a++-554*++a-347*++a-180*++a-390*a+++403*a++-617*a+++378*a+++544*++a-978*a+++952*a++-618*a++-516*++a-990*++a+540*++a-398*++a-187*++a+401*++a+829*a++-187*++... | C*++ language is quite similar to C++. The similarity manifests itself in the fact that the programs written in C*++ sometimes behave unpredictably and lead to absolutely unexpected effects. For example, let's imagine an arithmetic expression in C*++ that looks like this (expression is the main term):
* expression :... | 0 |
{"tests": "{\"inputs\": [\"4 4 3\\n1 3\\n1 2\\n2 3\\n3 4\\nArtem 1 1 4\\nDmitry 1 1 2\\nEdvard 4 2 1 3\\nArtem 2 0\\nDmitry 1 0\\nEdvard 4 4 1 2 3 4\\n\", \"2 1 2\\n1 2\\nDmitry 1 1 1\\nNatalia 2 0\\nNatalia 1 1 1\\nDmitry 2 0\\n\", \"7 8 2\\n3 7\\n7 6\\n1 2\\n4 5\\n1 3\\n5 6\\n4 6\\n2 3\\na 1 4 3 8 5 2\\nb 4 4 4 6 7 1... | Today you are to solve the problem even the famous Hercule Poirot can't cope with! That's why this crime has not yet been solved and this story was never included in Agatha Christie's detective story books.
You are not informed on what crime was committed, when and where the corpse was found and other details. We onl... | 0 |
{"tests": "{\"inputs\": [\"aaa\\nzzz\\n\", \"a\\nc\\n\", \"abcdefg\\nabcdefh\\n\", \"pkjlxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\\npkjlyaaaaaaaaaaaaaaaaaaaaaaaaaaaahr\\n\", \"kexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywl\\nkexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepx... | Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.
During the last lesson the teacher has provided two strings s and t to Vitaly. The strings have the same length, they consist of lowercase English l... | 0 |
{"tests": "{\"inputs\": [\"........\\n........\\n.B....B.\\n....W...\\n........\\n..W.....\\n........\\n........\\n\", \"..B.....\\n..W.....\\n......B.\\n........\\n.....W..\\n......B.\\n........\\n........\\n\", \"........\\n.......W\\n........\\n........\\n........\\n........\\n.......B\\n........\\n\", \"........\\n... | Galois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».
This new game is played on a board consisting of 8 rows and 8 columns. At the beginning of every game some black and white pawns are placed on the board. The number of black pawns placed... | 0 |
{"tests": "{\"inputs\": [\"4\\n1 3\\n2 3\\n4 3\\n4\\n2 1 2\\n3 2 3 4\\n3 1 2 4\\n4 1 2 3 4\\n\", \"7\\n1 2\\n2 3\\n3 4\\n1 5\\n5 6\\n5 7\\n1\\n4 2 4 6 7\\n\", \"4\\n1 2\\n2 3\\n1 4\\n1\\n3 1 3 4\\n\", \"30\\n1 2\\n1 3\\n1 4\\n2 5\\n2 6\\n2 7\\n4 8\\n4 9\\n6 10\\n6 11\\n11 30\\n11 23\\n30 24\\n30 25\\n25 26\\n25 27\\n27... | Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not wait for his daughter's marriage, reforms must be finished as soon as possible.
The kingdom curren... | 0 |
{"tests": "{\"inputs\": [\"3\\n1 2 -1\\n\", \"5\\n28 35 7 14 21\\n\", \"3\\n0 -44 -49\\n\", \"5\\n-1 1 0 0 0\\n\", \"11\\n-9 -1 -10 9 7 -4 0 -8 -3 3 5\\n\", \"3\\n0 0 0\\n\", \"4\\n1 -1 0 -2\\n\", \"10\\n0 0 0 0 0 0 0 0 0 0\\n\", \"5\\n0 0 0 0 0\\n\", \"2\\n1000000000 1000000000\\n\", \"2\\n0 0\\n\", \"5\\n-7 0 -7 -7 -... | Yash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibonacci-ish if
1. the sequence consists of at least two elements
2. f0 and f1 are arbitrary
3. fn + 2 = fn + 1 + fn for all n ≥ 0.
You are given some sequence of integers a1, a2, ..., an. Your task is... | 0.5 |
{"tests": "{\"inputs\": [\"1 1 1\\n1\\n\", \"2 7 10\\n5 6\\n\", \"3 10 10\\n5 7 7\\n\", \"1 5 10\\n7\\n\", \"5 10 20\\n10 10 10 10 1\\n\", \"2 951637 951638\\n44069 951637\\n\", \"5 234613 716125\\n642626 494941 234613 234613 234613\\n\", \"50 100 129\\n55 130 91 19 116 3 63 52 104 76 75 27 151 99 149 147 39 148 84 9 1... | Kolya is going to make fresh orange juice. He has n oranges of sizes a1, a2, ..., an. Kolya will put them in the juicer in the fixed order, starting with orange of size a1, then orange of size a2 and so on. To be put in the juicer the orange must have size not exceeding b, so if Kolya sees an orange that is strictly gr... | 0.75 |
{"tests": "{\"inputs\": [\"3 4 3\\n\", \"2 18 13\\n\", \"4 4 4\\n\", \"77810521 953603507 953603507\\n\", \"6 4 4\\n\", \"3 1000000000 1000000000\\n\", \"453145 999531525 999531525\\n\", \"1000000000 1 1\\n\", \"469568633 681052815 681052815\\n\", \"452081307 790635695 790635695\\n\", \"263288720 933114664 933114664\\n... | Arkadiy has lots square photos with size a × a. He wants to put some of them on a rectangular wall with size h × w.
The photos which Arkadiy will put on the wall must form a rectangular grid and the distances between neighboring vertically and horizontally photos and also the distances between outside rows and column... | 0 |
{"tests": "{\"inputs\": [\"10 5 1\\n3 3\\n\", \"7 7 3\\n1 2\\n2 1\\n5 5\\n\", \"1000 1000 10\\n630 843\\n959 696\\n75 966\\n691 982\\n390 44\\n863 380\\n467 293\\n94 96\\n415 411\\n161 497\\n\", \"1000000000 1000000000 1\\n243387905 466399354\\n\", \"4 5 19\\n1 1\\n1 2\\n1 3\\n1 4\\n1 5\\n2 1\\n2 2\\n2 3\\n2 5\\n3 1\\n... | The capital of Berland looks like a rectangle of size n × m of the square blocks of same size.
Fire!
It is known that k + 1 blocks got caught on fire (k + 1 ≤ n·m). Those blocks are centers of ignition. Moreover positions of k of these centers are known and one of these stays unknown. All k + 1 positions are distinct... | 0 |
{"tests": "{\"inputs\": [\"3\\n4 5 7\\n\", \"2\\n1 1\\n\", \"5\\n1 4 4 5 5\\n\", \"4\\n3 3 2 1\\n\", \"1\\n100000\\n\", \"10\\n50096 50096 50096 50096 50096 50096 28505 50096 50096 50096\\n\", \"3\\n4 4 100000\\n\", \"1\\n2\\n\", \"10\\n87900 87900 5761 87900 87900 87900 5761 87900 87900 87900\\n\", \"7\\n7 7 7 7 6 6 6... | Edogawa Conan got tired of solving cases, and invited his friend, Professor Agasa, over. They decided to play a game of cards. Conan has n cards, and the i-th card has a number ai written on it.
They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he removes all c... | 0 |
{"tests": "{\"inputs\": [\"11 3 10\\n.*....**.*.\\n\", \"5 1 1\\n*...*\\n\", \"3 2 3\\n***\\n\", \"6 2 3\\n*...*.\\n\", \"17 11 2\\n.*..*..*.*.***...\\n\", \"5 0 1\\n*.*.*\\n\", \"20 5 5\\n.*.*.............*..\\n\", \"5 1 2\\n...*.\\n\", \"10 5 1\\n..........\\n\", \"9 5 3\\n*...*...*\\n\", \"5 1 4\\n.....\\n\", \"5 2 ... | There are n consecutive seat places in a railway carriage. Each place is either empty or occupied by a passenger.
The university team for the Olympiad consists of a student-programmers and b student-athletes. Determine the largest number of students from all a+b students, which you can put in the railway carriage so t... | 0 |
{"tests": "{\"inputs\": [\"2 2 1\\n\", \"2 2 3\\n\", \"2 2 6\\n\", \"2 2 2\\n\", \"87 20 3\\n\", \"15 6729 6902\\n\", \"4364 1548 8026\\n\", \"6 831 878\\n\", \"16 43 56\\n\", \"57 39 82\\n\", \"2 1 5\\n\", \"54 46 81\\n\", \"8751 81 9336\\n\", \"9296 71 9842\\n\", \"85 5326 5840\\n\", \"2436 4734 9962\\n\", \"2474 203... | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 0 |
{"tests": "{\"inputs\": [\"1 2\\n100\\n60 70\\n\\nSAMPLE\", \"6 10\\n202 354 122 286 138 46\\n49 266 181 4 203 246 227 153 68 346\", \"4 5\\n120 304 184 200\\n331 352 251 208 332\", \"1 3\\n208\\n4 353 248\", \"1 2\\n100\\n60 112\\n\\nSAMPLE\", \"6 10\\n202 354 122 286 138 46\\n42 266 181 4 203 246 227 153 68 346\", \"... | Raju and Rani and playing games in the school. Raju has recently learned how to draw angles.
He knows how to draw some angles. He also can add/subtract any of the two angles he draws. Rani now wants to test Raju.
Input:
First line contains N and K, denoting number of angles Raju knows how to draw and K the number... | 0.625 |
{"tests": "{\"inputs\": [\"1\\n5\\n1 1\\n2 2\\n3 4\\n4 3\\n2 4\\n\\nSAMPLE\", \"1\\n5\\n1 1\\n2 4\\n3 4\\n4 3\\n2 4\\n\\nSAMPLE\", \"1\\n5\\n1 1\\n2 2\\n3 4\\n4 3\\n2 4\\n\\nSAEPLM\", \"1\\n5\\n1 1\\n1 2\\n3 4\\n4 3\\n2 8\\n\\nSAMPLE\", \"1\\n1\\n1 1\\n1 1\\n3 4\\n4 3\\n1 8\\n\\nSAMPLE\", \"1\\n5\\n2 1\\n2 2\\n3 1\\n4 ... | Monk has to visit a land where strange creatures, known as Pokemons, roam around in the wild. Each Pokemon in the land will attack any visitor. They can only be pacified by feeding them their favorite food.
The Pokemon of type X eats one food item of type X.
Monk knows that he will encounter N ponds on the way. At ea... | 0 |
{"tests": "{\"inputs\": [\"3\\n3\\n1 3\\n1 2\\n3 2\\n2\\n2 1\\n2 3\\n1\\n2 1\", \"100000\\n1\\n1 2\\n1\\n99999 100000\\n1\\n1 100000\", \"2\\n1\\n1 2\\n1\\n1 2\\n1\\n1 2\", \"3\\n3\\n1 3\\n2 2\\n3 2\\n2\\n2 1\\n2 3\\n1\\n2 1\", \"100000\\n1\\n1 3\\n1\\n99999 100000\\n1\\n1 100000\", \"2\\n1\\n1 2\\n1\\n1 3\\n1\\n1 2\",... | Given are simple undirected graphs X, Y, Z, with N vertices each and M_1, M_2, M_3 edges, respectively. The vertices in X, Y, Z are respectively called x_1, x_2, \dots, x_N, y_1, y_2, \dots, y_N, z_1, z_2, \dots, z_N. The edges in X, Y, Z are respectively (x_{a_i}, x_{b_i}), (y_{c_i}, y_{d_i}), (z_{e_i}, z_{f_i}).
Bas... | 0 |
{"tests": "{\"inputs\": [\"5 7\\n1 2 5\\n5 3 4\\n2 4 8\\n1 5 1\\n2 3 3\\n4 5 3\\n4 3 9\\n4\\n1\\n1 2\\n1\\n2 5\\n1\\n3 4\\n0\", \"5 7\\n1 2 5\\n5 3 4\\n2 4 12\\n1 5 1\\n2 3 3\\n4 5 3\\n4 3 9\\n4\\n1\\n1 2\\n1\\n2 5\\n1\\n3 4\\n0\", \"5 7\\n1 2 5\\n5 3 4\\n2 4 12\\n1 5 1\\n2 1 3\\n4 5 3\\n4 3 5\\n7\\n1\\n1 1\\n1\\n2 5\\... | Requirements
* All inputs are of non-negative integer value.
* T_{\text{max}} = 10000
* 200 \leq |V| \leq 400
* 1.5 |V| \leq |E| \leq 2 |V|
* 1 \leq u_{i}, v_{i} \leq |V| (1 \leq i \leq |E|)
* 1 \leq d_{u_i, v_i} \leq \lceil 4\sqrt{2|V|} \rceil (1 \leq i \leq |E|)
* The given graph has no self-loops / multiple edges a... | 0 |
{"tests": "{\"inputs\": [\"4 7\", \"12 20\", \"16 30\", \"6 7\", \"12 2\", \"16 38\", \"1 7\", \"12 1\", \"16 25\", \"2 7\", \"12 0\", \"16 29\", \"2 9\", \"16 46\", \"3 9\", \"16 31\", \"4 9\", \"27 31\", \"4 18\", \"27 51\", \"4 10\", \"27 102\", \"1 10\", \"42 102\", \"42 123\", \"46 123\", \"70 123\", \"70 2\", \"1... | E869120 defined a sequence $a$ like this:
* $a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \ (k \ge 1)$
He also defined sequences $d_1, d_2, d_3, \dots , d_n$, as the following recurrence relation :
* $d_{1, j} = a_j$
* $d_{i, j} = \sum_{k = 1}^j d_{i - 1, k} \ (i \ge 2)$
You are given integers $n$ and $m$. Please calculate... | 0.125 |
{"tests": "{\"inputs\": [\"3 2 5\\n1 1 2\\n1 2 3\\n2 1 1\\n2 3 2\\n2 2 1\", \"3 2 4\\n1 1 2\\n2 1 1\\n2 3 2\\n2 2 1\", \"3 2 2\\n1 1 2\\n2 1 1\", \"3 2 7\\n1 1 2\\n1 2 3\\n2 1 1\\n2 3 2\\n2 2 1\", \"3 2 4\\n1 1 2\\n2 1 1\\n2 3 2\\n1 2 1\", \"3 2 4\\n2 1 2\\n2 1 1\\n2 3 2\\n2 2 1\", \"3 2 5\\n2 1 2\\n1 2 3\\n2 1 1\\n2 3... | Akira, the student council president of A High School, decided to investigate which club activities the A High School students belong to. A High School has N students numbered 1 to N and M types of club activities numbered 1 to M. There is no limit to the number of people in each club activity, and there can be 0 club ... | 0 |
{"tests": "{\"inputs\": [\"5 4\\n3\\n1 1\\n3 4\\n5 3\", \"5 4\\n3\\n1 1\\n3 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 4\\n5 12\", \"6 4\\n3\\n0 1\\n1 4\\n5 12\", \"5 4\\n3\\n1 1\\n3 4\\n5 2\", \"5 4\\n3\\n1 1\\n3 4\\n7 6\", \"6 4\\n3\\n1 0\\n1 4\\n5 6\", \"6 4\\n3\\n1 1\\n1 3\\n5 12\", \"6 4\\n3\\n0... | At the end of last year, Santa Claus forgot to give Christmas presents to the children in JOI village. Therefore, I decided to deliver the chocolate cake to the children as an apology. The day to deliver is approaching tomorrow, so it's time to come up with a move plan.
JOI village is divided into a grid shape by W ro... | 0 |
{"tests": "{\"inputs\": [\"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 5 4 -2 4 -3 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 5 3 -2 4 -3 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 5 4 -2 4 -1 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\\n3 2 4 -2 4 -3 -2 -2 -1 0\", \"2\\n3 3 3 3 -3 3 2 -5 3 2 -5 ... | An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors.
The Ninja House can be modeled by a graph, as shown in Fi... | 0 |
{"tests": "{\"inputs\": [\"ABCABCABAB\\nZZZZZZZZZZZZ\\nEND\", \"ABCABCABAB\\nZZZZZZZZZZZZ\\n#END\", \"ABCABCABAB\\nZZZZZZZZZZZZ\\nNED\", \"ABCABCABAB\\nZZZZZZZZZZZZ\\nNDD\", \"ABCABCACAB\\nZZZZZZZZZZZZ\\nNDD\", \"ABBABCACAB\\nZZZZZZZZZZZZ\\nNDD\", \"ABBABCACAB\\nZ[ZZZZZZZZZZ\\nNDD\", \"ABCABCABAB\\nZZZZZZZZZZZZ\\nNEE\"... | You are a treasure hunter traveling around the world. Finally, you’ve got an ancient text indicating the place where the treasure was hidden. The ancient text looks like a meaningless string of characters at first glance. Actually, the secret place is embedded as the longest repeated subsequence of the text.
Well, the... | 0 |
{"tests": "{\"inputs\": [\"5R2D\", \"5R3D\", \"5D2R\", \"5T2D\", \"5D3R\", \"5U2D\", \"4D2R\", \"6T2D\", \"3R5D\", \"4R2D\", \"6D2T\", \"4R5D\", \"4R3D\", \"5D2T\", \"5U1D\", \"7T2D\", \"4D3R\", \"4R6D\", \"3R3D\", \"3D3R\", \"5R4D\", \"6R3D\", \"6U2D\", \"5D1T\", \"8T2D\", \"3R4D\", \"5T1D\", \"4U2D\", \"6D1T\", \"5U0... | A: Flick input
A college student who loves 2D, commonly known as 2D, replaced his long-used Galapagos mobile phone with a smartphone. 2D, who operated the smartphone for the first time, noticed that the character input method was a little different from that of old mobile phones. On smartphones, a method called flick ... | 0 |
{"tests": "{\"inputs\": [\"5 1\\na\\nb\\nc\\na\\nc\", \"3 3\\nuki\\nuku\\nuke\", \"4 2\\noi\\nio\\nrr\\nrr\", \"5 2\\na\\nb\\nc\\na\\nc\", \"3 2\\nuki\\nuku\\nuke\", \"4 2\\npi\\nio\\nrr\\nrr\", \"4 2\\npi\\nio\\nrr\\nqr\", \"7 2\\na\\nb\\nc\\n`\\nc\", \"2 3\\na\\nb\\nc\\n`\\nc\", \"5 1\\na\\nb\\nc\\nb\\nc\", \"4 2\\no... | Problem
Taro has N character strings, each of which is L in length. Taro loves palindromes, so I want to make palindromes as long as possible by selecting some of the N character strings and arranging them in any order.
Find the longest palindrome that Taro can make. If there are more than one, output the smallest on... | 0 |
{"tests": "{\"inputs\": [\"abcd\\n1\\n1 3\\n\", \"abba\\n2\\n1 4\\n1 2\\n\", \"AAaa\\n2\\n1 2\\n1 3\\n\", \"sYDMlMKcqjyzmIKKjjcNyUgaixfaNUJYXjHXRHiRzNyHysnxTt\\n68\\n19 15\\n46 34\\n38 30\\n50 39\\n22 11\\n4 14\\n23 2\\n10 47\\n42 15\\n9 5\\n38 40\\n43 16\\n11 46\\n29 46\\n49 5\\n28 1\\n33 22\\n48 8\\n5 33\\n8 34\\n31 ... | There is a colony of villains with several holes aligned in a row, where each hole contains exactly one villain.
Each colony arrangement can be expressed as a string of even length, where the i-th character of the string represents the type of villain in the i-th hole.
Iron Man can destroy a colony only if the colon... | 0 |
{"tests": "{\"inputs\": [\"1\\n\", \"4\\n\", \"7\\n\", \"60\\n\", \"36\\n\", \"18\\n\", \"8\\n\", \"44\\n\", \"39\\n\", \"3\\n\", \"57\\n\", \"5\\n\", \"12\\n\", \"17\\n\", \"19\\n\", \"11\\n\", \"59\\n\", \"47\\n\", \"56\\n\", \"27\\n\", \"6\\n\", \"2\\n\", \"9\\n\", \"24\\n\", \"32\\n\", \"14\\n\", \"10\\n\", \"16\\n... | You have a given integer n. Find the number of ways to fill all 3 × n tiles with the shape described in the picture below. Upon filling, no empty spaces are allowed. Shapes cannot overlap.
<image> This picture describes when n = 4. The left one is the shape and the right one is 3 × n tiles.
Input
The only line cont... | 0 |
{"tests": "{\"inputs\": [\"8\\n5 6 2\\n2 4 3 5 7\\n5 11 2\\n2 4 3 5 7\\n3 2 3\\n4 2 6\\n5 2 3\\n10 1 3 9 2\\n2 10000 2\\n10000 10000\\n2 9999 2\\n10000 10000\\n4 6 4\\n3 2 3 2\\n5 5 3\\n1 2 2 1 2\\n\", \"2\\n2 1 2\\n1 1\\n2 2000000000 2\\n1 1\\n\", \"8\\n5 6 2\\n2 4 3 5 7\\n5 4 2\\n2 4 3 5 7\\n3 2 3\\n4 2 6\\n5 2 3\\n1... | This is the hard version of this problem. The only difference is the constraint on k — the number of gifts in the offer. In this version: 2 ≤ k ≤ n.
Vasya came to the store to buy goods for his friends for the New Year. It turned out that he was very lucky — today the offer "k of goods for the price of one" is held in... | 0 |
{"tests": "{\"inputs\": [\"5\\n3\\n14\\n15\\n24\\n1\\n\", \"50\\n11833308\\n5211498\\n64660\\n9077929\\n2699416\\n2432035\\n234901\\n1337830\\n8457191\\n10523566\\n5722429\\n5452712\\n5511654\\n8587879\\n348160\\n3141182\\n2661936\\n395300\\n6950223\\n2119926\\n4407089\\n3559060\\n10228325\\n5752720\\n1607500\\n647047\... | A card pyramid of height 1 is constructed by resting two cards against each other. For h>1, a card pyramid of height h is constructed by placing a card pyramid of height h-1 onto a base. A base consists of h pyramids of height 1, and h-1 cards on top. For example, card pyramids of heights 1, 2, and 3 look as follows:
... | 0.25 |
{"tests": "{\"inputs\": [\"2 4\\n\", \"3 4\\n\", \"915 72\\n\", \"967 4\\n\", \"997 997\\n\", \"998 999\\n\", \"1 991\\n\", \"757 210\\n\", \"1 865\\n\", \"995 2\\n\", \"862 330\\n\", \"1 999\\n\", \"953 874\\n\", \"2 348\\n\", \"998 998\\n\", \"1 1000\\n\", \"555 349\\n\", \"993 2\\n\", \"936 759\\n\", \"44 343\\n\", ... | Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and one day Sir Lancelot h... | 0 |
{"tests": "{\"inputs\": [\"2\\n6\\nLRRRLL\\n3\\nLRL\\n\", \"2\\n6\\nLLRRRL\\n3\\nLRL\\n\", \"2\\n6\\nLLRRRL\\n3\\nRLL\\n\", \"2\\n6\\nLRRRLL\\n3\\nRLL\\n\", \"2\\n6\\nLLRRRL\\n3\\nLLR\\n\", \"2\\n6\\nLRRRLL\\n3\\nLLR\\n\", \"2\\n6\\nLRLRRL\\n3\\nLRL\\n\", \"2\\n6\\nRRLRLL\\n3\\nRLL\\n\", \"2\\n6\\nRRRLLL\\n3\\nLLR\\n\"... | There are n + 1 cities, numbered from 0 to n. n roads connect these cities, the i-th road connects cities i - 1 and i (i ∈ [1, n]).
Each road has a direction. The directions are given by a string of n characters such that each character is either L or R. If the i-th character is L, it means that the i-th road initiall... | 0 |
{"tests": "{\"inputs\": [\"6 200000\\n0 1 2 3 4 5\\n\", \"3 2\\n0 2 1\\n\", \"5 1\\n0 1 2 3 4\\n\", \"7 6\\n3 2 4 1 0 5 6\\n\", \"1 69258\\n0\\n\", \"1 195078\\n0\\n\", \"2 132707\\n1 0\\n\", \"1 1\\n0\\n\", \"7 129714\\n5 6 0 2 1 4 3\\n\", \"4 199473\\n1 3 2 0\\n\", \"73 95\\n4 53 37 9 45 54 16 34 12 10 13 24 2 36 33 ... | Once upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array.
More formally, given a suffix array of length n and having an alphabet size k, count the number of strings that produce such a suffix array.
Let s be a string of length n. Then the i-th suffix of s is the subst... | 0 |
{"tests": "{\"inputs\": [\"4\\nabc\\nbCb\\ncb1\\nb13\\n\", \"7\\naaa\\naaa\\naaa\\naaa\\naaa\\naaa\\naaa\\n\", \"5\\naca\\naba\\naba\\ncab\\nbac\\n\", \"1\\nabc\\n\", \"5\\n123\\n234\\n345\\n456\\n567\\n\", \"8\\nzHW\\ncwx\\nxmo\\nWcw\\nox1\\nwxm\\nmox\\nHWc\\n\", \"2\\nbba\\nabb\\n\", \"99\\naaJ\\nJx9\\naLL\\nrCx\\nll... | While dad was at work, a little girl Tanya decided to play with dad's password to his secret database. Dad's password is a string consisting of n + 2 characters. She has written all the possible n three-letter continuous substrings of the password on pieces of paper, one for each piece of paper, and threw the password ... | 0 |
{"tests": "{\"inputs\": [\"3 20 20\\n6 2\\n1 3\\n2 6\\n\", \"4 1 1\\n2 3\\n3 2\\n2 3\\n3 2\\n\", \"10 18 25\\n4 8\\n16 27\\n16 13\\n1 26\\n8 13\\n2 14\\n24 8\\n4 29\\n3 19\\n19 20\\n\", \"2 2 4\\n2 4\\n5 2\\n\", \"2 4 1\\n2 4\\n5 2\\n\", \"10 468662 93838\\n589910 727627\\n279516 867207\\n470524 533177\\n467834 784167\... | Mikhail the Freelancer dreams of two things: to become a cool programmer and to buy a flat in Moscow. To become a cool programmer, he needs at least p experience points, and a desired flat in Moscow costs q dollars. Mikhail is determined to follow his dreams and registered at a freelance site.
He has suggestions to wo... | 0 |
{"tests": "{\"inputs\": [\"5 6 3\\n5 5 5 5 5\\n\", \"5 6 3\\n1 2 1 1 1\\n\", \"5 6 3\\n5 4 3 2 1\\n\", \"4 1000000000 1\\n1000000000 1000000000 1000000000 1000000000\\n\", \"25 1000000000 1\\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000... | Vanya smashes potato in a vertical food processor. At each moment of time the height of the potato in the processor doesn't exceed h and the processor smashes k centimeters of potato each second. If there are less than k centimeters remaining, than during this second processor smashes all the remaining potato.
Vanya h... | 0 |
{"tests": "{\"inputs\": [\"3 2 7\\n5 4 2\\n\", \"5 3 1\\n5 4 4 5 5\\n\", \"5 3 1\\n5 4 3 5 2\\n\", \"5 3 1\\n5 4 3 5 5\\n\", \"100 21063 1\\n-2 -1 -1 -2 -1 -2 -1 0 0 -2 0 0 0 0 0 0 0 -1 -1 -2 2 2 0 2 2 2 2 0 1 1 2 1 2 1 0 1 2 2 0 2 0 2 1 1 2 1 0 1 1 0 1 0 0 0 0 0 0 2 1 0 2 2 0 2 0 1 1 2 1 2 2 1 1 1 1 1 0 2 2 2 2 2 2 0 ... | Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally, by applying single operation Maxim chooses integer i (1 ≤ i ≤ n) and replaces the i-th element of ... | 0 |
{"tests": "{\"inputs\": [\"3\\n123\\n4\\n1232\\n\\nSAMPLE\", \"10\\n969984598611528864415444996937557846331114612465421716422683572525567624244172721863154692447523986169821727438229944262851812796446955469445844493822941855374951479662771177348973949287611563314364779476542533687189474742358654947212144149565282478921... | Alice decides to challenge Bob to a problem. She gives him a number.
Bob can rearrange the digits of this number by applying pair-wise swaps between any 2 digits in the number as many times as he wants. Now Alice asks him to write down all the distinct numbers that he can form and sort them. Of these she wants him to... | 0.75 |
{"tests": "{\"inputs\": [\"2\\n1 1 10\\n3\\n2 1 10\\n2 3\\n\\nSAMPLE\", \"10\\n1 1 1000000000000000000\\n3\\n1 1000000000000000000 1000000000000000000\\n3\\n10 1 1000000000000000000\\n3 2 7 5 13 11 19 17 29 23\\n5 42 18509\\n97 67 13 31 83\\n5 26501 45670\\n89 61 11 83 53\\n3 11479 40837\\n83 41 11\\n1 24465 30170\\n37... | This problem of Oz is very straight forward. You are given N distinct prime integers i.e p1, p2,..., pN and an interval [L,R]. Calculate number of integers in this interval that are divisible by at least one of the given primes.
Input :
First line of input contain an integer T — the number of test cases. T tests foll... | 0.5 |
{"tests": "{\"inputs\": [\"2\\n2\\n2 4\\n3\\n2 4 8\\n\\nSAMPLE\", \"2\\n2\\n2 4\\n3\\n4 4 8\\n\\nSAMPLE\", \"2\\n2\\n2 2\\n3\\n4 4 8\\n\\nSAMPLE\", \"2\\n2\\n2 4\\n3\\n2 4 10\\n\\nSAMPLE\", \"2\\n2\\n2 4\\n3\\n1 4 8\\n\\nSAMPLE\", \"2\\n2\\n2 2\\n3\\n5 4 8\\n\\nSAMPLE\", \"2\\n2\\n2 4\\n0\\n2 4 10\\n\\nSAMPLE\", \"2\\n... | You will be given a set of distinct numbers. Your task is to find that even length subset which will give you a maximum value of P % (10^9 + 7). This value of P for a subset of length N is defined as below :
P = (product of N/2 maximum values) / (product of N/2 minimum values)
Now suppose we have a subset S... | 0.25 |
{"tests": "{\"inputs\": [\"3\\nmini 3\\nrini 5\\nmini 2\\n\\nSAMPLE\", \"10\\nmahi 3\\nmahi 2\\nvicky 5\\nankit 5\\npooja 4\\nramesh 4\\nankita 2\\nmanisha 3\\nmanisha 3\\nkejal 5\", \"15\\nmahi 3\\nmahi 2\\nvicky 5\\nankit 5\\npooja 4\\nramesh 4\\nankita 2\\nmanisha 3\\nmanisha 3\\nkejal 5\\ndarshit 2\\nrahul 4\\nmahi... | Campus Ambassador has organized a Coding Contest in his college. Contest has multiple rounds, in each round a participant may gain or lose few points. At the end, there is only one participant with the maximum points. In the course of the contest, the number of points is written in the line as
"name points", where nam... | 0 |
{"tests": "{\"inputs\": [\"3\\n(((\\n)\\n)\", \"2\\n)\\n(()\", \"4\\n((()))\\n((((((\\n))))))\\n()()()\", \"2\\n)(\\n()\", \"3\\n()(\\n)\\n)\", \"2\\n)\\n()(\", \"4\\n((()))\\n((((()\\n))))))\\n()()()\", \"2\\n)(\\n)(\", \"3\\n()(\\n)\\n(\", \"2\\n((\\n)(\", \"3\\n())\\n)\\n(\", \"2\\n((\\n()\", \"3\\n(((\\n)\\n(\", \"... | A bracket sequence is a string that is one of the following:
1. An empty string;
2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ;
3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B /
Given are N strings S_i. Can a bracket sequence be forme... | 0 |
{"tests": "{\"inputs\": [\"F F\", \"A B\", \"E C\", \"E F\", \"A A\", \"E B\", \"D F\", \"A C\", \"E A\", \"E E\", \"A D\", \"D B\", \"F E\", \"A E\", \"D C\", \"F D\", \"A F\", \"E D\", \"F C\", \"B E\", \"G E\", \"G D\", \"C E\", \"H E\", \"D D\", \"C D\", \"H D\", \"F B\", \"C C\", \"I E\", \"G B\", \"H F\", \"I D\"... | In programming, hexadecimal notation is often used.
In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively.
In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`,... | 0.125 |
{"tests": "{\"inputs\": [\"6 2 3\\n1 3\\n5 3\\n3 5\\n8 4\\n4 7\\n2 5\", \"5 1 2\\n1 1\\n4 3\\n6 1\\n5 5\\n4 8\", \"8 1 2\\n1 5\\n4 3\\n8 2\\n4 7\\n8 8\\n3 3\\n6 6\\n4 8\", \"6 2 3\\n1 3\\n5 3\\n3 5\\n8 4\\n4 10\\n2 5\", \"5 1 2\\n1 1\\n4 1\\n6 1\\n5 5\\n4 8\", \"8 1 2\\n1 5\\n4 3\\n8 2\\n4 7\\n7 8\\n3 3\\n6 6\\n4 8\", ... | There are N pinholes on the xy-plane. The i-th pinhole is located at (x_i,y_i).
We will denote the Manhattan distance between the i-th and j-th pinholes as d(i,j)(=|x_i-x_j|+|y_i-y_j|).
You have a peculiar pair of compasses, called Manhattan Compass. This instrument always points at two of the pinholes. The two legs ... | 0 |
{"tests": "{\"inputs\": [\"10 10\\n9\\n13\\n18\\n8\\n10\\n10\\n9\\n19\\n22\\n27\", \"5 3\\n6\\n4\\n11\", \"10 10\\n9\\n13\\n18\\n8\\n10\\n10\\n9\\n19\\n33\\n27\", \"10 10\\n9\\n13\\n18\\n8\\n10\\n1\\n9\\n19\\n33\\n27\", \"10 8\\n9\\n13\\n18\\n8\\n10\\n1\\n9\\n19\\n33\\n27\", \"10 10\\n9\\n13\\n18\\n7\\n10\\n10\\n9\\n19... | Snuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i. Snuke performs the following Q operations on this sequence. The i-th operation, described by a parameter q_i, is as follows:
* Take the first q_i elements from the sequence obtained by concaten... | 0 |
{"tests": "{\"inputs\": [\"5\\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\\n10 10\\n15 15\\n40 60\\n2 3\\n130 80\\n0\", \"5\\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\\n10 10\\n15 15\\n40 60\\n1 3\\n130 80\\n0\", \"5\\n<main>10,10,190,1... | Advanced Creative Mobile (ACM) has decided to develop a GUI application to be installed in a new portable computer.
As shown in the figure below, the GUI has a nested structure in which it has one main panel, several panels are arranged on it, and some panels are arranged on top of those panels. .. All panels are rect... | 0 |
{"tests": "{\"inputs\": [\"4\\n0 0 x\\n2 0 x\\n0 1 x\\n2 1 x\\n4\\n1 0 x\\n0 1 x\\n2 1 x\\n1 2 x\\n4\\n0 0 x\\n2 0 y\\n0 1 y\\n1 2 x\\n0\", \"4\\n0 0 x\\n2 0 x\\n0 1 x\\n2 1 x\\n4\\n1 0 x\\n0 1 x\\n2 1 x\\n1 2 x\\n4\\n0 0 x\\n2 0 y\\n1 1 y\\n1 2 x\\n0\", \"4\\n0 0 x\\n2 0 x\\n0 1 x\\n2 1 x\\n4\\n1 0 w\\n0 1 x\\n2 1 x\\... | The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan.
In the ryokan, people sleep in Japanese-style beds called futons. They all have put their futo... | 0 |
{"tests": "{\"inputs\": [\"8\\n0\\nBB\\n0\\nBG\\n0\\nBBGG\\n1\\nBGG\\n1\\nBGGB\\n1\\nBBBGG\\n2\\nBBGG\\n2\\nBGB\", \"8\\n1\\nBB\\n0\\nBG\\n0\\nBBGG\\n1\\nBGG\\n1\\nBGGB\\n1\\nBBBGG\\n2\\nBBGG\\n2\\nBGB\", \"8\\n1\\nBB\\n0\\nBG\\n0\\nBBGG\\n1\\nGBG\\n1\\nBGGB\\n1\\nBBBGG\\n2\\nBBGG\\n2\\nBGB\", \"8\\n0\\nBB\\n0\\nBG\\n0... | Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B' and 'G', where 'B' represents a boy and 'G' represents a girl.
De... | 0.75 |
{"tests": "{\"inputs\": [\"4\\n \\nYES\\n \\nNO\\n \\nYES\\n \\nYES\\n \\n\", \"10\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n..........\\n\", \"5\\n..#..\\n.#...\\n.....\\n#..#.\\n#....\\n\", \"10\\n...#.#.#..\\n....##..#.\\n###..#..#.\\n##...... | This is an interactive problem.
Bob lives in a square grid of size n × n, with rows numbered 1 through n from top to bottom, and columns numbered 1 through n from left to right. Every cell is either allowed or blocked, but you don't know the exact description of the grid. You are given only an integer n.
Bob can move... | 0 |
{"tests": "{\"inputs\": [\"4\\nc=aa#bb\\nd12=c\\nres=c^d12\\ntmp=aa$c\\n\", \"2\\nmax=aaaa$bbbb\\nmin=bbbb^aaaa\\n\", \"9\\nc111=a&b\\nd=b^a\\ne=c111#d\\nd=d\\nf=f\\nf=c111$d\\ng=e$f\\nh=e#f\\nres=g^h\\n\", \"3\\na=res\\nres=x^y\\nres=a\\n\", \"1\\nres=res\\n\", \"4\\nc=a\\na=b\\nb=c\\nres=a&b\\n\", \"5\\nres=a\\nb=c&d... | Let's analyze a program written on some strange programming language. The variables in this language have names consisting of 1 to 4 characters, and each character is a lowercase or an uppercase Latin letter, or a digit. There is an extra constraint that the first character should not be a digit.
There are four types ... | 0 |
{"tests": "{\"inputs\": [\"4 4\\n....\\n#.#.\\n....\\n.#..\\n\", \"2 2\\n..\\n..\\n\", \"3 4\\n....\\n.##.\\n....\\n\", \"6 3\\n.##\\n###\\n.##\\n.##\\n#.#\\n#..\\n\", \"20 1\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n.\\n\", \"3 6\\n.#####\\n######\\n#####.\\n\", \"3 6\\n.....#\\n...... | All of us love treasures, right? That's why young Vasya is heading for a Treasure Island.
Treasure Island may be represented as a rectangular table n × m which is surrounded by the ocean. Let us number rows of the field with consecutive integers from 1 to n from top to bottom and columns with consecutive integers from... | 0.125 |
{"tests": "{\"inputs\": [\"1\\n1\\n\", \"3\\n4 8 5\\n\", \"5\\n3 10 2 1 5\\n\", \"4\\n0 5 15 10\\n\", \"3\\n0 0 17\\n\", \"15\\n1 1 1 0 0 0 1 1 1 0 0 0 1 1 1\\n\", \"11\\n0 3 3 5 5 5 4 3 6 4 1\\n\", \"1\\n2103\\n\", \"3\\n0 0 1\\n\", \"15\\n17 7 1 8 2 2 0 18 0 12 11 0 12 12 5\\n\", \"16\\n12 0 9 14 12 26 21 24 3 13 7 4... | This is the harder version of the problem. In this version, 1 ≤ n ≤ 10^6 and 0 ≤ a_i ≤ 10^6. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems
Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend... | 0 |
{"tests": "{\"inputs\": [\"5\\n3 3\\n5 15\\n4 13\\n6 8\\n4 2\\n\", \"5\\n3 3\\n5 25\\n4 13\\n6 8\\n4 2\\n\", \"5\\n3 3\\n5 25\\n4 13\\n6 8\\n4 1\\n\", \"5\\n3 6\\n5 25\\n4 13\\n6 8\\n4 1\\n\", \"5\\n3 3\\n5 15\\n4 18\\n6 8\\n4 2\\n\", \"5\\n2 3\\n5 25\\n4 13\\n6 8\\n4 2\\n\", \"5\\n3 2\\n5 25\\n4 13\\n6 8\\n4 1\\n\", \... | Yeah, we failed to make up a New Year legend for this problem.
A permutation of length n is an array of n integers such that every integer from 1 to n appears in it exactly once.
An element y of permutation p is reachable from element x if x = y, or p_x = y, or p_{p_x} = y, and so on.
The decomposition of a permut... | 0 |
{"tests": "{\"inputs\": [\"15 5\\n0 3 7 14 15\\n11 11\\n\", \"13 4\\n0 3 7 13\\n9 9\\n\", \"15 5\\n15 3 7 0 14\\n11 11\\n\", \"4 5\\n0 3 1 2 4\\n1 1\\n\", \"4 5\\n0 3 1 2 4\\n2 1\\n\", \"30 8\\n0 1 9 10 23 24 26 30\\n40 7\\n\", \"15 5\\n15 14 7 3 0\\n11 11\\n\", \"100 5\\n3 100 7 13 0\\n99 5\\n\", \"4 3\\n0 4 2\\n2 2\\... | If the girl doesn't go to Denis, then Denis will go to the girl. Using this rule, the young man left home, bought flowers and went to Nastya.
On the way from Denis's house to the girl's house is a road of n lines. This road can't be always crossed in one green light. Foreseeing this, the good mayor decided to place s... | 0 |
{"tests": "{\"inputs\": [\"5\\n10000 0 1\\n2000 1 0\\n300 0 1\\n40 0 0\\n1 1 0\\n1 2\\n2 3\\n2 4\\n1 5\\n\", \"5\\n1 0 1\\n20 1 0\\n300 0 1\\n4000 0 0\\n50000 1 0\\n1 2\\n2 3\\n2 4\\n1 5\\n\", \"2\\n109 0 1\\n205 0 1\\n1 2\\n\", \"3\\n57 1 0\\n6 0 1\\n76 1 1\\n1 3\\n3 2\\n\", \"9\\n71 1 1\\n59 0 0\\n87 0 0\\n9 0 1\\n39... | Ashish has a tree consisting of n nodes numbered 1 to n rooted at node 1. The i-th node in the tree has a cost a_i, and binary digit b_i is written in it. He wants to have binary digit c_i written in the i-th node in the end.
To achieve this, he can perform the following operation any number of times:
* Select any... | 0 |
{"tests": "{\"inputs\": [\"5\\n4 -2 3 -9 2\\n\", \"9\\n-1 1 -1 1 -1 1 1 -1 -1\\n\", \"8\\n16 -5 -11 -15 10 5 4 -4\\n\", \"4\\n1 -5 3 2\\n\", \"3\\n1 2 -3\\n\", \"8\\n4 -3 -1 -2 6 -6 6 -6\\n\", \"15\\n1 -1 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -100000... | Kolya got an integer array a_1, a_2, ..., a_n. The array can contain both positive and negative integers, but Kolya doesn't like 0, so the array doesn't contain any zeros.
Kolya doesn't like that the sum of some subsegments of his array can be 0. The subsegment is some consecutive segment of elements of the array.
Y... | 0 |
{"tests": "{\"inputs\": [\"code\\nforces\\n\", \"aaa\\nbb\\n\", \"aaaaa\\naaa\\n\", \"justamassivetesttocheck\\nhowwellyouhandlemodulooperations\\n\", \"aaaccabcbc\\nabcbabbbaa\\n\", \"nclmevhtio\\nefnepwqphvwxiyguotuk\\n\", \"zkccmpbrfadhkukfvkci\\nfopwpsbztb\\n\", \"abbbaabbba\\nbaaaababbb\\n\", \"aaaccabcbc\\nacbbab... | You are given two strings x and y, both consist only of lowercase Latin letters. Let |s| be the length of string s.
Let's call a sequence a a merging sequence if it consists of exactly |x| zeros and exactly |y| ones in some order.
A merge z is produced from a sequence a by the following rules:
* if a_i=0, then re... | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.