problem_id stringlengths 32 32 | name stringlengths 2 112 | problem stringlengths 200 14k | test_cases stringlengths 33 79.2M | difficulty stringclasses 34
values | language listlengths 1 1 | source stringclasses 15
values | num_solutions int64 1 1.12M | starter_code stringlengths 0 1.47k | subset stringclasses 4
values |
|---|---|---|---|---|---|---|---|---|---|
e8d060c6b763f49d3bfda0c2d5dc9baf | New Year and Domino | They say "years are like dominoes, tumbling one after the other". But would a year fit into a grid? I don't think so.
Limak is a little polar bear who loves to play. He has recently got a rectangular grid with *h* rows and *w* columns. Each cell is a square, either empty (denoted by '.') or forbidden (denoted by '#').... | {"inputs": ["5 8\n....#..#\n.#......\n##.#....\n##..#.##\n........\n4\n1 1 2 3\n4 1 4 1\n1 2 4 5\n2 5 5 8", "7 39\n.......................................\n.###..###..#..###.....###..###..#..###.\n...#..#.#..#..#.........#..#.#..#..#...\n.###..#.#..#..###.....###..#.#..#..###.\n.#....#.#..#....#.....#....#.#..#..#.#.\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 51 | codeforces | |
e8e54a74db5b00dcc2b92b7c2602e26c | Crunching Numbers Just for You | You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...
You are given an array of integers. Sort it in non-descending order.
The input consists of a single line of spac... | {"inputs": ["3 3 1 2", "10 54 100 27 1 33 27 80 49 27 6"], "outputs": ["1 2 3 ", "1 6 27 27 27 33 49 54 80 100 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | |
e8ef8fbc062cb5617ef9df7bd68624ef | Field of Wonders | Polycarpus takes part in the "Field of Wonders" TV show. The participants of the show have to guess a hidden word as fast as possible. Initially all the letters of the word are hidden.
The game consists of several turns. At each turn the participant tells a letter and the TV show host responds if there is such letter ... | {"inputs": ["4\na**d\n2\nabcd\nacbd", "5\nlo*er\n2\nlover\nloser", "3\na*a\n2\naaa\naba", "1\n*\n1\na", "1\n*\n1\nz", "1\n*\n2\na\nz", "2\n**\n1\naa", "2\n**\n1\nfx", "2\n**\n2\nfx\nab", "2\n**\n2\nfx\naf", "2\na*\n2\naa\nab", "4\na*b*\n2\nabbc\nadbd", "4\na*b*\n3\nabbc\nadbd\nacbe", "4\na*b*\n3\nabbc\nadbd\nacbd", "3\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 31 | codeforces | |
e8fe414f9d8189bc044503e9ec4a1b2d | Unfair Poll | On the Literature lesson Sergei noticed an awful injustice, it seems that some students are asked more often than others.
Seating in the class looks like a rectangle, where *n* rows with *m* pupils in each.
The teacher asks pupils in the following order: at first, she asks all pupils from the first row in the order ... | {"inputs": ["1 3 8 1 1", "4 2 9 4 2", "5 5 25 4 3", "100 100 1000000000000000000 100 100", "3 2 15 2 2", "4 1 8 3 1", "3 2 8 2 1", "4 2 9 4 1", "1 3 7 1 1", "2 2 8 2 1", "3 1 6 2 1", "5 6 30 5 4", "3 8 134010 3 4", "10 10 25 5 1", "100 100 1000000000 16 32", "100 100 1 23 39", "1 1 1000000000 1 1", "1 1 1 1 1", "47 39 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
e93b27341586dc75e694066814ae4cfc | A Leapfrog in the Array | Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.
Let's consider that i... | {"inputs": ["4 3\n2\n3\n4", "13 4\n10\n5\n4\n8", "2 2\n1\n2", "1 1\n1", "3 3\n3\n2\n1", "12 12\n9\n11\n5\n3\n7\n2\n8\n6\n4\n10\n12\n1"], "outputs": ["3\n2\n4", "13\n3\n8\n9", "1\n2", "1", "2\n3\n1", "5\n6\n3\n2\n4\n7\n12\n8\n10\n9\n11\n1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | |
e9436315da64d24762ce73416e7de23c | PawnChess | 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... | {"inputs": [".BB.B.B.\nB..B..B.\n.B.BB...\nBB.....B\nBBB....B\nB..BB...\nBB.B...B\n....WWW.", "B.B.BB.B\nW.WWW.WW\n.WWWWW.W\nW.BB.WBW\n.W..BBWB\nBB.WWBBB\n.W.W.WWB\nWWW..WW.", "BB..BB..\nBW.W.W.B\n..B.....\n.....BB.\n.B..B..B\n........\n...BB.B.\nW.WWWW.W", "BB......\nW....BBW\n........\n.B.B.BBB\n....BB..\nB....BB.\n.... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 61 | codeforces | |
e946dd7624e584fa77bc531a34654cce | My pretty girl Noora | In Pavlopolis University where Noora studies it was decided to hold beauty contest "Miss Pavlopolis University". Let's describe the process of choosing the most beautiful girl in the university in more detail.
The contest is held in several stages. Suppose that exactly *n* girls participate in the competition initiall... | {"inputs": ["2 2 4", "7 2444902 2613424", "7 2055976 2242066", "5 431999 611310", "9 1621304 1742530", "71 3517969 3712339", "95 941230 1053167", "242954372 1561852 4674408", "844079775 8212 4470298", "17205735 14 4402745", "451693431 631385 4779609", "613442910 7402 7402", "491601604 602162 602166", "959694842 4587040... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
e9487853622129fa4af1e16040fc61b9 | Vasya and Chess | Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.
The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the same vertical, horizontal or diagonal line with queen, and the cell cont... | {"inputs": ["2", "3", "4", "6", "10", "16", "100", "10006", "99966246", "1000000000", "999999999", "999999997", "900001", "775681", "666666", "12345", "111111", "346367", "13", "11", "9", "7", "5", "19", "939698497", "999999996"], "outputs": ["white\n1 2", "black", "white\n1 2", "white\n1 2", "white\n1 2", "white\n1 2"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 60 | codeforces | |
e94e71bac3d4be298a3178a4b1660147 | Summer Homework | By the age of three Smart Beaver mastered all arithmetic operations and got this summer homework from the amazed teacher:
You are given a sequence of integers *a*1,<=*a*2,<=...,<=*a**n*. Your task is to perform on it *m* consecutive operations of the following type:
1. For given numbers *x**i* and *v**i* assign valu... | {"inputs": ["5 5\n1 3 1 2 4\n2 1 4\n2 1 5\n2 2 4\n1 3 10\n2 1 5", "1 3\n2\n2 1 1\n1 1 3\n2 1 1", "11 11\n6 1 9 0 2 9 1 6 2 8 0\n2 9 9\n1 9 0\n1 1 8\n2 2 5\n2 7 11\n2 2 8\n1 3 2\n1 10 0\n2 1 8\n2 9 11\n1 9 7", "11 18\n14 13 18 17 14 17 13 3 0 3 21\n2 6 9\n2 1 6\n2 5 7\n2 1 3\n2 1 9\n2 3 9\n2 2 5\n2 7 10\n2 1 5\n2 4 6\n2... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
e954e4594799351cf3326beb7d94c2f9 | Professor GukiZ's Robot | Professor GukiZ makes a new robot. The robot are in the point with coordinates (*x*1,<=*y*1) and should go to the point (*x*2,<=*y*2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find the minimal numbe... | {"inputs": ["0 0\n4 5", "3 4\n6 1", "0 0\n4 6", "1 1\n-3 -5", "-1 -1\n-10 100", "1 -1\n100 -100", "-1000000000 -1000000000\n1000000000 1000000000", "-1000000000 -1000000000\n0 999999999", "0 0\n2 1", "10 0\n100 0", "1 5\n6 4", "0 0\n5 4", "10 1\n20 1", "1 1\n-3 4", "-863407280 504312726\n786535210 -661703810", "-588306... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 373 | codeforces | |
e95cd29952a0862bf4dd0af544ea2c51 | Danil and a Part-time Job | Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher.
Danil works in a rooted tree (undirected connected acyclic graph) with *n* vertices, vertex 1 is the root of the tree. There is a room in each vertex, light can be switched on or off in each ... | {"inputs": ["4\n1 1 1\n1 0 0 1\n9\nget 1\nget 2\nget 3\nget 4\npow 1\nget 1\nget 2\nget 3\nget 4", "1\n\n1\n4\npow 1\nget 1\npow 1\nget 1", "10\n1 2 3 4 2 4 1 7 8\n1 1 0 1 1 0 0 0 1 1\n10\npow 1\nget 2\npow 2\npow 8\nget 6\npow 6\npow 10\nget 6\npow 8\npow 3", "10\n1 1 1 4 5 3 5 6 3\n0 0 0 0 0 0 1 0 0 0\n10\nget 2\nget... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
e9a0b293e135c9a2a244df6e57d25ea1 | Rectangle Puzzle | You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the side that is parallel to the *Ox* axis, equals *w*, the length of the side... | {"inputs": ["1 1 45", "6 4 30", "100 100 0", "100 100 30", "303304 904227 3", "217708 823289 162", "872657 1807 27", "787062 371814 73", "925659 774524 134", "852428 738707 49", "991024 917226 95", "938133 287232 156", "76730 689942 119", "507487 609004 180", "646084 979010 45", "560489 381720 91", "991245 527535 69", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | |
e9b4a333053f8e447d675f051b0bc56d | Rewards | Bizon the Champion is called the Champion for a reason.
Bizon the Champion has recently got a present — a new glass cupboard with *n* shelves and he decided to put all his presents there. All the presents can be divided into two types: medals and cups. Bizon the Champion has *a*1 first prize cups, *a*2 second prize c... | {"inputs": ["1 1 1\n1 1 1\n4", "1 1 3\n2 3 4\n2", "1 0 0\n1 0 0\n1", "0 0 0\n0 0 0\n1", "100 100 100\n100 100 100\n100", "100 100 100\n100 100 100\n1", "1 10 100\n100 10 1\n20", "1 1 1\n0 0 0\n1", "0 0 0\n1 1 1\n1", "5 5 5\n0 0 0\n2", "0 0 0\n10 10 10\n2", "21 61 39\n63 58 69\n44", "18 95 4\n7 1 75\n46", "64 27 81\n72 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 233 | codeforces | |
e9ba4678ec42e794fd34f5aedb24d337 | Pretty Song | When Sasha was studying in the seventh grade, he started listening to music a lot. In order to evaluate which songs he likes more, he introduced the notion of the song's prettiness. The title of the song is a word consisting of uppercase Latin letters. The prettiness of the song is the prettiness of its title.
Let's d... | {"inputs": ["IEAIAIO", "BYOB", "YISVOWEL", "EZYYOIYUZXEVRTOUYXIQ", "MTOESEPRFEIWAIWLAFJMGBIQB", "ZUBQNDCHHKWNWRVSDSRRRTGZDDPNTVJFKTCNGWND", "POKKJNWMNCSXBJLDWVG", "KZTNJQLPZVHZKZWIB", "A", "Z"], "outputs": ["28.0000000", "5.8333333", "17.0500000", "124.0168163", "127.2203685", "7.5320861", "6.0428477", "5.8202815", "1.... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
e9ba47b7421ed5da8d6f98ef3d9211e7 | Arpa’s hard exam and Mehrdad’s naive cheat | There exists an island called Arpa’s land, some beautiful girls live there, as ugly ones do.
Mehrdad wants to become minister of Arpa’s land. Arpa has prepared an exam. Exam has only one question, given *n*, print the last digit of 1378*n*.
Mehrdad has become quite confused and wants you to help him. Please help, al... | {"inputs": ["1", "2", "1000", "3", "4", "1000000000", "5", "6", "999999999", "1378", "13781378", "51202278", "999999998", "999999997", "12193721", "0", "989898989", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "999999996", "999999995", "999999994"], "outputs": ["8", "4", "6", "2", "6", "6", "8", "4", "2", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 249 | codeforces | |
e9e80f61195367d9ed2defd646c130bd | Mister B and Angle in Polygon | On one quiet day all of sudden Mister B decided to draw angle *a* on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex *n*-gon (regular convex polygon with *n* sides).
That's why Mister B decided to use this polygon. Now Mister B must... | {"inputs": ["3 15", "4 67", "4 68", "3 1", "3 180", "100000 1", "100000 180", "100000 42", "100000 123", "5 1", "5 36", "5 54", "5 55", "5 70", "5 89", "5 90", "5 91", "5 111", "5 126", "5 127", "5 141", "5 162", "5 180", "6 46", "6 33", "13 4", "23 11", "11 119", "13 117", "18 174", "8509 139", "29770 76", "59115 40",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 82 | codeforces | |
ea1466c65e068662ccb93b9f2bf20b65 | none | As you very well know, the whole Universe traditionally uses three-dimensional Cartesian system of coordinates. In this system each point corresponds to three real coordinates (*x*,<=*y*,<=*z*). In this coordinate system, the distance between the center of the Universe and the point is calculated by the following formu... | {"inputs": ["3\n1 1 1", "3\n2 0 0", "10\n1 6 3", "9\n8 2 0", "1\n0 9 2", "1\n3 5 1", "7\n8 2 2", "9\n3 7 0", "1000\n0 0 0", "624\n553 828 109", "902\n742 737 340", "239\n995 385 267", "797\n917 702 538", "938\n414 308 795", "422\n215 779 900", "413\n569 138 159", "188\n748 859 686", "48\n395 552 466", "492\n971 305 807... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
ea20b41b37dc6350d0b88e4cf865a2b7 | Tic-Tac-Toe | Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.
The game is played on the following field.
Players are making moves by turns. At first move a player can put his chip in any cell of any small field... | {"inputs": ["... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n6 4", "xoo x.. x..\nooo ... ...\nooo ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n7 4", "o.. ... ...\n... ... ...\n... ... ...\n\n... xxx ..... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 110 | codeforces | |
ea27ab9331ead61abf67215950c36393 | Measuring Lengths in Baden | Lengths are measures in Baden in inches and feet. To a length from centimeters it is enough to know that an inch equals three centimeters in Baden and one foot contains 12 inches.
You are given a length equal to *n* centimeters. Your task is to convert it to feet and inches so that the number of feet was maximum. The ... | {"inputs": ["42", "5", "24", "1", "2", "3", "4", "8", "10", "12", "13", "100", "120", "199", "501", "1000", "1233", "9876", "9999", "10000", "35", "71"], "outputs": ["1 2", "0 2", "0 8", "0 0", "0 1", "0 1", "0 1", "0 3", "0 3", "0 4", "0 4", "2 9", "3 4", "5 6", "13 11", "27 9", "34 3", "274 4", "277 9", "277 9", "1 0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 58 | codeforces | |
ea2800a75bc8751cf70a0c054703d0cf | Two Substrings | You are given string *s*. Your task is to determine if the given string *s* contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).
The only line of input contains a string *s* of length between 1 and 105 consisting of uppercase Latin letters.
Print "YES" (without the quotes), if str... | {"inputs": ["ABA", "BACFAB", "AXBYBXA", "ABABAB", "BBBBBBBBBB", "ABBA", "ABAXXXAB", "TESTABAXXABTEST", "A", "B", "X", "BA", "AB", "AA", "BB", "BAB", "AAB", "BAA", "ABB", "BBA", "AAA", "BBB", "AXBXBXA", "SKDSKDJABSDBADKFJDK", "ABAXXBBXXAA", "ABAB", "BABA", "AAAB", "AAAA", "AABA", "ABAA", "BAAA", "AABB", "BAAB", "BBAA", ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 176 | codeforces | |
ea328bc26e5db89c9b42b288c49b2abc | none | Ivan had string *s* consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string *s*. Ivan preferred making a new string to finding the old one.
Ivan knows some information about the string *s*. Namely, he remembers, that string *t**i* occurs in string *s* at least *k**... | {"inputs": ["3\na 4 1 3 5 7\nab 2 1 5\nca 1 4", "1\na 1 3", "3\nab 1 1\naba 1 3\nab 2 3 5", "6\nba 2 16 18\na 1 12\nb 3 4 13 20\nbb 2 6 8\nababbbbbaab 1 3\nabababbbbb 1 1", "17\na 4 2 7 8 9\nbbaa 1 5\nba 2 1 6\naa 2 7 8\nb 6 1 3 4 5 6 10\nbbbaa 1 4\nbbba 1 4\nbab 1 1\nbba 1 5\nbbb 2 3 4\nbb 3 3 4 5\nab 1 2\nabbb 1 2\nb... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
ea4c5c905f3855d3cf2b5c06ce51f938 | Cashback | Since you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.
You are given an array *a* of length *n* and an integer *c*.
The value of some array *b* of length *k* is the sum of its elements except for the smallest. For example, the value of the array [3,<=1,<=6,<... | {"inputs": ["3 5\n1 2 3", "12 10\n1 1 10 10 10 10 10 10 9 10 10 10", "7 2\n2 3 6 4 5 7 1", "8 4\n1 3 4 5 5 3 4 1", "15 5\n11 15 16 24 24 28 36 40 49 49 53 55 66 73 100", "11 10\n58 97 93 74 59 59 76 59 59 59 30", "1 1\n1", "15 5\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1", "15 10\n2 3 3 3 3 3 3 3 3 3 3 3 3 3 1", "15 10\n4 5 5 5 5 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
ea506486c9daab1ea0288db21c6d80d1 | World Cup | Allen wants to enter a fan zone that occupies a round square and has $n$ entrances.
There already is a queue of $a_i$ people in front of the $i$-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute.
Allen uses the following strategy to enter the fan zone:
- Initially he s... | {"inputs": ["4\n2 3 2 0", "2\n10 10", "6\n5 2 6 5 7 4", "2\n483544186 940350702", "10\n3 3 3 5 6 9 3 1 7 3", "10\n0 8 45 88 48 68 28 55 17 24", "100\n8 8 9 10 6 8 2 4 2 2 10 6 6 10 10 2 3 5 1 2 10 4 2 0 9 4 9 3 0 6 3 2 3 10 10 6 4 6 4 4 2 5 1 4 1 1 9 8 9 5 3 5 5 4 5 5 6 5 3 3 7 2 0 10 9 7 7 3 5 1 0 9 6 3 1 3 4 4 3 6 3 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 12 | codeforces | |
ea6a40cbcf6bd18d19f3bef28f952fe8 | Vasya and Public Transport | Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has *n* buses and *m* trolleys, the buses are numbered by integers from 1 to *n*, the trolleys are numbered by integers from 1 to *m*.
Public transport is not free. There are 4 types of tickets:
1. A ticket fo... | {"inputs": ["1 3 7 19\n2 3\n2 5\n4 4 4", "4 3 2 1\n1 3\n798\n1 2 3", "100 100 8 100\n3 5\n7 94 12\n100 1 47 0 42", "3 103 945 1000\n7 9\n34 35 34 35 34 35 34\n0 0 0 0 0 0 0 0 0", "7 11 597 948\n4 1\n5 1 0 11\n7", "7 32 109 645\n1 3\n0\n0 0 0", "680 871 347 800\n10 100\n872 156 571 136 703 201 832 213 15 333\n465 435 87... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 64 | codeforces | |
ea714bf98e97eed297eaa11c6ac550bc | Anton and Lines | The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In the task he was given a set of *n* lines defined by the equations *y*<==<=*k**i*·*x*<=+<=*b**i*. It was necessary to determine whether there is at least one point of intersection of t... | {"inputs": ["4\n1 2\n1 2\n1 0\n0 1\n0 2", "2\n1 3\n1 0\n-1 3", "2\n1 3\n1 0\n0 2", "2\n1 3\n1 0\n0 3", "2\n0 1\n-1000000 1000000\n1000000 -1000000", "2\n-1337 1888\n-1000000 1000000\n1000000 -1000000", "2\n-1337 1888\n-1000000 1000000\n-999999 -1000000", "15\n30 32\n-45 1\n-22 -81\n4 42\n-83 -19\n97 70\n55 -91\n-45 -64... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 42 | codeforces | |
ea74d39916f5ed7f6f66014b10648f43 | Robot Vacuum Cleaner | Pushok the dog has been chasing Imp for a few hours already.
Fortunately, Imp knows that Pushok is afraid of a robot vacuum cleaner.
While moving, the robot generates a string *t* consisting of letters 's' and 'h', that produces a lot of noise. We define noise of string *t* as the number of occurrences of string "sh... | {"inputs": ["4\nssh\nhs\ns\nhhhs", "2\nh\ns", "6\nh\ns\nhhh\nh\nssssss\ns", "1\ns", "10\nsshshss\nhssssssssh\nhhhhhh\nhhhs\nhshhh\nhhhhshsh\nhh\nh\nshs\nsshhshhss", "100\nh\nshh\nh\nhs\nshh\nhh\nh\nssh\nhss\nh\nhh\nh\nh\nh\nh\nh\nh\nh\nh\nh\nhh\nh\nh\nh\nh\nhhh\nh\nh\nhhh\nsh\nhh\nhs\nh\nh\nshs\nh\nh\nh\nshh\nhs\nhs\nh... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 17 | codeforces | |
ea78c85fa0679b34e19d492a4f4fbbc7 | Good Substrings | You've got string *s*, consisting of small English letters. Some of the English letters are good, the rest are bad.
A substring *s*[*l*...*r*] (1<=≤<=*l*<=≤<=*r*<=≤<=|*s*|) of string *s*<=<==<=<=*s*1*s*2...*s*|*s*| (where |*s*| is the length of string *s*) is string <=*s**l**s**l*<=+<=1...*s**r*.
The substring *s*[*l... | {"inputs": ["ababab\n01000000000000000000000000\n1", "acbacbacaa\n00000000000000000000000000\n2", "a\n00000000000000000000000000\n0", "aaaa\n00000000000000000000000000\n0", "aaaaaa\n00000000000000000000000000\n1", "bbbbbbbbba\n01000000000000000000000000\n0", "bbbbbbbbba\n10000000000000000000000000\n0", "kqdwdulmgvugvbl... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | |
ea87810aa22004f346f63313d553a2f9 | Name | Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.
Two young parents abac and bbad think what name to give to their first-born child. They decided that the name will be the permutation of letters of string *s*. To ke... | {"inputs": ["aad\naac", "abad\nbob", "abc\ndefg", "czaaab\nabcdef", "a\na", "a\nb", "z\na", "aa\naa", "ab\naa", "aa\nab", "abc\naca", "abc\ncaa", "abab\naaba", "zaaa\naaaw", "abacaba\naba", "abacaba\nabababa", "abc\nbbb", "abc\ncac", "abc\naaac", "abc\nabbc", "abc\naabb", "abcabc\naaccba", "aabbaa\ncaaaaaaaaa", "aabbaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
ea889f9ca3c5eae8346616216b5a120e | Round House | Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to *n*. Entrance *n* and entrance 1 are adjacent.
Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance *a* and he decided that during his walk he will move around the house *b* entrances in th... | {"inputs": ["6 2 -5", "5 1 3", "3 2 7", "1 1 0", "1 1 -1", "1 1 1", "100 1 -1", "100 54 100", "100 37 -100", "99 41 0", "97 37 -92", "99 38 59", "35 34 1", "48 1 -1", "87 65 -76", "76 26 29", "100 65 0", "2 1 100", "3 2 -100", "1 1 100", "1 1 -100", "3 1 -100", "4 3 -100", "3 2 -12", "2 2 -100", "3 2 -90", "6 2 -10", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 212 | codeforces | |
ea97e7c41443f3897db52cd4d1f5d504 | Light It Up | Recently, you bought a brand new smart lamp with programming features. At first, you set up a schedule to the lamp. Every day it will turn power on at moment $0$ and turn power off at moment $M$. Moreover, the lamp allows you to set a program of switching its state (states are "lights on" and "lights off"). Unfortunate... | {"inputs": ["3 10\n4 6 7", "2 12\n1 10", "2 7\n3 4", "1 2\n1", "5 10\n1 3 5 6 8", "7 1000000000\n1 10001 10011 20011 20021 40021 40031", "7 1000000000\n3 10001 10011 20011 20021 40021 40031", "1 10\n1", "1 10000000\n1", "1 8\n1", "7 17\n1 5 9 10 11 14 16", "4 17\n1 5 9 10", "5 12\n1 2 3 4 5", "2 1000000000\n100 111", "... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 162 | codeforces | |
eab4a34e792de7818ab268da734745b6 | Enduring Exodus | In an attempt to escape the Mischievous Mess Makers' antics, Farmer John has abandoned his farm and is traveling to the other side of Bovinia. During the journey, he and his *k* cows have decided to stay at the luxurious Grand Moo-dapest Hotel. The hotel consists of *n* rooms located in a row, some of which are occupie... | {"inputs": ["7 2\n0100100", "5 1\n01010", "3 2\n000", "10 1\n1101111101", "2 1\n00", "3 1\n010", "8 7\n00000000", "7 6\n0000000", "112 12\n0110101000000010101110010111100101011010011110100111111100011101011111000111101101110100111011110001100110110010", "9 8\n000000000", "9 3\n010001000", "5 3\n00000", "8 7\n00000000",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 26 | codeforces | |
eabcd07fee296c3e23fe3896ca4aa001 | A and B and Chess | A and B are preparing themselves for programming contests.
To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.
For each chess piece we know its weight:
- the queen's weight is 9, - the rook's weight is 5, - the bisho... | {"inputs": ["rnbqkbnr\npppppppp\n........\n........\n........\n........\nPPPPPPPP\nRNBQKBNR", "....bQ.K\n.B......\n.....P..\n........\n........\n........\n...N.P..\n.....R..", "b....p..\nR.......\n.pP...b.\npp......\nq.PPNpPR\n..K..rNn\nP.....p.\n...Q..B.", "...Nn...\n........\n........\n........\n.R....b.\n........\n.... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 100 | codeforces | |
eac03c31f374da8998234c71c2496881 | Om Nom and Candies | A sweet little monster Om Nom loves candies very much. One day he found himself in a rather tricky situation that required him to think a bit in order to enjoy candies the most. Would you succeed with the same task if you were on his place?
One day, when he came to his friend Evan, Om Nom didn't find him at home but h... | {"inputs": ["10 3 5 2 3", "5 3 1 6 7", "982068341 55 57 106 109", "930064129 32726326 25428197 83013449 64501049", "927155987 21197 15994 54746 41309", "902303498 609628987 152407246 8 2", "942733698 9180 9072 1020 1008", "951102310 39876134 24967176 70096104 43888451", "910943911 107 105 60 59", "910943911 38162 31949... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 6 | codeforces | |
eb08ac6547136d7a61bc73f76e633bec | Choosing Teams | The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has *n* students. For each student you know the number of times he/she has participated in the ACM ICPC world programming championship. According to the ACM ICPC rules, each person can participate in the world championship at most 5 times.
Th... | {"inputs": ["5 2\n0 4 5 1 0", "6 4\n0 1 2 3 4 5", "6 5\n0 0 0 0 0 0", "3 4\n0 1 0", "3 4\n0 2 0", "6 5\n0 0 0 0 0 0", "12 2\n0 1 2 3 4 0 1 2 3 4 0 1", "15 2\n0 1 2 3 4 0 1 2 3 4 0 1 2 3 4", "13 1\n5 0 5 0 1 5 0 4 1 1 1 4 1", "20 1\n5 0 4 2 2 3 2 1 2 4 1 3 5 5 5 4 4 1 3 0", "20 2\n1 4 5 1 3 4 0 5 0 3 3 0 4 0 0 1 4 2 0 4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1,007 | codeforces | |
eb3b920526be9ea37a4c0f8c8d250671 | Santa Claus and Candies | Santa Claus has *n* candies, he dreams to give them as gifts to children.
What is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all *n* candies he has.
The only line contains positive integer n... | {"inputs": ["5", "9", "2", "1", "3", "1000", "4", "6", "7", "8", "10", "11", "12", "13", "14", "15", "16", "20", "21", "22", "27", "28", "29", "35", "36", "37", "44", "45", "46", "230", "231", "232", "239", "629", "630", "631", "945", "946", "947", "989", "990", "991", "956", "981", "867", "906", "999", "100", "126"], ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 288 | codeforces | |
eb61db945f3becf1cef42dc551e366fc | Palindromes in a Tree | You are given a tree (a connected acyclic undirected graph) of *n* vertices. Vertices are numbered from 1 to *n* and each vertex is assigned a character from a to t.
A path in the tree is said to be palindromic if at least one permutation of the labels in the path is a palindrome.
For each vertex, output the number o... | {"inputs": ["5\n1 2\n2 3\n3 4\n3 5\nabcbb", "7\n6 2\n4 3\n3 7\n5 2\n7 2\n1 4\nafefdfs", "5\n3 1\n3 5\n5 4\n5 2\nticdm", "10\n10 8\n3 2\n9 7\n1 5\n5 3\n7 6\n8 4\n10 9\n2 6\nqbilfkqcll", "20\n10 9\n15 14\n11 12\n2 3\n15 16\n2 1\n18 19\n20 19\n8 9\n7 6\n8 7\n12 13\n5 6\n4 3\n13 14\n18 17\n11 10\n16 17\n5 4\naabbccddeeffgg... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
eb6b9fc1c91d845a2b77258e5ac780a2 | Anastasia and pebbles | Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in the park.
She has only two pockets. She can put at most *k* pebbles in each pocket at the same tim... | {"inputs": ["3 2\n2 3 4", "5 4\n3 1 8 9 7", "1 22\n1", "3 57\n78 165 54", "5 72\n74 10 146 189 184", "9 13\n132 87 200 62 168 51 185 192 118", "1 1\n10000", "10 1\n1 1 1 1 1 1 1 1 1 1", "2 2\n2 2"], "outputs": ["3", "5", "1", "3", "6", "48", "5000", "5", "1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 233 | codeforces | |
eb6bc5b829705259591a6f49ca015bae | Mahmoud and Ehab and yet another xor task | Ehab has an array *a* of *n* integers. He likes the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) and he likes to bother Mahmoud so he came up with a problem. He gave Mahmoud *q* queries. In each of them, he gave Mahmoud 2 integers *l* and *x*, and asked him to find the number of subseque... | {"inputs": ["5 5\n0 1 2 3 4\n4 3\n2 0\n3 7\n5 7\n5 8", "3 2\n1 1 1\n3 1\n2 0", "20 20\n353123 353123 677328 353123 0 997043 677328 420884 968991 566539 420884 801220 1030642 937882 762558 599450 196420 299659 101896 600581\n14 764540\n10 140147\n20 631492\n15 403662\n14 730429\n11 566539\n2 353123\n9 353123\n18 463456\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
eb7fe32e1f4b40295a8566b7a4956313 | Weakness and Poorness | You are given a sequence of n integers *a*1,<=*a*2,<=...,<=*a**n*.
Determine a real number *x* such that the weakness of the sequence *a*1<=-<=*x*,<=*a*2<=-<=*x*,<=...,<=*a**n*<=-<=*x* is as small as possible.
The weakness of a sequence is defined as the maximum value of the poorness over all segments (contiguous su... | {"inputs": ["3\n1 2 3", "4\n1 2 3 4", "10\n1 10 2 9 3 8 4 7 5 6", "1\n-10000", "3\n10000 -10000 10000", "20\n-16 -23 29 44 -40 -50 -41 34 -38 30 -12 28 -44 -49 15 50 -28 38 -2 0", "10\n-405 -230 252 -393 -390 -259 97 163 81 -129"], "outputs": ["1.000000000000000", "2.000000000000000", "4.500000000000000", "0.0000000000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
eb9f0d71bc5e7db3dc9654b0e76c8a88 | Fixing Typos | Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.
In this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for example, word "helllo" ... | {"inputs": ["helloo", "woooooow", "aabbaa", "yesssssss", "aabbaabbaabbaabbaabbaabbcccccc", "aaa", "abbbbbccbbbbbbbccccbbbbzbbbbbccbbbbbbbccccbbbbxybbbbbccbbbbbbbccccbbbb", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 18 | codeforces | |
ebb086d69d50f3fad48f0133208f782b | Sereja and Mirroring | Let's assume that we are given a matrix *b* of size *x*<=×<=*y*, let's determine the operation of mirroring matrix *b*. The mirroring of matrix *b* is a 2*x*<=×<=*y* matrix *c* which has the following properties:
- the upper half of matrix *c* (rows with numbers from 1 to *x*) exactly matches *b*; - the lower half o... | {"inputs": ["4 3\n0 0 1\n1 1 0\n1 1 0\n0 0 1", "3 3\n0 0 0\n0 0 0\n0 0 0", "8 1\n0\n1\n1\n0\n0\n1\n1\n0", "10 4\n0 0 1 0\n0 0 1 0\n1 1 0 1\n0 0 1 1\n1 0 1 0\n1 0 1 0\n0 0 1 1\n1 1 0 1\n0 0 1 0\n0 0 1 0", "10 3\n0 0 0\n1 1 1\n1 1 0\n0 0 0\n0 1 1\n0 1 1\n0 0 0\n1 1 0\n1 1 1\n0 0 0", "8 4\n1 0 0 0\n1 1 0 0\n1 0 0 1\n1 1 1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 49 | codeforces | |
ebbf2ce66da611800a98db2b6e240fec | Underfail | You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountered two unusually looking skeletons called Sanz and P’pairus, who decided to accompany you and give you some puzzle... | {"inputs": ["6\nabacba\n2\naba 6\nba 3\n3", "6\nabacba\n2\naba 6\nba 3\n1", "6\nabacba\n5\naba 6\nba 3\nbac 4\ncb 3\nc 6\n2", "6\nabacba\n5\naba 6\nba 3\nbac 4\ncb 3\nc 6\n1", "7\nafxfxfg\n3\nf 3\nx 2\nfxf 6\n1", "11\nfghdgrakmnq\n8\nfgh 4\ngh 3\nh 10\nhdg 6\nhdgra 7\nakm 12\nrakm 5\na 15\n3", "8\naxghcdex\n5\naxgh 13\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
ebc6d8198d92dcc6389b6e6800d27ac5 | Vanya and Table | Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right.
In this table, Vanya chose *n* rectangles with sides that go along borders of squares (some rectangles probably occur mu... | {"inputs": ["2\n1 1 2 3\n2 2 3 3", "2\n1 1 3 3\n1 1 3 3", "5\n4 11 20 15\n7 5 12 20\n10 8 16 12\n7 5 12 15\n2 2 20 13", "5\n4 11 20 20\n6 11 20 16\n5 2 19 15\n11 3 18 15\n3 2 14 11", "5\n1 1 1 100\n1 1 1 100\n1 1 1 100\n1 1 1 100\n1 1 1 100", "1\n1 1 1 1", "1\n100 100 100 100", "1\n1 1 1 100", "3\n1 1 1 1\n1 2 1 2\n1 3... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 116 | codeforces | |
ebd1932af5753d368e362327f9dccc1f | Game with Powers | Vasya and Petya wrote down all integers from 1 to *n* to play the "powers" game (*n* can be quite large; however, Vasya and Petya are not confused by this fact).
Players choose numbers in turn (Vasya chooses first). If some number *x* is chosen at the current turn, it is forbidden to choose *x* or all of its other pos... | {"inputs": ["1", "2", "8", "52", "53", "3", "4", "5", "6", "7", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "200", "246", "247", "248", "249", "250", "10153", "10154", "10155", "200702", "200703", "200704", "200705", "200706", "19000880", "19000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
ebd38a0a5c6f96dbd3510a8558a90998 | Boxes And Balls | Ivan has *n* different boxes. The first of them contains some balls of *n* different colors.
Ivan wants to play a strange game. He wants to distribute the balls into boxes in such a way that for every *i* (1<=≤<=*i*<=≤<=*n*) *i*-th box will contain all balls with color *i*.
In order to do this, Ivan will make some tu... | {"inputs": ["3\n1 2 3", "4\n2 3 4 5", "6\n1 4 4 4 4 4", "8\n821407370 380061316 428719552 90851747 825473738 704702117 845629927 245820158", "1\n10", "1\n4", "1\n12312", "1\n1", "2\n3 4"], "outputs": ["6", "19", "38", "8176373828", "0", "0", "0", "0", "7"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 26 | codeforces | |
ebe254ac02080f08c2de7e14791a211a | Night at the Museum | Grigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.
Embosser is a special devise that allows to "print" the text of a plastic tape. Text is printed sequentially, character by character... | {"inputs": ["zeus", "map", "ares", "l", "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuv", "gngvi", "aaaaa", "a", "z", "vyadeehhikklnoqrs", "jjiihhhhgggfedcccbazyxx", "fyyptqqxuciqvwdewyppjdzur", "fqcnzmzmbobmancqcoalzmanaobpdse", "zzzzzaaaaaaazzzzzzaaaaaaazzzzzzaaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1,067 | codeforces | |
ec1bcbab246384797e7e84147912b38e | Planting Trees | Vasya is a Greencode wildlife preservation society proponent. One day he found an empty field nobody owned, divided it into *n*<=×<=*m* squares and decided to plant a forest there. Vasya will plant *nm* trees of all different heights from 1 to *nm*. For his forest to look more natural he wants any two trees growing in ... | {"inputs": ["2 3", "2 1", "1 1", "1 2", "1 3", "1 4", "1 5", "1 6", "1 98", "1 99", "1 100", "1 1", "2 1", "3 1", "4 1", "5 1", "6 1", "98 1", "99 1", "100 1", "2 2", "2 4", "2 5", "2 6", "2 99", "2 100", "3 2", "3 3", "3 4", "3 5", "3 99", "3 100", "4 2", "4 3", "4 4", "4 5", "4 99", "4 100", "5 2", "5 3", "5 4", "5 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
ec1ddab062f5eecb7a4aacb90cb5fa2e | Rat Kwesh and Cheese | Wet Shark asked Rat Kwesh to generate three positive real numbers *x*, *y* and *z*, from 0.1 to 200.0, inclusive. Wet Krash wants to impress Wet Shark, so all generated numbers will have exactly one digit after the decimal point.
Wet Shark knows Rat Kwesh will want a lot of cheese. So he will give the Rat an opportuni... | {"inputs": ["1.1 3.4 2.5", "2.0 2.0 2.0", "1.9 1.8 1.7", "2.0 2.1 2.2", "1.5 1.7 2.5", "1.1 1.1 1.1", "4.2 1.1 1.2", "113.9 125.2 88.8", "185.9 9.6 163.4", "198.7 23.7 89.1", "141.1 108.1 14.9", "153.9 122.1 89.5", "25.9 77.0 144.8", "38.7 142.2 89.8", "51.5 156.3 145.1", "193.9 40.7 19.7", "51.8 51.8 7.1", "64.6 117.1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 5 | codeforces | |
ec34ac0f05f569c72bc274cc46a1ae83 | Crossword | Vasya trains to compose crossword puzzles. He can only compose crosswords of a very simplе type so far. All of them consist of exactly six words; the words can be read only from top to bottom vertically and from the left to the right horizontally. The words are arranged in the form of a rectangular "eight" or infinity ... | {"inputs": ["NOD\nBAA\nYARD\nAIRWAY\nNEWTON\nBURN", "AAA\nAAA\nAAAAA\nAAA\nAAA\nAAAAA", "PTC\nJYNYFDSGI\nZGPPC\nIXEJNDOP\nJJFS\nSSXXQOFGJUZ", "BAMSVFSFVUWRXSABRGSOINNWAQR\nUWHQCTMHVKWAWVT\nUACWQUGQUXXTBLUDFGCHB\nTXHHXRYEEAMLFWKSRUEBAZSUEYU\nROCCNYN\nUCWYOHJYZQGYN", "ABA\nCABA\nDABA\nCABA\nGIP\nTOII", "XOWGMRPLRJMSMEDRT... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
ec6093d406c61d479fbc0a78b0e39325 | Dima and Hares | Dima liked the present he got from Inna very much. He liked the present he got from Seryozha even more.
Dima felt so grateful to Inna about the present that he decided to buy her *n* hares. Inna was very happy. She lined up the hares in a row, numbered them from 1 to *n* from left to right and started feeding them wi... | {"inputs": ["4\n1 2 3 4\n4 3 2 1\n0 1 1 0", "7\n8 5 7 6 1 8 9\n2 7 9 5 4 3 1\n2 3 3 4 1 1 3", "3\n1 1 1\n1 2 1\n1 1 1", "7\n1 3 8 9 3 4 4\n6 0 6 6 1 8 4\n9 6 3 7 8 8 2", "2\n3 5\n9 8\n4 0", "7\n3 6 1 5 4 2 0\n9 7 3 7 2 6 0\n1 6 5 7 5 4 1", "1\n0\n1\n4", "1\n7\n1\n7", "8\n7 3 3 5 9 9 8 1\n8 2 6 6 0 3 8 0\n1 2 5 0 9 4 7 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 13 | codeforces | |
ec6954a439dbc886dbd02979577beaa8 | Average Score | After the educational reform Polycarp studies only two subjects at school, Safety Studies and PE (Physical Education). During the long months of the fourth term, he received *n* marks in them. When teachers wrote a mark in the journal, they didn't write in what subject the mark was for, they just wrote the mark.
Now i... | {"inputs": ["5\n3 2\n4 4 5 4 4", "4\n2 2\n3 5 4 5", "6\n1 5\n4 4 4 5 4 4", "4\n2 2\n2 1 3 3", "9\n3 6\n4 5 4 1 2 2 2 4 5", "2\n1 1\n4 4", "2\n1 1\n5 1", "3\n2 1\n1 2 2", "3\n1 2\n1 2 2", "3\n1 2\n1 2 3", "3\n2 1\n5 5 5", "4\n2 2\n1 2 2 3", "4\n1 3\n2 1 2 2", "4\n3 1\n2 1 2 2", "4\n3 1\n2 1 3 3", "4\n1 3\n2 3 3 3", "5\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | |
ec696b189ffe655aed8f50671e7ecc61 | String Typing | You are given a string *s* consisting of *n* lowercase Latin letters. You have to type this string using your keyboard.
Initially, you have an empty string. Until you type the whole string, you may perform the following operation:
- add a character to the end of the string.
Besides, at most once you may perform one... | {"inputs": ["7\nabcabca", "8\nabcdefgh", "100\nmhnzadklojbuumkrxjayikjhwuxihgkinllackcavhjpxlydxcmhnzadklojbuumkrxjayikjhwuxihgkinllackcavhjpxlydxc", "99\ntrolnjmzxxrfxuexcqpjvefndwuxwsukxwmjhhkqmlzuhrplrtrolnjmzxxrfxuexcqpjvefndwuxwsukxwmjhhkqmlzuhrplrm", "100\nyeywsnxcwslfyiqbbeoaawtmioksfdndptxxcwzfmrpcixjbzvicijofj... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | |
ed36ccf2b276a8c6143251b80d106d88 | Strange Addition | Unfortunately, Vasya can only sum pairs of integers (*a*, *b*), such that for any decimal place at least one number has digit 0 in this place. For example, Vasya can sum numbers 505 and 50, but he cannot sum 1 and 4.
Vasya has a set of *k* distinct non-negative integers *d*1,<=*d*2,<=...,<=*d**k*.
Vasya wants to choo... | {"inputs": ["4\n100 10 1 0", "3\n2 70 3", "39\n16 72 42 70 17 36 32 40 47 94 27 30 100 55 23 77 67 28 49 50 53 83 38 33 60 65 62 64 6 66 69 86 96 75 85 0 89 73 29", "50\n20 67 96 6 75 12 37 46 38 86 83 22 10 8 21 2 93 9 81 49 69 52 63 62 70 92 97 40 47 99 16 85 48 77 39 100 28 5 11 44 89 1 19 42 35 27 7 14 88 33", "2\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 24 | codeforces | |
ed3db0986ebe3ad377cd14cab75ec8ef | none | There is a rectangular grid of *n* rows of *m* initially-white cells each.
Arkady performed a certain number (possibly zero) of operations on it. In the *i*-th operation, a non-empty subset of rows *R**i* and a non-empty subset of columns *C**i* are chosen. For each row *r* in *R**i* and each column *c* in *C**i*, the... | {"inputs": ["5 8\n.#.#..#.\n.....#..\n.#.#..#.\n#.#....#\n.....#..", "5 5\n..#..\n..#..\n#####\n..#..\n..#..", "5 9\n........#\n#........\n..##.#...\n.......#.\n....#.#.#", "1 1\n#", "2 1\n.\n#", "2 5\n.####\n#..##", "5 2\n##\n##\n..\n##\n..", "5 2\n#.\n##\n##\n#.\n..", "4 10\n###..#..##\n...##..#..\n.##..#..#.\n......... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 84 | codeforces | |
ed6198d759f796ee6d8694da686f11a9 | Present | Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his informatics teacher is going to have a birthday and the beaver has decided to prepare a present for her. He planted *n* flowers in a row on his windowsill and started waiting for them to grow. However, after some time the beaver no... | {"inputs": ["6 2 3\n2 2 2 2 1 1", "2 5 1\n5 8", "1 1 1\n1", "3 2 3\n999999998 999999998 999999998", "10 8 3\n499 498 497 497 497 497 497 497 498 499", "11 18 8\n4996 4993 4988 4982 4982 4982 4982 4982 4986 4989 4994", "1 100000 1\n1000000000", "4 100 3\n1 100000 100000 1"], "outputs": ["2", "9", "2", "1000000000", "500... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 17 | codeforces | |
eda1e2852cb7129fa18c2743586c73a1 | The same permutation | Seyyed and MoJaK are friends of Sajjad. Sajjad likes a permutation. Seyyed wants to change the permutation in a way that Sajjad won't like it. Seyyed thinks more swaps yield more probability to do that, so he makes MoJaK to perform a swap between every pair of positions (*i*,<=*j*), where *i*<=<<=*j*, exactly once. ... | {"inputs": ["3", "1", "5", "6", "7", "8", "1000", "901", "800", "772", "10", "766", "555", "999", "997", "150", "808", "809", "899", "111", "2", "22", "695", "972", "245", "406", "219", "760", "609", "974", "431", "656", "801", "186", "75", "964", "161", "898", "731", "568", "845", "26", "551", "748", "917", "310", "84... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
edc5da9755841b3c40687396c3fbb42d | On a plane | The first line contains a single integer *n* (1<=≤<=*n*<=≤<=1000) — the number of points on a plane.
Each of the next *n* lines contains two real coordinates *x**i* and *y**i* of the point, specified with exactly 2 fractional digits. All coordinates are between <=-<=1000 and 1000, inclusive.
Output a single real num... | {"inputs": ["8\n-2.14 2.06\n-1.14 2.04\n-2.16 1.46\n-2.14 0.70\n-1.42 0.40\n-0.94 -0.48\n-1.42 -1.28\n-2.16 -1.62", "5\n2.26 1.44\n2.28 0.64\n2.30 -0.30\n1.58 0.66\n3.24 0.66", "8\n6.98 2.06\n6.40 1.12\n5.98 0.24\n5.54 -0.60\n7.16 0.30\n7.82 1.24\n8.34 0.24\n8.74 -0.76", "5\n10.44 2.06\n10.90 0.80\n11.48 -0.48\n12.06 0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | |
edd90ec0fb4192d4cf2ab1cba9399a94 | Free Cash | Valera runs a 24/7 fast food cafe. He magically learned that next day *n* people will visit his cafe. For each person we know the arrival time: the *i*-th person comes exactly at *h**i* hours *m**i* minutes. The cafe spends less than a minute to serve each client, but if a client comes in and sees that there is no free... | {"inputs": ["4\n8 0\n8 10\n8 10\n8 45", "3\n0 12\n10 11\n22 22", "5\n12 8\n15 27\n15 27\n16 2\n19 52", "7\n5 6\n7 34\n7 34\n7 34\n12 29\n15 19\n20 23", "8\n0 36\n4 7\n4 7\n4 7\n11 46\n12 4\n15 39\n18 6", "20\n4 12\n4 21\n4 27\n4 56\n5 55\n7 56\n11 28\n11 36\n14 58\n15 59\n16 8\n17 12\n17 23\n17 23\n17 23\n17 23\n17 23\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 330 | codeforces | |
ede3277e0b4e9adcab46d69aeb3e1e52 | Simple Skewness | Define the simple skewness of a collection of numbers to be the collection's mean minus its median. You are given a list of *n* (not necessarily distinct) integers. Find the non-empty subset (with repetition) with the maximum simple skewness.
The mean of a collection is the average of its elements. The median of a col... | {"inputs": ["4\n1 2 3 12", "4\n1 1 2 2", "2\n1 2", "1\n1000000", "20\n999999 999998 999996 999992 999984 999968 999936 999872 999744 999488 998976 997952 995904 991808 983616 967232 934464 868928 737856 475712", "21\n999999 999998 999996 999992 999984 999968 999936 999872 999744 999488 998976 997952 995904 991808 98361... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
edfcbfd7e4c41d5aa3ea7d87b45ca8c5 | Bash and a Tough Math Puzzle | Bash likes playing with arrays. He has an array *a*1,<=*a*2,<=... *a**n* of *n* integers. He likes to guess the greatest common divisor (gcd) of different segments of the array. Of course, sometimes the guess is not correct. However, Bash will be satisfied if his guess is almost correct.
Suppose he guesses that the gc... | {"inputs": ["3\n2 6 3\n4\n1 1 2 2\n1 1 3 3\n2 1 9\n1 1 3 2", "5\n1 2 3 4 5\n6\n1 1 4 2\n2 3 6\n1 1 4 2\n1 1 5 2\n2 5 10\n1 1 5 2", "1\n1000000000\n1\n1 1 1 1000000000", "4\n3 3 7 7\n1\n1 1 4 3"], "outputs": ["YES\nYES\nNO", "NO\nYES\nNO\nYES", "YES", "NO"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
ee0338e504b3be3af2f6f6a8319b86cd | Hacker, pack your bags! | It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha.
So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world. For such zeal boss gave the hacker a vacation of exactly *x* days. Y... | {"inputs": ["4 5\n1 3 4\n1 2 5\n5 6 1\n1 2 4", "3 2\n4 6 3\n2 4 1\n3 5 4", "2 1855\n159106 161198 437057705\n149039 158409 889963913", "15 17\n1 10 8\n5 19 1\n12 14 6\n9 19 8\n6 7 3\n5 11 9\n7 12 5\n17 20 8\n6 12 6\n11 19 4\n3 14 1\n15 19 10\n3 20 5\n5 19 9\n10 18 10", "15 7\n16 18 6\n11 15 2\n5 17 3\n4 5 1\n3 11 5\n13... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
ee290edbd5a1f89e87bcf4c569f8b0ac | Marks | Vasya, or Mr. Vasily Petrov is a dean of a department in a local university. After the winter exams he got his hands on a group's gradebook.
Overall the group has *n* students. They received marks for *m* subjects. Each student got a mark from 1 to 9 (inclusive) for each subject.
Let's consider a student the best at ... | {"inputs": ["3 3\n223\n232\n112", "3 5\n91728\n11828\n11111", "2 2\n48\n27", "2 1\n4\n6", "1 2\n57", "1 1\n5", "3 4\n2553\n6856\n5133", "8 7\n6264676\n7854895\n3244128\n2465944\n8958761\n1378945\n3859353\n6615285", "9 8\n61531121\n43529859\n18841327\n88683622\n98995641\n62741632\n57441743\n49396792\n63381994", "10 20\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 355 | codeforces | |
ee5b860445484c793c2090948a1390f4 | Cheap Travel | Ann has recently started commuting by subway. We know that a one ride subway ticket costs *a* rubles. Besides, Ann found out that she can buy a special ticket for *m* rides (she can buy it several times). It costs *b* rubles. Ann did the math; she will need to use subway *n* times. Help Ann, tell her what is the minimu... | {"inputs": ["6 2 1 2", "5 2 2 3", "10 3 5 1", "1000 1 1000 1000", "1000 3 1000 1000", "1 1 1 1", "10 2 1 1", "1 1000 1 2", "1 1000 3 2", "10 3 1 2", "995 1 2 1", "556 2 16 15", "477 2 16 14", "101 110 1 100", "9 3 3 10", "100 8 10 1", "6 4 1 3", "8 5 2 8", "1000 2 1 1000"], "outputs": ["6", "8", "4", "1000000", "334000... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 211 | codeforces | |
ee669d4259b4c354077301faf4447276 | Lucky Substring | Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
One day Petya was delivered a string *s*, containing only digits. He needs to find a string that
- ... | {"inputs": ["047", "16", "472747", "1925", "5486846414848445484", "516160414", "9458569865994896", "94894948577777777884888", "00000", "9589", "7665711", "538772857", "8679647744", "23607019991994", "86145305734278927901987281894864719533015270066521", "22438808523154336905543301642540261833729318191", "290732082244359... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 19 | codeforces | |
ee9f800ad09193009ed6954de62a602e | Batch Sort | You are given a table consisting of *n* rows and *m* columns.
Numbers in each row form a permutation of integers from 1 to *m*.
You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than once you are allowed to pick two columns and swap them. Thus, you are al... | {"inputs": ["2 4\n1 3 2 4\n1 3 4 2", "4 4\n1 2 3 4\n2 3 4 1\n3 4 1 2\n4 1 2 3", "3 6\n2 1 3 4 5 6\n1 2 4 3 5 6\n1 2 3 4 6 5", "3 10\n1 2 3 4 5 6 7 10 9 8\n5 2 3 4 1 6 7 8 9 10\n1 2 3 4 5 6 7 8 9 10", "5 12\n1 2 3 4 5 6 7 10 9 8 11 12\n1 2 3 4 5 6 7 10 9 8 11 12\n1 2 3 8 5 6 7 10 9 4 11 12\n1 5 3 4 2 6 7 10 9 8 11 12\n1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 32 | codeforces | |
eecb6998b9428babfb66e5c53e2102c3 | Game with String | Vasya and Kolya play a game with a string, using the following rules. Initially, Kolya creates a string *s*, consisting of small English letters, and uniformly at random chooses an integer *k* from a segment [0,<=*len*(*s*)<=-<=1]. He tells Vasya this string *s*, and then shifts it *k* letters to the left, i. e. create... | {"inputs": ["technocup", "tictictactac", "bbaabaabbb", "cbbbbcaaca", "cadbcdddda", "bababbdaee", "fabbbhgedd", "gaejllebhn", "bbababaaababaabbbbbabbbbbbaaabbabaaaaabbbbbaaaabbbbabaabaabababbbabbabbabaaababbabbababaaaaabaaaabbb", "eaaebccaeacdecaedcaabbbdeebccdcdaabeeaeeaddbaabdccebecebbbbedbdcbbbbbbecbaddcddcccdcbbadbe... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
eeea6d294ad71f72291c70c42d7bc5dd | Modulo Sum | You are given a sequence of numbers *a*1,<=*a*2,<=...,<=*a**n*, and a number *m*.
Check if it is possible to choose a non-empty subsequence *a**i**j* such that the sum of numbers in this subsequence is divisible by *m*.
The first line contains two numbers, *n* and *m* (1<=≤<=*n*<=≤<=106, 2<=≤<=*m*<=≤<=103) — the size ... | {"inputs": ["3 5\n1 2 3", "1 6\n5", "4 6\n3 1 1 3", "6 6\n5 5 5 5 5 5", "4 5\n1 1 1 1", "5 5\n1 1 1 1 1", "4 7\n1 2 3 3", "1 47\n0", "2 47\n1 0", "9 11\n8 8 8 8 8 8 8 8 5", "10 11\n8 8 8 8 8 8 8 8 7 8", "3 5\n2 1 3", "100 968\n966 966 967 966 967 967 967 967 966 966 966 967 966 966 966 967 967 966 966 967 967 967 967 9... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 15 | codeforces | |
eeec33d280b9716e115cd0080f123cb9 | Primal Sport | Alice and Bob begin their day with a quick game. They first choose a starting number *X*0<=≥<=3 and try to reach one million by the process described below.
Alice goes first and then they take alternating turns. In the *i*-th turn, the player whose turn it is selects a prime number smaller than the current number, an... | {"inputs": ["14", "20", "8192", "1000000", "959806", "1452", "4", "6", "8", "9", "10", "12", "15", "16", "110880", "166320", "221760", "277200", "332640", "498960", "554400", "665280", "720720", "510510", "570570", "690690", "959818", "959878", "959902", "974847", "974859", "974931", "885481", "896809", "908209", "9350... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 31 | codeforces | |
eeee9d9b5074f669b25f5aa86308738f | Repaintings | A chessboard *n*<=×<=*m* in size is given. During the zero minute we repaint all the black squares to the 0 color. During the *i*-th minute we repaint to the *i* color the initially black squares that have exactly four corner-adjacent squares painted *i*<=-<=1 (all such squares are repainted simultaneously). This proce... | {"inputs": ["3 3\n1", "3 3\n2", "1 1\n1", "8 8\n8", "9 10\n1", "9 9\n3", "10 9\n4", "1 5000\n3", "5000 1\n3", "4999 1\n7", "1 4999\n2309", "1 4999\n1000000", "1 1\n200", "5000 5000\n1000000000", "7 7\n777", "126 4125\n52", "1755 2051\n1", "3385 4978\n192", "3663 2904\n1149", "293 2183\n60", "1922 109\n41", "3552 3036\n... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 11 | codeforces | |
ef3243360f9822d7c0381c2f12cfbc4f | Guest From the Past | Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.
Kolya is hungry, so he went to the nearest milk shop. In 2084 you may buy kefir in a plas... | {"inputs": ["10\n11\n9\n8", "10\n5\n6\n1", "2\n2\n2\n1", "10\n3\n3\n1", "10\n1\n2\n1", "10\n2\n3\n1", "9\n2\n4\n1", "9\n2\n2\n1", "9\n10\n10\n1", "10\n2\n2\n1", "1000000000000000000\n2\n10\n9", "501000000000000000\n300000000000000000\n301000000000000000\n100000000000000000", "10\n1\n9\n8", "10\n8\n8\n7", "10\n5\n5\n1",... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 37 | codeforces | |
ef44ef5c48e114113fdb4216e7802b81 | Polo the Penguin and Segments | Little penguin Polo adores integer segments, that is, pairs of integers [*l*; *r*] (*l*<=≤<=*r*).
He has a set that consists of *n* integer segments: [*l*1; *r*1],<=[*l*2; *r*2],<=...,<=[*l**n*; *r**n*]. We know that no two segments of this set intersect. In one move Polo can either widen any segment of the set 1 uni... | {"inputs": ["2 3\n1 2\n3 4", "3 7\n1 2\n3 3\n4 7", "3 7\n1 10\n11 47\n74 128", "5 4\n1 1\n2 2\n3 3\n4 4\n5 5", "7 4\n2 2\n-1 -1\n0 1\n7 8\n-3 -2\n9 9\n4 6", "10 2\n92 92\n55 59\n70 73\n78 81\n62 65\n95 99\n74 75\n85 87\n51 51\n60 60", "10 474\n56 60\n82 82\n73 73\n105 109\n77 80\n51 51\n85 88\n97 100\n91 92\n64 68", "4... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 179 | codeforces | |
ef5a143b363c4530ff1b59426aee6913 | inc ARG | Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of *n* bits. These bits are numbered from 1 to *n*. An integer is stored in the cell in the following way: the least significant bit is stored in the first bit of the cell, the next significant bit is stored... | {"inputs": ["4\n1100", "4\n1111", "1\n0", "1\n1", "2\n00", "2\n01", "2\n10", "2\n11", "10\n0000000000", "20\n11111111110110001100", "50\n01011110100010000001010000100001001101001101101011", "60\n111111111101111111111111111111111111111111111111111111111111", "60\n111111111111111111111111111111111111111111111111111111111... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 244 | codeforces | |
ef87b2649896428f789cfd90fdffac08 | New Year and Rainbow Roads | Roy and Biv have a set of *n* points on the infinite number line.
Each point has one of 3 colors: red, green, or blue.
Roy and Biv would like to connect all the points with some edges. Edges can be drawn between any of the two of the given points. The cost of an edge is equal to the distance between the two points it... | {"inputs": ["4\n1 G\n5 R\n10 B\n15 G", "4\n1 G\n2 R\n3 B\n10 G", "4\n1 G\n123123 R\n987987987 B\n1000000000 G", "1\n3 R"], "outputs": ["23", "12", "1012135134", "0"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 10 | codeforces | |
ef910e6c990a4190029b939a4dbe2fc4 | Vasiliy's Multiset | Author has gone out of the stories about Vasiliy, so here is just a formal task description.
You are given *q* queries and a multiset *A*, initially containing only integer 0. There are three types of queries:
1. "+ x" — add integer *x* to multiset *A*.1. "- x" — erase one occurrence of integer *x* from multiset *A... | {"inputs": ["10\n+ 8\n+ 9\n+ 11\n+ 6\n+ 1\n? 3\n- 8\n? 3\n? 8\n? 11", "12\n+ 4\n+ 4\n+ 5\n? 3\n- 4\n? 3\n- 4\n? 3\n? 3\n- 5\n+ 10\n? 1", "10\n? 1\n+ 1\n+ 8\n- 1\n+ 2\n+ 7\n+ 4\n+ 7\n+ 3\n? 7", "7\n? 1\n+ 941492387\n+ 72235422\n+ 449924898\n+ 783332532\n- 941492387\n- 72235422", "3\n? 5\n? 4\n? 3", "1\n? 4", "14\n+ 4\n+... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
efdafdcc47849895660ecbe9f9495933 | Another Problem on Strings | A string is binary, if it consists only of characters "0" and "1".
String *v* is a substring of string *w* if it has a non-zero length and can be read starting from some position in string *w*. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if th... | {"inputs": ["1\n1010", "2\n01010", "100\n01010", "0\n01010", "0\n0010100011", "0\n10000", "988205\n000110001001000", "10\n1011110011111001100", "0\n000", "16\n1111011111110110111111111", "0\n0", "0\n1", "1\n0", "1\n1", "2\n0", "2\n1", "1000000\n0", "1000000\n1", "0\n00", "0\n01", "0\n10", "0\n11", "1\n00", "1\n01", "1\... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 54 | codeforces | |
eff454f64b8b6423e14d9b17630633b9 | Combination | Ilya plays a card game by the following rules.
A player has several cards. Each card contains two non-negative integers inscribed, one at the top of the card and one at the bottom. At the beginning of the round the player chooses one of his cards to play it. If the top of the card contains number *a**i*, and the botto... | {"inputs": ["2\n1 0\n2 0", "3\n1 0\n2 0\n0 2", "5\n0 0\n2 0\n2 0\n3 0\n5 1", "7\n9 1\n8 1\n9 0\n9 1\n5 1\n1 1\n0 1", "7\n5 0\n4 0\n3 0\n5 2\n3 0\n4 2\n0 0", "1\n7 0", "1\n10 1", "10\n18 0\n4 0\n10 0\n5 0\n1 0\n18 0\n19 0\n11 1\n11 1\n0 1", "20\n33 0\n53 0\n91 0\n15 0\n35 0\n55 0\n23 0\n70 0\n98 0\n98 0\n56 0\n65 0\n20 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
f00c2eef3bf338fe1407001f71720af1 | Huge Strings | You are given *n* strings *s*1,<=*s*2,<=...,<=*s**n* consisting of characters 0 and 1. *m* operations are performed, on each of them you concatenate two existing strings into a new one. On the *i*-th operation the concatenation *s**a**i**s**b**i* is saved into a new string *s**n*<=+<=*i* (the operations are numbered st... | {"inputs": ["5\n01\n10\n101\n11111\n0\n3\n1 2\n6 5\n4 4", "5\n01\n1\n0011\n0\n01\n6\n5 5\n3 2\n4 2\n6 7\n5 1\n9 7", "5\n111101000111100011100110000100\n000111001\n01101000\n0000110100100010011001000000010100100111110110\n0110001\n10\n5 5\n2 2\n5 6\n1 1\n1 7\n10 6\n6 2\n11 1\n3 6\n8 2", "1\n1\n1\n1 1", "5\n1101010101010... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
f03cd8a1aca18e581bedbee64b3aa5b1 | Beard Graph | Let's define a non-oriented connected graph of *n* vertices and *n*<=-<=1 edges as a beard, if all of its vertices except, perhaps, one, have the degree of 2 or 1 (that is, there exists no more than one vertex, whose degree is more than two). Let us remind you that the degree of a vertex is the number of edges that con... | {"inputs": ["3\n1 2\n2 3\n7\n3 1 2\n3 1 3\n3 2 3\n2 2\n3 1 2\n3 1 3\n3 2 3", "6\n1 5\n6 4\n2 3\n3 5\n5 6\n6\n3 3 4\n2 5\n3 2 6\n3 1 2\n2 3\n3 3 1", "3\n2 3\n1 3\n4\n3 3 1\n3 2 2\n3 1 3\n2 2", "5\n3 4\n1 2\n2 4\n5 3\n10\n3 4 1\n3 5 5\n3 3 3\n2 3\n3 1 1\n3 4 4\n3 3 1\n3 2 3\n3 4 3\n2 1", "10\n8 9\n4 1\n3 4\n2 6\n7 6\n1 5... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
f03f163d9dcf59356562a10964351ea7 | Colorful Points | You are given a set of points on a straight line. Each point has a color assigned to it. For point *a*, its neighbors are the points which don't have any other points between them and *a*. Each point has at most two neighbors - one from the left and one from the right.
You perform a sequence of operations on this set ... | {"inputs": ["aabb", "aabcaa", "abbcccbba", "aaaaaaaaaaa", "aaaaaaaaabbbbbaaaabaaaaaaaaaaaaaaaaabaaaaaabbbbbbbaaabbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa", "abc", "a", "ab", "ba", "aaabbb", "abababababab", "aaabbbbbbaaa", "bbbbbbbbbbbbbbbbbbbbbbddddddddddddddddaaaaaaaaaaaaaccccccccbbbbbbbaaaaaaaaaabbbbbbbbaaaaaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 3 | codeforces | |
f03f9da834f54eb8e8b876b0b59ffb7f | Sand Fortress | You are going to the beach with the idea to build the greatest sand castle ever in your head! The beach is not as three-dimensional as you could have imagined, it can be decribed as a line of spots to pile up sand pillars. Spots are numbered 1 through infinity from left to right.
Obviously, there is not enough sand o... | {"inputs": ["5 2", "6 8", "20 4", "1000000000000000000 1000000000000000000", "1 1", "1 1000000000000000000", "1000000000000000000 1", "1036191544337895 45523434", "1036191544337896 45523434", "1036191544337895 45523433", "1036191544337895 1", "1036191544337895 1000000000000000000", "30 3", "30 4", "6 100", "7 100", "10... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 51 | codeforces | |
f072fa63e87a25ed800de65e1ffc8d7c | Letters | There are $n$ dormitories in Berland State University, they are numbered with integers from $1$ to $n$. Each dormitory consists of rooms, there are $a_i$ rooms in $i$-th dormitory. The rooms in $i$-th dormitory are numbered from $1$ to $a_i$.
A postman delivers letters. Sometimes there is no specific dormitory and roo... | {"inputs": ["3 6\n10 15 12\n1 9 12 23 26 37", "2 3\n5 10000000000\n5 6 9999999999", "1 1\n1\n1", "5 15\n10 20 30 20 10\n1 6 10 11 15 30 31 54 60 61 76 80 81 84 90", "1 10\n10\n1 2 3 4 5 6 7 8 9 10", "5 8\n10 1 1 1 10\n9 10 11 12 13 14 15 23", "1 3\n10000\n1 4325 10000", "4 18\n5 6 3 4\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 156 | codeforces | |
f076dc74abe1afb96365abfa76bcf681 | Partitions | You are given a set of *n* elements indexed from 1 to *n*. The weight of *i*-th element is *w**i*. The weight of some subset of a given set is denoted as . The weight of some partition *R* of a given set into *k* subsets is (recall that a partition of a given set is a set of its subsets such that every element of the ... | {"inputs": ["4 2\n2 3 2 3", "5 2\n1 2 3 4 5", "1 1\n1", "1 1\n1000000000", "2 1\n6042 8885", "2 2\n8224 8138", "3 1\n2403 4573 3678", "3 2\n1880 3827 5158", "3 3\n4062 8888 5423", "4 1\n1867 5670 374 4815", "4 2\n4049 2220 6447 3695", "4 3\n3526 1473 9416 2974", "4 4\n9900 6535 5489 1853", "5 1\n6740 1359 1663 8074 568... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
f0ad95136bd7be42237709c4ab074470 | Bear and Displayed Friends | Limak is a little polar bear. He loves connecting with other bears via social networks. He has *n* friends and his relation with the *i*-th of them is described by a unique integer *t**i*. The bigger this value is, the better the friendship is. No two friends have the same value *t**i*.
Spring is starting and the Wint... | {"inputs": ["4 2 8\n300 950 500 200\n1 3\n2 4\n2 3\n1 1\n1 2\n2 1\n2 2\n2 3", "6 3 9\n50 20 51 17 99 24\n1 3\n1 4\n1 5\n1 2\n2 4\n2 2\n1 1\n2 4\n2 3", "6 3 10\n62417580 78150524 410053501 582708235 630200761 760672946\n2 2\n1 5\n1 2\n1 4\n2 4\n2 1\n2 1\n1 6\n2 5\n2 6", "20 2 15\n12698951 55128070 116962690 156763505 18... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 74 | codeforces | |
f0c98e53e5f00dc6fccb04a61d09a569 | Ray Tracing | There are *k* sensors located in the rectangular room of size *n*<=×<=*m* meters. The *i*-th sensor is located at point (*x**i*,<=*y**i*). All sensors are located at distinct points strictly inside the rectangle.
Opposite corners of the room are located at points (0,<=0) and (*n*,<=*m*). Walls of the room are paralle... | {"inputs": ["3 3 4\n1 1\n1 2\n2 1\n2 2", "3 4 6\n1 1\n2 1\n1 2\n2 2\n1 3\n2 3", "7 4 5\n1 3\n2 2\n5 1\n5 3\n4 3", "10 10 10\n3 8\n1 7\n2 3\n4 2\n4 8\n3 3\n2 8\n5 5\n6 3\n3 1"], "outputs": ["1\n-1\n-1\n2", "1\n-1\n-1\n2\n5\n-1", "13\n2\n9\n5\n-1", "-1\n-1\n-1\n-1\n-1\n3\n-1\n5\n-1\n-1"]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 7 | codeforces | |
f0cd2e3f5e07139f08498f5621356785 | Barnicle | Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance ... | {"inputs": ["8.549e2", "8.549e3", "0.33e0", "1.31e1", "1.038e0", "8.25983e5", "8.77056e6", "4.28522890224373996236468418851564462623381500262405e30", "4.09336275522154223604344399571355118601483591618747e85", "2.0629094807595491132306264747042243928486303384791951220362096240931158821630792563855724946791054152e85", "0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 67 | codeforces | |
f0e43d5e6116cabcd5a5afab0d7d9360 | Div. 64 | Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.
Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisi... | {"inputs": ["100010001", "100", "0000001000000", "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "1111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111", "01111111011111111111111111111111111111111111111111111111111111... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 266 | codeforces | |
f0ea84336296576d23e955b31c95fd20 | Magic Numbers | Consider the decimal presentation of an integer. Let's call a number d-magic if digit *d* appears in decimal presentation of the number on even positions and nowhere else.
For example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are not 7-magic. On the other hand the number 7 is 0-magic, 123 is 2-mag... | {"inputs": ["2 6\n10\n99", "2 0\n1\n9", "19 7\n1000\n9999", "9 4\n33\n52", "10 8\n18\n59", "43 3\n587\n850", "65 3\n3436\n3632", "850 8\n55735\n94089", "590 6\n428671\n715453", "1053 8\n1539368\n3362621", "477 9\n3062053\n6465858", "1901 9\n1941695\n3314270", "29 0\n1649127\n6241670", "566 3\n63724516599577003628541628... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 4 | codeforces | |
f0f8b71ffb52b06d4de452eb67b0aa25 | Counting Kangaroos is Fun | There are *n* kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.
Each kangaroo can hold at most one kangaroo, and the kangaroo who i... | {"inputs": ["8\n2\n5\n7\n6\n9\n8\n4\n2", "8\n9\n1\n6\n2\n6\n5\n8\n3", "12\n3\n99\n24\n46\n75\n63\n57\n55\n10\n62\n34\n52", "12\n55\n75\n1\n98\n63\n64\n9\n39\n82\n18\n47\n9", "100\n678\n771\n96\n282\n135\n749\n168\n668\n17\n658\n979\n446\n998\n331\n606\n756\n37\n515\n538\n205\n647\n547\n904\n842\n647\n286\n774\n414\n267... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 61 | codeforces | |
f12339773992c002ec45b994955d599d | PolandBall and Gifts | It's Christmas time! PolandBall and his friends will be giving themselves gifts. There are *n* Balls overall. Each Ball has someone for whom he should bring a present according to some permutation *p*, *p**i*<=≠<=*i* for all *i*.
Unfortunately, Balls are quite clumsy. We know earlier that exactly *k* of them will forg... | {"inputs": ["5 2\n3 4 1 5 2", "10 1\n2 3 4 5 6 7 8 9 10 1", "5 4\n3 1 4 5 2", "3 0\n2 3 1", "4 3\n2 3 4 1", "2 0\n2 1", "2 1\n2 1", "2 2\n2 1", "3 0\n2 3 1", "3 1\n2 3 1", "3 2\n2 3 1", "3 3\n2 3 1", "5 1\n2 3 4 5 1", "6 3\n2 3 1 5 6 4", "9 5\n3 4 5 2 7 8 1 9 6", "6 2\n4 5 6 2 1 3", "2 2\n2 1", "9 2\n8 6 7 5 2 3 1 9 4"... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
f1358e5820183e8ec8f2e3b61ee5ef36 | The number on the board | Some natural number was written on the board. Its sum of digits was not less than *k*. But you were distracted a bit, and someone changed this number to *n*, replacing some digits with others. It's known that the length of the number didn't change.
You have to find the minimum number of digits in which these two numbe... | {"inputs": ["3\n11", "3\n99", "10\n5205602270", "70\n3326631213", "200\n1000000010000000000000000000010000000000000001000001000000000000000000000000000000000000000000000000", "500\n1899337170458531693764539600958943248270674811247191310452938511077656066239840703432499357537079035", "700\n930721675640459016214334490155... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 86 | codeforces | |
f15218a1d52d8afdb6e5afd7f1b1934b | Spy Syndrome 2 | After observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observation of Siddhant’s sentences, Yash determined a new cipher technique.
For a given sentence, the ciphe... | {"inputs": ["30\nariksihsidlihcdnaehsetahgnisol\n10\nKira\nhates\nis\nhe\nlosing\ndeath\nchildish\nL\nand\nNote", "12\niherehtolleh\n5\nHI\nHo\nthere\nHeLLo\nhello", "71\nbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n8\na\naa\naaa\naaaa\naaaaa\naaaaaa\naaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 2 | codeforces | |
f16748607c785c0b98dd1acfb1db8b04 | Two Seals | One very important person has a piece of paper in the form of a rectangle *a*<=×<=*b*.
Also, he has *n* seals. Each seal leaves an impression on the paper in the form of a rectangle of the size *x**i*<=×<=*y**i*. Each impression must be parallel to the sides of the piece of paper (but seal can be rotated by 90 degrees... | {"inputs": ["2 2 2\n1 2\n2 1", "4 10 9\n2 3\n1 1\n5 10\n9 11", "3 10 10\n6 6\n7 7\n20 5", "2 1 1\n1 1\n1 1", "2 1 2\n1 1\n1 1", "2 100 100\n100 100\n1 1", "2 100 100\n50 100\n100 50", "2 100 100\n100 100\n87 72", "5 100 100\n100 100\n100 100\n100 100\n100 100\n100 100", "15 50 50\n9 36\n28 14\n77 74\n35 2\n20 32\n83 85... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 34 | codeforces | |
f1713e8c1a645361ed6d91822ead2758 | Depression | Do you remember a kind cartoon "Beauty and the Beast"? No, no, there was no firing from machine guns or radiation mutants time-travels!
There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle...
Everybody was upset. The beautiful ... | {"inputs": ["12:00", "04:30", "08:17", "07:20", "09:55", "11:59", "01:23", "11:00", "00:00", "12:30", "23:59", "20:00", "23:45", "07:14", "15:15", "16:05", "19:55", "23:58", "14:33", "18:00", "00:24", "19:45", "20:05", "21:13", "08:04", "07:40", "19:12", "06:36", "06:16", "11:49", "18:45", "06:44", "20:45", "17:48", "0... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 36 | codeforces | |
f1a35742b0a9a1e287eebb34373efa86 | Longest k-Good Segment | The array *a* with *n* integers is given. Let's call the sequence of one or more consecutive elements in *a* segment. Also let's call the segment k-good if it contains no more than *k* different values.
Find any longest k-good segment.
As the input/output can reach huge size it is recommended to use fast input/output... | {"inputs": ["5 5\n1 2 3 4 5", "9 3\n6 5 1 2 3 2 1 4 5", "3 1\n1 2 3", "1 1\n747391", "5 2\n171230 171230 171230 171230 171230", "10 3\n512008 512008 452221 512008 314256 123232 314256 512008 314256 123232", "6 1\n1 1 2 1 1 1", "5 4\n1 2 3 4 0", "5 4\n2 3 4 5 0", "2 2\n0 1", "2 2\n0 0", "5 4\n1 2 3 45 0"], "outputs": ["... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 54 | codeforces | |
f1cdb30715841ea0612c3bcf79aecec7 | Wilbur and Swimming Pool | After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the area of the rectangle must be positive. Wilbur had all four vertices of the planned... | {"inputs": ["2\n0 0\n1 1", "1\n1 1", "1\n-188 17", "1\n71 -740", "4\n-56 -858\n-56 -174\n778 -858\n778 -174", "2\n14 153\n566 -13", "2\n-559 894\n314 127", "1\n-227 -825", "2\n-187 583\n25 13", "2\n-337 451\n32 -395", "4\n-64 -509\n-64 960\n634 -509\n634 960", "2\n-922 -505\n712 -683", "2\n-1000 -1000\n-1000 0", "2\n-1... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 130 | codeforces | |
f1e893d735a5a95becb2ba80e08851fe | Matchmaker | Polycarpus has *n* markers and *m* marker caps. Each marker is described by two numbers: *x**i* is the color and *y**i* is the diameter. Correspondingly, each cap is described by two numbers: *a**j* is the color and *b**j* is the diameter. Cap (*a**j*,<=*b**j*) can close marker (*x**i*,<=*y**i*) only if their diameters... | {"inputs": ["3 4\n1 2\n3 4\n2 4\n5 4\n2 4\n1 1\n1 2", "2 2\n1 2\n2 1\n3 4\n5 1", "6 7\n2 1\n2 2\n2 1\n1 1\n2 1\n1 2\n2 2\n2 2\n2 2\n1 2\n2 2\n1 1\n1 2", "6 7\n2 1\n1 1\n2 2\n1 2\n1 1\n1 2\n2 1\n1 1\n1 1\n1 1\n1 2\n2 2\n1 1", "6 7\n2 1\n2 2\n1 1\n1 2\n2 2\n1 2\n1 2\n1 1\n1 2\n2 2\n2 2\n2 2\n1 1", "6 7\n1 1\n1 1\n1 2\n1 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 21 | codeforces | |
f1f9f715455d8c3f24e570cb59b1a3cb | Rats | Rats have bred to hundreds and hundreds in the basement of the store, owned by Vasily Petrovich. Vasily Petrovich may have not noticed their presence, but they got into the habit of sneaking into the warehouse and stealing food from there. Vasily Petrovich cannot put up with it anymore, he has to destroy the rats in th... | {"inputs": ["4 4 1\nXXXX\nXR.X\nX.RX\nXXXX", "9 14 5\nXXXXXXXXXXXXXX\nX....R...R...X\nX..R.........X\nX....RXR..R..X\nX..R...X.....X\nXR.R...X.....X\nX....XXR.....X\nX....R..R.R..X\nXXXXXXXXXXXXXX", "7 7 1\nXXXXXXX\nX.R.R.X\nX.....X\nX..X..X\nX..R..X\nX....RX\nXXXXXXX", "7 7 2\nXXXXXXX\nX.....X\nXRXR..X\nX.....X\nXR...... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
f1facf569ffcf5bc4df80b22352296b4 | Xor-Paths | There is a rectangular grid of size $n \times m$. Each cell has a number written on it; the number on the cell ($i, j$) is $a_{i, j}$. Your task is to calculate the number of paths from the upper-left cell ($1, 1$) to the bottom-right cell ($n, m$) meeting the following constraints:
- You can move to the right or to ... | {"inputs": ["3 3 11\n2 1 5\n7 10 0\n12 6 4", "3 4 2\n1 3 3 3\n0 3 3 2\n3 0 1 1", "3 4 1000000000000000000\n1 3 3 3\n0 3 3 2\n3 0 1 1", "1 1 1000000000000000000\n1000000000000000000", "1 1 1000000000000000000\n999999999999999999", "1 1 1\n1", "1 2 3\n1 2", "1 10 1023\n1 2 4 8 16 32 64 128 256 512", "1 20 1048575\n1 2 4 ... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 9 | codeforces | |
f206f390408b8469f5ead1d5a0d4ef6f | Ilya And The Tree | Ilya is very fond of graphs, especially trees. During his last trip to the forest Ilya found a very interesting tree rooted at vertex 1. There is an integer number written on each vertex of the tree; the number written on vertex *i* is equal to *a**i*.
Ilya believes that the beauty of the vertex *x* is the greatest co... | {"inputs": ["2\n6 2\n1 2", "3\n6 2 3\n1 2\n1 3", "1\n10", "10\n2 3 4 5 6 7 8 9 10 11\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n4 8\n8 9\n9 10", "4\n6 2 3 2\n1 2\n2 3\n3 4"], "outputs": ["6 6 ", "6 6 6 ", "10 ", "2 3 2 1 1 1 1 1 1 1 ", "6 6 3 2 "]} | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 1 | codeforces | |
f20f51e123ce54994ea16251d4a30538 | Hexadecimal's theorem | Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe. She thinks that each Fibonacci number can be represented as sum of three not necessary different Fibonacci numbers.
Let's remember how Fibonacci numbers can be calculated. *F*0<==<=0, *F*1<==<=1, and all the next numbers are *F... | {"inputs": ["3", "13", "0", "1", "2", "1597", "0", "1", "1", "2", "3", "5", "8", "13", "21", "34", "55", "89", "144", "233", "377", "610", "987", "1597", "2584", "4181", "6765", "10946", "17711", "28657", "46368", "75025", "121393", "196418", "317811", "514229", "832040", "1346269", "2178309", "3524578", "5702887", "92... | UNKNOWN | [
"PYTHON3"
] | CODEFORCES | 437 | codeforces |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.