Search is not available for this dataset
problem_id
stringlengths
32
32
name
stringlengths
2
112
problem
stringlengths
200
14k
test_cases
stringlengths
33
79.2M
difficulty
stringclasses
33 values
language
listlengths
1
1
source
stringclasses
14 values
num_solutions
int64
2
1.9M
starter_code
stringlengths
0
1.47k
subset
stringclasses
3 values
591ed0b026ba4de1b7775863a47e033e
none
You are given an array *a* with *n* distinct integers. Construct an array *b* by permuting *a* such that for every non-empty subset of indices *S*<==<={*x*1,<=*x*2,<=...,<=*x**k*} (1<=≤<=*x**i*<=≤<=*n*, 0<=&lt;<=*k*<=&lt;<=*n*) the sums of elements on that positions in *a* and *b* are different, i. e. The first line co...
{"inputs": ["2\n1 2", "4\n1000 100 10 1", "5\n1 3 4 5 2", "1\n10000000", "4\n1 5 8 4", "3\n1 3 2", "4\n3 1 2 4", "12\n7 1 62 12 3 5 8 9 10 22 23 0", "17\n1 3 2 5 4 6 7 8 10 9 13 11 12 14 15 16 18", "22\n1 3 5 7 22 2 4 6 8 9 10 11 12 13 15 14 17 18 16 20 19 23", "22\n17 6 1 22 9 23 38 40 10 20 29 11 12 39 3 32 26 4 13 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
29
codeforces
5936c23389b0b6633ac3994de8d5c7ce
Polo the Penguin and Lucky Numbers
Everybody knows that lucky numbers are positive integers that contain only lucky digits 4 and 7 in their decimal representation. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Polo the Penguin have two positive integers *l* and *r* (*l*<=&lt;<=*r*), both of them are lucky numbers. Moreover, their le...
{"inputs": ["4\n7", "474\n777", "44\n77", "444\n777", "444\n477", "444\n744", "47\n74", "447\n774", "4444\n7777", "44444\n77777", "444444\n777777", "44744\n74747", "47774\n74777", "47\n77", "474\n747", "7447\n7744", "74744\n74747", "7447777\n7774477", "747447\n777744", "4477447744\n4477744774", "77474444777444447747\n7...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
594a2bc844be518fed9dfa9b8c429849
Buses
Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly *n*<=+<=1 bus stops. All of them are numbered with integers from 0 to *n* in the order in which ...
{"inputs": ["2 2\n0 1\n1 2", "3 2\n0 1\n1 2", "5 5\n0 1\n0 2\n0 3\n0 4\n0 5", "3 3\n1 2\n2 3\n1 3", "10 10\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10", "6 6\n3 4\n2 3\n3 5\n0 1\n1 2\n3 6", "7 7\n0 1\n1 3\n2 3\n4 6\n5 7\n4 5\n5 7", "1000000000 0", "8 8\n0 1\n4 5\n7 8\n3 4\n2 3\n6 7\n5 6\n1 2", "6 1\n0 6", "6 4\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
596bbbc9d1dd8f16b95163e9dd40dfc4
Toda 2
A group of *n* friends enjoys playing popular video game Toda 2. There is a rating system describing skill level of each player, initially the rating of the *i*-th friend is *r**i*. The friends decided to take part in the championship as a team. But they should have equal ratings to be allowed to compose a single team...
{"inputs": ["5\n4 5 1 7 4", "2\n1 2", "3\n1 1 1", "10\n6 8 7 6 8 7 6 7 8 7", "5\n4 4 4 7 3", "5\n4 7 5 2 2", "6\n5 4 2 4 3 2", "7\n7 8 2 7 10 11 5", "10\n2 3 3 3 2 6 2 5 3 5", "90\n45 69 0 10 8 58 25 66 22 2 4 62 64 90 82 83 67 32 56 80 64 51 78 21 2 90 65 55 11 51 1 43 6 32 25 46 22 46 26 6 43 14 50 40 74 52 44 60 76 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
5981eb223dfdc830bf9b127597cd72c8
Chocolate
Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces. You are asked to calculate the number of ways he can...
{"inputs": ["3\n0 1 0", "5\n1 0 1 0 1", "10\n0 0 1 0 0 0 1 1 0 1", "20\n0 0 0 0 1 1 1 0 1 0 0 1 0 1 1 0 1 1 1 0", "50\n0 1 1 1 1 1 1 0 1 1 0 1 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0 1 1 0 0 0 1 0 0 0 0 1 0 1 1 0 0 0 0 0", "99\n0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 1 1 1 1 1 1 0 1 0 1 1 0 1 1 1 0 0 0 0 0 1 1 0 1 0 0 0 1 0 1 1 0 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
59a8a4fb362b2db5b70755c3f8abc200
Kayaking
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·*n* people in the group (including Vadim), and they have exact...
{"inputs": ["2\n1 2 3 4", "4\n1 3 4 6 3 4 100 200", "3\n305 139 205 406 530 206", "3\n610 750 778 6 361 407", "5\n97 166 126 164 154 98 221 7 51 47", "50\n1 1 2 2 1 3 2 2 1 1 1 1 2 3 3 1 2 1 3 3 2 1 2 3 1 1 2 1 3 1 3 1 3 3 3 1 1 1 3 3 2 2 2 2 3 2 2 2 2 3 1 3 3 3 3 1 3 3 1 3 3 3 3 2 3 1 3 3 1 1 1 3 1 2 2 2 1 1 1 3 1 2 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
169
codeforces
5a03252e08654084ead3b38a23622e60
Square
There is a square painted on a piece of paper, the square's side equals *n* meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to the right, then downwa...
{"inputs": ["3\n4 8 100", "8\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 13", "3\n13 17 21"], "outputs": ["17\n33\n401", "4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n4000000001\n27", "27\n35\n43"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
51
codeforces
5a234bc7c81e13b4b00b7ffd6934843d
Fruits
The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of *m* fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includes it into the list several times. When he came to the fruit stall of A...
{"inputs": ["5 3\n4 2 1 10 5\napple\norange\nmango", "6 5\n3 5 1 6 8 1\npeach\ngrapefruit\nbanana\norange\norange", "2 2\n91 82\neiiofpfpmemlakcystpun\nmcnzeiiofpfpmemlakcystpunfl", "1 4\n1\nu\nu\nu\nu", "3 3\n4 2 3\nwivujdxzjm\nawagljmtc\nwivujdxzjm", "3 4\n10 10 10\nodchpcsdhldqnkbhwtwnx\nldqnkbhwtwnxk\nodchpcsdhldqn...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
114
codeforces
5a24aa8483eed58623cb80e41be4360e
Three Parts of the Array
You are given an array $d_1, d_2, \dots, d_n$ consisting of $n$ integer numbers. Your task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and each of the parts forms a consecutive contiguous subsegment (possib...
{"inputs": ["5\n1 3 1 1 4", "5\n1 3 2 1 4", "3\n4 1 2", "1\n1000000000", "2\n1 1", "5\n1 3 5 4 5"], "outputs": ["5", "4", "0", "0", "1", "9"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
213
codeforces
5a338e4f6ff782ab607304e21f0f2372
DNA Evolution
Everyone knows that DNA strands consist of nucleotides. There are four types of nucleotides: "A", "T", "G", "C". A DNA strand is a sequence of nucleotides. Scientists decided to track evolution of a rare species, which DNA strand was string *s* initially. Evolution of the species is described as a sequence of changes...
{"inputs": ["ATGCATGC\n4\n2 1 8 ATGC\n2 2 6 TTT\n1 4 T\n2 2 6 TA", "GAGTTGTTAA\n6\n2 3 4 TATGGTG\n1 1 T\n1 6 G\n2 5 9 AGTAATA\n1 10 G\n2 2 6 TTGT", "TCAATCGGGCGGACTAACCC\n20\n2 4 17 CTCGGATGTT\n1 4 T\n1 1 C\n2 15 18 CA\n2 13 20 GGCACCCA\n1 20 T\n2 3 11 TCGGAG\n1 4 C\n2 13 18 A\n1 14 C\n1 18 T\n1 5 T\n1 8 T\n1 6 A\n2 3 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
5a3e001f740f7d6ec5e22ec35d23b8a5
none
It is nighttime and Joe the Elusive got into the country's main bank's safe. The safe has *n* cells positioned in a row, each of them contains some amount of diamonds. Let's make the problem more comfortable to work with and mark the cells with positive numbers from 1 to *n* from the left to the right. Unfortunately, ...
{"inputs": ["2 3 1\n2 3", "3 2 2\n4 1 3", "5 10 10\n7 0 7 0 7", "6 10 4\n1 2 3 4 5 6", "7 5 2\n1 2 3 4 5 6 7", "16 100 100\n30 89 12 84 62 24 10 59 98 21 13 69 65 12 54 32", "99 999 999\n9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
5a3e4daa29dd1209216eaed32f5c3fa4
Pupils Redistribution
In Berland each high school student is characterized by academic performance — integer value between 1 and 5. In high school 0xFF there are two groups of pupils: the group *A* and the group *B*. Each group consists of exactly *n* students. An academic performance of each student is known — integer value between 1 and ...
{"inputs": ["4\n5 4 4 4\n5 5 4 5", "6\n1 1 1 1 1 1\n5 5 5 5 5 5", "1\n5\n3", "9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1", "1\n1\n2", "1\n1\n1", "8\n1 1 2 2 3 3 4 4\n4 4 5 5 1 1 1 1", "10\n1 1 1 1 1 1 1 1 1 1\n2 2 2 2 2 2 2 2 2 2", "100\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
168
codeforces
5a43cf8bfbc24f17efa03fa099792295
Anton and Polyhedrons
Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: - Tetrahedron. Tetrahedron has 4 triangular faces. - Cube. Cube has 6 square faces. - Octahedron. Octahedron has 8 triangular faces. - Dodecahedron. Dodecahedron has 12 pentagonal faces. - Icosahed...
{"inputs": ["4\nIcosahedron\nCube\nTetrahedron\nDodecahedron", "3\nDodecahedron\nOctahedron\nOctahedron", "25\nIcosahedron\nOctahedron\nTetrahedron\nDodecahedron\nCube\nIcosahedron\nOctahedron\nCube\nTetrahedron\nIcosahedron\nIcosahedron\nTetrahedron\nOctahedron\nDodecahedron\nIcosahedron\nOctahedron\nIcosahedron\nTetr...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
902
codeforces
5a4bf7ceadb1d94314cfa46d3536750f
New Year Snowmen
As meticulous Gerald sets the table and caring Alexander sends the postcards, Sergey makes snowmen. Each showman should consist of three snowballs: a big one, a medium one and a small one. Sergey's twins help him: they've already made *n* snowballs with radii equal to *r*1, *r*2, ..., *r**n*. To make a snowman, one nee...
{"inputs": ["7\n1 2 3 4 5 6 7", "3\n2 2 3", "1\n255317", "6\n1 1 2 2 3 3", "6\n1 2 2 2 3 3", "6\n1 1 2 2 2 2", "6\n1 2 2 3 3 3", "6\n1 1 1 2 2 3", "14\n1 1 2 2 3 3 4 4 4 4 5 5 5 5", "20\n8 2 9 1 1 4 7 3 8 3 9 4 5 1 9 7 1 6 8 8", "20\n1 3 2 2 1 2 3 4 2 4 4 3 1 4 2 1 3 1 4 4", "20\n4 2 2 2 5 2 4 2 2 3 5 2 1 3 1 2 2 5 4 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
5a520f7f2910b43b1571de9435761b7a
Xenia and Spies
Xenia the vigorous detective faced *n* (*n*<=≥<=2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to *n* from left to right. Spy *s* has an important note. He has to pass the note to spy *f*. Xenia interrogates the spies in several steps. During one step the spy keeping the important note c...
{"inputs": ["3 5 1 3\n1 1 2\n2 2 3\n3 3 3\n4 1 1\n10 1 3", "2 3 2 1\n1 1 2\n2 1 2\n4 1 2", "5 11 1 5\n1 1 5\n2 2 2\n3 1 1\n4 3 3\n5 3 3\n6 1 1\n7 4 4\n8 4 5\n10 1 3\n11 5 5\n13 1 5", "4 6 4 2\n2 2 2\n3 3 3\n4 1 1\n10 1 4\n11 2 3\n12 2 4", "7 5 7 6\n1 4 5\n2 7 7\n3 6 6\n4 3 4\n5 1 3", "4 4 3 4\n1 2 4\n2 1 2\n3 3 4\n4 2 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
5a587b91d3cc6bf57740e0b2e69de3a2
Factory
One industrial factory is reforming working plan. The director suggested to set a mythical detail production norm. If at the beginning of the day there were *x* details in the factory storage, then by the end of the day the factory has to produce (remainder after dividing *x* by *m*) more details. Unfortunately, no cu...
{"inputs": ["1 5", "3 6", "1 8", "2 3", "3 24", "1 1", "100000 100000", "1 99989", "512 2", "100 24", "1 100000", "100000 1", "3 99929", "99961 99971", "1 65536", "4 65536", "3 65536", "32768 65536", "65535 65536", "1 65535", "98812 100000", "10 5", "6 8"], "outputs": ["No", "Yes", "Yes", "No", "Yes", "Yes", "Yes", "No...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
143
codeforces
5a5e1e98fe1734fbbdcb54b182736712
Almost Arithmetical Progression
Gena loves sequences of numbers. Recently, he has discovered a new type of sequences which he called an almost arithmetical progression. A sequence is an almost arithmetical progression, if its elements can be represented as: - *a*1<==<=*p*, where *p* is some integer; - *a**i*<==<=*a**i*<=-<=1<=+<=(<=-<=1)*i*<=+<=1·...
{"inputs": ["2\n3 5", "4\n10 20 10 30", "5\n4 4 3 5 1", "6\n2 3 2 2 1 3", "8\n2 2 5 3 4 3 3 2", "2\n468 335", "1\n170", "5\n479 359 963 465 706", "6\n282 828 962 492 996 943", "8\n437 392 605 903 154 293 383 422", "42\n68 35 1 70 25 79 59 63 65 6 46 82 28 62 92 96 43 28 37 92 5 3 54 93 83 22 17 19 96 48 27 72 39 70 13 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
5a69561084767484a896765b580a3e2c
The Eternal Immortality
Even if the world is full of counterfeits, I still regard it as wonderful. Pile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this. The phoenix has a rather long lifespan, and reincarnates itself once every *a*! years. Here *a*! deno...
{"inputs": ["2 4", "0 10", "107 109", "10 13", "998244355 998244359", "999999999000000000 1000000000000000000", "2 3", "3 15", "24 26", "14 60", "11 79", "1230 1232", "2633 2634", "535 536", "344319135 396746843", "696667767 696667767", "419530302 610096911", "238965115 821731161", "414626436 728903812", "274410639 293...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
275
codeforces
5a6cf8639416a46ab7eda2b3000d21e2
Simple Game
One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to *n*. Let's assume that Misha chose number *m*, and Andrew chose number *a*. Then, by using a random generator they choose a random integer *c* in the range between 1 and *n* (any integer from 1 to *n*...
{"inputs": ["3 1", "4 3", "5 5", "10 5", "20 13", "51 1", "100 50", "100 51", "100 49", "1000000000 1000000000", "1000000000 1", "1000000000 100000000", "1000000000 500000000", "1000000000 123124", "12412523 125123", "54645723 432423", "1 1", "262833325 131416663", "477667530 238833766", "692501734 346250868", "9073359...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
120
codeforces
5a88c52a8e48a0bb5db9c989b05f3b7c
Safe cracking
Right now you are to solve a very, very simple problem — to crack the safe. Four positive integers stand one by one on a circle protecting the safe. You know that to unlock this striking safe you have to make all four numbers equal to one. Operations are as follows: you may choose two adjacent numbers and increase both...
{"inputs": ["1 2 4 2", "3 3 1 1", "2 1 2 4", "5 5 1 1", "4 4 4 4", "1 1 1 2", "1 1 1 3", "1 2 1 2", "657276544 772661397 705084822 888450280", "414333101 226069413 997273309 495622139", "242246693 78731970 483090981 265550001", "688606352 535518276 574101164 397812691", "214168203 414790853 766098599 644798097", "28588...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
5aadac2815c9ae74cba7aae270fa2bab
Tavas and Nafas
Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas. His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words. He ate coffee mix without...
{"inputs": ["6", "99", "20", "10", "15", "27", "40", "63", "0", "1", "2", "8", "9", "11", "12", "13", "14", "16", "17", "18", "19", "21", "29", "30", "32", "38", "43", "47", "50", "54", "56", "60", "66", "70", "76", "80", "82", "90", "91", "95", "71", "46", "84", "22", "23", "24", "25", "26", "28", "31", "33", "34", "3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
95
codeforces
5aadd7c6ae2e239904112e924628ef9b
Swap Adjacent Elements
You have an array *a* consisting of *n* integers. Each integer from 1 to *n* appears exactly once in this array. For some indices *i* (1<=≤<=*i*<=≤<=*n*<=-<=1) it is possible to swap *i*-th element with (*i*<=+<=1)-th, for other indices it is not possible. You may perform any number of swapping operations any order. T...
{"inputs": ["6\n1 2 5 3 4 6\n01110", "6\n1 2 5 3 4 6\n01010", "6\n1 6 3 4 5 2\n01101", "6\n2 3 1 4 5 6\n01111", "4\n2 3 1 4\n011", "2\n2 1\n0", "5\n1 2 4 5 3\n0101", "5\n1 2 4 5 3\n0001", "5\n1 4 5 2 3\n0110", "5\n4 5 1 2 3\n0111", "3\n3 1 2\n10", "5\n2 3 4 5 1\n0011", "16\n3 4 14 16 11 7 13 9 10 8 6 5 15 12 1 2\n11111...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
85
codeforces
5ab9c601c9a94cdb1168ab643f4355bf
Lieges of Legendre
Kevin and Nicky Sun have invented a new game called Lieges of Legendre. In this game, two players take turns modifying the game state with Kevin moving first. Initially, the game is set up so that there are *n* piles of cows, with the *i*-th pile containing *a**i* cows. During each player's turn, that player calls upon...
{"inputs": ["2 1\n3 4", "1 2\n3", "4 5\n20 21 22 25", "5 1\n1 7 7 6 6", "7 1\n8 6 10 10 1 5 8", "10 1\n2 3 5 2 7 4 7 7 4 2", "10 1\n5 6 3 10 6 6 1 1 5 3", "6 1\n1 4 4 4 2 2", "10 2\n3 10 10 8 6 10 9 9 5 7", "6 2\n5 3 5 6 2 2", "9 2\n8 2 9 4 7 5 2 4 9", "9 2\n2 8 4 2 5 7 1 8 10", "7 2\n9 1 7 6 10 3 5", "2 2\n1 2", "2 2\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
5aba9714089213b40d5a9627e3af22e9
Replacing Digits
You are given an integer *a* that consists of *n* digits. You are also given a sequence of digits *s* of length *m*. The digit in position *j* (1<=≤<=*j*<=≤<=*m*) of sequence *s* means that you can choose an arbitrary position *i* (1<=≤<=*i*<=≤<=*n*) in *a* and replace the digit in the chosen position *i* with *s**j*. ...
{"inputs": ["1024\n010", "987\n1234567", "10\n1", "11\n1", "12\n2", "1\n0", "123456\n9999", "909090\n000111", "588\n24", "25206\n88", "9776247464\n8629", "3666566898\n3001", "3338860467\n5848", "9768757689\n1010", "6669490269\n6240849376", "1794210278\n50931901955213461294", "6997854871\n15113453341706470344", "8947769...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
61
codeforces
5abfc1559fdbd07702d539e4c4bf2ae9
Mahmoud and a Triangle
Mahmoud has *n* line segments, the *i*-th of them has length *a**i*. Ehab challenged him to use exactly 3 line segments to form a non-degenerate triangle. Mahmoud doesn't accept challenges unless he is sure he can win, so he asked you to tell him if he should accept the challenge. Given the lengths of the line segments...
{"inputs": ["5\n1 5 3 2 4", "3\n4 1 2", "30\n197 75 517 39724 7906061 1153471 3 15166 168284 3019844 272293 316 16 24548 42 118 5792 5 9373 1866366 4886214 24 2206 712886 104005 1363 836 64273 440585 3576", "30\n229017064 335281886 247217656 670601882 743442492 615491486 544941439 911270108 474843964 803323771 17711539...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
269
codeforces
5ae999481a4320688b1d6b02a240dada
Queue
There are *n* schoolchildren, boys and girls, lined up in the school canteen in front of the bun stall. The buns aren't ready yet and the line is undergoing some changes. Each second all boys that stand right in front of girls, simultaneously swap places with the girls (so that the girls could go closer to the beginni...
{"inputs": ["MFM", "MMFF", "FFMMM", "MMFMMFFFFM", "MFFFMMFMFMFMFFFMMMFFMMMMMMFMMFFMMMFMMFMFFFMMFMMMFFMMFFFFFMFMFFFMMMFFFMFMFMFMFFFMMMMFMMFMMFFMMMMMMFFM", "MFFMFMFFMM", "MFFFFFMFFM", "MMMFMFFFFF", "MMMMMFFMFMFMFMMFMMFFMMFMFFFFFFFMFFFMMMMMMFFMMMFMFMMFMFFMMFMMMFFFFFMMMMMFMMMMFMMMFFMFFMFFFMFFMFFMMFFM", "MMMMFMMMMMFFMMFMFMM...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
5af3996112509cc07f8add53fa6f0c12
Cookies
Fangy collects cookies. Once he decided to take a box and put cookies into it in some way. If we take a square *k*<=×<=*k* in size, divided into blocks 1<=×<=1 in size and paint there the main diagonal together with cells, which lie above it, then the painted area will be equal to the area occupied by one cookie *k* in...
{"inputs": ["3", "1", "2", "4", "6", "11", "14", "15", "7", "0", "1000", "657", "561", "823", "850", "298", "262", "910", "617", "857", "69", "589", "928", "696", "226"], "outputs": ["9", "1", "3", "27", "243", "59049", "594320", "782957", "729", "1", "691074", "874011", "842553", "858672", "557186", "999535", "946384"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
46
codeforces
5af75c396e8515ffc1c890d93db329c3
Shell Game
Today the «Z» city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent cups upside down in a row. Then he openly puts a small ball under one of the cups and starts to shuffle the cups around very quickly so ...
{"inputs": ["1\n1 2\n2 1\n2 1", "1\n2 1\n3 1\n1 3", "3\n3 1\n2 1\n1 2", "1\n1 3\n1 2\n2 3", "3\n3 2\n3 1\n3 1", "1\n2 1\n1 3\n1 3", "3\n3 1\n2 3\n3 2", "2\n1 3\n1 2\n2 1", "1\n1 3\n3 2\n1 2", "1\n1 3\n1 3\n2 3", "2\n1 2\n2 3\n2 1", "3\n1 3\n3 2\n2 1", "1\n1 2\n2 1\n2 3", "1\n2 3\n1 3\n1 2", "2\n3 1\n3 2\n2 3", "2\n1 3\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
99
codeforces
5b1f6ea3b80876a99fa3edeb8b62611e
none
As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional equation and needs your help. For two fixed integers *k* and *p*, w...
{"inputs": ["3 2", "5 4", "7 2", "7 6", "10007 25", "40037 4", "5 0", "5 3", "7 1", "13 5", "13 4", "5 2", "11 1", "11 10", "6907 2590", "3229 153", "727 282", "7621 6195", "4649 4648", "5527 1711", "1901 633", "463 408", "6871 5566", "4177 556", "65213 29960", "375103 52131", "990037 453792", "95531 94787", "498653 11...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
5b430d79388af1e2fbbc9587b9a391b7
Brain Network (medium)
Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of *n* brains and *m* brain connectors joining some pairs of brains together. It was observed that the intellectual abilities of a zombie depend mainly on the topology ...
{"inputs": ["2 1\n1 2", "3 2\n2 1\n3 2", "10 9\n5 1\n1 2\n9 3\n10 5\n6 3\n8 5\n2 7\n2 3\n9 4", "4 3\n1 2\n1 3\n1 4", "5 4\n1 2\n2 3\n3 4\n3 5"], "outputs": ["1", "2", "6", "2", "3"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
5b996c84a4e9b643847702897cd4376e
Shovel Sale
There are *n* shovels in Polycarp's shop. The *i*-th shovel costs *i* burles, that is, the first shovel costs 1 burle, the second shovel costs 2 burles, the third shovel costs 3 burles, and so on. Polycarps wants to sell shovels in pairs. Visitors are more likely to buy a pair of shovels if their total cost ends with ...
{"inputs": ["7", "14", "50", "999999999", "15", "3", "6500", "4", "13", "10", "499999", "6", "8", "9", "11", "12", "5", "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", "4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
15
codeforces
5bb0e40b287748d6afecc3d5be073136
Anya and Ghosts
Anya loves to watch horror movies. In the best traditions of horror, she will be visited by *m* ghosts tonight. Anya has lots of candles prepared for the visits, each candle can produce light for exactly *t* seconds. It takes the girl one second to light one candle. More formally, Anya can spend one second to light one...
{"inputs": ["1 8 3\n10", "2 10 1\n5 8", "1 1 3\n10", "21 79 1\n13 42 51 60 69 77 94 103 144 189 196 203 210 215 217 222 224 234 240 260 282", "125 92 2\n1 2 3 4 5 7 8 9 10 12 17 18 20 21 22 23 24 25 26 28 30 32 33 34 35 36 37 40 41 42 43 44 45 46 50 51 53 54 55 57 60 61 62 63 69 70 74 75 77 79 80 81 82 83 84 85 86 88 8...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
9
codeforces
5bb44940fe915dd1fa210408ac57c145
Yet Another Maxflow Problem
In this problem you will have to deal with a very special network. The network consists of two parts: part *A* and part *B*. Each part consists of *n* vertices; *i*-th vertex of part *A* is denoted as *A**i*, and *i*-th vertex of part *B* is denoted as *B**i*. For each index *i* (1<=≤<=*i*<=&lt;<=*n*) there is a dire...
{"inputs": ["4 3 2\n1 2\n3 4\n5 6\n2 2 7\n1 4 8\n4 3 9\n1 100\n2 100", "10 10 10\n291546518 199012865\n327731857 137263959\n145140225 631959974\n559674936 815057131\n677050070 949982094\n839693202 160045764\n967872826 489258292\n706535160 594950620\n230389718 274785590\n1 10 861488983\n7 10 994974516\n4 3 117635148\n6 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
5bea950a4b3692c0b55275b4bd4d1133
Conan and Agasa play a Card Game
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 *a**i* written on it. They take turns playing, starting with Conan. In each turn, the player chooses a card and removes it. Also, he remov...
{"inputs": ["3\n4 5 7", "2\n1 1", "10\n38282 53699 38282 38282 38282 38282 38282 38282 38282 38282", "10\n50165 50165 50165 50165 50165 50165 50165 50165 50165 50165", "10\n83176 83176 83176 23495 83176 8196 83176 23495 83176 83176", "10\n32093 36846 32093 32093 36846 36846 36846 36846 36846 36846", "3\n1 2 3", "4\n2 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
70
codeforces
5c05aa54bdafe322b5a3076e15032999
Ping-Pong (Easy Version)
In this problem at each moment you have a set of intervals. You can move from interval (*a*,<=*b*) from our set to interval (*c*,<=*d*) from our set if and only if *c*<=&lt;<=*a*<=&lt;<=*d* or *c*<=&lt;<=*b*<=&lt;<=*d*. Also there is a path from interval *I*1 from our set to interval *I*2 from our set if there is a seq...
{"inputs": ["5\n1 1 5\n1 5 11\n2 1 2\n1 2 9\n2 1 2", "10\n1 -311 -186\n1 -1070 -341\n1 -1506 -634\n1 688 1698\n2 2 4\n1 70 1908\n2 1 2\n2 2 4\n1 -1053 1327\n2 5 4", "10\n1 -1365 -865\n1 1244 1834\n2 1 2\n1 -1508 -752\n2 3 2\n2 2 1\n1 -779 595\n1 -1316 877\n2 2 1\n1 -698 1700", "20\n1 1208 1583\n1 -258 729\n1 -409 1201\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
43
codeforces
5c31552aa05de8e16664f4d645bf4d91
Longtail Hedgehog
This Christmas Santa gave Masha a magic picture and a pencil. The picture consists of *n* points connected by *m* segments (they might cross in any way, that doesn't matter). No two segments connect the same pair of points, and no segment connects the point to itself. Masha wants to color some segments in order paint a...
{"inputs": ["8 6\n4 5\n3 5\n2 5\n1 2\n2 8\n6 7", "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4", "5 7\n1 3\n2 4\n4 5\n5 3\n2 1\n1 4\n3 2", "5 9\n1 3\n2 4\n4 5\n5 3\n2 1\n1 4\n3 2\n1 5\n2 5", "10 10\n6 3\n2 9\n9 4\n4 5\n10 3\n8 3\n10 5\n7 6\n1 4\n6 8", "100 50\n66 3\n92 79\n9 44\n84 45\n30 63\n30 20\n33 86\n8 83\n40 75\n7 36\n91 4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
5c4478806ba085b0df028f9fe6a6e89b
Harry Potter and the Sorting Hat
As you know, Hogwarts has four houses: Gryffindor, Hufflepuff, Ravenclaw and Slytherin. The sorting of the first-years into houses is done by the Sorting Hat. The pupils are called one by one in the alphabetical order, each of them should put a hat on his head and, after some thought, the hat solemnly announces the nam...
{"inputs": ["11\nG????SS???H", "2\nH?", "1\n?", "1\nG", "3\nGHS", "4\n????", "5\nGH??S", "5\nH?S?G", "7\n???????", "10\n??HS??HSGR", "55\n??RS?HGH?S?GS?HRGHRHRR?G?GSGSSHGS?HRSHRSR?HGHGRH?GGGHHH", "108\n??RS?HGH?S?GS?HRGHRHRR?G?GSGSSHGS?HRSHRSR?HGHGRH??????????????RS?HGH?S?GS?HRGHRHRR?G?GSGSSHGS?HRSHRSR?HGHGRH", "20\n?H...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
5c467ca04386f97d028df6a21043acfd
Mischievous Mess Makers
It is a balmy spring afternoon, and Farmer John's *n* cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through *n*, are arranged so that the *i*-th cow occupies the *i*-th stall from the left. However, Elsie, after realizing that she will forever live in the shadows beyond Bessie's limeligh...
{"inputs": ["5 2", "1 10", "100000 2", "1 1", "8 3", "7 1", "100000 40000", "1 1000", "100 45", "9 2", "456 78", "100000 50000", "100000 50001", "100000 50002", "100000 50003", "100000 49998", "100000 49997", "99999 49998", "99999 49997", "99999 49996", "99999 50000", "99999 50001", "99999 50002", "30062 9", "13486 3",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
87
codeforces
5c49c54a42a6a4ed55defba272f7a724
Shop
Vasya plays one very well-known and extremely popular MMORPG game. His game character has *k* skill; currently the *i*-th of them equals to *a**i*. Also this game has a common rating table in which the participants are ranked according to the product of all the skills of a hero in the descending order. Vasya decided t...
{"inputs": ["2 4 3\n13 20\n1 1 14\n1 2 30\n2 1 6\n3 2 2", "1 0 0\n1", "1 1 1\n1\n3 1 8", "1 1 1\n1\n2 1 8", "1 1 1\n1\n1 1 8", "1 0 0\n8", "1 1 1\n8\n3 1 8", "1 1 1\n8\n2 1 8", "1 1 1\n8\n1 1 8", "2 10 10\n8 8\n1 2 8\n1 1 8\n1 1 8\n1 1 8\n1 2 8\n1 2 8\n1 2 8\n1 1 8\n1 1 8\n1 2 8", "10 7 6\n7 1 8 7 1 2 1 3 3 5\n3 1 5\n3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
5c6b49b83886363de94d6f84869ae958
Next Round
"Contestant who earns a score equal to or greater than the *k*-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules. A total of *n* participants took part in the contest (*n*<=≥<=*k*), and you already know their scores. Calculate...
{"inputs": ["8 5\n10 9 8 7 7 7 5 5", "4 2\n0 0 0 0", "5 1\n1 1 1 1 1", "5 5\n1 1 1 1 1", "1 1\n10", "17 14\n16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0", "5 5\n3 2 1 0 0", "8 6\n10 9 8 7 7 7 5 5", "8 7\n10 9 8 7 7 7 5 5", "8 4\n10 9 8 7 7 7 5 5", "8 3\n10 9 8 7 7 7 5 5", "8 1\n10 9 8 7 7 7 5 5", "8 2\n10 9 8 7 7 7 5 5", "...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
235
codeforces
5c7e34e3e37936ee6716f219e3a22ed8
One-Based Arithmetic
Prof. Vasechkin wants to represent positive integer *n* as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent 121 as 121=111+11+–1. Help him to find the least number of digits 1 in such sum. The first line of the input contains integer *n* (1<=≤<=*n*<=&lt;<=1015)...
{"inputs": ["121", "10", "72", "1", "2", "3", "4", "5", "6", "7", "11", "12", "2038946593", "81924761239462", "973546235465729", "999999999999999", "21", "79", "33", "185", "513", "634", "5300", "3724", "2148", "82415", "35839", "79263", "274634", "690762", "374186", "2673749", "5789877", "1873301", "30272863", "333889...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
8
codeforces
5ca219f9efcff505576207e1dd0ceb89
Treasure Hunt
Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure. Bottle with potion has two values *x* and *y* written on it. These values define four moves which can be perfo...
{"inputs": ["0 0 0 6\n2 3", "1 1 3 6\n1 5", "5 4 6 -10\n1 1", "6 -3 -7 -7\n1 2", "2 -5 -8 8\n2 1", "70 -81 -17 80\n87 23", "41 366 218 -240\n3456 1234", "-61972 -39646 -42371 -24854\n573 238", "-84870 -42042 94570 98028\n8972 23345", "-58533 -50999 -1007 -59169\n8972 23345", "-100000 -100000 100000 100000\n100000 10000...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
166
codeforces
5cbdab2b174eb6f2360e10275bea52ea
Polycarp and Letters
Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string *s* consisting only of lowercase and uppercase Latin letters. Let *A* be a set of positions in the string. Let's call it pretty if following conditions are met: - letters on positions from *A* in the string are all distinct and lowerc...
{"inputs": ["11\naaaaBaabAbA", "12\nzACaAbbaazzC", "3\nABC", "1\na", "2\naz", "200\nXbTJZqcbpYuZQEoUrbxlPXAPCtVLrRExpQzxzqzcqsqzsiisswqitswzCtJQxOavicSdBIodideVRKHPojCNHmbnrLgwJlwOpyrJJIhrUePszxSjJGeUgTtOfewPQnPVWhZAtogRPrJLwyShNQaeNsvrJwjuuBOMPCeSckBMISQzGngfOmeyfDObncyeNsihYVtQbSEh", "2\nAZ", "28\nAabcBabcCBNMaaaaabb...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
115
codeforces
5cd7e775c7c97932f3b29d2af3121b29
Jeff and Periods
One day Jeff got hold of an integer sequence *a*1, *a*2, ..., *a**n* of length *n*. The boy immediately decided to analyze the sequence. For that, he needs to find all values of *x*, for which these conditions hold: - *x* occurs in sequence *a*. - Consider all positions of numbers *x* in the sequence *a* (such *i*, ...
{"inputs": ["1\n2", "8\n1 2 1 3 1 2 1 5", "3\n1 10 5", "4\n9 9 3 5", "6\n1 2 2 1 1 2", "6\n2 6 3 8 7 2", "7\n2 1 2 1 2 1 2", "8\n1 1 1 1 1 1 1 1", "9\n2 3 3 3 2 1 2 3 2", "10\n3 1 1 1 1 3 1 2 2 1", "12\n10 9 8 7 7 8 9 10 10 9 8 7"], "outputs": ["1\n2 0", "4\n1 2\n2 4\n3 0\n5 0", "3\n1 0\n5 0\n10 0", "3\n3 0\n5 0\n9 1",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
64
codeforces
5cf7fec69f77240413a6649520c63d03
Help General
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...
{"inputs": ["2 4", "3 4", "4 4", "4 3", "4 2", "1 1", "3 5", "5 3", "506 44", "555 349", "757 210", "419 503", "515 19", "204 718", "862 330", "494 982", "967 4", "449 838", "635 458", "156 911", "409 295", "755 458", "936 759", "771 460", "563 802", "953 874", "354 720", "915 72", "860 762", "396 387", "675 710", "728...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
5d1998d3222e1d5f64d103af6720a3ee
Trading Business
To get money for a new aeonic blaster, ranger Qwerty decided to engage in trade for a while. He wants to buy some number of items (or probably not to buy anything at all) on one of the planets, and then sell the bought items on another planet. Note that this operation is not repeated, that is, the buying and the sellin...
{"inputs": ["3 3 10\nVenus\n6 5 3\n7 6 5\n8 6 10\nEarth\n10 9 0\n8 6 4\n10 9 3\nMars\n4 3 0\n8 4 12\n7 2 5", "2 1 5\nA\n6 5 5\nB\n10 9 0", "2 2 5\nAbcdefghij\n20 15 20\n10 5 13\nKlmopqrstu\n19 16 20\n12 7 14", "3 1 5\nTomato\n10 7 20\nBanana\n13 11 0\nApple\n15 14 10", "3 2 11\nMars\n15 10 4\n7 6 3\nSnickers\n20 17 2\n...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
13
codeforces
5d26438dd2e65309025b672de207b5c1
Monsters and Diamonds
Piegirl has found a monster and a book about monsters and pies. When she is reading the book, she found out that there are *n* types of monsters, each with an ID between 1 and *n*. If you feed a pie to a monster, the monster will split into some number of monsters (possibly zero), and at least one colorful diamond. Mon...
{"inputs": ["6 4\n1 3 -1 1 -1\n1 2 -1 -1\n2 3 -1 3 -1\n2 3 -1 -1 -1\n3 2 -1 -1\n4 2 4 -1", "3 2\n1 2 1 -1\n2 2 -1 -1\n2 3 2 1 -1", "2 1\n1 3 -1 1 -1\n1 5 -1 -1 -1 -1 -1", "5 4\n1 2 2 -1\n2 2 1 -1\n3 4 4 4 4 -1\n4 3 -1 -1 -1\n3 5 -1 -1 -1 -1 -1", "11 10\n1 9 -1 -1 -1 -1 -1 -1 -1 -1 -1\n1 10 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
5d4fdd95fa479ea92ad5478277d97c62
Zebra Tower
Little Janet likes playing with cubes. Actually, she likes to play with anything whatsoever, cubes or tesseracts, as long as they are multicolored. Each cube is described by two parameters — color *c**i* and size *s**i*. A Zebra Tower is a tower that consists of cubes of exactly two colors. Besides, the colors of the c...
{"inputs": ["4\n1 2\n1 3\n2 4\n3 3", "2\n1 1\n2 1", "3\n1 2\n2 2\n2 1", "4\n2 1\n2 1\n1 1\n1 2", "6\n1 1\n1 1\n2 2\n1 2\n1 2\n2 2", "20\n1 2\n3 2\n4 2\n2 2\n5 2\n2 5\n3 2\n3 4\n4 4\n5 3\n2 1\n5 2\n5 3\n2 1\n5 5\n2 3\n1 5\n5 2\n3 4\n3 3", "100\n2 5\n1 4\n1 2\n5 4\n1 3\n5 2\n4 4\n5 2\n3 5\n2 2\n5 5\n4 5\n5 3\n5 3\n1 1\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
5d6f4738ba2052d7b15af604afb86be9
Sereja and Dima
Sereja and Dima play a game. The rules of the game are very simple. The players have *n* cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or the rightmost one. Th...
{"inputs": ["4\n4 1 2 10", "7\n1 2 3 4 5 6 7", "42\n15 29 37 22 16 5 26 31 6 32 19 3 45 36 33 14 25 20 48 7 42 11 24 28 9 18 8 21 47 17 38 40 44 4 35 1 43 39 41 27 12 13", "43\n32 1 15 48 38 26 25 14 20 44 11 30 3 42 49 19 18 46 5 45 10 23 34 9 29 41 2 52 6 17 35 4 50 22 33 51 7 28 47 13 39 37 24", "1\n3", "45\n553 40 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
867
codeforces
5d8ef656cdf086c8101d576fae62302e
Square Subsets
Petya was late for the lesson too. The teacher gave him an additional task. For some array *a* Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product is equal to a square of some integer. Two ways are considered different if sets of indexes of ele...
{"inputs": ["4\n1 1 1 1", "4\n2 2 2 2", "5\n1 2 4 5 8", "1\n64", "5\n2 2 2 2 2", "6\n1 2 3 4 5 6", "2\n70 70", "7\n4 9 16 25 36 49 64", "13\n64 65 40 26 36 46 53 31 63 11 2 46 59", "15\n66 34 43 45 61 14 12 67 38 25 55 9 30 41 16", "17\n44 57 54 57 54 65 40 57 59 16 39 51 32 51 20 9 8", "18\n22 41 40 8 36 48 23 5 58 12...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
11
codeforces
5dacd674c9a16102502820681cad23bc
Valera and X
Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today. At the test Valera got a square piece of squared paper. The length of the...
{"inputs": ["5\nxooox\noxoxo\nsoxoo\noxoxo\nxooox", "3\nwsw\nsws\nwsw", "3\nxpx\npxp\nxpe", "5\nliiil\nilili\niilii\nilili\nliiil", "7\nbwccccb\nckcccbj\nccbcbcc\ncccbccc\nccbcbcc\ncbcccbc\nbccccdt", "13\nsooooooooooos\nosoooooooooso\noosooooooosoo\nooosooooosooo\noooosooosoooo\nooooososooooo\noooooosoooooo\nooooososoo...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
157
codeforces
5db2e7f14bd88a44a444bfbc8f828386
none
Профиль горного хребта схематично задан в виде прямоугольной таблицы из символов «.» (пустое пространство) и «*» (часть горы). Каждый столбец таблицы содержит хотя бы одну «звёздочку». Гарантируется, что любой из символов «*» либо находится в нижней строке матрицы, либо непосредственно под ним находится другой символ «...
{"inputs": ["6 11\n...........\n.........*.\n.*.......*.\n**.......*.\n**..*...**.\n***********", "5 5\n....*\n...**\n..***\n.****\n*****", "8 7\n.......\n.*.....\n.*.....\n.**....\n.**.*..\n.****.*\n.******\n*******", "1 1\n*", "2 2\n**\n**", "1 10\n**********", "10 1\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*", "5 5\n.....\n........
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
32
codeforces
5dda3e0143c8d305726f93da43852f5d
Carrot Cakes
In some game by Playrix it takes *t* minutes for an oven to bake *k* carrot cakes, all cakes are ready at the same moment *t* minutes after they started baking. Arkady needs at least *n* cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady...
{"inputs": ["8 6 4 5", "8 6 4 6", "10 3 11 4", "4 2 1 4", "28 17 16 26", "60 69 9 438", "599 97 54 992", "11 22 18 17", "1 13 22 11", "1 1 1 1", "3 1 1 1", "1000 1000 1000 1000", "1000 1000 1 1", "1000 1000 1 400", "1000 1000 1 1000", "1000 1000 1 999", "53 11 3 166", "313 2 3 385", "214 9 9 412", "349 9 5 268", "611 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
280
codeforces
5df9d8e573c06fc045114e08ee7bca33
Extract Numbers
You are given string *s*. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for example, the string *s*=";;" contains three empty words separated by ';'. ...
{"inputs": ["aba,123;1a;0", "1;;01,a0,", "1", "a", ",;,,;", "123;abacab,123;1,sadasfas,123213132g;02131313;aaa,0,012;0;03242;1", ".", ";", "6;2,", "000", "5345rhhr34t.k;k;k;k;k;5677;000000,000000;000098,0.70k;89.;;;", "100.000", ",,;,;,5345rh;hr;34t.k;k;k0,;,0,;k;k;5677.;000000,000000;000098,000.70k;89.;;;", "01", "ash...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
39
codeforces
5e4e2e8c7c34063b37d1d4c3797d8ccc
Gadgets for dollars and pounds
Nura wants to buy *k* gadgets. She has only *s* burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency are not changing. Nura can buy gadgets for *n* days. For each day you know the exchange rates ...
{"inputs": ["5 4 2 2\n1 2 3 2 1\n3 2 1 2 3\n1 1\n2 1\n1 2\n2 2", "4 3 2 200\n69 70 71 72\n104 105 106 107\n1 1\n2 2\n1 2", "4 3 1 1000000000\n900000 910000 940000 990000\n990000 999000 999900 999990\n1 87654\n2 76543\n1 65432", "5 5 3 1000000\n921 853 547 187 164\n711 462 437 307 246\n2 94\n2 230\n1 373\n1 476\n2 880",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
5e5d9db11c7acd51d33b3de0186daa19
Dima and Friends
Dima and his friends have been playing hide and seek at Dima's place all night. As a result, Dima's place got messy. In the morning they decided that they need to clean the place. To decide who exactly would clean the apartment, the friends want to play a counting-out game. First, all the guys stand in a circle, and t...
{"inputs": ["1\n1", "1\n2", "2\n3 5", "2\n3 5", "1\n5", "5\n4 4 3 5 1", "6\n2 3 2 2 1 3", "8\n2 2 5 3 4 3 3 2", "7\n4 1 3 2 2 4 5", "3\n3 5 1", "95\n4 2 3 4 4 5 2 2 4 4 3 5 3 3 3 5 4 2 5 4 2 1 1 3 4 2 1 3 5 4 2 1 1 5 1 1 2 2 4 4 5 4 5 5 2 1 2 2 2 4 5 5 2 4 3 4 4 3 5 2 4 1 5 4 5 1 3 2 4 2 2 1 5 3 1 5 3 4 3 3 2 1 2 2 1 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
646
codeforces
5e684bd707170b65c68bb4d8d2a77f83
Solitaire
A boy named Vasya wants to play an old Russian solitaire called "Accordion". In this solitaire, the player must observe the following rules: - A deck of *n* cards is carefully shuffled, then all *n* cards are put on the table in a line from left to right; - Before each move the table has several piles of cards lying...
{"inputs": ["4\n2S 2S 2C 2C", "2\n3S 2C", "5\n2S 2S 4S 3S 2S", "5\n5S 5S 7S 4S 3H", "5\n7S 7S 4S 8H 4H", "5\n4S 2H 3S 3S 2H", "52\n3H 6S 3S 2S 2S 3S 4S 3H 2C 4S 3C 3S 2S 2C 2S 6S 4C 3S 5C 3S 2S 4S 3S 5S 2H 2S 4H 3S 3S 4H 4S 2C 2H 2S 4S 6D 4C 4H 2H 4S 3H 6D 6S 3C 3C 4H 5S 3S 3S 2H 2S 4C", "52\n2S 4S 3S 2S 4S 3S 4S 4S 8S...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
5e705e49fe98a254385e215185763e89
STL
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...
{"inputs": ["3\npair pair int int int", "1\npair int", "4\npair pair int int pair int int", "4\npair pair pair int int int int", "5\npair pair int pair int pair int int int", "2\nint int", "1\nint", "2\npair int int", "3\npair pair int int int", "5\npair pair pair pair int int int int int", "6\npair pair pair pair pair...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
5e87611ad3c19c8e572fd38f664c1e27
Foe Pairs
You are given a permutation *p* of length *n*. Also you are given *m* foe pairs (*a**i*,<=*b**i*) (1<=≤<=*a**i*,<=*b**i*<=≤<=*n*,<=*a**i*<=≠<=*b**i*). Your task is to count the number of different intervals (*x*,<=*y*) (1<=≤<=*x*<=≤<=*y*<=≤<=*n*) that do not contain any foe pairs. So you shouldn't count intervals (*x...
{"inputs": ["4 2\n1 3 2 4\n3 2\n2 4", "9 5\n9 7 2 3 1 4 6 5 8\n1 6\n4 5\n2 7\n7 2\n2 7", "2 1\n1 2\n1 2", "10 3\n4 10 5 1 6 8 9 2 3 7\n10 5\n2 10\n4 1", "50 10\n41 15 17 1 5 31 7 38 30 39 43 35 2 26 20 42 48 25 19 32 50 4 8 10 44 12 9 18 13 36 28 6 27 23 40 24 3 14 29 11 49 47 45 46 34 21 37 16 22 33\n13 48\n24 12\n2 3...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
5ec25699a1e8a3a06113525155678244
Felicity is Coming!
It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has *n* gyms. The *i*-th gym has *g**i* Pokemon in it. There are *m* distinct Pokemon types in the Himalayan region numbered from 1 to *m*. There is a special evolution camp...
{"inputs": ["2 3\n2 1 2\n2 2 3", "1 3\n3 1 2 3", "2 4\n2 1 2\n3 2 3 4", "2 2\n3 2 2 1\n2 1 2", "3 7\n2 1 2\n2 3 4\n3 5 6 7", "10 100\n16 25 7 48 43 16 23 66 3 17 31 64 27 7 17 11 60\n62 76 82 99 77 19 26 66 46 9 54 77 8 34 76 70 48 53 35 69 29 84 22 16 53 36 27 24 81 2 86 67 45 22 54 96 37 8 3 22 9 30 63 61 86 19 16 47...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
5ecc297312cc4b918f5e71caed554d42
New Year Present
The New Year is coming! That's why many people today are busy preparing New Year presents. Vasily the Programmer is no exception. Vasily knows that the best present is (no, it's not a contest) money. He's put *n* empty wallets from left to right in a row and decided how much money to put in what wallet. Vasily decided...
{"inputs": ["2\n1 2", "4\n0 2 0 2", "10\n2 3 4 0 0 1 1 3 4 2", "10\n0 0 0 0 0 0 0 0 1 0", "5\n2 2 2 2 2", "2\n6 0"], "outputs": ["PRPLRP", "RPRRPLLPLRRRP", "PRPRPRRRPRPRPRPRPLPLPLLLLLPLPLPRPRPRRRRRPRPRPLPLLLLLLPLL", "RRRRRRRRPR", "PRPRPRPRPLPLPLPLPRRRRP", "PRLPRLPRLPRLPRLP"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
5ed7cffa8b0078ab40b7a770e5f54ea3
Sereja and the Arrangement of Numbers
Let's call an array consisting of *n* integer numbers *a*1, *a*2, ..., *a**n*, beautiful if it has the following property: - consider all pairs of numbers *x*,<=*y* (*x*<=≠<=*y*), such that number *x* occurs in the array *a* and number *y* occurs in the array *a*; - for each pair *x*,<=*y* must exist some position *...
{"inputs": ["5 2\n1 2\n2 3", "100 3\n1 2\n2 1\n3 1", "1 2\n1 1\n2 100", "25 29\n82963 53706\n63282 73962\n14996 48828\n84392 31903\n96293 41422\n31719 45448\n46772 17870\n9668 85036\n36704 83323\n73674 63142\n80254 1548\n40663 44038\n96724 39530\n8317 42191\n44289 1041\n63265 63447\n75891 52371\n15007 56394\n55630 6008...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
5f055246626e15ae85a2320bf48ff035
Wilbur and Array
Wilbur the pig is tinkering with arrays again. He has the array *a*1,<=*a*2,<=...,<=*a**n* initially consisting of *n* zeros. At one step, he can choose any index *i* and either add 1 to all elements *a**i*,<=*a**i*<=+<=1,<=... ,<=*a**n* or subtract 1 from all elements *a**i*,<=*a**i*<=+<=1,<=...,<=*a**n*. His goal is ...
{"inputs": ["5\n1 2 3 4 5", "4\n1 2 2 1", "3\n1 2 4", "6\n1 2 3 6 5 4", "10\n2 1 4 3 6 5 8 7 10 9", "7\n12 6 12 13 4 3 2", "15\n15 14 13 1 2 3 12 11 10 4 5 6 9 8 7", "16\n1 2 3 4 13 14 15 16 9 10 11 12 5 6 7 8", "6\n1000 1 2000 1 3000 1", "1\n0", "5\n1000000000 1 1000000000 1 1000000000", "5\n1000000000 0 1000000000 0 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
183
codeforces
5f1cd4a396749b78daf8cc5487e0a46a
Tanya and Stairways
Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $1$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, the first of which contains $3$ steps, and the second contains $4$ ...
{"inputs": ["7\n1 2 3 1 2 3 4", "4\n1 1 1 1", "5\n1 2 3 4 5", "5\n1 2 1 2 1", "1\n1", "48\n1 2 3 4 1 2 3 1 1 2 3 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 2 1 2 1 2 1 1 2 1 2 1 2 3 1 2 1 2 1", "2\n1 2", "3\n1 1 2", "4\n1 1 2 3", "8\n1 2 3 1 2 3 4 5", "5\n1 1 1 2 3"], "outputs": ["2\n3 4 ", "4\n1 1 1 1 ", "1\n5 ", "3\n2 2 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
192
codeforces
5f292eed4d5faa894c50048b3cebaf39
Lesson Timetable
When Petya has free from computer games time, he attends university classes. Every day the lessons on Petya’s faculty consist of two double classes. The floor where the lessons take place is a long corridor with *M* classrooms numbered from 1 to *M*, situated along it. All the students of Petya’s year are divided into...
{"inputs": ["3\n1 1 1\n1 2 3", "3\n1 1 1\n1 1 1", "3\n2 1 1\n5 1 2", "5\n2 1 1 1 1\n5 3 1 1 3", "5\n1 3 15 3 18\n2 6 18 5 19", "6\n3 8 2 6 18 2\n6 20 9 6 19 3", "7\n3 4 7 8 6 5 2\n6 12 19 16 15 7 5", "9\n1 1 1 3 6 1 4 2 1\n1 14 1 6 15 2 14 5 2", "9\n7 1 4 7 8 4 5 7 1\n12 10 6 15 13 7 5 17 1", "11\n4 12 2 1 2 9 13 1 12 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
5f2c9558381de1736909b582f70980f6
none
Fox Ciel is going to publish a paper on FOCS (Foxes Operated Computer Systems, pronounce: "Fox"). She heard a rumor: the authors list on the paper is always sorted in the lexicographical order. After checking some examples, she found out that sometimes it wasn't true. On some papers authors' names weren't sorted in l...
{"inputs": ["3\nrivest\nshamir\nadleman", "10\ntourist\npetr\nwjmzbmr\nyeputons\nvepifanov\nscottwu\noooooooooooooooo\nsubscriber\nrowdark\ntankengineer", "10\npetr\negor\nendagorion\nfeferivan\nilovetanyaromanova\nkostka\ndmitriyh\nmaratsnowbear\nbredorjaguarturnik\ncgyforever", "7\ncar\ncare\ncareful\ncarefully\nbeca...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
25
codeforces
5f389135c7741bbbe16125a372058e67
Lomsat gelral
You are given a rooted tree with root in vertex 1. Each vertex is coloured in some colour. Let's call colour *c* dominating in the subtree of vertex *v* if there are no other colours that appear in the subtree of vertex *v* more times than colour *c*. So it's possible that two or more colours will be dominating in the...
{"inputs": ["4\n1 2 3 4\n1 2\n2 3\n2 4", "15\n1 2 3 1 2 3 3 1 1 3 2 2 1 2 3\n1 2\n1 3\n1 4\n1 14\n1 15\n2 5\n2 6\n2 7\n3 8\n3 9\n3 10\n4 11\n4 12\n4 13"], "outputs": ["10 9 3 4", "6 5 4 3 2 3 3 1 1 3 2 2 1 2 3"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
10
codeforces
5f41442c2de274280c23e2f1c8c8dd84
Dice Tower
A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left). Alice...
{"inputs": ["3\n6\n3 2\n5 4\n2 4", "3\n3\n2 6\n4 1\n5 3", "1\n3\n2 1", "2\n2\n3 1\n1 5", "3\n2\n1 4\n5 3\n6 4", "4\n3\n5 6\n1 3\n1 5\n4 1", "2\n2\n3 1\n1 3", "3\n2\n1 4\n3 1\n4 6", "4\n3\n5 6\n1 5\n5 1\n1 5", "5\n1\n2 3\n5 3\n5 4\n5 1\n3 5", "10\n5\n1 3\n2 3\n6 5\n6 5\n4 5\n1 3\n1 2\n3 2\n4 2\n1 2", "15\n4\n2 1\n2 4\n6...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
243
codeforces
5f544507a89d8890327fa2f6658e917e
none
...Once upon a time a man came to the sea. The sea was stormy and dark. The man started to call for the little mermaid to appear but alas, he only woke up Cthulhu... Whereas on the other end of the world Pentagon is actively collecting information trying to predict the monster's behavior and preparing the secret super...
{"inputs": ["6 6\n6 3\n6 4\n5 1\n2 5\n1 4\n5 4", "6 5\n5 6\n4 6\n3 1\n5 1\n1 2", "10 10\n4 10\n8 5\n2 8\n4 9\n9 3\n2 7\n10 6\n10 2\n9 8\n1 8", "5 4\n1 5\n1 3\n1 4\n3 2", "12 12\n4 12\n4 7\n4 9\n7 2\n5 12\n2 1\n5 9\n8 6\n10 12\n2 5\n10 9\n12 3", "12 15\n3 2\n11 12\n1 9\n2 1\n1 8\n9 6\n11 5\n9 5\n9 10\n11 3\n7 11\n5 6\n1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
56
codeforces
5f55ca8af46f5d6579c10f09189e234d
24 Game
Little X used to play a card game called "24 Game", but recently he has found it too easy. So he invented a new game. Initially you have a sequence of *n* integers: 1,<=2,<=...,<=*n*. In a single step, you can pick two of them, let's denote them *a* and *b*, erase them from the sequence, and append to the sequence eit...
{"inputs": ["1", "8", "12", "100", "1000", "987", "2", "3", "4", "5", "6", "7", "100000", "99999", "99998", "99997", "580", "422", "116", "447", "62052", "25770", "56118", "86351", "48108", "33373", "9782", "19082", "4", "7", "3"], "outputs": ["NO", "YES\n8 * 7 = 56\n6 * 5 = 30\n3 - 4 = -1\n1 - 2 = -1\n30 - -1 = 31\n56...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
42
codeforces
5f78c17e3e077560c33137901ccbd807
Simple Subset
A tuple of positive integers {*x*1,<=*x*2,<=...,<=*x**k*} is called simple if for all pairs of positive integers (*i*,<=<=*j*) (1<=<=≤<=*i*<=<=&lt;<=<=*j*<=≤<=*k*), *x**i*<=<=+<=<=*x**j* is a prime. You are given an array *a* with *n* positive integers *a*1,<=<=*a*2,<=<=...,<=<=*a**n* (not necessary distinct). You wan...
{"inputs": ["2\n2 3", "2\n2 2", "3\n2 1 1", "2\n83 14", "10\n10 10 1 2 3 3 1 2 1 5", "100\n314 905 555 526 981 360 424 104 920 814 143 872 741 592 105 573 837 962 220 692 560 493 889 824 145 491 828 960 889 87 375 486 609 423 386 323 124 830 206 446 899 522 514 696 786 783 268 483 318 261 675 445 1000 896 812 277 131 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
5
codeforces
5f7f173ec7b8e0e45134a0c4d3a65ec4
Winter Is Coming
The winter in Berland lasts *n* days. For each day we know the forecast for the average air temperature that day. Vasya has a new set of winter tires which allows him to drive safely no more than *k* days at any average air temperature. After *k* days of using it (regardless of the temperature of these days) the set ...
{"inputs": ["4 3\n-5 20 -3 0", "4 2\n-5 20 -3 0", "10 6\n2 -5 1 3 0 0 -4 -3 1 0", "4 4\n-5 20 -3 0", "4 1\n-5 20 -3 0", "1 0\n-13", "2 0\n-12 -13", "3 1\n9 -16 -7", "5 5\n-15 -10 -20 -19 -14", "7 3\n-2 -14 3 -17 -20 -13 -17", "10 10\n-9 4 -3 16 -15 12 -12 8 -14 15", "30 9\n12 8 -20 0 11 -17 -11 -6 -2 -18 -19 -19 -18 -1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
7
codeforces
5faca9bc5d53ce1b6775356223a21f65
Bicycle Chain
Vasya's bicycle chain drive consists of two parts: *n* stars are attached to the pedal axle, *m* stars are attached to the rear wheel axle. The chain helps to rotate the rear wheel by transmitting the pedal rotation. We know that the *i*-th star on the pedal axle has *a**i* (0<=&lt;<=*a*1<=&lt;<=*a*2<=&lt;<=...<=&lt;<...
{"inputs": ["2\n4 5\n3\n12 13 15", "4\n1 2 3 4\n5\n10 11 12 13 14", "1\n1\n1\n1", "2\n1 2\n1\n1", "1\n1\n2\n1 2", "4\n3 7 11 13\n4\n51 119 187 221", "4\n2 3 4 5\n3\n1 2 3", "10\n6 12 13 20 48 53 74 92 96 97\n10\n1 21 32 36 47 54 69 75 95 97", "10\n5 9 10 14 15 17 19 22 24 26\n10\n2 11 17 19 21 22 24 25 27 28", "10\n24 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
414
codeforces
5fb2747ed83e4c02b1581533dd4e7d2c
Mice
Modern researches has shown that a flock of hungry mice searching for a piece of cheese acts as follows: if there are several pieces of cheese then each mouse chooses the closest one. After that all mice start moving towards the chosen piece of cheese. When a mouse or several mice achieve the destination point and ther...
{"inputs": ["3 2 0 2\n0 1 3\n2 5", "7 11 10 20\n6 18 32 63 66 68 87\n6 8 15 23 25 41 53 59 60 75 90", "13 17 14 1\n6 9 10 12 17 25 91 100 118 136 145 163 172\n0 1 2 3 4 10 12 13 16 17 19 22 26 27 28 109 154", "19 23 13 11\n3 6 7 15 21 22 23 33 35 37 40 44 79 86 100 114 121 135 142\n2 3 5 6 7 14 15 17 18 19 20 22 25 27 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
4
codeforces
5fca268576815fab64c58a47fbb928cc
Two Sets
Little X has *n* distinct integers: *p*1,<=*p*2,<=...,<=*p**n*. He wants to divide all of them into two sets *A* and *B*. The following two conditions must be satisfied: - If number *x* belongs to set *A*, then number *a*<=-<=*x* must also belong to set *A*. - If number *x* belongs to set *B*, then number *b*<=-<=*x...
{"inputs": ["4 5 9\n2 3 4 5", "3 3 4\n1 2 4", "100 8883 915\n1599 4666 663 3646 754 2113 2200 3884 4082 1640 3795 2564 2711 2766 1122 4525 1779 2678 2816 2182 1028 2337 4918 1273 4141 217 2682 1756 309 4744 915 1351 3302 1367 3046 4032 4503 711 2860 890 2443 4819 4169 4721 3472 2900 239 3551 1977 2420 3361 3035 956 253...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
6
codeforces
60122b5a7d52bc435984453c4c38584a
Mahmoud and Ehab and the bipartiteness
Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees. A tree is a connected acyclic graph. A bipartite graph is a graph, whose vertices can be partitioned into 2 sets in such a way, that for each edge (*u*,<=*v*) that belongs to the graph, *...
{"inputs": ["3\n1 2\n1 3", "5\n1 2\n2 3\n3 4\n4 5", "10\n3 8\n6 2\n9 7\n10 1\n3 5\n1 3\n6 7\n5 4\n3 6", "10\n7 6\n2 7\n4 1\n8 5\n9 4\n5 3\n8 7\n10 8\n10 4", "10\n2 6\n3 7\n8 4\n4 10\n6 9\n9 7\n3 10\n1 2\n5 8", "10\n6 9\n9 7\n9 4\n10 9\n9 1\n9 8\n9 2\n9 5\n3 9", "2\n1 2"], "outputs": ["0", "2", "16", "16", "16", "0", "0...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
124
codeforces
6014b9478d7f57ed59cdafd03fe47e3e
none
Johnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point *d*. Johnny's truck has a gas tank that holds exactly *n* liters, and his tank is initially full. As he drives, the truck consu...
{"inputs": ["10 4 4\n3 5\n5 8\n6 3\n8 4", "16 5 2\n8 2\n5 1", "400000000 400000000 3\n1 139613\n19426 13509\n246298622 343529", "229 123 2\n170 270968\n76 734741", "153 105 1\n96 83995", "281 12 23\n178 650197\n129 288456\n34 924882\n43 472160\n207 957083\n103 724815\n167 308008\n135 906958\n74 242828\n229 146026\n85 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
601619bbc1a70e0f37eec361a968484a
Rebus
You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer *n*. The goal is to replace each question mark with some positive integer from 1 to *n*, such that equality holds. The only line of the input contains a rebus....
{"inputs": ["? + ? - ? + ? + ? = 42", "? - ? = 1", "? = 1000000", "? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? = 9", "? - ? + ? + ? + ? + ? - ? - ? - ? - ? + ? - ? - ? - ? + ? - ? + ? + ? + ? - ? + ? + ? + ? - ? + ? + ? - ? + ? - ? + ? - ? - ? + ? + ? + ? + ? + ? + ? + ? - ? + ? + ? + ? + ? - ? - ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
22
codeforces
602b71ae265c6a9862d03253d3a2378a
Wizards and Minimal Spell
Let's dive into one of the most interesting areas of magic — writing spells. Learning this exciting but challenging science is very troublesome, so now you will not learn the magic words, but only get to know the basic rules of writing spells. Each spell consists of several lines. The line, whose first non-space chara...
{"inputs": [" # include <cstdio>\n\nusing namespace std;\n\nint main ( ){\nputs(\"Hello # World\"); #\n#\n}", "#\n\n#", "#\n \n#", "#a\n#a\n\n#a\n\n\n#a\n \n#a\n \n\n#a\n\n \n#a\n \n \n#a", " # a \n # a \n\n # a \n\n\n # a ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
604fde0d7c396166ca579aaf2833553f
Hiking
A traveler is planning a water hike along the river. He noted the suitable rest points for the night and wrote out their distances from the starting point. Each of these locations is further characterized by its picturesqueness, so for the *i*-th rest point the distance from the start equals *x**i*, and its picturesque...
{"inputs": ["5 9\n10 10\n20 10\n30 1\n31 5\n40 10", "1 20\n9 1", "2 7\n1 9\n5 6", "3 2\n2 6\n3 9\n6 8", "4 3\n1 6\n5 10\n9 9\n10 6", "5 1\n2 3\n5 4\n7 9\n8 10\n10 7", "10 6\n1 16\n8 27\n23 2\n26 21\n32 50\n38 53\n51 79\n62 97\n77 18\n100 5", "11 6\n9 50\n10 56\n14 39\n17 91\n22 1\n25 65\n38 15\n39 93\n54 62\n62 31\n90 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
606225754191071a59ac3caab457cd3b
Jzzhu and Apples
Jzzhu has picked *n* apples from his big apple tree. All the apples are numbered from 1 to *n*. Now he wants to sell them to an apple store. Jzzhu will pack his apples into groups and then sell them. Each group must contain two apples, and the greatest common divisor of numbers of the apples in each group must be gre...
{"inputs": ["6", "9", "2", "10", "100", "99998", "100000", "1", "3", "5", "98765", "52999", "99524", "99994", "5249", "99999", "10007", "30011", "60013", "99991"], "outputs": ["2\n6 3\n2 4", "3\n9 3\n2 4\n6 8", "0", "4\n2 4\n6 8\n10 5\n9 3", "44\n33 27\n22 11\n25 5\n64 66\n42 44\n31 62\n58 29\n43 86\n15 21\n6 99\n8 12\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
3
codeforces
60697373d2b5fcb2993cba287677c38d
The Values You Can Make
Pari wants to buy an expensive chocolate from Arya. She has *n* coins, the value of the *i*-th coin is *c**i*. The price of the chocolate is *k*, so Pari will take a subset of her coins with sum equal to *k* and give it to Arya. Looking at her coins, a question came to her mind: after giving the coins to Arya, what va...
{"inputs": ["6 18\n5 6 1 10 12 2", "3 50\n25 25 50", "1 79\n79", "1 114\n114", "5 1\n1 500 205 6 355", "8 42\n7 24 22 25 31 12 17 26", "8 91\n74 25 66 50 62 30 50 50", "8 15\n13 3 5 5 6 14 5 5", "8 39\n38 17 25 33 7 29 15 22", "15 185\n69 61 185 127 169 42 140 93 12 115 36 46 19 80 123", "15 109\n92 60 14 9 22 99 17 22...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
16
codeforces
60834fd7364cc020a919b4ea17ddf492
Testing Pants for Sadness
The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness". The test consists of *n* questions; the questions are to be answered strictly in the order in which they are given, from question 1 t...
{"inputs": ["2\n1 1", "2\n2 2", "1\n10", "3\n2 4 1", "4\n5 5 3 1", "2\n1000000000 1000000000", "10\n5 7 8 1 10 3 6 4 10 6", "100\n5 7 5 3 5 4 6 5 3 6 4 6 6 2 1 9 6 5 3 8 4 10 1 9 1 3 7 6 5 5 8 8 7 7 8 9 2 10 3 5 4 2 6 10 2 6 9 6 1 9 3 7 7 8 3 9 9 5 10 10 3 10 7 8 3 9 8 3 2 4 10 2 1 1 7 3 9 10 4 6 9 8 2 1 4 10 1 10 6 8 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
104
codeforces
60c6fd01f2a44cd778910c3d04369750
Two Friends
Two neighbours, Alan and Bob, live in the city, where there are three buildings only: a cinema, a shop and the house, where they live. The rest is a big asphalt square. Once they went to the cinema, and the film impressed them so deeply, that when they left the cinema, they did not want to stop discussing it. Bob wa...
{"inputs": ["0 2\n0 0\n4 0\n-3 0", "0 0\n0 0\n2 0\n1 0", "0 2\n0 0\n40 0\n-31 1", "100 2\n0 0\n4 0\n-3 0", "2 100\n0 0\n4 0\n-3 0", "0 0\n0 0\n5 0\n10 0", "2 0\n0 0\n5 0\n10 0", "0 2\n0 0\n5 0\n10 0", "0 0\n0 0\n4 0\n4 3", "0 4\n0 0\n4 0\n4 3", "0 3\n0 0\n4 0\n4 3", "1 4\n0 0\n4 0\n4 3", "0 0\n0 0\n100 100\n100 0", "1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
60d12ffdce709d46156de6423c7c6ee1
Intercepted Message
Hacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information. Zhorik knows that each of the messages is an archive containing one or more files. Zhorik knows how each of these archives was transferred...
{"inputs": ["7 6\n2 5 3 1 11 4 4\n7 8 2 4 1 8", "3 3\n1 10 100\n1 100 10", "1 4\n4\n1 1 1 1", "1 1\n1000000\n1000000", "3 5\n2 2 9\n2 1 4 2 4", "5 3\n1 1 4 1 2\n1 4 4", "30 50\n3 3 1 3 1 2 4 3 4 1 3 2 3 3 2 3 2 1 3 4 2 1 1 3 2 2 1 3 1 60\n4 4 1 2 2 2 3 1 3 2 1 2 4 4 2 1 2 3 1 3 4 4 3 3 4 4 4 1 2 1 3 3 1 1 3 3 4 3 2 3 2...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
83
codeforces
6100c1c63131367d738e0408b5f12c9d
Little Elephant and Numbers
The Little Elephant loves numbers. He has a positive integer *x*. The Little Elephant wants to find the number of positive integers *d*, such that *d* is the divisor of *x*, and *x* and *d* have at least one common (the same) digit in their decimal representations. Help the Little Elephant to find the described num...
{"inputs": ["1", "10", "47", "100", "128", "2", "17", "1000000", "1000000000", "4584725", "999999999", "9", "3", "4", "20", "24", "48", "2458450", "97648850", "96488450", "879541", "111111111", "222222222", "777777777", "211768200", "536870912", "654885000", "223092870", "901800900", "101871000", "49", "999999993", "99...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
53
codeforces
61084951b3b6e5a68f9fc621f812352a
Fake News (easy)
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it... The...
{"inputs": ["abcheaibcdi", "hiedi", "ihied", "diehi", "deiih", "iheid", "eihdi", "ehdii", "edhii", "deiih", "ehdii", "eufyajkssayhjhqcwxmctecaeepjwmfoscqprpcxsqfwnlgzsmmuwuoruantipholrauvxydfvftwfzhnckxswussvlidcojiciflpvkcxkkcmmvtfvxrkwcpeelwsuzqgamamdtdgzscmikvojfvqehblmjczkvtdeymgertgkwfwfukafqlfdhtedcctixhyetdypswg...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
330
codeforces
611d5edf1fac73722d75e675883f655e
Laboratory Work
Anya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value *n* times, and then compute the average value to lower the error. Kirill has already made his measurements, and has got the following integer values: *x*1, *x*2, ..., *x**n*. It is important that the values are clo...
{"inputs": ["6\n-1 1 1 0 0 -1", "3\n100 100 101", "7\n-10 -9 -10 -8 -10 -9 -9", "60\n-8536 -8536 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8535 -8536 -8536 -8535 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -8536 -...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
28
codeforces
61210c098c09d3189bc978f2beecaf95
Hexagons!
After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known "Heroes of Might &amp; Magic". A part of the game is turn-based fights of big squadrons of enemies on infinite fields where every...
{"inputs": ["2", "0", "1", "3", "749431", "748629743", "945234000", "900000000", "999999999", "1000000000"], "outputs": ["19", "1", "7", "37", "1684942719577", "1681339478558627377", "2680401947103702001", "2430000002700000001", "2999999997000000001", "3000000003000000001"]}
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
21
codeforces
61331892fdd37295b2e464408bc46a91
Bear and Finding Criminals
There are *n* cities in Bearland, numbered 1 through *n*. Cities are arranged in one long row. The distance between cities *i* and *j* is equal to |*i*<=-<=*j*|. Limak is a police officer. He lives in a city *a*. His job is to catch criminals. It's hard because he doesn't know in which cities criminals are. Though, he...
{"inputs": ["6 3\n1 1 1 0 1 0", "5 2\n0 0 0 1 0", "1 1\n1", "1 1\n0", "9 3\n1 1 1 1 1 1 1 1 0", "9 5\n1 0 1 0 1 0 1 0 1", "20 17\n1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 1 0 0 0 0", "100 60\n1 1 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 0 1 0 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 0 0 1 1 1 0 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
292
codeforces
6188ca22b8da96766b5b984e5b443947
Effective Approach
Once at a team training Vasya, Petya and Sasha got a problem on implementing linear search in an array. According to the boys, linear search works as follows. The array elements in a pre-selected order are in turn compared with the number that you need to find. Once you find the array element that is equal to the requ...
{"inputs": ["2\n1 2\n1\n1", "2\n2 1\n1\n1", "3\n3 1 2\n3\n1 2 3", "9\n2 9 3 1 6 4 7 8 5\n9\n5 1 5 2 8 4 4 4 5", "10\n3 10 9 2 7 6 5 8 4 1\n1\n4", "10\n5 2 10 8 3 1 9 7 6 4\n9\n2 5 9 2 3 2 5 9 8", "9\n3 8 4 7 1 2 5 6 9\n3\n2 7 1", "9\n5 3 8 4 2 6 1 7 9\n4\n6 1 9 2", "4\n1 3 2 4\n4\n3 1 2 3", "3\n1 2 3\n8\n3 2 1 1 2 3 1 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
344
codeforces
618e02f7384cdd19508ebd84ad809d18
Union of Doubly Linked Lists
Doubly linked list is one of the fundamental data structures. A doubly linked list is a sequence of elements, each containing information about the previous and the next elements of the list. In this problem all lists have linear structure. I.e. each element except the first has exactly one previous element, each eleme...
{"inputs": ["7\n4 7\n5 0\n0 0\n6 1\n0 2\n0 4\n1 0", "2\n2 0\n0 1", "1\n0 0", "4\n0 2\n1 0\n0 4\n3 0", "5\n0 0\n0 0\n0 0\n0 0\n0 0", "2\n0 0\n0 0", "2\n0 2\n1 0", "5\n5 3\n4 0\n1 4\n3 2\n0 1", "5\n2 0\n0 1\n0 4\n3 5\n4 0", "5\n3 4\n0 0\n0 1\n1 0\n0 0", "5\n3 0\n0 0\n0 1\n0 0\n0 0", "10\n7 5\n5 0\n4 7\n10 3\n1 2\n0 9\n3 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
19
codeforces
6199397c95c09acba408fadef4aae0c7
Chips
There are *n* walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number *n*. The presenter has *m* chips. The pre...
{"inputs": ["4 11", "17 107", "3 8", "46 7262", "32 6864", "36 6218", "25 9712", "9 7601", "1 9058", "29 7772", "45 9465", "46 866", "29 1241", "17 4248", "20 8082", "50 9555", "4 7455", "36 880", "24 7440", "44 7888", "1 1", "50 10000", "1 10000", "50 1", "50 50"], "outputs": ["0", "2", "1", "35", "0", "14", "11", "5"...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
517
codeforces
61f4b3564579a1f7b930cb0ef135aa17
Ilya and Bank Account
Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can be a negative number. This means that the owner of the account ow...
{"inputs": ["2230", "-10", "-100003", "544883178", "-847251738", "423654797", "-623563697", "645894116", "-384381709", "437587210", "-297534606", "891773002", "-56712976", "963662765", "-272656295", "383441522", "-477665112", "791725034", "-812168727", "528894922", "-479977172", "568044564", "-392784794", "925596634", ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
234
codeforces
620529f2264406c5758083e8026c0720
World Football Cup
Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations: - the final tournament features *n* teams (*n* is always even) - the first *n*<=/<=2 t...
{"inputs": ["4\nA\nB\nC\nD\nA-B 1:1\nA-C 2:2\nA-D 1:0\nB-C 1:0\nB-D 0:3\nC-D 0:3", "2\na\nA\na-A 2:1", "2\nEULEUbCmfrmqxtzvg\nuHGRmKUhDcxcfqyruwzen\nuHGRmKUhDcxcfqyruwzen-EULEUbCmfrmqxtzvg 13:92", "4\nTeMnHVvWKpwlpubwyhzqvc\nAWJwc\nbhbxErlydiwtoxy\nEVASMeLpfqwjkke\nAWJwc-TeMnHVvWKpwlpubwyhzqvc 37:34\nbhbxErlydiwtoxy-Te...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
49
codeforces
622f88a1bbe0ffe4c3d7e4698161b0f0
Magic Matrix
You're given a matrix *A* of size *n*<=×<=*n*. Let's call the matrix with nonnegative elements magic if it is symmetric (so *a**ij*<==<=*a**ji*), *a**ii*<==<=0 and *a**ij*<=≤<=*max*(*a**ik*,<=*a**jk*) for all triples *i*,<=*j*,<=*k*. Note that *i*,<=*j*,<=*k* do not need to be distinct. Determine if the matrix is mag...
{"inputs": ["3\n0 1 2\n1 0 2\n2 2 0", "2\n0 1\n2 3", "4\n0 1 2 3\n1 0 3 4\n2 3 0 5\n3 4 5 0", "5\n0 2 5 9 5\n2 0 5 9 5\n5 5 0 9 4\n9 9 9 0 9\n5 5 4 9 0", "10\n0 16 5 14 14 17 14 14 9 14\n16 0 16 16 16 17 16 16 16 16\n5 16 0 14 14 17 14 14 9 14\n14 16 14 0 7 17 3 8 14 12\n14 16 14 7 0 17 7 8 14 12\n17 17 17 17 17 0 17 1...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces
6252b2f7bbb9c359601f5f67e3a97eee
Artsem and Saunders
Artsem has a friend Saunders from University of Chicago. Saunders presented him with the following problem. Let [*n*] denote the set {1,<=...,<=*n*}. We will also write *f*:<=[*x*]<=→<=[*y*] when a function *f* is defined in integer points 1, ..., *x*, and all its values are integers from 1 to *y*. Now then, you are ...
{"inputs": ["3\n1 2 3", "3\n2 2 2", "2\n2 1", "1\n1", "2\n2 1", "2\n2 2", "5\n5 5 5 3 5", "10\n4 4 4 4 4 4 4 4 4 4", "2\n1 2", "3\n3 2 3", "3\n1 2 1", "4\n4 2 4 4", "5\n1 4 5 4 5", "4\n1 2 1 2", "5\n1 3 3 4 4", "4\n4 2 2 4", "7\n7 3 3 5 5 7 7", "6\n1 1 1 3 3 3", "4\n2 2 3 2", "6\n1 2 3 4 5 5", "3\n1 1 2", "4\n3 4 3 4",...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
20
codeforces
6254108ea889c419d9f8e2afba6f5ada
Babaei and Birthday Cake
As you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake. Simple cake is a cylinder of some radius and height. The volume of the simple cake is equal to the volume of corresponding cylinder. Babaei has *n* simple cakes and he is going to make a special ...
{"inputs": ["2\n100 30\n40 10", "4\n1 1\n9 7\n1 4\n10 7", "3\n2 2\n1 1\n3 3", "3\n2 2\n3 3\n1 1", "3\n3 3\n1 1\n2 2", "3\n1 1\n2 2\n3 3", "3\n1 1\n3 3\n2 2", "3\n3 3\n2 2\n1 1", "1\n1 1", "2\n1 1\n2 2", "2\n2 2\n1 1", "4\n1 1\n2 2\n3 3\n4 4", "4\n1 1\n2 2\n4 4\n3 3", "4\n1 1\n3 3\n2 2\n4 4", "4\n1 1\n3 3\n4 4\n2 2", "4...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
2
codeforces
626718e6c98f6f2994a519cc90bf888d
Suit and Tie
Allen is hosting a formal dinner party. $2n$ people come to the event in $n$ pairs (couples). After a night of fun, Allen wants to line everyone up for a final picture. The $2n$ people line up, but Allen doesn't like the ordering. Allen prefers if each pair occupies adjacent positions in the line, as this makes the pic...
{"inputs": ["4\n1 1 2 3 3 2 4 4", "3\n1 1 2 2 3 3", "3\n3 1 2 3 1 2", "8\n7 6 2 1 4 3 3 7 2 6 5 1 8 5 8 4", "2\n1 2 1 2", "3\n1 2 3 3 1 2", "38\n26 28 23 34 33 14 38 15 35 36 30 1 19 17 18 28 22 15 9 27 11 16 17 32 7 21 6 8 32 26 33 23 18 4 2 25 29 3 35 8 38 37 31 37 12 25 3 27 16 24 5 20 12 13 29 11 30 22 9 19 2 24 7 ...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
75
codeforces
62701aa73b10e5e72bb53185e0b68677
Desk Disorder
A new set of desks just arrived, and it's about time! Things were getting quite cramped in the office. You've been put in charge of creating a new seating chart for the engineers. The desks are numbered, and you sent out a survey to the engineering team asking each engineer the number of the desk they currently sit at,...
{"inputs": ["4\n1 5\n5 2\n3 7\n7 3", "5\n1 10\n2 10\n3 10\n4 10\n5 5", "1\n1 2", "30\n22 37\n12 37\n37 58\n29 57\n43 57\n57 58\n58 53\n45 4\n1 4\n4 51\n35 31\n21 31\n31 51\n51 53\n53 48\n60 55\n52 55\n55 33\n36 9\n10 9\n9 33\n33 19\n5 23\n47 23\n23 32\n50 44\n26 44\n44 32\n32 19\n19 48", "50\n73 1\n65 73\n16 65\n57 65\...
UNKNOWN
[ "PYTHON3" ]
CODEFORCES
1
codeforces