dataset stringclasses 1
value | question stringlengths 29 13k | exe_method stringclasses 1
value | solutions null | task_id int64 0 5.07k | test_time_limit int64 1 1 | example_input listlengths 0 5 | example_output listlengths 0 5 | test_input listlengths 1 10 | test_output listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|
CodeContests | N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green.
The person numbered i says:
* "In front of me, exactly A_i people are wearing hats with the same color as mine."
Assuming that all these statements are correct, find the number of p... | stdin | null | 1,966 | 1 | [
"54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17\n",
"3\n0 0 0\n",
"6\n0 1 2 3 4 5\n"
] | [
"115295190\n",
"6\n",
"3\n"
] | [
"54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 20 13 14 14 15 15 15 16 16 16 17 17 17\n",
"6\n0 1 2 0 3 4\n",
"6\n0 1 1 3 4 5\n",
"54\n0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17... | [
"0\n",
"6\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
] |
CodeContests | A positive integer is called a "prime-factor prime" when the number of its prime factors is prime. For example, $12$ is a prime-factor prime because the number of prime factors of $12 = 2 \times 2 \times 3$ is $3$, which is prime. On the other hand, $210$ is not a prime-factor prime because the number of prime factors ... | stdin | null | 3,059 | 1 | [
"180 180\n",
"999000001 1000000000\n",
"575 57577\n",
"9900001 10000000\n",
"1 9\n"
] | [
"1\n",
"592955\n",
"36172\n",
"60997\n",
"4\n"
] | [
"180 355\n",
"575 105187\n",
"1 12\n",
"8 355\n",
"575 184476\n",
"1 17\n",
"575 263927\n",
"8 29\n",
"575 229506\n",
"1 7\n"
] | [
"110\n",
"66154\n",
"6\n",
"220\n",
"115815\n",
"8\n",
"165557\n",
"14\n",
"144091\n",
"2\n"
] |
CodeContests | Given are N points on the circumference of a circle centered at (0,0) in an xy-plane. The coordinates of the i-th point are (\cos(\frac{2\pi T_i}{L}),\sin(\frac{2\pi T_i}{L})).
Three distinct points will be chosen uniformly at random from these N points. Find the expected x- and y-coordinates of the center of the circ... | stdin | null | 453 | 1 | [
"3 4\n0\n1\n3\n",
"10 100\n2\n11\n35\n42\n54\n69\n89\n91\n93\n99\n",
"4 8\n1\n3\n5\n6\n"
] | [
"0.414213562373095 -0.000000000000000\n",
"0.352886583546338 -0.109065017701873\n",
"-0.229401949926902 -0.153281482438188\n"
] | [
"10 100\n2\n10\n35\n42\n54\n69\n89\n91\n93\n99\n",
"4 8\n1\n5\n5\n6\n",
"10 100\n2\n10\n35\n42\n54\n69\n87\n91\n93\n99\n",
"4 8\n1\n2\n5\n6\n",
"4 8\n1\n2\n5\n5\n",
"4 8\n1\n3\n5\n5\n",
"4 15\n1\n3\n5\n5\n",
"3 4\n0\n0\n3\n",
"10 100\n2\n11\n40\n42\n54\n69\n89\n91\n93\n99\n",
"10 100\n4\n10\n35\n4... | [
"0.359183517098 -0.113357499556\n",
"-0.436508731113 -0.653281482438\n",
"0.344179693189 -0.120298491279\n",
"-0.000000000000 0.000000000000\n",
"-0.270598050073 -0.053825298748\n",
"-0.500000000000 -0.207106781187\n",
"-0.122207425642 0.826317804167\n",
"1.000000000000 0.000000000000\n",
"0.3227507... |
CodeContests | There are N slimes standing on a number line. The i-th slime from the left is at position x_i.
It is guaruanteed that 1 \leq x_1 < x_2 < \ldots < x_N \leq 10^{9}.
Niwango will perform N-1 operations. The i-th operation consists of the following procedures:
* Choose an integer k between 1 and N-i (inclusive) with equ... | stdin | null | 174 | 1 | [
"12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 982631932\n",
"3\n1 2 3\n"
] | [
"750927044\n",
"5\n"
] | [
"12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 1765707086\n",
"3\n1 2 5\n",
"12\n161735902 394362112 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 1765707086\n",
"3\n1 3 5\n",
"12\n161735902 39436... | [
"161914202\n",
"11\n",
"887780913\n",
"10\n",
"9952620\n",
"89619489\n",
"3107276\n",
"58421608\n",
"602338330\n",
"604332739\n"
] |
CodeContests | Rohan bought new book Puzzleria in which he has to solve the puzzle.
So,now he need your help to solve one of the puzzle were he is given X consonant
and Y vowels to make a word from it whose length is equals to X + Y.
So now your are given the number of consonant and vowels and has to tell how many words can be formed... | stdin | null | 4,102 | 1 | [
"1\n5 2\n\nSAMPLE\n"
] | [
"1058400\n"
] | [
"30\n2 4 \n3 4 \n6 1 \n4 2 \n5 3 \n3 5 \n5 1 \n6 2 \n1 4\n7 3 \n2 1 \n1 2 \n2 5 \n4 1 \n4 3 \n5 4 \n3 2\n4 4\n5 2\n1 3\n7 2\n1 1\n2 1\n7 5\n2 3\n6 3\n7 4\n6 4\n5 5\n2 2\n",
"1\n5 4\n\nSAMPLE\n",
"30\n2 4 \n3 4 \n6 1 \n4 2 \n5 3 \n3 5 \n5 1 \n6 2 \n1 4\n7 4 \n2 1 \n1 2 \n2 5 \n4 1 \n4 3 \n5 4 \n3 2\n4 4\n5 2\n... | [
"75600\n882000\n176400\n252000\n8467200\n1411200\n75600\n2822400\n4200\n36288000\n630\n420\n105840\n21000\n1764000\n38102400\n42000\n7056000\n1058400\n1680\n3628800\n70\n630\n479001600\n25200\n25401600\n199584000\n127008000\n76204800\n5040\n",
"38102400\n",
"75600\n882000\n176400\n252000\n8467200\n1411200\n7560... |
CodeContests | J - Tree Reconstruction
Problem Statement
You have a directed graph. Some non-negative value is assigned on each edge of the graph. You know that the value of the graph satisfies the flow conservation law That is, for every node v, the sum of values on edges incoming to v equals to the sum of values of edges outgoing... | stdin | null | 708 | 1 | [
"9 13\n1 2\n1 3\n2 9\n3 4\n3 5\n3 6\n4 9\n5 7\n6 7\n6 8\n7 9\n8 9\n9 1\n"
] | [
"5\n"
] | [
"9 13\n1 2\n1 3\n2 9\n3 4\n3 5\n3 6\n4 9\n5 8\n6 7\n6 8\n7 9\n8 9\n9 1\n",
"9 13\n1 2\n1 3\n1 9\n1 4\n3 5\n5 6\n4 9\n5 7\n6 7\n8 8\n7 9\n5 9\n9 1\n",
"9 1\n1 1\n1 3\n1 9\n1 4\n3 5\n5 6\n4 9\n5 7\n6 7\n6 8\n7 9\n5 9\n9 1\n",
"9 10\n1 2\n1 3\n2 9\n1 4\n3 5\n4 6\n3 9\n5 7\n6 7\n6 8\n7 9\n5 9\n9 1\n",
"9 10\n1 ... | [
"5\n",
"6\n",
"1\n",
"2\n",
"3\n",
"0\n",
"4\n",
"5\n",
"5\n",
"5\n"
] |
CodeContests | I have a plan to go on a school trip at a school. I conducted a questionnaire survey for that purpose. Students have student numbers from 1 to n, and the locations of travel candidates are represented by numbers from 1 to m, and where they want to go ○ , Mark the places you don't want to go with a cross and submit.
At... | stdin | null | 2,214 | 1 | [
"4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n"
] | [
"1 3 2 5 4 6\n1 3 2 5 4 6\n"
] | [
"4 6\n1 0 1 0 1 1\n1 2 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n",
"4 6\n1 0 1 0 1 1\n1 2 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n1 0 1 0 1 1\n2 1 0 1 1 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n0 0\n",
"4 6\n1 0 1 0 1 1\n1 1 0 1 0 0\n1 1 1 0 0 0\n1 0 1 0 1 0\n4 6\n0 0... | [
"1 2 3 5 4 6\n1 3 2 5 4 6\n",
"1 2 3 5 4 6\n1 3 5 2 4 6\n",
"1 3 2 5 4 6\n1 3 2 5 4 6\n",
"1 2 3 5 4 6\n1 2 3 5 4 6\n",
"1 2 3 5 6 4\n1 3 5 2 4 6\n",
"1 3 5 2 4 6\n1 3 2 5 4 6\n",
"1 2 3 5 6 4\n1 2 3 5 4 6\n",
"1 2 3 5 4 6\n1 5 2 3 4 6\n",
"1 3 5 6 2 4\n1 3 5 2 4 6\n",
"1 3 2 5 4 6\n1 3 5 2 4 6\n"... |
CodeContests | Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.
The text includes only alphabetical characters and spaces. A word is a sequence of letters which is separate... | stdin | null | 3,681 | 1 | [
"Thank you for your mail and your lectures\n"
] | [
"your lectures\n"
] | [
"Thank you for your mail amd your lectures\n",
"ahTnk you for your mail and your serutcel\n",
"Uhank you for your mail mad your lrctuees\n",
"ahTnk you for your mail and your leeturcs\n",
"khTna you for your mail and your sequtcel\n",
"khTna you for your mail dna your sequucel\n",
"Uhank uzp gor your ma... | [
"your lectures\n",
"your serutcel\n",
"your lrctuees\n",
"your leeturcs\n",
"your sequtcel\n",
"your sequucel\n",
"your lecsures\n",
"your lectuser\n",
"your servtcel\n",
"your serutcek\n"
] |
CodeContests | Find the number of integers between 1 and K (inclusive) satisfying the following condition, modulo 10^9 + 7:
* The sum of the digits in base ten is a multiple of D.
Constraints
* All values in input are integers.
* 1 \leq K < 10^{10000}
* 1 \leq D \leq 100
Input
Input is given from Standard Input in the following ... | stdin | null | 2,440 | 1 | [
"98765432109876543210\n58\n",
"30\n4\n",
"1000000009\n1\n"
] | [
"635270834\n",
"6\n",
"2\n"
] | [
"98765432109876543210\n66\n",
"30\n1\n",
"1000000009\n2\n",
"98765432109876543210\n18\n",
"1000000009\n4\n",
"98765432109876543210\n11\n",
"1000000009\n5\n",
"98765432109876543210\n12\n",
"1000000009\n9\n",
"98765432109876543210\n10\n"
] | [
"678072802\n",
"30\n",
"500000004\n",
"852803440\n",
"250000009\n",
"501683936\n",
"200000001\n",
"209841644\n",
"111111112\n",
"851852334\n"
] |
CodeContests | My flatmate, Sayan, once invited all his relatives and friends from all over the city to join him on his birthday party.
He is also famous for boasting that all his friends and relatives belong to "proper" families.
Now, he appointed a gaurd to allow only his relatives and friends into the party.
It is gauranteed that ... | stdin | null | 4,489 | 1 | [
"2\n8 3\n1 2 8\n2 2 2 3 4 4 4 4\n10 3\n2 4 6\n2 9 9 9 19 19 19 19 19 20\n\nSAMPLE\n"
] | [
"2\n0\n"
] | [
"1\n536 539\n1 7 10 12 13 14 15 18 19 23 25 26 27 31 35 36 38 49 55 58 59 60 61 62 63 64 65 66 70 73 77 81 82 83 84 87 88 90 91 95 96 98 102 103 105 108 110 112 114 115 116 117 119 121 122 123 125 127 129 130 131 133 134 135 136 137 138 141 142 144 148 150 151 152 153 156 157 159 161 162 163 164 165 167 168 169 171... | [
"5\n",
"0\n0\n",
"1\n0\n",
"1\n1\n",
"3\n0\n",
"3\n",
"2\n0\n",
"1\n2\n",
"3\n1\n",
"0\n1\n"
] |
CodeContests | Tom and Jerry started fighting, as always! But this time the fight is on numbers. They ended up bringing a game to decide who is better.
They have N marbles and they choose two integers M1 and M2, in each turn a player can take either M1 or M2 marbles(if available!). One who can't make any move further, loses.
Game is... | stdin | null | 2,953 | 1 | [] | [] | [
"10\n1 1 3\n3 4 5\n7 7 9\n13 1 2\n21 8 10\n31 5 7\n43 4 6\n57 5 7\n73 8 10\n91 1 2\n",
"10\n1 1 3\n3 4 5\n7 7 9\n13 1 2\n21 8 10\n31 5 7\n43 4 6\n57 5 7\n73 10 10\n91 1 2\n",
"10\n1 1 3\n3 3 5\n7 7 9\n13 1 2\n21 8 10\n31 5 7\n43 4 4\n57 5 7\n73 8 10\n91 1 2\n",
"10\n1 1 3\n3 4 5\n7 7 9\n13 1 2\n21 8 4\n31 5 7... | [
"1\n0\n1\n1\n0\n1\n0\n1\n0\n1\n",
"1\n0\n1\n1\n0\n1\n0\n1\n1\n1\n",
"1\n1\n1\n1\n0\n1\n0\n1\n0\n1\n",
"1\n0\n1\n1\n1\n1\n0\n1\n0\n1\n",
"0\n1\n1\n1\n0\n1\n0\n1\n0\n1\n",
"1\n0\n0\n1\n0\n1\n0\n1\n1\n1\n",
"1\n0\n1\n1\n0\n0\n0\n1\n0\n1\n",
"1\n0\n1\n1\n1\n0\n0\n1\n0\n1\n",
"1\n0\n0\n1\n0\n0\n0\n1\n1\n... |
CodeContests | problem
AOR Ika is at the $ S $ th bus stop at time $ 0 $ and wants to go from there to the $ G $ th bus stop. The number of bus stops $ N $ and $ M $ routes (*) connecting different bus stops are given. The bus stops are numbered $ 1, \ dots, and N $, respectively. Each route consists of $ 4 $ values: origin $ u $, d... | stdin | null | 2,861 | 1 | [
"2 2 1 2\n1 2 10 100\n1 2 5 500\n"
] | [
"5\n"
] | [
"2 1 1 2\n1 2 10 100\n1 2 5 500\n",
"2 2 1 2\n1 2 10 101\n1 2 5 500\n",
"2 1 1 2\n1 2 13 011\n2 2 5 500\n",
"2 1 1 2\n1 2 19 011\n2 2 5 500\n",
"2 2 1 2\n1 2 10 100\n1 2 7 893\n",
"2 1 1 2\n1 2 34 011\n2 2 5 500\n",
"2 1 1 2\n1 2 9 011\n2 2 5 500\n",
"3 2 1 2\n1 2 11 110\n1 2 6 893\n",
"2 2 1 2\n1 2... | [
"10\n",
"5\n",
"13\n",
"19\n",
"7\n",
"34\n",
"9\n",
"6\n",
"0\n",
"16\n"
] |
CodeContests | Stylish is a programming language whose syntax comprises names, that are sequences of Latin alphabet letters, three types of grouping symbols, periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ')'), curly brackets ('{' and '}'), and square brackets ('[' and ']'), must match and be nested pro... | stdin | null | 3,966 | 1 | [
"5 4\n(Follow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.to.use.round.brackets)\n.........[but.not.about.square.brackets]\n.........{nor.curly... | [
"0 9 14 16\n0 9\n0 -1\n0 2\n0 0\n0 2 4 6\n0 -1\n0 -1 4\n0 20 40 60\n"
] | [
"5 4\n(Follow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.to.use.round.brackets)\n.........[but.not.about.square.brackets]\n.........{nor.curly... | [
"0 9 14 16\n0 9\n0 -1\n0 2\n0 0\n0 2 4 6\n0 -1\n0 -1 4\n0 20 40 60\n",
"0 9 10 16\n0 9\n0 -1\n0 2\n0 0\n0 2 4 6\n0 -1\n0 -1 4\n0 20 40 60\n",
"0 9 14 16\n0 9\n0 -1\n0 2\n0 0\n0 2 4 5\n0 -1\n0 -1 4\n0 20 40 60\n",
"0 9 14 16\n0 9\n0 -1\n0 2\n0 0\n0 2 4 6\n0 -1\n0 -1 4\n0 -1 -1 41\n",
"0 9 14 16\n0 9\n0 -1\n0... |
CodeContests | problem
You love pasta, and you make and eat pasta for dinner every day. You can make three types of pasta: tomato sauce, cream sauce, and basil sauce.
I decided to plan a dinner for N days. Choose one of the three types of pasta each day. However, if the same pasta continues, you will get bored, so do not choose the... | stdin | null | 1,857 | 1 | [
"5 3\n3 1\n1 1\n4 2\n"
] | [
"6\n"
] | [
"5 3\n3 1\n1 1\n4 1\n",
"5 3\n5 1\n1 1\n4 1\n",
"5 3\n3 2\n1 1\n4 1\n",
"5 2\n3 1\n1 1\n4 1\n",
"9 3\n5 1\n1 1\n4 1\n",
"5 1\n3 1\n1 1\n4 1\n",
"9 3\n5 1\n1 1\n4 2\n",
"5 3\n4 1\n1 1\n4 1\n",
"9 3\n5 1\n1 2\n4 2\n",
"5 3\n5 2\n1 1\n4 2\n"
] | [
"4\n",
"6\n",
"9\n",
"16\n",
"264\n",
"60\n",
"420\n",
"22\n",
"480\n",
"5\n"
] |
CodeContests | Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B' and 'G', where 'B' represents a boy and 'G' represents a girl.
De... | stdin | null | 2,866 | 1 | [
"8\n0\nBB\n0\nBG\n0\nBBGG\n1\nBGG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB\n"
] | [
"-1\n0\n1\n1\n1\n3\n1\n0\n"
] | [
"8\n1\nBB\n0\nBG\n0\nBBGG\n1\nBGG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB\n",
"8\n1\nBB\n0\nBG\n0\nBBGG\n1\nGBG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB\n",
"8\n0\nBB\n0\nBG\n0\nBBGG\n1\nBGG\n1\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBBG\n",
"8\n0\nBB\n0\nBG\n0\nBBGG\n1\nGBG\n1\nBGGB\n1\nGBBBG\n2\nBBGG\n2\nBGB\n",
"8\n1\nBB\n0... | [
"-1\n0\n1\n1\n1\n3\n1\n0\n",
"-1\n0\n1\n0\n1\n3\n1\n0\n",
"-1\n0\n1\n1\n1\n3\n1\n1\n",
"-1\n0\n1\n0\n1\n2\n1\n0\n",
"-1\n0\n1\n1\n1\n1\n1\n1\n",
"-1\n0\n1\n1\n1\n1\n1\n0\n",
"-1\n0\n1\n0\n0\n3\n1\n0\n",
"-1\n0\n0\n1\n1\n3\n1\n0\n",
"-1\n0\n1\n-1\n1\n3\n1\n0\n",
"-1\n0\n1\n1\n1\n3\n0\n0\n"
] |
CodeContests | You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i.
How many kinds of items did you get?
Constraints
* 1 \leq N \leq 2\times 10^5
* S_i consists of lowercase English letters and has a length between 1 and 10 (inclusive).
Input
Input is given from Standard Input in t... | stdin | null | 4,619 | 1 | [
"4\naaaa\na\naaa\naa\n",
"3\napple\norange\napple\n",
"5\ngrape\ngrape\ngrape\ngrape\ngrape\n"
] | [
"4\n",
"2\n",
"1\n"
] | [
"4\na`aa\na\naaa\naa\n",
"3\nbpple\norange\napple\n",
"5\ngrape\ngrape\ngraoe\ngrape\ngrape\n",
"5\negapr\ngrape\ngraoe\ngr`pe\nepaqg\n",
"4\na`ab\na\naaa\naa\n",
"3\nbpple\negnaro\napple\n",
"5\ngrape\ngrape\ngraoe\ngrape\neparg\n",
"4\nb`aa\na\naaa\naa\n",
"3\nbpple\negnaro\nappld\n",
"5\ngrape\... | [
"4\n",
"3\n",
"2\n",
"5\n",
"4\n",
"3\n",
"3\n",
"4\n",
"3\n",
"3\n"
] |
CodeContests | Cat Snuke is learning to write characters. Today, he practiced writing digits `1` and `9`, but he did it the other way around.
You are given a three-digit integer n written by Snuke. Print the integer obtained by replacing each digit `1` with `9` and each digit `9` with `1` in n.
Constraints
* 111 \leq n \leq 999
* ... | stdin | null | 2,286 | 1 | [
"119\n",
"999\n"
] | [
"991\n",
"111\n"
] | [
"191\n",
"111\n",
"199\n",
"111\n",
"199\n",
"191\n"
] | [
"919\n",
"999\n",
"911\n",
"999\n",
"911\n",
"919\n"
] |
CodeContests | Agent 007 is on a secret mission in country "Codeland" on which he was transferring data in form of binary string to secret base of MI6. One day agents of country Codeland detect some ambiguity in system as they find that someone is leaking their data. When Agent 007 get to know about this, he become more careful and ... | stdin | null | 4,568 | 1 | [
"2\n1011\n1\n0010\n2\n\nSAMPLE\n"
] | [
"1\n3\n"
] | [
"100\n00\n467\n0000111111\n724\n101001\n942\n100\n382\n010101\n447\n0110110111\n35\n001111110\n547\n0000000\n35\n101000110\n446\n0000001001\n623\n1000111\n323\n000101\n639\n1000111\n21\n00101110\n512\n00\n52\n00\n724\n11111111\n191\n1000001001\n758\n010\n655\n11100100\n548\n1\n596\n001011000\n199\n101011101\n127\n1... | [
"0\n6\n3\n2\n3\n7\n6\n0\n5\n2\n4\n2\n3\n4\n0\n0\n8\n7\n1\n4\n1\n3\n6\n1\n0\n4\n1\n3\n2\n0\n2\n3\n1\n3\n4\n2\n2\n4\n5\n3\n4\n1\n5\n4\n3\n5\n2\n2\n4\n2\n4\n0\n3\n0\n2\n1\n3\n4\n3\n1\n4\n2\n1\n6\n2\n1\n0\n6\n1\n4\n2\n3\n2\n1\n1\n2\n8\n0\n5\n2\n3\n4\n3\n2\n2\n4\n2\n2\n7\n0\n2\n1\n2\n3\n2\n2\n5\n4\n5\n1\n",
"1\n2\n",
... |
CodeContests | As every other little boy, Mike has a favorite toy to play with. Mike's favorite toy is a set of N disks. The boy likes to compose his disks in stacks, but there's one very important rule: the disks in a single stack must be ordered by their radiuses in a strictly increasing order such that the top-most disk will have ... | stdin | null | 1,592 | 1 | [
"3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n14 5 13 19 17 10 18 12\n"
] | [
"3 1 1 2\n5 2 2 4 7 10\n4 5 10 12 18\n"
] | [
"3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n9 5 13 19 17 10 18 12\n",
"3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 9 4 14 7 10\n8\n9 5 13 19 23 10 18 12\n",
"3\n6\n3 4 5 1 1 2\n10\n3 2 9 5 2 3 4 14 7 10\n8\n9 5 13 19 23 10 18 12\n",
"3\n6\n3 4 5 1 1 2\n10\n3 2 5 5 2 3 4 14 7 3\n8\n9 5 13 19 23 10 18 12\n",
"3\n6... | [
"3 1 1 2\n5 2 2 4 7 10\n4 5 10 12 18\n",
"3 1 1 2\n5 2 2 4 7 10\n4 5 10 12 23\n",
"3 1 1 2\n6 2 2 3 4 7 10\n4 5 10 12 23\n",
"3 1 1 2\n5 2 2 3 3 7\n4 5 10 12 23\n",
"3 1 2 5\n5 2 2 3 3 7\n4 5 10 12 23\n",
"3 1 2 2\n5 2 2 3 3 7\n4 5 10 12 23\n",
"3 1 2 2\n5 1 2 3 3 14\n4 5 10 12 23\n",
"3 0 1 2\n5 1 2 ... |
CodeContests | Given is a string S consisting of `0` and `1`. Find the number of strings, modulo 998244353, that can result from applying the following operation on S between 0 and K times (inclusive):
* Choose a pair of integers i, j (1\leq i < j\leq |S|) such that the i-th and j-th characters of S are `0` and `1`, respectively. Re... | stdin | null | 4,029 | 1 | [
"0101 1\n",
"01100110 2\n",
"1101010010101101110111100011011111011000111101110101010010101010101 20\n"
] | [
"4\n",
"14\n",
"113434815\n"
] | [
"0111 1\n",
"01000110 2\n",
"1101010010101101110111100011011111011000111101110111010010101010101 20\n",
"0111 0\n",
"01000110 4\n",
"1101010010101101110111100011011111011000111101110111010010101010101 17\n",
"0011 1\n",
"01100110 4\n",
"110001001010110111011110001101111101100011110111011101001010101... | [
"2\n",
"19\n",
"243789638\n",
"1\n",
"25\n",
"434266482\n",
"3\n",
"22\n",
"353017980\n",
"914259453\n"
] |
CodeContests | N circles are drawn on the paper. The rabbit has k-colored paint and paints the paper according to the following rules.
* Paint each area with one color of paint or nothing. Here, the "area" refers to the part with a finite area surrounded by a set of arcs.
* Two adjacent areas cannot be painted with the same color. H... | stdin | null | 1,182 | 1 | [
"2 1\n10 0 10\n20 0 10\n"
] | [
"2\n"
] | [
"2 1\n10 1 10\n20 0 10\n",
"2 1\n15 1 17\n20 0 5\n",
"2 2\n7 1 9\n20 0 10\n",
"1 0\n44 6 0\n0 -2 0\n",
"2 1\n15 1 10\n20 0 10\n",
"2 1\n15 1 10\n20 0 5\n",
"2 0\n15 1 17\n20 0 5\n",
"2 0\n15 1 17\n1 0 5\n",
"2 0\n15 1 17\n1 -1 5\n",
"2 0\n8 1 17\n1 -1 5\n"
] | [
"2\n",
"1\n",
"3\n",
"0\n",
"2\n",
"2\n",
"1\n",
"2\n",
"2\n",
"1\n"
] |
CodeContests | Chef belongs to a very rich family which owns many gold mines. Today, he brought N gold coins and decided to form a triangle using these coins. Isn't it strange?
Chef has a unusual way of forming a triangle using gold coins, which is described as follows:
He puts 1 coin in the 1^st row.
then puts 2 coins in the 2^nd r... | stdin | null | 3,742 | 1 | [
"3\n3\n5\n7\n"
] | [
"2\n2\n3\n"
] | [
"3\n3\n5\n11\n",
"3\n2\n5\n11\n",
"3\n2\n9\n11\n",
"3\n4\n9\n11\n",
"3\n5\n9\n2\n",
"3\n5\n5\n2\n",
"3\n2\n5\n2\n",
"3\n5\n5\n7\n",
"3\n4\n9\n21\n",
"3\n5\n15\n2\n"
] | [
"2\n2\n4\n",
"1\n2\n4\n",
"1\n3\n4\n",
"2\n3\n4\n",
"2\n3\n1\n",
"2\n2\n1\n",
"1\n2\n1\n",
"2\n2\n3\n",
"2\n3\n6\n",
"2\n5\n1\n"
] |
CodeContests | Given any integer x, Aoki can do the operation below.
Operation: Replace x with the absolute difference of x and K.
You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
Constraints
* 0 ≤ N ≤ 10^{18}
* 1 ≤ K ≤ 10^{18}
* All valu... | stdin | null | 727 | 1 | [
"1000000000000000000 1\n",
"7 4\n",
"2 6\n"
] | [
"0\n",
"1\n",
"2\n"
] | [
"1000000000000010000 1\n",
"7 6\n",
"7 9\n",
"17 12\n",
"7 13\n",
"8 16\n",
"5 9\n",
"30 23\n",
"10 22\n",
"37 10\n"
] | [
"0\n",
"1\n",
"2\n",
"5\n",
"6\n",
"8\n",
"4\n",
"7\n",
"10\n",
"3\n"
] |
CodeContests | How Many Divisors?
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
Constraints
* 1 ≤ a, b, c ≤ 10000
* a ≤ b
Input
Three integers a, b and c are given in a line separated by a single space.
Output
Print the number of divisors in a line.
Example
Inp... | stdin | null | 239 | 1 | [
"5 14 80\n"
] | [
"3\n"
] | [
"7 14 80\n",
"7 4 80\n",
"1 1 80\n",
"9 22 80\n",
"5 20 80\n",
"7 25 80\n",
"1 23 80\n",
"2 23 80\n",
"4 32 80\n",
"4 32 120\n"
] | [
"2\n",
"0\n",
"1\n",
"3\n",
"5\n",
"4\n",
"8\n",
"7\n",
"6\n",
"10\n"
] |
CodeContests | The numbers 1 to n x n are contained in the n x n square squares one by one, and the sum of the squares in any vertical column and the sum of the squares in any horizontal column are diagonal squares. Those with the same sum of eyes are called magic squares.
There are the following methods to create a magic square wit... | stdin | null | 3,440 | 1 | [
"3\n5\n0\n"
] | [
"4 9 2\n 3 5 7\n 8 1 6\n 11 24 7 20 3\n 4 12 25 8 16\n 17 5 13 21 9\n 10 18 1 14 22\n 23 6 19 2 15\n"
] | [
"3\n0\n0\n",
"3\n7\n0\n",
"3\n3\n0\n",
"3\n11\n0\n",
"3\n9\n0\n",
"3\n15\n0\n",
"3\n19\n0\n",
"3\n17\n0\n",
"3\n27\n0\n",
"3\n13\n0\n"
] | [
"4 9 2\n 3 5 7\n 8 1 6\n",
"4 9 2\n 3 5 7\n 8 1 6\n 22 47 16 41 10 35 4\n 5 23 48 17 42 11 29\n 30 6 24 49 18 36 12\n 13 31 7 25 43 19 37\n 38 14 32 1 26 44 20\n 21 39 8 33 2 27 45\n 46 15 40 9 34 3 28\n",
"4 9 2\n 3... |
CodeContests | Problem
There are N vacant lots on the two-dimensional plane. Numbers from 1 to N are assigned to each vacant lot. Every vacant lot is so small that it can be considered a point. The i-th vacant lot exists at (xi, yi).
Taro chose just K from these N vacant lots and decided to build a building in those vacant lots. Ho... | stdin | null | 237 | 1 | [
"4 3\n2 1\n1 2\n1 3\n2 4\n",
"5 3\n5 7\n5 6\n6 8\n20 20\n4 8\n",
"3 2\n2 1\n1 2\n1 3\n"
] | [
"-1\n",
"2\n3\n4\n",
"1\n3\n"
] | [
"3 3\n2 1\n1 2\n1 3\n2 4\n",
"5 3\n2 7\n5 6\n6 8\n20 20\n4 8\n",
"3 2\n0 1\n1 2\n1 3\n",
"3 2\n0 1\n2 2\n1 3\n",
"5 3\n5 7\n5 6\n6 8\n20 24\n4 8\n",
"5 1\n0 5\n5 6\n6 8\n20 20\n4 8\n",
"5 3\n5 7\n5 6\n6 8\n20 24\n0 8\n",
"5 2\n5 7\n5 6\n6 8\n20 24\n0 8\n",
"5 3\n2 7\n5 9\n6 8\n18 20\n0 8\n",
"3 2\... | [
"-1\n",
"1\n2\n3\n",
"1\n3\n",
"1\n2\n",
"2\n3\n4\n",
"1\n",
"1\n4\n5\n",
"1\n4\n",
"1\n2\n4\n",
"2\n3\n"
] |
CodeContests | You have N items that you want to put them into a knapsack. Item i has value vi, weight wi and limitation mi.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most W, that is capacity of the knapsack.
* You can select at m... | stdin | null | 1,110 | 1 | [
"2 100\n1 1 100\n2 1 50\n",
"4 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2\n"
] | [
"150\n",
"12\n"
] | [
"2 100\n1 1 100\n2 1 25\n",
"5 8\n4 3 2\n2 1 1\n1 2 4\n3 2 2\n",
"2 101\n1 1 100\n2 1 25\n",
"5 8\n4 2 2\n2 1 1\n1 2 4\n3 2 2\n",
"2 101\n1 1 100\n1 1 25\n",
"5 3\n4 2 2\n2 1 1\n1 2 3\n3 2 2\n",
"5 3\n4 1 2\n2 1 1\n1 2 3\n3 2 2\n",
"6 3\n3 1 4\n2 1 0\n2 2 0\n3 2 2\n",
"2 100\n1 2 100\n2 1 25\n",
"... | [
"125\n",
"12\n",
"126\n",
"14\n",
"101\n",
"6\n",
"10\n",
"9\n",
"87\n",
"151\n"
] |
CodeContests | Fennec and Snuke are playing a board game.
On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g... | stdin | null | 4,075 | 1 | [
"4\n1 4\n4 2\n2 3\n",
"7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n"
] | [
"Snuke\n",
"Fennec\n"
] | [
"4\n1 4\n4 3\n2 3\n",
"7\n3 6\n2 2\n3 1\n7 4\n5 7\n1 4\n",
"7\n3 6\n2 2\n3 1\n7 4\n4 7\n1 4\n",
"7\n3 6\n1 2\n3 2\n7 4\n5 7\n1 4\n",
"7\n3 6\n2 2\n3 1\n5 4\n4 7\n1 4\n",
"4\n1 2\n4 2\n2 3\n",
"4\n1 4\n4 3\n2 1\n",
"7\n3 6\n1 2\n3 1\n7 4\n5 7\n2 4\n",
"4\n1 4\n4 3\n2 2\n",
"7\n3 6\n1 2\n3 2\n7 4\n5... | [
"Snuke\n",
"Fennec\n",
"Fennec\n",
"Fennec\n",
"Fennec\n",
"Fennec\n",
"Snuke\n",
"Fennec\n",
"Snuke\n",
"Fennec\n"
] |
CodeContests | The "Western calendar" is a concept imported from the West, but in Japan there is a concept called the Japanese calendar, which identifies the "era name" by adding a year as a method of expressing the year on the calendar. For example, this year is 2016 in the Christian era, but 2016 in the Japanese calendar. Both are ... | stdin | null | 4,904 | 1 | [
"0 2015\n",
"0 1912\n",
"4 28\n",
"2 1\n"
] | [
"H27\n",
"T1\n",
"2016\n",
"1912\n"
] | [
"4 2\n",
"3 1\n",
"1 28\n",
"2 0\n",
"3 2\n",
"4 1\n",
"1 42\n",
"1 0\n",
"3 0\n",
"4 0\n"
] | [
"1990\n",
"1926\n",
"1895\n",
"1911\n",
"1927\n",
"1989\n",
"1909\n",
"1867\n",
"1925\n",
"1988\n"
] |
CodeContests | Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The ... | stdin | null | 3,531 | 1 | [
"6\n1 2 1 3 4 5\n7\n1 3 4 5 3 1 0\n2 4 5 3 4 5 3\n"
] | [
"Yes\nYes\nYes\nYes\nYes\nNo\nNo\n"
] | [
"6\n1 2 1 3 4 5\n7\n1 3 4 5 3 1 0\n2 8 5 3 4 5 3\n",
"6\n1 2 1 3 4 5\n7\n1 3 4 10 3 1 0\n2 4 5 3 4 5 3\n",
"6\n1 2 1 5 4 5\n7\n1 3 4 7 3 1 0\n2 8 5 3 7 5 3\n",
"6\n1 2 2 5 4 5\n7\n1 3 4 7 3 1 0\n2 8 5 3 7 5 3\n",
"6\n2 0 1 3 3 5\n7\n1 1 4 10 3 1 0\n2 4 5 3 4 5 3\n",
"6\n1 2 1 6 3 1\n7\n1 3 4 7 3 1 0\n2 8 ... | [
"Yes\nNo\nYes\nYes\nYes\nNo\nNo\n",
"Yes\nYes\nYes\nYes\nYes\nNo\nNo\n",
"Yes\nNo\nYes\nYes\nNo\nNo\nNo\n",
"No\nNo\nYes\nYes\nNo\nNo\nNo\n",
"No\nNo\nYes\nYes\nYes\nNo\nNo\n",
"Yes\nYes\nYes\nYes\nYes\nYes\nNo\n",
"Yes\nNo\nYes\nYes\nYes\nYes\nNo\n",
"Yes\nNo\nYes\nYes\nNo\nYes\nNo\n",
"Yes\nNo\nYe... |
CodeContests | A binary search tree can be unbalanced depending on features of data. For example, if we insert $n$ elements into a binary search tree in ascending order, the tree become a list, leading to long search times. One of strategies is to randomly shuffle the elements to be inserted. However, we should consider to maintain t... | stdin | null | 2,941 | 1 | [
"16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 86 47\ninsert 21 12\ninsert 7 10\ninsert 6 90\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint\n"
] | [
"1 3 6 7 14 21 35 42 80 86\n 35 6 3 1 14 7 21 80 42 86\nyes\nno\n 1 3 6 7 14 21 42 80 86\n 6 3 1 80 14 7 21 42 86\n"
] | [
"16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 102 47\ninsert 21 12\ninsert 7 10\ninsert 6 90\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint\n",
"16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 86 47\ninsert 26 12\nin... | [
"1 3 6 7 14 21 35 42 80 102\n 35 6 3 1 14 7 21 80 42 102\nyes\nno\n 1 3 6 7 14 21 42 80 102\n 6 3 1 80 14 7 21 42 102\n",
"1 3 6 7 14 26 35 42 80 86\n 35 6 3 1 14 7 26 80 42 86\nno\nno\n 1 3 6 7 14 26 42 80 86\n 6 3 1 80 14 7 26 42 86\n",
"1 3 6 7 14 26 35 42 80 86\n 6 3 1 80 35 14 7 26 42 86\nno\nno\n 1 3 6 7 ... |
CodeContests | There are X+Y+Z people, conveniently numbered 1 through X+Y+Z. Person i has A_i gold coins, B_i silver coins and C_i bronze coins.
Snuke is thinking of getting gold coins from X of those people, silver coins from Y of the people and bronze coins from Z of the people. It is not possible to get two or more different col... | stdin | null | 3,397 | 1 | [
"1 2 1\n2 4 4\n3 2 1\n7 6 7\n5 2 3\n",
"6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n44255 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963... | [
"18\n",
"3093929975\n",
"110\n"
] | [
"1 2 1\n2 4 4\n0 2 1\n7 6 7\n5 2 3\n",
"6 2 4\n33189 87907 277349742\n71616 46764 575306520\n8801 53151 327161251\n58589 4337 796697686\n66854 17565 289910583\n50598 35195 478112689\n13919 88414 103962455\n7953 69657 699253752\n42489 98144 468443709\n2332 42580 752437097\n39752 19060 845062869\n60126 74101 382963... | [
"18\n",
"3093929146\n",
"111\n",
"3093891435\n",
"113\n",
"3093871658\n",
"110\n",
"17\n",
"105\n",
"2872505176\n"
] |
CodeContests | The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`.
You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
Constraints
* 1≤A,B≤5
* |S|=A+B+1
* S consists of `-` and di... | stdin | null | 257 | 1 | [
"1 2\n7444\n",
"3 4\n269-6650\n",
"1 1\n---\n"
] | [
"No\n",
"Yes\n",
"No\n"
] | [
"2 2\n7444\n",
"6 4\n269-6650\n",
"1 2\n---\n",
"0 2\n7444\n",
"6 8\n269-6650\n",
"1 0\n---\n",
"0 2\n5343\n",
"6 1\n269-6650\n",
"1 0\n-,-\n",
"0 1\n5343\n"
] | [
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n"
] |
CodeContests | Takahashi has received an undirected graph with N vertices, numbered 1, 2, ..., N. The edges in this graph are represented by (u_i, v_i). There are no self-loops and multiple edges in this graph.
Based on this graph, Takahashi is now constructing a new graph with N^2 vertices, where each vertex is labeled with a pair ... | stdin | null | 4,824 | 1 | [
"7 5\n1 2\n3 4\n3 5\n4 5\n2 6\n",
"3 1\n1 2\n"
] | [
"18\n",
"7\n"
] | [
"7 5\n1 2\n3 4\n3 5\n4 1\n2 6\n",
"7 5\n1 2\n3 7\n3 5\n4 1\n2 6\n",
"7 5\n1 2\n3 7\n3 5\n4 1\n2 2\n",
"7 5\n1 2\n3 7\n6 5\n4 1\n2 2\n",
"12 5\n1 2\n3 4\n3 5\n4 1\n2 6\n",
"7 5\n1 2\n3 7\n3 7\n4 1\n2 3\n",
"12 5\n1 2\n3 4\n3 5\n4 1\n2 2\n",
"7 5\n1 2\n2 6\n6 5\n4 1\n2 2\n",
"7 5\n2 2\n2 6\n6 5\n4 1\n... | [
"15\n",
"8\n",
"18\n",
"13\n",
"110\n",
"26\n",
"120\n",
"25\n",
"29\n",
"76\n"
] |
CodeContests | The fundamental idea in the JPEG compression algorithm is to sort coeffi- cient of given image by zigzag path and encode it. In this problem, we don’t discuss about details of the algorithm, but you are asked to make simple pro- gram. You are given single integer N , and you must output zigzag path on a matrix where si... | stdin | null | 3,805 | 1 | [
"3\n4\n0\n"
] | [
"Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6 7\n 3 5 8 13\n 4 9 12 14\n 10 11 15 16\n"
] | [
"3\n7\n0\n",
"3\n3\n0\n",
"3\n0\n0\n",
"3\n1\n0\n",
"3\n2\n0\n",
"3\n-1\n0\n",
"3\n5\n0\n",
"3\n8\n0\n",
"3\n6\n0\n",
"3\n9\n0\n"
] | [
"Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6 7 15 16 28\n 3 5 8 14 17 27 29\n 4 9 13 18 26 30 39\n 10 12 19 25 31 38 40\n 11 20 24 32 37 41 46\n 21 23 33 36 42 45 47\n 22 34 35 43 44 48 49\n",
"Case 1:\n 1 2 6\n 3 5 7\n 4 8 9\nCase 2:\n 1 2 6\n 3 5 7\n 4 8 9\n",
"Case 1:... |
CodeContests | Quantum love solving mathematical problems. One day his teacher give him problem on divisibility to check his mathematical skills. He give him four numbers a,b,c,d and asked him to check whether (a^b) is divisible by (c^d) or not. As the constrains are high, so quantum need your help to answer the query.
INPUT
First ... | stdin | null | 2,394 | 1 | [
"1\n4 6 2 4\n\nSAMPLE\n"
] | [
"Divisible\n"
] | [
"1\n4 6 1 4\n\nSAMPLE\n",
"1\n3 4 2 2\n\nSAMPLE\n",
"1\n4 4 2 4\n\nSAMPLE\n",
"1\n4 6 2 1\n\nSAMPLE\n",
"1\n4 4 2 2\n\nSAMPLE\n",
"1\n4 3 2 1\n\nSAMPLE\n",
"1\n4 0 2 1\n\nSAMPLE\n",
"1\n1 4 2 2\n\nSAMPLE\n",
"1\n8 0 2 1\n\nSAMPLE\n",
"1\n1 4 2 2\n\nELPMAS\n"
] | [
"Divisible\n",
"Not divisible\n",
"Divisible\n",
"Divisible\n",
"Divisible\n",
"Divisible\n",
"Not divisible\n",
"Not divisible\n",
"Not divisible\n",
"Not divisible\n"
] |
CodeContests | Silver Fox is fighting with N monsters.
The monsters are standing in a row, and we can assume them to be standing on a number line. The i-th monster, standing at the coordinate X_i, has the health of H_i.
Silver Fox can use bombs to attack the monsters. Using a bomb at the coordinate x decreases the healths of all mo... | stdin | null | 1,924 | 1 | [
"9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n",
"3 3 2\n1 2\n5 4\n9 2\n",
"3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n"
] | [
"5\n",
"2\n",
"3000000000\n"
] | [
"9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 0\n",
"3 3 2\n1 4\n5 4\n9 2\n",
"3 0 1\n77888184 1000000000\n100000000 1000000000\n200000000 1000000000\n",
"3 0 1\n86580931 1000000000\n100000000 1000001000\n200000000 1000000000\n",
"2 3 1\n1 1\n5 6\n9 2\n",
"2 0 1\n1 1\n5 6\n9 2\n",
"2 0 2\n1 1\n5 6\n... | [
"5\n",
"3\n",
"3000000000\n",
"3000001000\n",
"6\n",
"7\n",
"4\n",
"1\n",
"0\n",
"10\n"
] |
CodeContests | Little Jhool always wanted to have some psychic powers so that he could showoff his skills, and magic to people and impress them. (Specially, his girlfriend Big Jhool!) But, in spite all his efforts, hardwork, dedication, Googling, watching youtube videos he couldn't garner any psychic abilities!
He knew everyone was ... | stdin | null | 4,260 | 1 | [
"0001111110\n\nSAMPLE\n"
] | [
"Sorry, sorry!\n"
] | [
"1000111000111001111000111\n",
"1111010100110100101011101100101101110011000010100010000001111100010011100101010001101111000001011000\n",
"0101100011001110001110100111100011010101011000000000110110010010110100101111010111100011101100100101\n",
"1111110\n",
"11111111101111\n",
"110000111110\n",
"000111111... | [
"Good luck!\n",
"Sorry, sorry!\n",
"Sorry, sorry!\n",
"Sorry, sorry!\n",
"Sorry, sorry!\n",
"Good luck!\n",
"Sorry, sorry!\n",
"Good luck!\n",
"Sorry, sorry!\n",
"Sorry, sorry!\n"
] |
CodeContests | Read a set of coordinates of three different points P1 (x1, y1), P2 (x2, y2), Q (xq, yq) on the plane, and line symmetry with point Q with the straight line passing through point P1 point P2 as the axis of symmetry. Create a program that outputs the point R (x, y) at the position of. Note that the point Q is not on its... | stdin | null | 1,933 | 1 | [
"1.0,0.0,-1.0,0.0,1.0,1.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n0.0,1.0,0.0,-1.0,1.0,1.0\n"
] | [
"1.000000 -1.000000\n1.000000 2.000000\n-1.000000 1.000000\n"
] | [
"1.0,0.0,-1.0,0.0,1.0,1.0\n1.0,0.0,0.0,-1.0,0.0,0.3\n0.0,1.0,0.0,-1.0,1.0,1.0\n",
"1.0,0.0,-1.0,0.0,1.0,1.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n1.0,1.0,0.0,-1.0,1.0,1.0\n",
"1.0,0.0,-1.0,0.0,1.0,2.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n1.0,1.0,0.1,-1.0,1.0,1.0\n",
"0.0,0.1,-1.0,0.0,1.0,2.0\n1.0,0.0,0.0,-1.0,3.0,0.0\n1.0,1.0,0.1... | [
"1.00000 -1.00000\n1.30000 -1.00000\n-1.00000 1.00000\n",
"1.00000 -1.00000\n1.00000 2.00000\n1.00000 1.00000\n",
"1.00000 -2.00000\n1.00000 2.00000\n1.00000 1.00000\n",
"1.35644 -1.56436\n1.00000 2.00000\n1.00000 1.00000\n",
"1.35644 -1.56436\n1.00000 2.00000\n1.99448 0.10497\n",
"1.00000 -1.00000\n-3.00... |
CodeContests | In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages
.
Assume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built functions. So here's your cha... | stdin | null | 3,658 | 1 | [
"3\n10\n5\n10000\n"
] | [
"3\n2\n100\n"
] | [
"3\n10\n5\n10010\n",
"3\n1\n5\n10000\n",
"3\n1\n11\n10000\n",
"3\n1\n2\n10000\n",
"3\n10\n2\n10100\n",
"3\n1\n12\n11100\n",
"3\n1\n17\n10000\n",
"3\n2\n6\n11100\n",
"3\n16\n2\n10000\n",
"3\n19\n5\n10001\n"
] | [
"3\n2\n100\n",
"1\n2\n100\n",
"1\n3\n100\n",
"1\n1\n100\n",
"3\n1\n100\n",
"1\n3\n105\n",
"1\n4\n100\n",
"1\n2\n105\n",
"4\n1\n100\n",
"4\n2\n100\n"
] |
CodeContests | Reordering the Documents
Susan is good at arranging her dining table for convenience, but not her office desk.
Susan has just finished the paperwork on a set of documents, which are still piled on her desk. They have serial numbers and were stacked in order when her boss brought them in. The ordering, however, is not... | stdin | null | 3,406 | 1 | [
"6 3\n1 3 4 2 6 5\n"
] | [
"4\n"
] | [
"6 3\n1 5 4 2 6 5\n",
"2 1\n0 1 -1 1 -1 -1\n",
"6 3\n1 5 4 2 0 5\n",
"6 3\n1 5 4 2 0 2\n",
"6 3\n1 5 4 2 0 3\n",
"6 3\n1 5 4 4 0 3\n",
"6 3\n1 5 4 1 0 3\n",
"6 3\n1 5 1 1 0 3\n",
"6 3\n1 5 1 1 0 0\n",
"11 3\n1 5 4 2 0 5\n"
] | [
"0\n",
"2\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
] |
CodeContests | Description
THE BY DOLM @ STER is a training simulation game scheduled to be released on EXIDNA by 1rem on April 1, 2010. For the time being, it probably has nothing to do with an arcade game where the network connection service stopped earlier this month.
This game is a game in which members of the unit (formation) t... | stdin | null | 2,617 | 1 | [
"3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n5 3 11 14\n2 300\nBydo System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300\n"
] | [
"29\n462\n"
] | [
"3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n5 3 11 14\n2 300\nBydp System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300\n",
"3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n5 7 21 14\n2 300\nBydp System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300\n",
"3 10\nDobkeradops\n7 5 23 10\nPataPat... | [
"29\n462\n",
"42\n462\n",
"42\n493\n",
"34\n493\n",
"54\n493\n",
"140\n462\n",
"42\n514\n",
"32\n493\n",
"6\n493\n",
"57\n493\n"
] |
CodeContests | There are N points on the 2D plane, i-th of which is located on (x_i, y_i). There can be multiple points that share the same coordinate. What is the maximum possible Manhattan distance between two distinct points?
Here, the Manhattan distance between two points (x_i, y_i) and (x_j, y_j) is defined by |x_i-x_j| + |y_i-... | stdin | null | 3,075 | 1 | [
"3\n1 1\n2 4\n3 2\n",
"2\n1 1\n1 1\n"
] | [
"4\n",
"0\n"
] | [
"3\n1 2\n2 4\n3 2\n",
"2\n0 1\n1 1\n",
"2\n0 0\n1 1\n",
"3\n1 2\n1 4\n3 1\n",
"2\n0 -1\n1 2\n",
"3\n0 0\n1 4\n6 1\n",
"3\n0 0\n2 4\n6 1\n",
"3\n0 0\n2 4\n9 1\n",
"3\n0 0\n2 5\n9 1\n",
"3\n-1 0\n2 5\n9 0\n"
] | [
"3\n",
"1\n",
"2\n",
"5\n",
"4\n",
"8\n",
"7\n",
"10\n",
"11\n",
"12\n"
] |
CodeContests | Jiro is a fun loving lad. His classmates are very competitive and are striving for getting a good rank, while he loves seeing them fight for it. The results are going to be out soon. He is anxious to know what is the rank of each of his classmates.
Rank of i'th student = 1+ (Number of students having strictly grea... | stdin | null | 52 | 1 | [
"4\n62 96 82 55\n\nSAMPLE\n"
] | [
"3 1 2 4\n"
] | [
"384\n87 78 16 94 36 87 93 50 22 63 28 91 60 64 27 41 27 73 37 12 69 68 30 83 31 63 24 68 36 30 3 23 59 70 68 94 57 12 43 30 74 22 20 85 38 99 25 16 71 14 27 92 81 57 74 63 71 97 82 6 26 85 28 37 6 47 30 14 58 25 96 83 46 15 68 35 65 44 51 88 9 77 79 89 85 4 52 55 100 33 61 77 69 40 13 27 87 95 40 96 71 35 79 68 2 ... | [
"53 90 329 28 242 53 33 190 305 148 275 38 156 145 279 217 279 104 234 342 123 129 259 70 255 148 297 129 242 259 377 299 160 118 129 28 165 342 209 259 99 305 314 60 230 9 288 329 113 334 279 36 80 165 99 148 113 16 74 363 285 60 275 234 363 194 259 334 164 288 21 70 197 332 129 245 141 203 184 49 353 91 87 46 60 ... |
CodeContests | A rich man has a square room with mirrors for security or just for fun. Each side of the room is eight meters wide. The floor, the ceiling and the walls are not special; however, the room can be equipped with a lot of mirrors on the walls or as vertical partitions.
Every mirror is one meter wide, as tall as the wall, ... | stdin | null | 4,161 | 1 | [
"0\n1\ny 8 7\n4\ny 8 7\nx 7 8\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 2\ny 0 0\nx 0 0\n-1\n"
] | [
"800 750\n750 800\n75 25\n75 25\n"
] | [
"0\n1\ny 1 7\n4\ny 8 7\nx 7 8\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 2\ny 0 0\nx 0 0\n-1\n",
"0\n1\ny 1 7\n4\ny 8 7\nx 7 8\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 4\ny 0 0\nx 0 0\n-1\n",
"0\n1\ny 1 7\n4\ny 8 7\nx 7 7\ny 0 0\nx 0 0\n4\ny 2 1\nx 1 2\ny 0 0\nx 0 0\n-1\n",
"0\n1\ny 1 7\n4\ny 8 7\nx 7 7\ny 0 0\nx 0 0\n4\nx 2 1\nx 1 2\... | [
"800 750\n800 750\n75 25\n75 25\n",
"800 750\n800 750\n75 25\n0 350\n",
"800 750\n800 750\n800 650\n75 25\n",
"800 750\n800 750\n800 650\n800 750\n",
"800 750\n750 800\n50 0\n75 25\n",
"800 750\n800 750\n800 650\n450 0\n",
"800 750\n800 750\n800 750\n0 350\n",
"800 750\n800 750\n800 750\n800 750\n",
... |
CodeContests | William Robinson was completely puzzled in the music room; he could not find his triangle in his bag. He was sure that he had prepared it the night before. He remembered its clank when he had stepped on the school bus early that morning. No, not in his dream. His triangle was quite unique: no two sides had the same len... | stdin | null | 3,324 | 1 | [
"2\n50.36493 81.61338 79.96592\n5\n-10293.83 -4800.033 -5296.238\n14936.30 6964.826 7684.818\n-4516.069 25748.41 -27016.06\n18301.59 -11946.25 5380.309\n27115.20 43415.93 -71607.81\n11.51547 13.35555 14.57307\n5\n-56292.27 2583.892 67754.62\n-567.5082 -756.2763 -118.7268\n-1235.987 -213.3318 -216.4862\n-... | [
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n"
] | [
"2\n 50.36493 81.61338 79.96592\n5\n -10293.83 -4800.033 -5296.238\n 14936.30 6964.826 7684.818\n -4516.069 25748.41 -27016.06\n 18301.59 -11946.25 5380.309\n 27115.20 43415.99770967086 -71607.81\n 11.51547 13.35555 14.57307\n5\n -56292.27 2583.892 67754.62\n -567.5082 -756.2763 -118.7268\n... | [
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n",
"1 2 4\n3 4 2\n"
] |
CodeContests | There are N people numbered 1 to N. Each person wears a red hat or a blue hat.
You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.
Determine if there are more people wearing a red hat than people wearing a blue hat.
Constraints
* 1 \l... | stdin | null | 176 | 1 | [
"4\nRRBR\n",
"4\nBRBR\n"
] | [
"Yes\n",
"No\n"
] | [
"4\nRBRR\n",
"4\nBBRR\n",
"4\nRRCR\n",
"4\nRRAR\n",
"4\nRARR\n",
"4\nBQBR\n",
"4\nRCRR\n",
"4\nBPBR\n",
"4\nRRRC\n",
"4\nAQBR\n"
] | [
"Yes\n",
"No\n",
"Yes\n",
"Yes\n",
"Yes\n",
"No\n",
"Yes\n",
"No\n",
"Yes\n",
"No\n"
] |
CodeContests | Alice and Brown are brothers in a family and each receives pocket money in celebration of the coming year. They are very close and share the total amount of the money fifty-fifty. The pocket money each receives is a multiple of 1,000 yen.
Write a program to calculate each one’s share given the amount of money Alice an... | stdin | null | 3,402 | 1 | [
"5000 5000\n",
"1000 2000\n",
"1000 3000\n"
] | [
"5000\n",
"1500\n",
"2000\n"
] | [
"3857 5000\n",
"0000 2000\n",
"1010 3000\n",
"428 5000\n",
"0000 2954\n",
"0010 3000\n",
"824 5000\n",
"0000 4848\n",
"0000 3000\n",
"45 5000\n"
] | [
"4428\n",
"1000\n",
"2005\n",
"2714\n",
"1477\n",
"1505\n",
"2912\n",
"2424\n",
"1500\n",
"2522\n"
] |
CodeContests | Given a set S. Generate T, a set that contains all subsets of S minus the null set and calculate A, XOR sum of the set T.
S={1,2,3}
T={{1},{2},{3},{1,2},{1,3},{2,3} ,{1,2,3}}
A=XORiana of T .
XORiana of a set is defined as XOR of all the elements it contains.
Constraints:
1 ≤ T ≤ 100
1 ≤ N ≤ 100
0 ≤ Array[i] ≤ 200
... | stdin | null | 3,669 | 1 | [
"2\n2 \n3 3\n3 \n1 2 3\n\nSAMPLE\n"
] | [
"0\n0\n"
] | [
"100\n100\n41 67 134 100 169 124 78 158 162 64 105 145 81 27 161 91 195 142 27 36 191 4 102 153 92 182 21 116 118 95 47 126 171 138 69 112 67 99 35 94 103 11 122 133 73 64 141 111 53 68 147 44 62 157 37 59 123 141 129 178 116 35 190 42 88 106 40 142 64 48 46 5 90 129 170 150 6 101 193 148 29 23 84 154 156 40 166 17... | [
"0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n27\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n",
"0\n0\n",... |
CodeContests | On a large chess board, there are N ants, each numbered from 1 to N. As shown in the figure, the chess board is a rectangle consisting of H × W squares, with the northwest corner as white, and white squares and black squares are arranged alternately.
<image>
Initially, every ant is in a chessboard square, facing ea... | stdin | null | 1,816 | 1 | [
"3 3 3\n2 1 S\n1 2 E\n2 2 E\n",
"5 4 3\n3 1 S\n2 2 E\n1 3 E\n"
] | [
"3\n1\n2\n",
"2\n3\n1\n"
] | [
"3 3 3\n2 1 S\n1 2 E\n3 2 E\n",
"3 3 1\n2 1 S\n1 2 E\n3 2 E\n",
"5 4 3\n3 1 S\n2 3 E\n1 3 E\n",
"3 3 3\n2 1 S\n1 1 E\n1 2 E\n",
"3 5 2\n2 1 S\n2 2 E\n6 2 E\n",
"3 3 3\n2 0 S\n1 2 E\n2 2 E\n",
"5 4 2\n3 1 S\n2 3 E\n2 3 E\n",
"3 3 3\n2 2 S\n1 2 E\n2 2 E\n",
"3 3 1\n2 1 S\n2 2 E\n3 2 E\n",
"3 2 1\n2 ... | [
"3\n1\n2\n",
"1\n",
"2\n3\n1\n",
"1\n2\n3\n",
"2\n1\n",
"3\n2\n1\n",
"1\n2\n",
"1\n3\n2\n",
"1\n",
"1\n"
] |
CodeContests | There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the nu... | stdin | null | 537 | 1 | [
"8\n7 5 1 1 7 3 5 3\n",
"7\n6 4 0 2 4 0 2\n",
"5\n2 4 4 0 2\n"
] | [
"16\n",
"0\n",
"4\n"
] | [
"8\n7 5 1 2 7 3 5 3\n",
"7\n6 4 0 2 4 0 4\n",
"5\n0 4 4 0 2\n",
"7\n6 4 0 2 4 -1 4\n",
"5\n0 4 4 0 1\n",
"7\n6 4 0 2 8 -1 4\n",
"5\n0 4 1 0 1\n",
"7\n6 4 0 2 8 0 4\n",
"5\n0 4 0 0 1\n",
"7\n6 4 1 2 8 0 4\n"
] | [
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n",
"0\n"
] |
CodeContests | Given is a three-digit integer N. Does N contain the digit 7?
If so, print `Yes`; otherwise, print `No`.
Constraints
* 100 \leq N \leq 999
Input
Input is given from Standard Input in the following format:
N
Output
If N contains the digit 7, print `Yes`; otherwise, print `No`.
Examples
Input
117
Output
Y... | stdin | null | 3,631 | 1 | [
"777\n",
"123\n",
"117\n"
] | [
"Yes\n",
"No\n",
"Yes\n"
] | [
"1413\n",
"187\n",
"68\n",
"1760\n",
"89\n",
"144\n",
"2610\n",
"151\n",
"91\n",
"3439\n"
] | [
"No\n",
"Yes\n",
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n"
] |
CodeContests | Today Oz is playing a new game. He has an array arr[] of N distinct integers . In each turn he is will follow two actions -
1) He select a random number from arr[]. Say value of this element is X.
2) He will remove X from arr[]. if X-1 is present in arr[] then he will remove it. if X+1 is present in arr[] then he will... | stdin | null | 4,063 | 1 | [
"1\n6\n291 292 295 297 298 299\n\nSAMPLE\n"
] | [
"4\n"
] | [
"1\n6\n291 292 295 297 158 299\n\nSAMPLE\n",
"1\n6\n559 292 295 297 158 299\n\nSAMPLE\n",
"1\n6\n291 292 529 297 298 299\n\nSAMPLE\n",
"1\n6\n559 292 295 297 158 115\n\nSAMPLE\n",
"1\n6\n559 292 295 297 158 115\n\nPAMSLE\n",
"1\n6\n559 292 295 297 120 115\n\nPAMSLE\n",
"1\n6\n559 292 295 297 120 212\n\n... | [
"5\n",
"6\n",
"4\n",
"6\n",
"6\n",
"6\n",
"6\n",
"6\n",
"6\n",
"6\n"
] |
CodeContests | The postal system in the area where Masa lives has changed a bit. In this area, each post office is numbered consecutively from 1 to a different number, and mail delivered to a post office is intended from that post office via several post offices. Delivered to the post office. Mail "forwarding" is only done between sp... | stdin | null | 2,895 | 1 | [
"4 5\n1 2 10\n1 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 20 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinessMailC\n2 3 1 BusinessMailB\n3 1 1 BusinessMailA\n0 0\n"
] | [
"Greetings 25\nLoveLetter 33\n\nBusinessMailA 2\nBusinessMailB 2\nBusinessMailC 2\n"
] | [
"4 5\n1 2 10\n1 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 13 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinessMailC\n2 3 1 BusinessMailB\n3 1 1 BusinessMailA\n0 0\n",
"4 5\n1 2 10\n2 3 15\n2 3 5\n2 4 3\n3 4 10\n2\n1 4 10 LoveLetter\n2 3 13 Greetings\n3 3\n1 2 1\n2 3 1\n3 1 1\n3\n1 2 1 BusinesrMai... | [
"Greetings 18\nLoveLetter 26\n\nBusinessMailA 2\nBusinessMailB 2\nBusinessMailC 2\n",
"Greetings 18\nLoveLetter 26\n\nBusinesrMailC 2\nBusinessMailA 2\nBusinessMailB 2\n",
"Greetings 18\nLoveLetter 27\n\nBusinessMailA 2\nBusinessMailB 2\nBusinessMailC 2\n",
"Greetings 18\nLoveLetter 30\n\nBusinesrMailC 2\nBus... |
CodeContests | There is a grid with H rows and W columns.
The square at the i-th row and j-th column contains a string S_{i,j} of length 5.
The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet.
<image>
Exactly one of... | stdin | null | 3,560 | 1 | [
"15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsna... | [
"H6\n",
"A1\n"
] | [
"15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsna... | [
"H6\n",
"H6\n",
"H6\n",
"H6\n",
"H6\n",
"H6\n",
"H6\n",
"H6\n",
"H6\n",
"H6\n"
] |
CodeContests | Would you want to fight against bears riding horses?
Me neither.
Limak is a grizzly bear.
He is a general of the dreadful army of Bearland.
The most important part of an army is the cavalry of course.
The cavalry of Bearland consists of N warriors and N horses, both numbered 1 through N.
Limak knows the strength of e... | stdin | null | 3,623 | 1 | [
"2\n6\n12 9 7 1 20 10\n3 6 4 7 5 5\n4\n5 17 10 1\n200 400 800 600\n\nSAMPLE\n"
] | [
"YES\nNO\n"
] | [
"50\n4\n100 785 393 616 \n2 45 586 236 \n4\n200 448 825 664 \n905 570 664 402 \n8\n500 536 971 937 162 289 63 442 \n845 427 269 921 860 259 298 8 \n12\n700 42 623 44 87 560 631 398 8 807 413 264 \n376 76 665 682 964 987 970 125 275 32 918 471 \n13\n500 539 743 669 797 393 28 839 434 651 234 872 562 \n864 622 921 67... | [
"NO\nNO\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\n",
"NO\nNO\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\n... |
CodeContests | C: Canisal cryptography
problem
Ebi-chan was given the string C obtained by encrypting a non-negative integer D with "canisal cipher". This cipher replaces each number in decimal notation with a fixed number (not necessarily different from the original). Different numbers will not be replaced with the same number, an... | stdin | null | 553 | 1 | [
"2\n1000000007\n"
] | [
"1000000009\n"
] | [
"2\n1036219253\n",
"2\n8\n",
"2\n1612950356\n",
"2\n2998753809\n",
"2\n1978754927\n",
"2\n2655259302\n",
"2\n3155611415\n",
"2\n1020631181\n",
"2\n120033745\n",
"2\n37469551\n"
] | [
"-1\n",
"2\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
] |
CodeContests | Little Fajlu and Laal Baadshah are extremely good, and passionate Age of Empires 2 players. They're crazy about the game, and the passion they display for the game, if displayed for their semester exams - will make them top the university, even. But well, that's them.
Laal Baadshah relies on rushing through the game, ... | stdin | null | 1,878 | 1 | [
"1\n389 130 16 13 18 24\n\nSAMPLE\n"
] | [
"42\n"
] | [
"43\n7878 11534 994 594 238 1250\n907 25648 745 699 879 2683\n5983 18415 152 1125 329 2446\n9953 39484 664 217 183 803\n25088 23845 164 1000 625 1234\n20871 29178 798 473 321 2156\n17429 18787 492 470 862 358\n31262 32383 898 151 666 1707\n9447 19848 167 620 545 150\n15265 6082 995 284 105 2892\n8512 4417 602 904 6... | [
"76520\n13139\n51087\n65116\n237641\n164149\n200196\n349009\n102310\n148453\n65243\n329018\n109037\n415519\n223737\n15129\n213164\n103053\n206031\n258777\n47225\n164619\n352188\n4324\n174024\n67337\n139475\n349935\n71652\n146882\n330063\n230849\n34030\n249662\n8930\n33144\n242570\n147976\n122022\n188322\n-1\n83837\... |
CodeContests | Railroad Trip
There are N cities in the JOI country, numbered 1, 2, ..., and N, respectively. In addition, there are N − 1 railroads, which are numbered 1, 2, ..., and N − 1, respectively. The railroad i (1 ≤ i ≤ N − 1) connects the city i and the city i + 1 in both directions.
There are two ways to get on the JOI ra... | stdin | null | 1,333 | 1 | [
"4 4\n1 3 2 4\n120 90 100\n110 50 80\n250 70 130\n"
] | [
"550\n"
] | [
"4 4\n1 3 2 4\n120 90 100\n110 50 80\n250 70 24\n",
"4 4\n1 3 2 4\n120 90 100\n110 50 80\n250 75 130\n",
"4 4\n1 3 2 4\n120 90 100\n110 50 33\n250 70 24\n",
"4 4\n1 3 2 4\n120 90 100\n110 50 96\n250 75 130\n",
"4 4\n1 3 2 4\n120 90 100\n110 75 33\n250 70 24\n",
"4 4\n1 3 2 4\n120 90 100\n110 50 96\n115 75... | [
"444\n",
"555\n",
"397\n",
"571\n",
"472\n",
"481\n",
"550\n",
"412\n",
"503\n",
"635\n"
] |
CodeContests | Given the time shown by a wall clock, you have to output the internal angle between the minute and hour hand of the clock.
(Wall Clock displays a 12 hour format.)
For instance, if the time shown is 01:00 , the angle between the hands is 30 degrees.
Input : Time in HH:MM format
Output: The angle in degrees, correct u... | stdin | null | 3,348 | 1 | [
"04:00\n\nSAMPLE\n"
] | [
"120.000000\n"
] | [
"06:55\n",
"05:56\n",
"04:00\n\nSAMELP\n",
"01:10\n",
"00:10\n",
"04:01\n\nEAMRMP\n",
"00:04\n\nOLSMAE\n",
"04:10\n\nNLSMAE\n",
"01:00\n",
"02:00\n"
] | [
"122.500000\n",
"158.000000\n",
"120.000000\n",
"25.000000\n",
"55.000000\n",
"114.500000\n",
"22.000000\n",
"65.000000\n",
"30.000000\n",
"60.000000\n"
] |
CodeContests | Problem Statement
Do you know the data structure called BDD (Binary Decision Diagram)? In recent years, ZDD, which has become a hot topic in the video related to Combinatorial Explosion Sister, is a data structure derived from BDD. This problem is a basic implementation of BDD.
BDD is a cycleless graph (DAG) that rep... | stdin | null | 2,027 | 1 | [
"2\n0000\n",
"5\n11110101011100110010111100010001\n",
"3\n01100110\n",
"2\n0110\n",
"N\nbit_line\n"
] | [
"0\n",
"12\n",
"3\n",
"3\n",
"3\n"
] | [
"2\n0001\n",
"5\n11110101011100110010111100010011\n",
"3\n00100110\n",
"N\nbit_ljne\n",
"2\n0011\n",
"3\n00101110\n",
"5\n11110101011100110010111100000010\n",
"3\n00101010\n",
"5\n10111101011100110010111100000010\n",
"5\n10111100111100110010110100010010\n"
] | [
"2\n",
"13\n",
"5\n",
"0\n",
"1\n",
"4\n",
"12\n",
"3\n",
"14\n",
"15\n"
] |
CodeContests | Alfie was a prisoner in mythland. Though Alfie was a witty and intelligent guy.He was confident of escaping prison.After few days of observation,He figured out that the prison consists of (N × N) cells.i.e The shape of prison was (N × N) matrix. Few of the cells of the prison contained motion detectors.So Alfie planned... | stdin | null | 1,316 | 1 | [
"3\n4\n0 1 1 0 \n0 0 1 0 \n0 0 0 0 \n0 1 1 0 \n4\n0 0 0 1 \n0 0 0 0 \n1 1 1 0 \n1 0 0 0 \n4\n0 1 1 0 \n0 0 1 1 \n0 0 0 0 \n0 1 0 0 \n \nSAMPLE\n"
] | [
"2\n4\n4\n"
] | [
"3\n4\n0 1 1 0 \n0 0 1 0 \n0 0 0 1 \n0 1 1 0 \n4\n0 0 0 1 \n0 0 0 0 \n1 1 1 0 \n1 0 0 0 \n4\n0 1 1 0 \n0 0 1 1 \n0 0 0 0 \n0 1 0 0\n",
"3\n4\n0 1 1 0 \n0 0 1 0 \n1 0 0 0 \n0 1 1 0 \n4\n0 0 0 1 \n0 0 0 0 \n1 1 1 0 \n1 0 0 0 \n4\n0 1 1 0 \n0 0 1 1 \n0 0 0 0 \n0 1 0 0 \n \nSAMPLE\n",
"3\n4\n0 1 1 0 \n0 0 1 0 \n0 0... | [
"0\n4\n4\n",
"1\n4\n4\n",
"0\n4\n0\n",
"2\n4\n4\n",
"4\n4\n4\n",
"0\n16\n0\n",
"2\n4\n1\n",
"0\n4\n2\n",
"0\n28\n0\n",
"0\n2\n0\n"
] |
CodeContests | See Russian Translation
It's a fine sunny afternoon today in California. Looking at the pleasant weather, Sumit is all ready to go out and play with his friend Rohil. Unfortunately, Rohil is down with fever. Seeing that his friend is ill, Sumit decides not to go out - instead play with Rohil inside the house. Sumit lo... | stdin | null | 4,967 | 1 | [
"6\nvinay\nvainy\nvinit\nviint\navinash\naasivnh\n\nSAMPLE\n"
] | [
"3\n"
] | [
"24\nabcd\nabdc\nacbd\nacdb\nadbc\nadcb\nbacd\nbadc\nbcad\nbcda\ncadb\nbdca\ncabd\ncadb\ncbad\ncbda\ncdab\ncdba\ndabc\ndacb\ndbac\ndbca\ndcab\ndcba\n",
"6\nvynai\nvainy\nvinit\nviint\navinash\naasivnh\n\nSAMPLE\n",
"24\nabcd\nabdc\nacbd\nacdb\nadbc\nadcb\nbacd\nbadc\nbcad\nbcda\ncadb\nbdca\ncabd\ncadb\ncbad\ncb... | [
"12\n",
"4\n",
"13\n",
"5\n",
"6\n",
"12\n",
"5\n",
"12\n",
"12\n",
"6\n"
] |
CodeContests | In Group C of the 3rd year, we decided to use the "class flag" used at the sports festival on November 10, 2007 at future class reunions. So, in order to decide which students to keep the "class flag", I decided to play the following game using a large amount of candy that the teacher gave me the other day.
* Each stu... | stdin | null | 698 | 1 | [
"50\n5576\n5577\n5578\n"
] | [
"3C11\n3C38\n3C39\n3C01\n"
] | [
"50\n5576\n6063\n5578\n",
"50\n5576\n6063\n515\n",
"50\n5576\n6063\n39\n",
"50\n9200\n6063\n39\n",
"50\n2171\n6063\n39\n",
"50\n1864\n6063\n39\n",
"50\n1864\n7383\n39\n",
"50\n1864\n7046\n39\n",
"50\n1864\n13193\n39\n",
"50\n1864\n896\n39\n"
] | [
"3C11\n3C38\n3C18\n3C01\n",
"3C11\n3C38\n3C18\n3C08\n",
"3C11\n3C38\n3C18\n3C39\n",
"3C11\n3C35\n3C18\n3C39\n",
"3C11\n3C26\n3C18\n3C39\n",
"3C11\n3C31\n3C18\n3C39\n",
"3C11\n3C31\n3C12\n3C39\n",
"3C11\n3C31\n3C26\n3C39\n",
"3C11\n3C31\n3C11\n3C39\n",
"3C11\n3C31\n3C38\n3C39\n"
] |
CodeContests | There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i).
We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation:
* Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates... | stdin | null | 2,802 | 1 | [
"3\n1 4\n4 6\n7 8\n",
"4\n1 1\n1 2\n2 1\n2 2\n",
"2\n1 1\n2 2\n"
] | [
"1\n",
"2\n",
"1\n"
] | [
"3\n1 4\n4 6\n11 8\n",
"2\n1 2\n2 2\n",
"4\n1 1\n1 4\n2 1\n2 2\n",
"3\n1 4\n4 6\n11 3\n",
"3\n0 4\n4 6\n11 3\n",
"3\n-1 4\n4 6\n11 3\n",
"3\n-2 4\n4 6\n11 3\n",
"3\n-2 4\n5 6\n11 3\n",
"3\n-2 4\n5 6\n11 4\n",
"3\n-1 4\n5 6\n11 4\n"
] | [
"2\n",
"1\n",
"3\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n"
] |
CodeContests | problem
Given the sequence $ A $ of length $ N $. The $ i $ item in $ A $ is $ A_i $. You can do the following for this sequence:
* $ 1 \ leq i \ leq N --Choose the integer i that is 1 $. Swap the value of $ A_i $ with the value of $ A_ {i + 1} $.
Find the minimum number of operations required to make $ A $ a sequ... | stdin | null | 2,939 | 1 | [
"5\n1 2 3 4 5\n"
] | [
"2\n"
] | [
"5\n0 2 3 4 5\n",
"5\n1 2 1 4 5\n",
"5\n0 4 3 13 4\n",
"5\n0 2 3 4 8\n",
"5\n0 2 3 4 14\n",
"5\n0 1 3 4 5\n",
"5\n0 2 3 4 2\n",
"5\n0 2 3 8 2\n",
"5\n0 2 3 13 2\n",
"5\n0 2 3 13 4\n"
] | [
"2\n",
"1\n",
"0\n",
"2\n",
"2\n",
"2\n",
"1\n",
"1\n",
"1\n",
"1\n"
] |
CodeContests | Matryoshka
Matryoshka is a famous Russian folk craft doll. Matryoshka can be divided into upper and lower parts, and when opened, there is another smaller doll inside. The nesting structure is such that when the small doll that appears is opened, a smaller doll is contained.
<image>
You found an unusually shaped ma... | stdin | null | 2,382 | 1 | [
"2\n1 2 3\n4 2 3\n3\n2 5 2\n3 3 4\n5 5 5\n5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n5\n1 1 1\n2 1 1\n3 1 1\n4 1 1\n5 1 1\n10\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n3 2 3\n8 4 6\n2 6 4\n3 3 8\n3 2 7\n0\n"
] | [
"24\n145\n125\n15\n864\n"
] | [
"2\n1 4 3\n4 2 3\n3\n2 5 2\n3 3 4\n5 5 5\n5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n5\n1 1 1\n2 1 1\n3 1 1\n4 1 1\n5 1 1\n10\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9\n3 2 3\n8 4 6\n2 6 4\n3 3 8\n3 2 7\n0\n",
"2\n1 4 3\n4 2 3\n3\n2 5 2\n3 3 4\n5 5 5\n5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n5 5 5\n5\n2 1 1\n2 1 1\n3 1 1\n4 1 1\n5 1 1... | [
"36\n145\n125\n15\n864\n",
"36\n145\n125\n16\n864\n",
"36\n145\n150\n16\n864\n",
"36\n145\n150\n16\n945\n",
"24\n145\n137\n15\n864\n",
"36\n145\n125\n15\n846\n",
"36\n145\n125\n16\n804\n",
"36\n145\n125\n18\n864\n",
"36\n245\n150\n16\n864\n",
"36\n145\n150\n16\n903\n"
] |
CodeContests | Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20.
Input
An integer n (1 ≤ n ≤ 20) in a line.
Output
Print the factorial of n in a line.
Example
Input
5
Output
120 | stdin | null | 2,055 | 1 | [
"5\n"
] | [
"120\n"
] | [
"3\n",
"4\n",
"6\n",
"10\n",
"20\n",
"27\n",
"41\n",
"34\n",
"40\n",
"47\n"
] | [
"6\n",
"24\n",
"720\n",
"3628800\n",
"2432902008176640000\n",
"10888869450418352160768000000\n",
"33452526613163807108170062053440751665152000000000\n",
"295232799039604140847618609643520000000\n",
"815915283247897734345611269596115894272000000000\n",
"258623241511168180642964355153611979969197632... |
CodeContests | Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the number of different ways for the robot using exactly K turns (we define a "... | stdin | null | 2,505 | 1 | [
"4 2\n4 3\n5 3\n0 0\n"
] | [
"4\n8\n18\n"
] | [
"2 2\n4 3\n5 3\n0 0\n",
"2 2\n5 3\n5 3\n0 0\n",
"2 1\n4 3\n5 3\n0 0\n",
"2 1\n4 2\n5 3\n0 0\n",
"2 2\n5 5\n5 2\n0 0\n",
"2 1\n3 2\n5 3\n0 0\n",
"2 2\n5 0\n5 3\n0 0\n",
"2 1\n4 6\n5 3\n0 0\n",
"2 2\n0 5\n5 3\n0 0\n",
"2 1\n5 5\n5 2\n0 0\n"
] | [
"774058230\n8\n18\n",
"774058230\n18\n18\n",
"2\n8\n18\n",
"2\n4\n18\n",
"774058230\n18\n6\n",
"2\n2\n18\n",
"774058230\n693514561\n18\n",
"2\n258019410\n18\n",
"774058230\n160285127\n18\n",
"2\n18\n6\n"
] |
CodeContests | Example
Input
2
1 2
Output
2 | stdin | null | 667 | 1 | [
"2\n1 2\n"
] | [
"2\n"
] | [
"2\n2 2\n",
"2\n2 3\n",
"2\n2 4\n",
"2\n2 7\n",
"2\n2 17\n",
"2\n1 12\n",
"2\n0 12\n",
"2\n1 1\n",
"2\n-1 -5\n",
"2\n1 3\n"
] | [
"4\n",
"6\n",
"8\n",
"-1\n",
"34\n",
"12\n",
"0\n",
"1\n",
"5\n",
"3\n"
] |
CodeContests | There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i.
You are now at town 1, and you want to visit all the ... | stdin | null | 3,839 | 1 | [
"7 1 100\n40 43 45 105 108 115 124\n",
"7 1 2\n24 35 40 68 72 99 103\n",
"4 2 5\n1 2 5 7\n"
] | [
"84\n",
"12\n",
"11\n"
] | [
"7 1 100\n40 43 45 3 108 115 124\n",
"7 1 2\n24 35 40 26 72 99 103\n",
"7 1 100\n40 43 45 3 108 196 37\n",
"7 1 100\n40 67 45 3 146 196 37\n",
"7 1 101\n40 67 45 3 146 196 37\n",
"7 2 101\n40 67 45 3 146 196 37\n",
"7 2 101\n40 67 30 4 146 147 37\n",
"7 2 101\n40 105 30 4 146 147 37\n",
"7 2 101\n20... | [
"79\n",
"-4\n",
"-8\n",
"-46\n",
"-45\n",
"-191\n",
"-189\n",
"-218\n",
"-224\n",
"-155\n"
] |
CodeContests | At Aizu Riverside Hospital, inpatients walk twice a day for rehabilitation and health promotion. As the number of people trying to recover their physical strength by walking is increasing day by day in order to leave the hospital energetically, the director plans to give a present to the person who walked the longest d... | stdin | null | 2,409 | 1 | [
"5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10000 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n"
] | [
"5000 5633\n345 7396\n"
] | [
"5\n263 2345 2504\n1 3210 1985\n5000 1501 4132\n10001 503 3107\n51 1758 2690\n3\n345 5000 2396\n7 3910 1590\n6789 2525 3616\n0\n",
"5\n263 1519 1817\n2 1240 1985\n5000 1501 4132\n10001 503 3107\n51 1421 2690\n3\n345 1628 2396\n7 3910 1590\n5982 2525 3616\n0\n",
"5\n263 1519 1817\n2 1240 1985\n5000 1896 4132\n10... | [
"5000 5633\n345 7396\n",
"5000 5633\n5982 6141\n",
"5000 6028\n5982 6141\n",
"8382 6028\n5982 6141\n",
"11656 6028\n5982 6141\n",
"11656 6028\n5982 8154\n",
"5000 5633\n477 7396\n",
"5000 5633\n6789 6141\n",
"5000 5633\n45 7396\n",
"8382 6028\n7 5500\n"
] |
CodeContests | "Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfaction occurs, but I'm too busy to check the actual procession while the ... | stdin | null | 2,096 | 1 | [
"5\n6\n7\n8\n"
] | [
"0\n14\n9\n4\n"
] | [
"5\n12\n7\n8\n",
"5\n12\n12\n8\n",
"5\n12\n12\n13\n",
"5\n24\n12\n13\n",
"5\n24\n18\n13\n",
"5\n24\n34\n13\n",
"5\n25\n34\n13\n",
"5\n25\n23\n13\n",
"5\n25\n27\n13\n",
"5\n24\n27\n13\n"
] | [
"0\n3\n9\n4\n",
"0\n3\n3\n4\n",
"0\n3\n3\n2\n",
"0\n11\n3\n2\n",
"0\n11\n15\n2\n",
"0\n11\n8\n2\n",
"0\n6\n8\n2\n",
"0\n6\n9\n2\n",
"0\n6\n18\n2\n",
"0\n11\n18\n2\n"
] |
CodeContests | Niwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.
Niwango-kun has N black rare soft toys of Niconico TV-chan and they are spread together with ordinary ones. He wanted these black rare soft toys to be close together, so he deci... | stdin | null | 4,229 | 1 | [
"19 2\n1 3\n2 3\n0 1\n1 1\n2 1\n3 1\n4 4\n5 4\n6 4\n7 4\n8 4\n8 3\n8 2\n8 1\n8 0\n7 0\n6 0\n5 0\n4 0\n",
"3 1\n0 0\n1 0\n2 0\n",
"8 3\n0 0\n0 3\n3 0\n3 3\n2 2\n2 5\n5 2\n5 5\n"
] | [
"4\n",
"1\n",
"4\n"
] | [
"19 2\n1 3\n2 3\n0 1\n1 1\n2 1\n3 1\n4 4\n5 4\n6 4\n7 4\n8 4\n8 1\n8 2\n8 1\n8 0\n7 0\n6 0\n5 0\n4 0\n",
"3 2\n0 0\n1 0\n2 0\n",
"1 4\n0 0\n2 1\n2 0\n",
"8 3\n0 0\n0 3\n6 0\n1 3\n2 0\n2 10\n5 2\n0 8\n",
"17 2\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 0\n11 0\n11 -1\n7 0\... | [
"4\n",
"2\n",
"0\n",
"3\n",
"5\n",
"1\n",
"6\n",
"8\n",
"4\n",
"4\n"
] |
CodeContests | On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.
For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.
The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.
Two participants A and B can c... | stdin | null | 4,547 | 1 | [
"4 6\n3 1 2 3\n2 4 2\n2 4 6\n1 6\n",
"4 4\n2 1 2\n2 1 2\n1 3\n2 4 3\n"
] | [
"YES\n",
"NO\n"
] | [
"4 4\n2 1 2\n2 1 2\n0 3\n2 4 3\n",
"4 6\n3 2 3 3\n2 4 2\n2 4 6\n1 6\n",
"4 4\n2 2 2\n2 1 2\n0 3\n2 4 3\n",
"4 4\n2 2 2\n2 1 2\n1 3\n2 4 3\n",
"4 6\n3 1 3 3\n2 4 2\n2 4 6\n1 6\n",
"4 4\n2 2 2\n2 2 2\n0 3\n2 4 3\n",
"4 4\n2 2 2\n2 2 2\n0 3\n2 4 4\n",
"4 6\n3 2 3 4\n2 4 2\n2 4 6\n1 6\n",
"4 4\n2 2 2\n2... | [
"NO\n",
"YES\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"NO\n",
"YES\n",
"NO\n",
"NO\n"
] |
CodeContests | Apples and Oranges. You thought this question was gone when you passed class 6th. WELL YOU ARE WRONG. It's back.
See we have n apples and m oranges. You need to put these apples and oranges into some boxes. Though we've put some terms&conditions with a bright *
1. Number of apples should be same in each box.
2. Numb... | stdin | null | 2,432 | 1 | [
"12028 12772\n",
"12028 12772\n\nSAMPLE\n"
] | [
"97 103\n",
"97 103\n"
] | [
"10005123 78827706\n",
"157976 510009\n",
"12028 12462\n",
"11934 12772\n\nSAMPLE\n",
"10005123 6956314\n",
"157976 174734\n",
"14870 12462\n",
"11934 24366\n\nSAMPLE\n",
"10005123 5167368\n",
"157976 125087\n"
] | [
"3335041 26275902\n",
"157976 510009\n",
"194 201\n",
"5967 6386\n",
"10005123 6956314\n",
"1612 1783\n",
"7435 6231\n",
"1989 4061\n",
"3335041 1722456\n",
"157976 125087\n"
] |
CodeContests | As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.
We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as sho... | stdin | null | 2,171 | 1 | [
"2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n"
] | [
"77\n5\n"
] | [
"2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n1,4,1\n",
"2,5,3\n1,6,3\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n",
"2,5,3\n3,6,1\n2,4,2\n4,5,2\n3,6,3\n1,4,1\n",
"2,5,3\n3,6,1\n3,4,2\n5,5,2\n3,6,3\n1,4,1\n",
"2,5,3\n3,6,1\n2,4,2\n4,6,2\n3,6,3\n1,4,1\n",
"2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,2\n",
"1,5,3\n1,6,3\n3,4,2\n4,5,2\... | [
"75\n5\n",
"73\n5\n",
"76\n5\n",
"72\n4\n",
"77\n5\n",
"76\n6\n",
"71\n5\n",
"72\n5\n",
"70\n4\n",
"73\n4\n"
] |
CodeContests | Here is your task. You are given two strings and you have to merge/compress them in single string with minimum length such that both strings can be found (one at a time) by breaking that merged string into two parts.
NOTE:
String s2 should follow string s1.
INPUT
First line contain number of test cases T. Each test ca... | stdin | null | 2,277 | 1 | [
"2\nroadshow\nshowman\ntarun\ntarunnum\n\nSAMPLE\n"
] | [
"roadshowman\ntarunnum\n"
] | [
"2\nroadshow\nhsowman\ntarun\ntarunnum\n\nSAMPLE\n",
"2\nwoadshor\nhsowman\ntarun\ntarunnum\n\nSAMPLE\n",
"2\nwoadshor\nisowman\ntarun\ntarunnum\n\nSAMPLE\n",
"2\nwoadshor\nisowman\nnurat\ntarunnum\n\nSAMPLE\n",
"2\nwoadshor\nisoxman\nnurat\ntarunnum\n\nSAMPLE\n",
"2\nwoadshor\nnamxosi\nnurat\ntarunnum\n\... | [
"roadshowhsowman\ntarunnum\n",
"woadshorhsowman\ntarunnum\n",
"woadshorisowman\ntarunnum\n",
"woadshorisowman\nnuratarunnum\n",
"woadshorisoxman\nnuratarunnum\n",
"woadshornamxosi\nnuratarunnum\n",
"woadshoroamxosi\nnuratarunnum\n",
"woadshoroamxosi\nnuraturannum\n",
"woadshoroamyosi\nnuraturannum\n... |
CodeContests | You got an old map, which turned out to be drawn by the infamous pirate "Captain Q". It shows the locations of a lot of treasure chests buried in an island.
The map is divided into square sections, each of which has a digit on it or has no digit. The digit represents the number of chests in its 9 neighboring sections ... | stdin | null | 3,927 | 1 | [
"5 6\n*2.2**\n..*...\n..2...\n..*...\n*2.2**\n6 5\n.*2*.\n..*..\n..*..\n..2..\n..*..\n.*2*.\n5 6\n.1111.\n**...*\n33....\n**...0\n.*2**.\n6 9\n....1....\n...1.1...\n....1....\n.1..*..1.\n1.1***1.1\n.1..*..1.\n9 9\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4***\n*********\n0 0... | [
"6\n5\n5\n6\n23\n",
"6\n"
] | [
"5 6\n*3.2**\n..*...\n..2...\n..*...\n*2.2**\n6 5\n.*2*.\n..*..\n..*..\n..2..\n..*..\n.*2*.\n5 6\n.1111.\n**...*\n33....\n**...0\n.*2**.\n6 9\n....1....\n...1.1...\n....1....\n.1..*..1.\n1.1***1.1\n.1..*..1.\n9 9\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4*4*\n*********\n*4*4*4***\n*********\n0 0... | [
"7\n5\n5\n6\n23\n",
"0\n",
"6\n5\n5\n6\n23\n",
"6\n5\n5\n6\n13\n",
"7\n5\n5\n5\n23\n",
"6\n5\n5\n1\n",
"7\n5\n5\n1\n",
"6\n2\n",
"7\n5\n6\n6\n23\n",
"6\n5\n4\n6\n23\n"
] |
CodeContests | Adriana was playing with the English alphabet. When she was done playing with the alphabet, she realised that she had jumbled up the positions of the letters. Now, given a set of words, she wondered what would be the dictionary ordering of these words based on the new alphabet ordering which she made.
In other words,... | stdin | null | 4,141 | 1 | [
"2\nabcdefghijklmnopqrstuvwxyz\n2\naa\nbb\nbacdefghijklmnopqrstuvwxyz\n2\naa\nbb\n\nSAMPLE\n"
] | [
"aa\nbb\nbb\naa\n"
] | [
"5\neklpyqrbgjdwtcaxzsnifvhmou\n30\ncdxrjmowfrxsjybldbefsarcbynecdy\ngxxpklorellnmpapqfwkh\np\nmcoqhnwnk\newhsqmgbbuq\nljjivswmdkqtbxixmvtrrbljptnsn\nwzqf\nmafadrrwsofsbcnuvqhf\nbsaqxw\nqcacehchzvfrkmlnozjkpqpxrjxkitzyxacbhhkicqco\nndtomfgdwdwfcgpxiqvkuytdlcgdewhtaciohor\ntq\nvwcsgspqoqmsboaguwnnyqxnzlgdg\npbtrwbln... | [
"ewhsqmgbbuq\nkwcibxubumenmeyatdrmydiajxloghiqfmz\nljjivswmdkqtbxixmvtrrbljptnsn\nlvihjo\np\npbtrwblnsad\npggkbbipzzrzucxamlu\nyjgfdxvtnunneslsplwuiupfxlzbknhkw\nqcacehchzvfrkmlnozjkpqpxrjxkitzyxacbhhkicqco\nbsaqxw\ngxxpklorellnmpapqfwkh\ngiooobppleqlwphapjnadqhdcnvw\njddntgeiqvdgaijvwcyaubwewpjvygehljxepbpiwu\nwzq... |
CodeContests | Coding in Sprout (a programming language) is very intuitive. Chef is giving his minions a demonstration in Sprout and wants you to
help him determine if they are not too difficult for them.
A program in Sprout is written using three kinds of instructions.
Load Instruction: Load a value into buffer.
Increment Instr... | stdin | null | 1,389 | 1 | [
"2\nhelloworld\nmississippi\n"
] | [
"NO\nYES\n"
] | [
"2\ndlrowolleh\nmississippi\n",
"2\nielmoworld\nmississippi\n",
"2\nielomworld\nmisrissippi\n",
"2\njeopmujlrd\nhqhspsrhlpj\n",
"2\ndlrowomleh\nmississippi\n",
"2\ndlrowomleh\nippississim\n",
"2\ndlrowomlei\nmississippi\n",
"2\nielomworld\nmississippi\n",
"2\nielomworld\nmisrisshppi\n",
"2\nielomw... | [
"NO\nYES\n",
"YES\nYES\n",
"NO\nNO\n",
"YES\nNO\n",
"NO\nYES\n",
"NO\nYES\n",
"NO\nYES\n",
"NO\nYES\n",
"NO\nNO\n",
"NO\nYES\n"
] |
CodeContests | C: Acrophobia
Yayoi Takasugi is a super-selling idol. There is one thing she is not good at. It's a high place ... She is extremely afraid of heights. This time, due to the producer's inadequacy, she decided to take on the following challenges on a variety show.
This location will be held in a room in a ninja mansion... | stdin | null | 3,891 | 1 | [
"3 4\nS.M\n...\n...\nM.G\n"
] | [
"9\n"
] | [
"3 4\nM.S\n...\n...\nM.G\n",
"3 4\nM.S\n...\n...\nG.M\n",
"3 4\nS.N\n...\n...\nM.G\n",
"3 4\nM.S\n...\n...\nMG.\n",
"3 4\nL.S\n...\n...\nN.G\n",
"3 4\nL.S\n...\n...\nNG.\n",
"3 4\nM.S\n...\n...\n.GM\n",
"3 4\n.MS\n...\n...\nM.G\n",
"3 4\n.MS\n...\n...\nG.M\n",
"3 4\n.MS\n...\n..-\nM.G\n"
] | [
"7\n",
"9\n",
"5\n",
"6\n",
"3\n",
"4\n",
"8\n",
"7\n",
"7\n",
"7\n"
] |
CodeContests | In 4272 A.D., Master of Programming Literature, Dr. Isaac Cornell Panther-Carol, who has miraculously survived through the three World Computer Virus Wars and reached 90 years old this year, won a Nobel Prize for Literature. Media reported every detail of his life. However, there was one thing they could not report -- ... | stdin | null | 3,725 | 1 | [
"1 4\nAABBCCDDEEFFGGHHIJJKKLLMMNNOOPP\nAABBCCDDEEFFGG\nCCDDEEFFGGHHII\nFFGGHHIIJJKKLL\nJJKKLLMMNNOOPP\n2 3\nABRACADABRA.ABBRACADABRA.\nABRACADABRA.A\n.ABRACADABRA.\nBRA.ABRACADAB\n2 2\nAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAA\nAAAAAAAAAAAAA\n2 3\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXAXXXXXX\nXXXXXXBXXXXXX\nXXXXXXXXXXXXX\... | [
"1\nAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPP\n5\n.ABRACADABRA.ABRACADABRA.\nABRACADABRA.A.ABRACADABRA.\nABRACADABRA.AABRACADABRA.A\nABRACADABRA.ABRACADABRA.\nABRACADABRA.ABRACADABRA.A\n5\nAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAA\n257\n"
] | [
"1 4\nAABBCCDDEEFFGGHHIJJKKLLMMNNOOPP\nAABBCCDDEEFFGG\nCCDDEEFFGGHHII\nFFGGHHIIJJKKLL\nJJKKLLMMNNOOPP\n2 3\nABRACADABRA.ABBRACADABRA.\nABRACADABRA.A\n.ABRADADABRA.\nBRA.ABRACADAB\n2 2\nAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAA\nAAAAAAAAAAAAA\n2 3\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXAXXXXXX\nXXXXXXBXXXXXX\nXXXXXXXXXXXXX\... | [
"1\nAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPP\n3\nABRACADABRA.AABRACADABRA.A\nABRACADABRA.ABRACADABRA.A\nABRACADABRA.ABRADADABRA.\n5\nAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAA\n257\n",
"1\nAABBCCDDEEFFGGHHIIJJKKLLMMNNOOPP\n5\n.ABRACADABRA.ABRACADABRA.\nABRACADABRA.A.ABRACADAB... |
CodeContests | Koto Municipal Subway
Koto Municipal Subway
Koto City is a famous city whose roads are in a grid pattern, as shown in the figure below. The roads extending from north to south and the roads extending from east to west are lined up at intervals of 1 km each. Let Koto station at the southwestern intersection of Koto ci... | stdin | null | 4,404 | 1 | [
"2 1\n7 5\n7 6\n7 7\n76 5\n8 41\n0 0\n"
] | [
"0.4142135624\n0\n0.0827625303\n0\n48.7401153702\n33\n"
] | [
"2 1\n7 6\n7 6\n7 7\n76 5\n8 41\n0 0\n",
"1 1\n7 5\n7 6\n7 7\n76 5\n8 41\n0 0\n",
"2 1\n7 6\n7 6\n7 7\n76 3\n8 41\n0 0\n",
"2 1\n7 6\n7 6\n7 3\n76 3\n8 41\n0 0\n",
"2 1\n7 6\n7 6\n7 3\n76 3\n11 41\n0 0\n",
"2 1\n7 5\n14 6\n7 7\n76 5\n8 41\n0 0\n",
"1 1\n6 5\n7 6\n7 7\n76 5\n8 41\n0 0\n",
"2 1\n7 6\n7 ... | [
"0.414213562373\n0.0827625302982\n0.0827625302982\n0.0\n48.7401153702\n33.0\n",
"0.0\n0.0\n0.0827625302982\n0.0\n48.7401153702\n33.0\n",
"0.414213562373\n0.0827625302982\n0.0827625302982\n0.0\n50.7401153702\n33.0\n",
"0.414213562373\n0.0827625302982\n0.0827625302982\n2.0\n50.7401153702\n33.0\n",
"0.41421356... |
CodeContests | Aniruddha is given a milestone M to reach in terms of distance.
He is living in a different Galaxy where there are N days in a year.At the ith day he can walk atmost X distance.Assuming he walks optimally you need to output the minimum day number on which he will reach the milestone.
Input
The first input line contai... | stdin | null | 3,861 | 1 | [
"2\n5\n1 5 0 0 2\n9\n3\n1 0 3\n2\n\nSAMPLE\n"
] | [
"1\n3\n"
] | [
"2\n5\n1 5 0 0 2\n9\n3\n1 -1 3\n2\n\nSAMPLE\n",
"2\n5\n1 5 0 0 2\n9\n3\n2 0 3\n2\n\nELPMAS\n",
"2\n5\n1 5 0 0 4\n9\n3\n2 0 3\n2\n\nELPMAS\n",
"2\n5\n1 5 0 1 2\n9\n3\n1 0 2\n2\n\nSAMPLF\n",
"2\n5\n1 5 0 1 2\n9\n3\n1 1 1\n2\n\nSAMPLF\n",
"2\n5\n1 5 0 0 2\n9\n3\n1 1 1\n2\n\nSAMPLF\n",
"2\n5\n1 5 0 0 0\n9\n... | [
"1\n3\n",
"1\n1\n",
"5\n1\n",
"5\n3\n",
"5\n2\n",
"1\n2\n",
"2\n2\n",
"2\n3\n",
"2\n1\n",
"3\n3\n"
] |
CodeContests | Problem Statement
One day, you found an old scroll with strange texts on it.
You revealed that the text was actually an expression denoting the position of treasure. The expression consists of following three operations:
* From two points, yield a line on which the points lie.
* From a point and a line, yield a poin... | stdin | null | 2,780 | 1 | [
"((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,1)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((30,40))))))\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\n#\n"
] | [
"3.00000000 3.00000000\n3.00000000 1.00000000\n1.00000000 4.00000000\n0.00000000 2.00000000\n-10.00000000 10.00000000\n-99.83681795 -91.92248853\n"
] | [
"((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,1)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((20,40))))))\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\n#\n",
"((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,2)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((2... | [
"3.000000 3.000000\n3.000000 1.000000\n1.000000 4.000000\n0.000000 2.000000\n-0.000000 0.000000\n-99.836818 -91.922489\n",
"3.000000 3.000000\n3.000000 1.000000\n2.000000 4.000000\n0.000000 2.000000\n-0.000000 0.000000\n-99.836818 -91.922489\n",
"3.000000 3.000000\n3.000000 1.000000\n1.000000 4.000000\n0.000000... |
CodeContests | Problem
Given an undirected graph of $ N $ vertices $ M $ edges. Each vertex has a different number from $ 1 $ to $ N $. You want to start at vertex $ S $ at time $ 0 $ and move to vertex $ G $. Parameters $ a and b $ are set on each side, and if the time $ t $ starts from the vertex on one side of that side, the time... | stdin | null | 4,053 | 1 | [
"2 1 1 2\n1 2 1 100\n",
"3 1 1 3\n1 2 1 1\n",
"3 3 1 3\n1 2 1 1\n2 3 1 6\n2 3 50 100\n",
"2 1 1 2\n1 2 50 100\n",
"3 3 1 3\n1 2 10 100\n2 3 1 6\n2 3 50 100\n"
] | [
"19\n",
"-1\n",
"3\n",
"2\n",
"11\n"
] | [
"3 3 1 3\n1 2 2 1\n2 3 1 6\n2 3 50 100\n",
"3 3 1 3\n1 2 2 1\n2 3 1 6\n2 3 50 001\n",
"2 1 1 2\n1 2 1 101\n",
"3 3 1 1\n1 2 2 1\n2 3 1 6\n2 3 50 001\n",
"3 0 1 2\n1 2 1 101\n",
"3 3 1 3\n1 2 10 100\n2 3 1 6\n3 3 50 100\n",
"3 3 1 3\n1 2 2 1\n2 3 1 6\n2 3 50 110\n",
"3 3 1 3\n1 3 2 1\n2 3 1 6\n2 3 50 1... | [
"3\n",
"2\n",
"20\n",
"0\n",
"-1\n",
"11\n",
"4\n",
"1\n",
"6\n",
"12\n"
] |
CodeContests | We will buy a product for N yen (the currency of Japan) at a shop.
If we use only 1000-yen bills to pay the price, how much change will we receive?
Assume we use the minimum number of bills required.
Constraints
* 1 \leq N \leq 10000
* N is an integer.
Input
Input is given from Standard Input in the following for... | stdin | null | 1,163 | 1 | [
"3000\n",
"1900\n"
] | [
"0\n",
"100\n"
] | [
"5614\n",
"2651\n",
"636\n",
"975\n",
"860\n",
"1858\n",
"541\n",
"209\n",
"1054\n",
"89\n"
] | [
"386\n",
"349\n",
"364\n",
"25\n",
"140\n",
"142\n",
"459\n",
"791\n",
"946\n",
"911\n"
] |
CodeContests | Today is the 25th anniversary of Berland International School in Berland. On this auspicious Occasion, our friend Monk has been given the responsibility of preparing the Inventory for his school.
There are exactly N teachers and M students in the school. Each of these teachers teaches arbitary number of students. Ho... | stdin | null | 3,984 | 1 | [
"3 4\nvasya\npetya\nkolya\nvasya errichto 21\nkolya petr 22\npetya egor 19\nvasya tourist 19\n\nSAMPLE\n"
] | [
"kolya\npetr 22\npetya\negor 19\nvasya\ntourist 19\nerrichto 21\n"
] | [
"3 4\nvasya\npetya\nkolya\nvasya errichto 17\nkolya petr 22\npetya egor 19\nvasya tourist 19\n\nSAMPLE\n",
"3 4\nvasya\npetya\nkolya\nvasya errichto 17\nkolya petr 22\npetya egor 25\nvasya tourist 19\n\nSAMPLE\n",
"3 4\nvasya\npetya\nkolya\nvasya errichto 17\nkolya petr 23\npetya egor 25\nvasya tourist 19\n\nSA... | [
"kolya\npetr 22\npetya\negor 19\nvasya\nerrichto 17\ntourist 19\n",
"kolya\npetr 22\npetya\negor 25\nvasya\nerrichto 17\ntourist 19\n",
"kolya\npetr 23\npetya\negor 25\nvasya\nerrichto 17\ntourist 19\n",
"kolya\npetr 23\npetya\negor 25\nvasya\nerrichto 17\ntouqist 19\n",
"kolya\npetr 23\npetya\negor 25\nvas... |
CodeContests | The smallest unit of data handled by a computer is called a bit, and the amount of information that represents multiple bits together is called a word. Currently, many computers process one word as 32 bits.
For a computer that represents one word in 32 bits, create a program that outputs the amount of data W given in ... | stdin | null | 1,057 | 1 | [
"4\n",
"3\n"
] | [
"128\n",
"96\n"
] | [
"0\n",
"5\n",
"1\n",
"2\n",
"-1\n",
"8\n",
"-2\n",
"14\n",
"6\n",
"26\n"
] | [
"0\n",
"160\n",
"32\n",
"64\n",
"-32\n",
"256\n",
"-64\n",
"448\n",
"192\n",
"832\n"
] |
CodeContests | Write a program which reads two integers a and b, and calculates the following values:
* a ÷ b: d (in integer)
* remainder of a ÷ b: r (in integer)
* a ÷ b: f (in real number)
Constraints
* 1 ≤ a, b ≤ 109
Input
Two integers a and b are given in a line.
Output
Print d, r and f separated by a space in a line. For ... | stdin | null | 2,187 | 1 | [
"3 2\n"
] | [
"1 1 1.50000\n"
] | [
"0 2\n",
"1 2\n",
"5 2\n",
"-1 2\n",
"1 3\n",
"5 3\n",
"1 5\n",
"2 3\n",
"1 1\n",
"4 2\n"
] | [
"0 0 0.000000\n",
"0 1 0.500000\n",
"2 1 2.500000\n",
"-1 1 -0.500000\n",
"0 1 0.333333\n",
"1 2 1.666667\n",
"0 1 0.200000\n",
"0 2 0.666667\n",
"1 0 1.000000\n",
"2 0 2.000000\n"
] |
CodeContests | Most problems on CodeChef highlight chef's love for food and cooking but little is known about his love for racing sports. He is an avid Formula 1 fan. He went to watch this year's Indian Grand Prix at New Delhi. He noticed that one segment of the circuit was a long straight road. It was impossible for a car to overtak... | stdin | null | 437 | 1 | [
"3\n1\n10\n3\n8 3 6\n5\n4 5 1 2 3\n"
] | [
"1\n2\n2\n"
] | [
"3\n1\n10\n3\n8 3 6\n5\n4 5 1 2 4\n",
"3\n1\n10\n3\n0 3 6\n5\n4 5 1 2 3\n",
"3\n1\n10\n3\n8 3 1\n5\n4 5 1 2 4\n",
"3\n1\n0\n3\n8 3 6\n5\n6 5 1 2 5\n",
"3\n1\n10\n3\n8 3 1\n5\n6 5 1 2 4\n",
"3\n1\n10\n3\n8 3 1\n5\n0 8 1 2 7\n",
"3\n1\n10\n3\n0 3 6\n5\n6 5 1 3 4\n",
"3\n1\n1\n3\n0 3 1\n5\n0 5 1 2 5\n",
... | [
"1\n2\n2\n",
"1\n1\n2\n",
"1\n3\n2\n",
"1\n2\n3\n",
"1\n3\n3\n",
"1\n3\n1\n",
"1\n1\n3\n",
"1\n1\n1\n",
"1\n2\n1\n",
"1\n2\n2\n"
] |
CodeContests | problem
$ M $ students will be tested in a classroom with $ N $ seats in a straight line. Seats are numbered $ 1 \ dots N $ from the front, and $ 1 $ per seat can seat $ 1 $ students.
Now each student is sitting in the $ A_1, \ dots, A_M $ seats.
To start the test, the following conditions must be met:
* $ 1 \ dots... | stdin | null | 4,052 | 1 | [
"6 4\n1 4 5 6\n"
] | [
"2\n"
] | [
"6 4\n0 4 5 6\n",
"6 4\n0 4 4 6\n",
"9 3\n0 0 0 3\n",
"6 4\n0 4 6 6\n",
"6 4\n0 1 4 6\n",
"6 4\n0 2 4 6\n",
"6 3\n0 2 4 6\n",
"6 3\n0 2 4 5\n",
"6 3\n0 2 4 3\n",
"6 3\n0 0 4 3\n"
] | [
"2\n",
"1\n",
"0\n",
"2\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n"
] |
CodeContests | Example
Input
8
0 2
0 0
2 0
2 1
3 1
3 3
1 3
1 2
Output
1 | stdin | null | 4,520 | 1 | [
"8\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n1 3\n1 2\n"
] | [
"1\n"
] | [
"8\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n0 3\n1 2\n",
"8\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n0 3\n1 0\n",
"8\n-1 2\n0 0\n2 0\n2 1\n3 1\n3 3\n0 3\n1 0\n",
"8\n0 2\n0 0\n2 0\n2 2\n3 1\n3 3\n0 3\n1 0\n",
"8\n-1 2\n0 -1\n2 0\n2 1\n3 1\n3 3\n0 3\n1 0\n",
"8\n0 2\n-1 0\n2 0\n2 2\n3 1\n3 3\n0 3\n1 0\n",
"8\n-1 2\n0 -1\n2 ... | [
"1\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n",
"2\n"
] |
CodeContests | Background
The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves rectangular blocks as much as programming. Yu-kun has been enthusiastic about making mountains with building blocks recently.
Yu-kun was playing with... | stdin | null | 1,540 | 1 | [
"3\n1 1\n2 2\n3 3\n",
"5\n1 5\n2 4\n3 3\n4 2\n5 1\n",
"5\n2 3\n3 5\n1 2\n1 4\n3 5\n",
"10\n5 11\n12 12\n4 14\n22 12\n11 13\n3 3\n3 3\n12 5\n55 55\n1 1\n"
] | [
"1\n",
"5\n",
"2\n",
"3\n"
] | [
"3\n0 1\n2 2\n3 3\n",
"5\n1 5\n2 4\n3 3\n0 2\n5 1\n",
"5\n2 3\n3 5\n1 2\n0 4\n3 5\n",
"10\n5 11\n12 12\n4 14\n38 12\n11 13\n3 3\n3 3\n12 5\n55 55\n1 1\n",
"5\n1 3\n0 4\n3 0\n0 3\n3 1\n",
"10\n0 9\n16 1\n6 48\n22 0\n12 0\n4 0\n0 11\n19 9\n103 55\n0 2\n",
"3\n0 1\n2 2\n5 3\n",
"5\n1 5\n2 4\n3 3\n0 2\n3 ... | [
"1\n",
"4\n",
"2\n",
"3\n",
"5\n",
"6\n",
"1\n",
"3\n",
"3\n",
"3\n"
] |
CodeContests | Nikhil got to know about what is a matrice. He made several patterns using 1-d and 2-d matrices. One of which was his favorite pattern. Your task is to right a code for his favorite pattern.
NOTE :- To understand his favorite pattern see the sample output
Input:-
First line of code takes number of test cases 'N' as ... | stdin | null | 1,918 | 1 | [
"1\n3\n\nSAMPLE\n"
] | [
"123\n894\n765\n"
] | [
"1\n6\n\nSAMPLE\n",
"1\n8\n\nELQMSA\n",
"1\n9\n\nELQMSA\n",
"1\n2\n\nELQMSA\n",
"1\n3\n\nASMQLE\n",
"1\n1\n\nSAMQLE\n",
"1\n12\n\nELQMSA\n",
"1\n4\n\nASMQLE\n",
"1\n5\n\nDKLQSA\n",
"1\n10\n\nDKLRSA\n"
] | [
"123456\n20212223247\n19323334258\n18313635269\n173029282710\n161514131211\n",
"12345678\n282930313233349\n2748495051523510\n2647606162533611\n2546596463543712\n2445585756553813\n2344434241403914\n2221201918171615\n",
"123456789\n323334353637383910\n315657585960614011\n305572737475624112\n295471808176634213\n28... |
CodeContests | We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.
We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?
Constraints
* All values in input are integers.
* 0 \leq A, B, C
* 1 \leq K \l... | stdin | null | 3,711 | 1 | [
"2000000000 0 0 2000000000\n",
"1 2 3 4\n",
"2 1 1 3\n"
] | [
"2000000000\n",
"0\n",
"2\n"
] | [
"1 2 5 4\n",
"2 0 1 3\n",
"0 3 8 6\n",
"0 3 8 5\n",
"-1 3 5 5\n",
"-1 3 5 6\n",
"-1 6 3 2\n",
"2 2 3 4\n",
"-2 3 5 5\n",
"4 2 0 4\n"
] | [
"0\n",
"1\n",
"-3\n",
"-2\n",
"-4\n",
"-5\n",
"-1\n",
"2\n",
"-6\n",
"4\n"
] |
CodeContests | Takahashi and Aoki will have a battle using their monsters.
The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.
The two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ... Here, an attack decreases ... | stdin | null | 925 | 1 | [
"46 4 40 5\n",
"10 9 10 10\n"
] | [
"Yes\n",
"No\n"
] | [
"46 4 4 5\n",
"10 9 13 10\n",
"64 4 4 5\n",
"5 9 13 10\n",
"64 8 4 5\n",
"5 9 3 10\n",
"54 8 4 5\n",
"5 13 3 10\n",
"54 8 2 5\n",
"5 14 3 10\n"
] | [
"Yes\n",
"No\n",
"Yes\n",
"No\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n"
] |
CodeContests | Given 2 numbers n1 and n2, following operations can be performed:
1) Decrement n1 by 1(if n1>1)
2) Decrement n2 by 1(if n2>1)
3) Incremenet n1 by 1
4) Incremenet n2 by 1
Find the maximum possible value of gcd(n1,n2) with atmost k operations.
Note: Any of the 4 operations counts for one operation.
gcd(n1,n2) refers to G... | stdin | null | 48 | 1 | [
"1\n9\n10\n1\n\nSAMPLE\n"
] | [
"10\n"
] | [
"4\n11833\n5512\n100\n28436\n33903\n100\n84816\n75747\n100\n92281\n31380\n100\n",
"1\n45819\n95605\n90\n",
"1\n9\n10\n1\n\nSANPLE\n",
"1\n45819\n95605\n136\n",
"1\n18\n10\n1\n\nSANPLE\n",
"4\n11833\n5512\n100\n28436\n33903\n100\n84816\n71631\n101\n92281\n31380\n100\n",
"1\n45819\n95605\n111\n",
"1\n18... | [
"917\n1357\n3031\n2097\n",
"3824\n",
"10\n",
"4160\n",
"9\n",
"917\n1357\n2653\n2097\n",
"4158\n",
"6\n",
"917\n1357\n1593\n2097\n",
"62\n"
] |
CodeContests | Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.
But he couldn't see some parts of the list. Invisible part is denoted `?`.
Please calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical ord... | stdin | null | 1,289 | 1 | [
"2\ntourist\npetr\ne\n"
] | [
"1\n"
] | [
"2\ntourist\neptr\ne\n",
"2\nssvuhnr\nerrs\nf\n",
"2\nhupouvt\netor\ni\n",
"2\nsourist\neptr\ne\n",
"2\nsourist\neqtr\ne\n",
"2\nsourist\netqr\ne\n",
"2\nsourisu\netqr\ne\n",
"2\nsourisu\netqr\nd\n",
"2\nsourisu\netrr\nd\n",
"2\nsourisu\nrrte\nd\n"
] | [
"1\n",
"2\n",
"3\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n",
"1\n"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.