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 | Xenny had N cubes. Each cube had six faces and each face had a Latin character on each of it's sides.
Xenny's friend Asdoc had an interesting activity in mind. He gave Xenny a string S and asked him to use the cubes to form that string. Xenny being a very lazy person, just wanted to randomly roll the cubes and then ar... | stdin | null | 4,067 | 1 | [
"5 4\na a a a a a\na a a a a a\nb b b b b b\nc c c c c c\nd d d d d d\nabcd\n\nSAMPLE\n"
] | [
"2592\n"
] | [
"9 9\nd e b a e g\nd a e f a e\na b a e g c\nc c b f b g\ne a c e c a\nf d b d a a\nd d g f b b\nb b b e e a\nb c e a e g\nddabefdbb\n",
"10 7\nf a b d g a\nc g e f a g\nf c c a c c\nd e e b f e\nf f g g e g\ne c e b d c\nf e d g b b\nf c g f f e\nc c a c d d\nd c a d f d\nfcfdfeffcd\n",
"5 4\na a a a a a\na a ... | [
"46224\n",
"861144\n",
"2160\n",
"43632\n",
"453120\n",
"864\n",
"41904\n",
"0\n",
"100656\n",
"89784\n"
] |
CodeContests | This is the story of 20XX. The number of air passengers increased as a result of the stable energy supply by the renewable power network and the invention of liquefied synthetic fuel. However, the threat of terrorism by aircraft still exists, and the importance of fast and highly reliable automatic baggage inspection s... | stdin | null | 3,447 | 1 | [
"6\n1 1\n.\n3 3\n...\n.W.\n...\n10 10\n..........\n.DDDDCCC..\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA..CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\n..........\n.DDDDDD...\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA..CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\nR..E..C.T.\nR.EEE.C.T.\... | [
"SAFE\nSAFE\nSAFE\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\n"
] | [
"6\n1 1\n.\n3 3\n...\n.W.\n...\n10 10\n..........\n.DDDDCCC..\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA..CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\n..........\n.DDDDDD...\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA.-CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\nR..E..C.T.\nR.EEE.C.T.\... | [
"SAFE\nSAFE\nSAFE\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\n",
"SAFE\nSAFE\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\n",
"SAFE\nSAFE\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\n",
"SAFE\nSAFE\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\n",
"SAFE\nSAFE\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOUS\nSUSPICIOU... |
CodeContests | Bob has just learned bit manipulation and is very excited about it. He goes to his friend Alice to show off his skills who is new to programming, and thus Bob challenges Alice to solve the following problem. Given two positive integers L and R, find L ^ (L+1) ^ (L+2) ^ ....... ^ (R-1) ^ R.
Alice needs to answer k such... | stdin | null | 2,232 | 1 | [
"2\n2 3\n3 5\n\nSAMPLE\n"
] | [
"1\n2\n"
] | [
"1000\n778 1778\n83 1083\n324 1324\n56 1056\n80 1080\n682 1682\n643 1643\n245 1245\n140 1140\n573 1573\n587 1587\n85 1085\n679 1679\n949 1949\n727 1727\n83 1083\n819 1819\n827 1827\n887 1887\n941 1941\n154 1154\n529 1529\n764 1764\n715 1715\n857 1857\n23 1023\n564 1564\n543 1543\n549 1549\n834 1834\n279 1279\n213 1... | [
"1778\n83\n1324\n1056\n1080\n1682\n643\n245\n1140\n573\n587\n85\n679\n949\n727\n83\n819\n827\n887\n941\n1154\n529\n1764\n715\n857\n23\n1564\n543\n549\n1834\n279\n213\n1964\n1960\n1568\n541\n1184\n999\n1792\n1750\n399\n1286\n1160\n821\n1462\n1780\n1382\n1006\n1312\n1904\n563\n411\n465\n1992\n1418\n731\n1280\n1998\n1... |
CodeContests | Dr. Fukuoka has placed a simple robot in a two-dimensional maze. It moves within the maze and never goes out of the maze as there is no exit.
The maze is made up of H × W grid cells as depicted below. The upper side of the maze faces north. Consequently, the right, lower and left sides face east, south and west respec... | stdin | null | 1,583 | 1 | [
"3 3 10\nE..\n.#.\n...\n5 5 19\n####.\n.....\n.#S#.\n...#.\n#.##.\n5 5 6\n#.#..\n#....\n##.#.\n#..S.\n#....\n5 4 35\n..##\n....\n.##.\n.#S.\n...#\n0 0 0\n",
"3 3 10\nE..\n.#.\n...\n5 5 19\n.\n.....\n.#S#.\n...#.\n.##.\n5 5 6\n.#..\n....\n.#.\n..S.\n....\n5 4 35\n..##\n....\n.##.\n.#S.\n...#\n0 0 0\n"
] | [
"1 3 E\n4 5 S\n4 4 E\n1 1 N\n",
"1 3 E\n4 5 S\n4 4 E\n1 1 N\n"
] | [
"3 3 10\nE..\n.#.\n...\n5 5 19\n####.\n.....\n.#S#.\n...#.\n#.##.\n5 5 6\n#.#..\n#....\n##.#.\n#..S.\n#....\n5 4 35\n.#.#\n....\n.##.\n.#S.\n...#\n0 0 0\n",
"3 3 19\nE..\n.#.\n...\n5 5 19\n.\n.....\n.#S#.\n...#.\n.##.\n5 5 6\n.#..\n....\n.#.\n..S.\n....\n5 4 35\n..##\n....\n.##.\n.#S.\n...#\n0 0 0\n",
"3 3 10\n... | [
"1 3 E\n4 5 S\n4 4 E\n5 1 S\n",
"2 3 S\n5 4 W\n2 1 N\n1 1 N\n",
"1 3 E\n4 5 N\n4 4 E\n5 1 S\n",
"3 1 W\n5 4 W\n2 1 N\n1 1 N\n",
"1 3 E\n4 5 N\n2 2 N\n5 1 S\n",
"1 3 E\n4 5 S\n4 4 E\n1 1 N\n",
"1 3 E\n5 4 W\n2 1 N\n3 1 N\n",
"1 3 E\n4 5 S\n5 3 W\n1 1 N\n",
"2 1 N\n5 4 W\n2 1 N\n1 1 N\n",
"1 2 E\n5 ... |
CodeContests | Sometimes inventing a story for the problem is a very hard task.
Fortunately for us, Limak has just been kidnapped by an insane mathematician.
We need some name for the mathematician and let it be Mathew.
Limak is a little polar bear.
He has been kidnapped and now must deal with puzzles invented by Mathew.
There were ... | stdin | null | 3,581 | 1 | [
"3\n4 987654323\n5 11\n12 2\n\nSAMPLE\n"
] | [
"68\n8\n0\n"
] | [
"3\n4 987654323\n3 11\n12 2\n\nSAMPLE\n",
"100\n9 657681137\n9 459211231\n9 421854149\n10 919145723\n9 201797513\n6 105479273\n7 119609519\n8 336121607\n9 93853663\n10 260929637\n9 974056219\n10 551709247\n10 607613777\n9 689940947\n9 14567611\n10 81152371\n9 502271117\n10 496195387\n10 796995161\n9 556351291\n10... | [
"68\n8\n0\n",
"203640388\n257707436\n58021828\n402252374\n130927318\n127792\n57140352\n217927815\n68568959\n160588228\n615376747\n263161464\n313628976\n299091050\n170967\n72838808\n350982993\n147649675\n662660061\n523474056\n464809573\n54260961\n201574719\n60444225\n217323330\n295269990\n402906717\n14363956\n2758... |
CodeContests | curtain
Summer is coming soon. You decide to redecorate your room for the summer. It is expected that the sun will be very strong this summer, and it will be a difficult season for you who are not good at dazzling. So you thought about installing a curtain on the window of the room to adjust the brightness of the room... | stdin | null | 4,914 | 1 | [
"4\n0 0\n10 0\n10 10\n0 10\n0 0\n5 0\n5 10\n0 10\n6\n0 0\n10 0\n10 5\n5 5\n5 10\n0 10\n2 0\n8 0\n8 10\n2 10\n12\n1 1\n1 3\n-1 3\n-1 1\n-3 1\n-3 -1\n-1 -1\n-1 -3\n1 -3\n1 -1\n3 -1\n3 1\n2 2\n-2 2\n-2 -2\n2 -2\n4\n20000 20000\n-20000 20000\n-20000 -20000\n20000 -20000\n1000 1000\n-1000 1000\n-1000 -1000\n1000 -1000\n... | [
"50\n30\n8\n1596000000\n0\n100\n"
] | [
"4\n0 0\n10 0\n10 10\n0 10\n0 0\n5 0\n5 10\n0 10\n6\n0 0\n10 0\n10 5\n5 5\n5 10\n0 10\n2 0\n8 0\n8 10\n2 10\n12\n1 1\n1 3\n-1 3\n-1 1\n-3 1\n-3 -1\n-1 -1\n-1 -3\n1 -3\n1 -1\n3 -1\n3 1\n2 2\n-2 2\n-2 -2\n2 -2\n4\n20000 20000\n-20000 20000\n-20000 -20000\n20000 -20000\n1000 1000\n-1000 1000\n-1000 -1000\n1000 -1000\n... | [
"50\n30\n8\n1596000000\n0\n100\n",
"50\n30\n8\n1596000000\n0\n",
"50\n",
"50\n30\n8\n1596000000\n0\n100\n",
"50\n30\n8\n1596000000\n0\n100\n",
"50\n30\n8\n1596000000\n0\n100\n",
"50\n30\n8\n1596000000\n0\n100\n",
"50\n30\n8\n1596000000\n0\n100\n",
"50\n30\n8\n1596000000\n0\n100\n",
"50\n30\n8\n159... |
CodeContests | The chef has a recipe he wishes to use for his guests,
but the recipe will make far more food than he can serve to the guests.
The chef therefore would like to make a reduced version of the recipe which has the same ratios of ingredients, but makes less food.
The chef, however, does not like fractions.
The original rec... | stdin | null | 1,309 | 1 | [
"3\n2 4 4\n3 2 3 4\n4 3 15 9 6\n"
] | [
"1 1\n2 3 4\n1 5 3 2\n"
] | [
"3\n2 4 4\n3 2 3 4\n4 3 20 9 6\n",
"3\n2 4 4\n3 2 1 4\n4 3 15 9 6\n",
"3\n2 4 4\n3 2 3 4\n4 3 20 9 8\n",
"3\n2 4 7\n3 2 1 4\n4 3 15 9 6\n",
"3\n2 4 4\n3 2 3 6\n4 3 20 9 8\n",
"3\n2 4 4\n3 2 3 8\n4 3 15 9 6\n",
"3\n2 4 8\n3 2 3 4\n4 3 20 9 6\n",
"3\n2 4 8\n3 2 1 4\n4 3 15 9 6\n",
"3\n2 4 4\n3 3 3 8\n... | [
"1 1\n2 3 4\n3 20 9 6\n",
"1 1\n2 1 4\n1 5 3 2\n",
"1 1\n2 3 4\n3 20 9 8\n",
"4 7\n2 1 4\n1 5 3 2\n",
"1 1\n2 3 6\n3 20 9 8\n",
"1 1\n2 3 8\n1 5 3 2\n",
"1 2\n2 3 4\n3 20 9 6\n",
"1 2\n2 1 4\n1 5 3 2\n",
"1 1\n3 3 8\n1 5 3 2\n",
"1 1\n3 4 8\n1 5 3 2\n"
] |
CodeContests | The Little Elephant from the Zoo of Lviv likes listening to music.
There are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers Bi and Li - the band (represented as integer) that performed that song and the length of that song in seconds. The Little Elephant is going to list... | stdin | null | 1,269 | 1 | [
"2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 4\n"
] | [
"12\n16\n"
] | [
"2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 8\n",
"2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 2\n",
"2\n3\n1 1\n2 2\n3 2\n3\n2 3\n1 2\n2 2\n",
"2\n3\n1 2\n2 2\n4 2\n3\n2 3\n1 2\n2 4\n",
"2\n3\n1 1\n2 2\n3 2\n3\n2 3\n1 2\n2 8\n",
"2\n3\n1 2\n2 2\n3 2\n3\n2 3\n1 2\n2 3\n",
"2\n3\n1 1\n2 2\n1 2\n3\n2 3\n1 2\n2 2\n",
"... | [
"12\n24\n",
"12\n12\n",
"11\n12\n",
"12\n16\n",
"11\n24\n",
"12\n14\n",
"9\n12\n",
"15\n16\n",
"8\n24\n",
"15\n14\n"
] |
CodeContests | National Association of Tennis is planning to hold a tennis competition among professional players. The competition is going to be a knockout tournament, and you are assigned the task to make the arrangement of players in the tournament.
You are given the detailed report about all participants of the competition. The ... | stdin | null | 2,377 | 1 | [
"2 1\n0 1\n0 0\n2 1\n0 0\n1 0\n3 3\n0 1 1\n0 0 1\n0 0 0\n3 3\n0 1 0\n0 0 0\n1 1 0\n3 1\n0 1 0\n0 0 0\n1 1 0\n3 3\n0 1 0\n0 0 1\n1 0 0\n6 4\n0 0 0 0 0 1\n1 0 1 0 1 0\n1 0 0 1 1 0\n1 1 0 0 1 0\n1 0 0 0 0 0\n0 1 1 1 1 0\n7 2\n0 1 0 0 0 1 0\n0 0 1 0 1 1 1\n1 0 0 1 1 0 0\n1 1 0 0 0 1 0\n1 0 0 1 0 0 1\n0 0 1 0 1 0 0\n1 0... | [
"1\n0\n0\n3\n0\n1\n11\n139\n78\n"
] | [
"2 1\n0 1\n0 0\n2 1\n0 0\n1 0\n3 3\n0 1 1\n0 0 1\n0 0 0\n3 3\n0 1 0\n0 0 0\n1 1 0\n3 1\n0 1 0\n0 0 0\n1 1 0\n3 3\n0 1 0\n0 0 1\n1 0 0\n6 4\n0 0 0 0 0 1\n1 0 1 0 1 0\n1 0 0 1 1 0\n1 1 0 0 1 0\n1 0 0 0 0 0\n0 1 1 1 1 0\n7 2\n0 1 0 0 0 1 0\n0 0 1 0 1 1 1\n1 0 0 1 1 0 0\n1 1 0 0 0 1 0\n1 0 0 1 0 0 1\n0 0 1 0 0 0 0\n1 0... | [
"1\n0\n0\n3\n0\n1\n11\n120\n78\n",
"1\n0\n0\n",
"0\n0\n0\n",
"1\n0\n0\n3\n0\n1\n11\n139\n64\n",
"1\n0\n0\n1\n0\n1\n11\n139\n64\n",
"1\n0\n0\n1\n0\n1\n11\n139\n60\n",
"0\n1\n0\n",
"1\n1\n0\n",
"1\n0\n0\n3\n0\n1\n11\n2\n78\n",
"0\n1\n"
] |
CodeContests | At 17:00, special agent Jack starts to escape from the enemy camp. There is a cliff in between the camp and the nearest safety zone. Jack has to climb the almost vertical cliff by stepping his feet on the blocks that cover the cliff. The cliff has slippery blocks where Jack has to spend time to take each step. He also ... | stdin | null | 2,412 | 1 | [
"6 6\n4 4 X X T T\n4 7 8 2 X 7\n3 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X\n8 9 9 9 6 3 X 5 X 5\n8 9 9 9 ... | [
"12\n5\n-1\n22\n12\n"
] | [
"6 6\n4 4 X X T T\n4 7 8 2 X 7\n1 X X X 1 8\n1 2 X X X 6\n1 1 2 4 4 7\nS S 2 3 X X\n2 10\nT 1\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n2 10\nT X\n1 X\n1 X\n1 X\n1 1\n1 X\n1 X\n1 1\n1 X\nS S\n10 10\nT T T T T T T T T T\nX 2 X X X X X 3 4 X\n9 8 9 X X X 2 9 X 9\n7 7 X 7 3 X X 8 9 X\n8 9 9 9 6 3 X 5 X 5\n8 9 9 9 ... | [
"12\n5\n-1\n22\n12\n",
"12\n5\n-1\n23\n12\n",
"12\n6\n-1\n22\n12\n",
"12\n5\n-1\n20\n12\n",
"12\n5\n-1\n23\n11\n",
"12\n5\n-1\n21\n12\n",
"12\n5\n-1\n22\n10\n",
"13\n5\n-1\n20\n12\n",
"12\n5\n-1\n22\n11\n",
"10\n5\n-1\n21\n12\n"
] |
CodeContests | Given a string S, count the number of non empty sub strings that are palindromes.
A sub string is any continuous sequence of characters in the string.
A string is said to be palindrome, if the reverse of the string is same as itself.
Two sub strings are different if they occur at different positions in S
Input
Input c... | stdin | null | 286 | 1 | [
"dskjkd\n\nSAMPLE\n"
] | [
"7\n"
] | [
"wpc\n",
"mygrlbiadhzlabefwjtghfrtydurkpmoveczbqzzlenezq\n",
"dskdkj\n\nSAMPLE\n",
"dsjdkj\n\nELPMAQ\n",
"qzenelzzqbzbyvompkrudytrfigtjwfebalfhdaiblrgzm\n",
"rjjmem\n\nQNHQDQ\n",
"megrlbiadhzlabefwjtghfrtydurkpmovyczbqzzlenfzq\n",
"qzenelzzqbzbyvompksudytfrigtjwfebalfhdaialrgzm\n",
"cpw\n",
"megrl... | [
"3\n",
"48\n",
"7\n",
"6\n",
"49\n",
"8\n",
"47\n",
"50\n",
"3\n",
"48\n"
] |
CodeContests | Given is an integer x that is greater than or equal to 0, and less than or equal to 1. Output 1 if x is equal to 0, or 0 if x is equal to 1.
Constraints
* 0 \leq x \leq 1
* x is an integer
Input
Input is given from Standard Input in the following format:
x
Output
Print 1 if x is equal to 0, or 0 if x is equal ... | stdin | null | 1,523 | 1 | [
"1\n",
"0\n"
] | [
"0\n",
"1\n"
] | [
"000\n",
"000\n"
] | [
"1\n",
"1\n"
] |
CodeContests | Find the number of ways of distributing N objects into R groups such that each group gets 1 or more objects.
Input:
The one and only line of input contains two numbers separated by a single space, which are N and R respectively.
Output:
The corresponding answer modulo 10000007 in a single line and if no answer exist... | stdin | null | 1,398 | 1 | [
"4 2\n\nSAMPLE\n"
] | [
"3\n"
] | [
"72 41\n",
"76 32\n",
"4 2\n\nSBMPLE\n",
"76 41\n",
"55 41\n",
"4 6\n\nSBMPLE\n",
"94 41\n",
"2 1\n\nSBMPLE\n",
"43 36\n",
"76 19\n"
] | [
"1731062\n",
"2570059\n",
"3\n",
"2677959\n",
"598911\n",
"-1\n",
"3715910\n",
"1\n",
"6978314\n",
"5341414\n"
] |
CodeContests | Three-valued logic is a logic system that has, in addition to "true" and "false", "unknown" as a valid value. In the following, logical values "false", "unknown" and "true" are represented by 0, 1 and 2 respectively.
Let "-" be a unary operator (i.e. a symbol representing one argument function) and let both "*" and "+... | stdin | null | 383 | 1 | [
"(P*Q)\n(--R+(P*Q))\n(P*-P)\n2\n1\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n.\n"
] | [
"3\n11\n0\n27\n0\n7\n"
] | [
"(P*Q)\n(--R+(P*R))\n(P*-P)\n2\n1\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n.\n",
"(P*Q)\n(--R+(P*Q))\n(P*-P)\n1\n1\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n.\n",
"(P*Q)\n(--R+(P*R))\n(P*-P)\n1\n0\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n.\n",
"(P*Q)\n(--R+(P*Q))\n(P*-P)\n1\n2\n(-1+(((---P+Q)*(--Q+---R))*(-R+-P)))\n... | [
"3\n9\n0\n27\n0\n7\n",
"3\n11\n0\n0\n0\n7\n",
"3\n9\n0\n0\n0\n7\n",
"3\n11\n0\n0\n27\n7\n",
"9\n9\n0\n27\n0\n7\n",
"3\n11\n0\n0\n27\n8\n",
"3\n9\n0\n27\n0\n5\n",
"3\n9\n0\n0\n27\n7\n",
"9\n9\n0\n0\n0\n7\n",
"15\n9\n0\n0\n0\n7\n"
] |
CodeContests | The Little Elephant from the Zoo of Lviv is going to the Birthday Party of the Big Hippo tomorrow. Now he wants to prepare a gift for the Big Hippo.
He has N balloons, numbered from 1 to N. The i-th balloon has the color Ci and it costs Pi dollars. The gift for the Big Hippo will be any subset (chosen randomly, possi... | stdin | null | 1,951 | 1 | [
"2\n2 2\n1 4\n2 7\n2 1\n1 4\n2 7\n"
] | [
"11.000000000\n7.333333333\n"
] | [
"2\n2 2\n1 4\n2 7\n2 1\n1 4\n0 7\n",
"2\n2 2\n1 4\n2 7\n2 1\n1 3\n0 7\n",
"2\n2 0\n1 4\n2 7\n2 1\n1 4\n2 7\n",
"2\n2 2\n1 4\n2 0\n2 1\n1 4\n0 7\n",
"2\n2 1\n1 4\n2 7\n2 1\n1 4\n2 7\n",
"2\n2 1\n1 0\n2 7\n2 1\n1 4\n2 7\n",
"2\n2 2\n1 4\n2 7\n2 2\n1 4\n0 7\n",
"2\n2 2\n1 4\n2 7\n2 1\n1 2\n0 7\n",
"2\n... | [
"11.0000000000\n7.3333333333\n",
"11.0000000000\n6.6666666667\n",
"5.5000000000\n7.3333333333\n",
"4.0000000000\n7.3333333333\n",
"7.3333333333\n7.3333333333\n",
"4.6666666667\n7.3333333333\n",
"11.0000000000\n11.0000000000\n",
"11.0000000000\n6.0000000000\n",
"11.0000000000\n4.6666666667\n",
"11.... |
CodeContests | C - Iyasugigappa
Problem Statement
Three animals Frog, Kappa (Water Imp) and Weasel are playing a card game.
In this game, players make use of three kinds of items: a guillotine, twelve noble cards and six action cards. Some integer value is written on the face of each noble card and each action card. Before stating... | stdin | null | 747 | 1 | [
"3 2 1 3 2 1 3 2 1 3 2 1\n1 1\n1 1\n1 1\n"
] | [
"4 8 12\n"
] | [
"3 2 1 3 2 1 3 2 1 1 2 1\n1 1\n1 1\n1 1\n",
"3 2 1 3 2 1 3 2 1 2 2 1\n1 1\n1 1\n1 1\n",
"3 2 1 5 2 1 3 2 1 3 2 1\n1 1\n1 1\n1 1\n",
"3 2 1 5 2 0 3 2 1 3 2 1\n1 1\n1 1\n1 1\n",
"3 2 1 5 2 0 3 2 1 2 2 1\n1 1\n1 1\n1 1\n",
"3 2 1 5 2 0 3 2 1 2 2 2\n1 1\n1 1\n1 1\n",
"3 2 1 3 2 1 3 2 1 3 2 0\n1 1\n1 1\n1 1\... | [
"4 8 10\n",
"4 8 11\n",
"4 8 14\n",
"3 8 14\n",
"3 8 13\n",
"4 8 13\n",
"3 8 12\n",
"5 8 10\n",
"2 8 14\n",
"3 8 8\n"
] |
CodeContests | Your friend Max has written a string S in your textbook. The string consists of lowercase latin letters. The problem is that Max is not good at writing at all! Especially, you never know if he wanted to write "w" or two consecutive "v". Given the string S, return the minimum and maximum length of a word which can be re... | stdin | null | 3,223 | 1 | [
"5\navwvb\n\nSAMPLE\n"
] | [
"4 6\n"
] | [
"5\navwvb\n\nSAMPLF\n",
"5\nvawvb\n\nSAMPLF\n",
"5\nwawvb\n\nSAMPLF\n",
"5\nbvvxa\n\nSFAPMM\n",
"5\nwwwba\n\nFKMPAS\n",
"5\nawwvb\n\nSAMPLF\n",
"5\nbvwwa\n\nSAMPLF\n",
"5\nbvwwa\n\nSFMPLA\n",
"5\nbvwxa\n\nSFMPLA\n",
"5\nbvwxa\n\nSFMPMA\n"
] | [
"4 6\n",
"5 6\n",
"5 7\n",
"4 5\n",
"5 8\n",
"5 7\n",
"5 7\n",
"5 7\n",
"5 6\n",
"5 6\n"
] |
CodeContests | Magic is great, isn't it?. We all love it. However if you do the same magic trick again and again, it will become boring. Also there are chances people
might see through your trick. So you always want to minimize the number of times you perform the same magic trick again and again.
In this question, you are given a pe... | stdin | null | 4,377 | 1 | [
"3\n1\n2\n3\n\nSAMPLE\n"
] | [
"1\n1\n3\n"
] | [
"12\n1\n2\n3\n4\n5\n6\n7\n8\n9\n14\n11\n12\n",
"5\n1\n1\n3\n4\n5\n",
"12\n1\n2\n3\n4\n2\n6\n7\n8\n9\n14\n11\n12\n",
"5\n1\n1\n4\n4\n5\n",
"12\n1\n2\n3\n4\n2\n6\n7\n8\n9\n20\n11\n12\n",
"5\n1\n1\n1\n4\n5\n",
"5\n1\n1\n1\n4\n7\n",
"12\n2\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n",
"5\n1\n2\n3\n4\n4\n",
... | [
"1\n1\n3\n5\n11\n21\n43\n85\n171\n5461\n683\n1365\n",
"1\n1\n3\n5\n11\n",
"1\n1\n3\n5\n1\n21\n43\n85\n171\n5461\n683\n1365\n",
"1\n1\n5\n5\n11\n",
"1\n1\n3\n5\n1\n21\n43\n85\n171\n349525\n683\n1365\n",
"1\n1\n1\n5\n11\n",
"1\n1\n1\n5\n43\n",
"1\n1\n3\n5\n11\n21\n43\n85\n171\n341\n683\n1365\n",
"1\n1... |
CodeContests | You went shopping to buy cakes and donuts with X yen (the currency of Japan).
First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.
How much do you have left after shopping?
Constraints
* 1 \leq A, B \leq 1 000
* A + B \leq X \leq 10 000
* ... | stdin | null | 3,677 | 1 | [
"1000\n108\n108\n",
"1234\n150\n100\n",
"579\n123\n456\n",
"7477\n549\n593\n"
] | [
"28\n",
"84\n",
"0\n",
"405\n"
] | [
"1000\n18\n108\n",
"579\n17\n456\n",
"7477\n549\n1145\n",
"1000\n18\n210\n",
"579\n17\n446\n",
"7477\n549\n494\n",
"1000\n18\n302\n",
"579\n17\n393\n",
"7477\n678\n494\n",
"1000\n18\n500\n"
] | [
"10\n",
"106\n",
"58\n",
"142\n",
"116\n",
"12\n",
"76\n",
"169\n",
"377\n",
"482\n"
] |
CodeContests | There is a cave.
The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.
It is dark in th... | stdin | null | 529 | 1 | [
"6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 6\n",
"4 4\n1 2\n2 3\n3 4\n4 2\n"
] | [
"Yes\n6\n5\n5\n1\n1\n",
"Yes\n1\n2\n2\n"
] | [
"4 4\n1 4\n2 3\n3 4\n4 2\n",
"6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 2\n4 5\n5 3\n",
"4 4\n1 4\n2 3\n4 4\n4 2\n",
"6 9\n3 4\n6 1\n2 4\n5 3\n4 6\n1 5\n6 4\n4 5\n5 3\n",
"6 9\n3 4\n6 1\n2 1\n5 3\n4 6\n1 5\n6 4\n4 5\n5 3\n",
"6 5\n3 4\n6 1\n2 1\n5 3\n4 6\n1 5\n6 4\n4 5\n3 3\n",
"6 9\n3 4\n6 1\n2 4\n5 1\n4 6\... | [
"Yes\n4\n4\n1\n",
"Yes\n6\n5\n6\n1\n1\n",
"Yes\n4\n2\n1\n",
"Yes\n4\n5\n6\n1\n1\n",
"Yes\n1\n5\n6\n1\n1\n",
"Yes\n1\n4\n6\n3\n1\n",
"Yes\n6\n4\n6\n1\n1\n",
"Yes\n1\n4\n6\n1\n1\n",
"Yes\n1\n4\n6\n6\n1\n",
"Yes\n6\n4\n6\n6\n1\n"
] |
CodeContests | problem
AOR Co., Ltd. is a $ N $ story building. There is no basement floor.
AOR Ika-chan is a squid, so she can go down the stairs, but not up.
I decided to install $ M $ elevators in the building because it would be inconvenient if I couldn't climb upstairs.
It takes time to install the elevator, and the $ i $ th e... | stdin | null | 4,761 | 1 | [
"5 1 2\n3 1 5\n3 1 5\n4 1 5\n"
] | [
"No\nYes\n"
] | [
"10 1 2\n3 1 5\n3 1 5\n4 1 5\n",
"10 1 2\n3 1 2\n3 1 5\n4 1 5\n",
"10 1 2\n3 1 3\n2 8 5\n7 1 2\n",
"10 1 2\n3 1 1\n2 8 5\n7 1 2\n",
"10 1 1\n3 1 5\n3 1 10\n4 1 5\n",
"15 1 1\n2 1 1\n3 8 5\n15 1 2\n",
"16 1 3\n3 1 2\n2 1 4\n3 2 1\n",
"11 1 4\n3 1 5\n3 1 5\n3 5 2\n",
"16 1 3\n3 0 0\n2 1 0\n3 3 2\n",
... | [
"No\nYes\n",
"No\nNo\n",
"Yes\nYes\n",
"Yes\nNo\n",
"No\n",
"Yes\n",
"No\nYes\nYes\n",
"No\nYes\nYes\nYes\n",
"Yes\nYes\nYes\n",
"Yes\nYes\nNo\n"
] |
CodeContests | Ranjan came to know about competitive programming today and created an
account on Hackerearth.
With his full determination he started to solve his first problem.
He saw a question stated as.
Calculate the sum of numbers from 1 to N as:
for ( i=1;i ≤ N;i++ )
sum += i % MOD;
He wrote the code for it but could no... | stdin | null | 4,417 | 1 | [
"3\n5 3\n10 2\n20 4\n\nSAMPLE\n"
] | [
"6\n5\n30\n"
] | [
"3000\n8786 8705\n8419 7334\n8091 7406\n9692 8580\n2185 1951\n9195 8840\n1469 1159\n9424 2726\n9847 945\n8894 7210\n8680 6646\n9303 2351\n3298 1409\n6306 1275\n9130 8907\n8654 6048\n9652 9408\n9813 9686\n8678 742\n9955 1422\n8401 7395\n8562 4408\n7556 6839\n6595 5439\n6136 4626\n9629 7517\n3929 1869\n8958 7668\n974... | [
"37887481\n27479266\n27655670\n37422738\n1929720\n39131570\n719266\n11919406\n4539403\n27407215\n24150930\n10819650\n2099312\n3976521\n39687847\n21683049\n44280418\n46912583\n3157407\n7072318\n27845836\n18342963\n23639944\n15457387\n11838430\n30480214\n3509628\n30227973\n2632417\n34366476\n15164376\n43426316\n10256... |
CodeContests | Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.
You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
Constraints
* 1 ≦ x ≦ 3{,}000
* x i... | stdin | null | 1,249 | 1 | [
"1000\n",
"2000\n"
] | [
"ABC\n",
"ARC\n"
] | [
"0000\n",
"2936\n",
"0100\n",
"1432\n",
"1100\n",
"146\n",
"1101\n",
"242\n",
"0110\n",
"171\n"
] | [
"ABC\n",
"ARC\n",
"ABC\n",
"ARC\n",
"ABC\n",
"ABC\n",
"ABC\n",
"ABC\n",
"ABC\n",
"ABC\n"
] |
CodeContests | You are given a tree with N vertices 1,2,\ldots,N, and positive integers c_1,c_2,\ldots,c_N. The i-th edge in the tree (1 \leq i \leq N-1) connects Vertex a_i and Vertex b_i.
We will write a positive integer on each vertex in T and calculate our score as follows:
* On each edge, write the smaller of the integers writ... | stdin | null | 2,682 | 1 | [
"5\n1 2\n1 3\n1 4\n1 5\n3141 59 26 53 59\n",
"5\n1 2\n2 3\n3 4\n4 5\n1 2 3 4 5\n"
] | [
"197\n59 26 3141 59 53\n",
"10\n1 2 3 4 5\n"
] | [
"5\n1 2\n2 3\n3 4\n4 5\n2 2 3 4 5\n",
"5\n1 2\n2 3\n3 4\n4 5\n1 2 3 3 5\n",
"5\n1 2\n2 3\n3 4\n4 5\n2 2 2 4 5\n",
"5\n1 2\n2 3\n3 4\n4 5\n1 2 1 3 5\n",
"5\n1 2\n2 3\n3 4\n4 5\n0 2 1 3 5\n",
"5\n1 2\n2 5\n3 4\n3 5\n2 2 2 1 5\n",
"5\n1 2\n2 5\n3 4\n3 5\n2 0 2 1 5\n",
"5\n1 2\n1 3\n1 4\n1 5\n3141 59 39 5... | [
"11\n5 4 3 2 2\n",
"9\n5 3 3 2 1\n",
"10\n5 4 2 2 2\n",
"7\n5 3 2 1 1\n",
"6\n5 3 2 1 0\n",
"7\n5 2 2 1 2\n",
"5\n5 2 1 0 2\n",
"210\n3141 59 59 53 39\n",
"8\n4 3 2 2 1\n",
"10\n5 3 3 3 1\n"
] |
CodeContests | Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X ... | stdin | null | 930 | 1 | [
"5\n30 44\n26\n18\n81\n18\n6\n",
"3\n7 1\n2\n5\n10\n",
"2\n8 20\n1\n10\n"
] | [
"56\n",
"8\n",
"29\n"
] | [
"5\n30 44\n26\n18\n81\n27\n6\n",
"3\n7 1\n1\n5\n10\n",
"2\n8 20\n1\n19\n",
"3\n7 1\n2\n5\n19\n",
"2\n8 23\n1\n19\n",
"5\n1 44\n26\n18\n76\n27\n6\n",
"3\n1 1\n2\n5\n19\n",
"3\n1 2\n2\n5\n15\n",
"5\n1 52\n26\n21\n11\n27\n6\n",
"3\n1 0\n2\n5\n15\n"
] | [
"56\n",
"11\n",
"29\n",
"8\n",
"32\n",
"49\n",
"4\n",
"5\n",
"57\n",
"3\n"
] |
CodeContests | Darshit is planning to celebrate the birthday of his friend, Diksha. There are two types of gifts that Diksha wants from Darshit: one is black and the other is white. To make her happy, Darshit has to buy B number of black gifts and W number of white gifts.
The cost of each black gift is X units.
The cost of every wh... | stdin | null | 1,956 | 1 | [
"5\n10 10\n1 1 1\n5 9\n2 3 4\n3 6\n9 1 1\n7 7\n4 2 1\n3 3\n1 9 2\n\nSAMPLE\n"
] | [
"20\n37\n12\n35\n12\n"
] | [
"5\n10 10\n1 1 1\n5 9\n2 3 4\n3 6\n9 1 2\n7 7\n4 2 1\n3 3\n1 9 2\n",
"10\n443463982 833847400\n429734889 628664883 610875522\n623669229 435417504\n266946955 600641444 515391879\n763364819 37220400\n711640763 34378393 655626808\n177742229 51792729\n358392247 642296973 158448705\n402332409 253667421\n384186676 7289... | [
"20\n37\n15\n35\n12\n",
"714782523241122198\n428016399954183471\n528005272909240819\n90470040201136571\n339491328041275785\n37534663611326090\n597975411899462458\n315075570539747764\n228175680952112475\n79823777832550346\n",
"582539235\n520171110\n910379967\n318252516\n244393494\n846446262\n221899579\n600420492... |
CodeContests | Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
Constraints
* $-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$
* $ n \leq 20$
Input
Inpu... | stdin | null | 1,134 | 1 | [
"1\n0.0 0.0 2.0 0.0 2.0 2.0\n"
] | [
"1.000 1.000 1.414\n"
] | [
"1\n0.0 0.0 2.0 0.5127281311709682 2.0 2.0\n",
"1\n0.0 0.0 2.4487612247110815 0.5127281311709682 2.0 2.0\n",
"1\n0.0 0.0 2.4487612247110815 0.5127281311709682 2.0 2.033916337250816\n",
"1\n0.0 0.8678187768154128 2.4487612247110815 0.5127281311709682 2.0 2.033916337250816\n",
"1\n0.6737465592371317 0.8678187... | [
"0.744 1.256 1.460\n",
"1.087 0.913 1.420\n",
"1.082 0.936 1.431\n",
"1.268 0.991 1.274\n",
"1.644 1.102 0.998\n",
"1.547 1.212 0.939\n",
"1.824 0.897 1.150\n",
"1.605 1.673 1.231\n",
"1.754 1.762 1.105\n",
"2.072 1.953 0.889\n"
] |
CodeContests | An extraterrestrial visit!
Remember your childhood friend JAADU from outer space?? Well, he is back again to our mighty Planet Earth.
But do you expect us geeks to introduce a character like Rohit Mehra in this story?
A Hell No!!
Instead, he encounters the creepy Scientists of Planet Earth all the way from S.H.I.E.... | stdin | null | 4,769 | 1 | [
"4\n1 1\n2 1\n2 3\n2 5\n\nSAMPLE\n"
] | [
"G\nG\nC\n-1\n"
] | [
"4\n1 2\n2 1\n2 3\n2 5\n",
"659\n8 972726106237281\n29 516908306\n9 294\n27 84664275\n30 888188693\n6 40\n6 29\n8 877878903230015\n29 66695922\n6 38\n31 1799217893\n3 3\n12 311\n31 631884547720169\n15 26933\n9 497416784631326\n26 47553572\n35 27143570505\n33 4229111886\n17 86199\n20 789098\n26 8186139\n13 4681\n2... | [
"-1\nG\nC\n-1\n",
"-1\nG\nC\nC\nG\nG\nG\n-1\nG\nC\nG\nC\nC\n-1\nG\n-1\nG\nG\nC\nC\nG\nC\nG\n-1\nC\nC\n-1\nC\nG\nG\nC\nG\nG\nC\nG\nG\nG\nC\nC\nG\nC\nG\nC\nC\nC\n-1\nC\nC\nG\nC\nG\nC\nG\nG\nG\nG\nG\nG\nC\nC\nG\nG\nC\nG\nG\nC\nC\n-1\nG\n-1\nG\nC\nG\nG\n-1\nC\nG\nG\nC\nG\n-1\nG\nG\nC\nG\nG\n-1\nG\nC\nG\nG\nC\nG\n-1\n... |
CodeContests | Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.
Constraints
* 1 ≤ length of T ≤ 1000000
* 1 ≤ length of P ≤ 10000
* The input consists of alphabetical characters and digits
Input
In the first line, a text T is given. In the second line, a s... | stdin | null | 4,879 | 1 | [
"xyzz\nyz\n",
"aabaaa\naa\n"
] | [
"1\n",
"0\n3\n4\n"
] | [
"aaabaa\naa\n",
"aabbaa\naa\n",
"aabaab\naa\n",
"aababb\naa\n",
"aaabaa\nab\n",
"aabba`\na`\n",
"cbabaa\nba\n",
"cbaaaa\nba\n",
"dbaaba\nba\n",
"dbaaba\nab\n"
] | [
"0\n1\n4\n",
"0\n4\n",
"0\n3\n",
"0\n",
"2\n",
"4\n",
"1\n3\n",
"1\n",
"1\n4\n",
"3\n"
] |
CodeContests | Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edge.
Determine whether it is possible to divide the vertices into non-e... | stdin | null | 3,473 | 1 | [
"2\n01\n10\n",
"6\n010110\n101001\n010100\n101000\n100000\n010000\n",
"3\n011\n101\n110\n"
] | [
"2\n",
"4\n",
"-1\n"
] | [
"3\n011\n111\n110\n",
"3\n010\n101\n010\n",
"3\n011\n111\n111\n",
"3\n011\n110\n111\n",
"6\n010111\n101001\n010100\n101000\n100000\n010000\n",
"3\n010\n101\n110\n",
"3\n011\n011\n110\n",
"3\n011\n111\n011\n",
"3\n011\n011\n011\n",
"6\n010110\n101001\n010100\n101000\n100100\n010000\n"
] | [
"-1\n",
"3\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
] |
CodeContests | Problem
Given the string S, which consists of lowercase letters and numbers. Follow the steps below to compress the length of string S.
1. Change the order of the characters in the character string to any order.
Example: "0ig3he12fz99"-> "efghiz012399"
2. Perform the following operations any number of times.
* Sele... | stdin | null | 1,697 | 1 | [
"0ig3he12fz99\n",
"1122334455\n"
] | [
"9\n",
"6\n"
] | [
"0ig3hd12fz99\n",
"0hg3hd12fz99\n",
"833453334\n",
"2336078995\n",
"1437005866\n",
"4037065\n",
"15423151\n",
"8181\n",
"111\n",
"0hg3hd13fz99\n"
] | [
"10\n",
"11\n",
"9\n",
"8\n",
"7\n",
"5\n",
"6\n",
"4\n",
"3\n",
"12\n"
] |
CodeContests | This time Panda is doing great. He is good with mathematical problems. His teacher decided to puzzle him with summation problems.
Consider the following definitions, assuming 1-based indexing:
In the computation of B, one can choose +1 or -1 to multiply, for each arr[i].
Also, you are allowed to re-order the elem... | stdin | null | 2,271 | 1 | [
"1\n4\n1 2 3 4\n\nSAMPLE\n"
] | [
"40\n"
] | [
"1\n4\n1 4 3 4\n\nSAMPLE\n",
"1\n4\n1 2 3 0\n\nELAMPS\n",
"1\n4\n1 2 0 0\n\nSPNALE\n",
"1\n4\n1 0 0 0\n\nSPNALE\n",
"1\n4\n1 0 1 0\n\nSPNALE\n",
"1\n4\n1 2 1 4\n\nSAMPLE\n",
"1\n4\n1 4 4 4\n\nSAMPLE\n",
"1\n4\n1 2 3 4\n\nSPMALE\n",
"1\n4\n1 2 3 1\n\nELAMPS\n",
"1\n4\n1 2 1 0\n\nSPMALE\n"
] | [
"48\n",
"24\n",
"9\n",
"1\n",
"4\n",
"32\n",
"39\n",
"40\n",
"21\n",
"8\n"
] |
CodeContests | M-kun is a student in Aoki High School, where a year is divided into N terms.
There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows:
* For the first through (K-1)-th terms: not given.
* For each of the K-th through N-th terms: the multipl... | stdin | null | 4,698 | 1 | [
"3 2\n1001 869120 1001\n",
"15 7\n3 1 4 1 5 9 2 6 5 3 5 8 9 7 9\n",
"5 3\n96 98 95 100 20\n"
] | [
"No\n",
"Yes\nYes\nNo\nYes\nYes\nNo\nYes\nYes\n",
"Yes\nNo\n"
] | [
"3 1\n1001 869120 1001\n",
"15 7\n3 1 4 1 5 9 2 6 5 3 5 7 9 7 9\n",
"15 7\n3 1 4 1 5 9 2 6 5 5 5 7 9 7 9\n",
"15 7\n3 1 8 1 5 9 1 8 1 5 9 7 9 7 16\n",
"15 7\n3 1 9 1 5 5 0 8 1 5 9 8 9 7 15\n",
"3 2\n1011 869120 1001\n",
"5 3\n96 98 95 000 20\n",
"5 0\n96 98 162 100 39\n",
"15 7\n3 1 8 1 5 8 1 6 5 5 ... | [
"Yes\nNo\n",
"Yes\nYes\nNo\nYes\nYes\nNo\nYes\nYes\n",
"Yes\nYes\nYes\nYes\nYes\nNo\nYes\nYes\n",
"Yes\nNo\nNo\nYes\nYes\nNo\nYes\nYes\n",
"Yes\nNo\nNo\nYes\nYes\nYes\nYes\nYes\n",
"No\n",
"No\nNo\n",
"No\nNo\nNo\nNo\nNo\n",
"Yes\nYes\nNo\nYes\nYes\nYes\nYes\nYes\n",
"Yes\nYes\nNo\nYes\n"
] |
CodeContests | We have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.
The square (i, j) has two numbers A_{ij} and B_{ij} written on it.
First, for each square, Takahashi paints one of the written numbers red and the other blue.
Then... | stdin | null | 4,384 | 1 | [
"2 2\n1 2\n3 4\n3 4\n2 1\n",
"2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n"
] | [
"0\n",
"2\n"
] | [
"2 2\n1 2\n6 4\n3 4\n2 1\n",
"2 3\n1 10 80\n80 10 1\n1 2 3\n4 2 6\n",
"2 3\n2 10 98\n80 14 1\n1 2 3\n4 2 6\n",
"2 3\n4 10 98\n80 14 1\n1 2 3\n4 2 6\n",
"1 3\n4 10 90\n80 14 1\n1 2 3\n4 2 6\n",
"1 3\n0 10 90\n80 14 2\n1 2 3\n3 2 6\n",
"1 3\n0 10 90\n64 14 2\n1 2 3\n3 2 6\n",
"1 3\n0 10 90\n64 10 2\n1 7... | [
"1\n",
"5\n",
"0\n",
"2\n",
"9\n",
"4\n",
"20\n",
"24\n",
"25\n",
"8\n"
] |
CodeContests | E: Markup language has declined
It's been centuries since we humans have been declining slowly. The earth may already belong to "Progurama". Programa-sans with an average height of 170 cm, 7 heads, high intelligence, and loves Kodingu. I have returned to my hometown of Nibunki, becoming an important international civi... | stdin | null | 115 | 1 | [
"1\nindex.dml\n<dml><title>Markup language has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index\n"
] | [
"Markup language\n has Declined..\nProgrammers wor\n"
] | [
"1\nindex.dml\n<dml><title>Markup aangulge has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index\n",
"1\nindex.dml\n<dml><title>Markup aangulge sah Declined</title><br>Programmers world</dml>\n1\n15 3 0 index\n",
"1\nindex.dml\n<dml><title>Markup aanlugge sah Declined</title><br>Programmers world</dm... | [
"Markup aangulge\n has Declined..\nProgrammers wor\n",
"Markup aangulge\n sah Declined..\nProgrammers wor\n",
"Markup aanlugge\n sah Declined..\nProgrammers wor\n",
"Markup language\n",
"Markup language has Dec\n",
"Markup aangulge\n sah Declined..\nProgrammert wor\n",
"Markup languagd has Dec\n",
"Ma... |
CodeContests | There are N towers in the town where Ikta lives. Each tower is given a different number from 0 to N-1, and the tower with number i is called tower i. Curious Ikta was interested in the height of the N towers and decided to make a table T showing the magnitude relationship between them. T has N × N elements, and each el... | stdin | null | 4,050 | 1 | [
"1\n",
"3\n0 1\n0 2\n",
"7\n0 1\n1 2\n2 3\n3 4\n0 5\n0 6\n",
"3\n0 1\n1 2\n"
] | [
"1\n",
"3\n",
"91\n",
"1\n"
] | [
"7\n0 1\n1 2\n2 3\n0 4\n0 5\n0 6\n",
"7\n0 1\n1 2\n0 3\n3 4\n0 5\n0 6\n",
"3\n0 2\n0 1\n",
"7\n0 1\n1 2\n0 3\n3 4\n0 5\n1 6\n",
"3\n1 2\n0 1\n",
"7\n0 1\n1 2\n2 3\n2 4\n0 5\n0 6\n",
"7\n0 1\n0 2\n2 3\n0 4\n0 5\n0 6\n",
"7\n0 1\n1 2\n1 3\n3 4\n0 5\n1 6\n",
"7\n0 1\n2 2\n2 3\n0 4\n0 5\n0 6\n",
"7\n0... | [
"535\n",
"919\n",
"3\n",
"579\n",
"1\n",
"239\n",
"2071\n",
"295\n",
"75\n",
"387\n"
] |
CodeContests | Rabbits and cats are competing. The rules are as follows.
First, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. Each time a card is drawn, the two will mark it if the same number a... | stdin | null | 5,027 | 1 | [
"3 2 2 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8\n",
"3 2 1 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8\n"
] | [
"USAGI\n",
"DRAW\n"
] | [
"3 2 4 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n6 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n2\n1\n3\n8\n",
"3 3 4 11\n1 2 3\n8 5 6\n7 8 9\n1 2 3\n8 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n3\n1\n3\n8\n",
"3 5 4 11\n1 2 3\n8 5 6\n7 8 9\n1 2 3\n8 5 4\n7 8 9\n11\n4\n7\n5\n10\n9\n3\n1\n3\n8\n",
"3 2 4 10\n1 2 3\n4 5 6\n7 8 9\n1 2 3\n8 5 4\n... | [
"USAGI\n",
"DRAW\n",
"NEKO\n",
"USAGI\n",
"USAGI\n",
"USAGI\n",
"USAGI\n",
"USAGI\n",
"USAGI\n",
"USAGI\n"
] |
CodeContests | problem
AOR Ika got a water tank with a size of $ 1 $ in length and $ N $ in width. The aquarium is tall enough to hold water. The aquarium has $ N-1 $ partitions and is evenly spaced into $ N $ compartments. When water was poured here, the height of the water in each section became $ a_i $.
AOR Ika decided to remove... | stdin | null | 4,012 | 1 | [
"5 3\n9 1 2 3 9\n"
] | [
"20.000000\n"
] | [
"5 3\n9 1 4 3 9\n",
"5 3\n9 1 4 3 8\n",
"5 3\n9 1 3 3 8\n",
"4 3\n9 1 3 3 8\n",
"4 3\n5 1 3 3 8\n",
"4 3\n5 1 5 3 8\n",
"4 3\n5 1 3 0 12\n",
"7 3\n5 1 3 0 12\n",
"5 3\n9 1 2 3 5\n",
"5 3\n4 1 4 3 9\n"
] | [
"20.66666667\n",
"19.66666667\n",
"19.33333333\n",
"14.00000000\n",
"10.00000000\n",
"11.00000000\n",
"7.50000000\n",
"14.25000000\n",
"16.00000000\n",
"15.66666667\n"
] |
CodeContests | For a positive integer n
* If n is even, divide by 2.
* If n is odd, multiply by 3 and add 1.
If you repeat the above operation, the result will be 1. A problem called "Colatz conjecture" is that repeating this operation for any positive integer n will always result in 1. This problem is an unsolved problem, also k... | stdin | null | 1,372 | 1 | [
"3\n10\n0\n"
] | [
"7\n6\n"
] | [
"3\n15\n0\n",
"3\n3\n0\n",
"3\n11\n0\n",
"3\n2\n0\n",
"3\n9\n0\n",
"3\n6\n0\n",
"3\n1\n0\n",
"3\n0\n0\n",
"3\n18\n0\n",
"3\n16\n0\n"
] | [
"7\n17\n",
"7\n7\n",
"7\n14\n",
"7\n1\n",
"7\n19\n",
"7\n8\n",
"7\n0\n",
"7\n",
"7\n20\n",
"7\n4\n"
] |
CodeContests | In a public bath, there is a shower which emits water for T seconds when the switch is pushed.
If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds.
N people will pus... | stdin | null | 3,638 | 1 | [
"9 10\n0 3 5 7 100 110 200 300 311\n",
"2 4\n0 3\n",
"1 1\n0\n",
"2 4\n0 5\n",
"4 1000000000\n0 1000 1000000 1000000000\n"
] | [
"67\n",
"7\n",
"1\n",
"8\n",
"2000000000\n"
] | [
"2 4\n0 2\n",
"1 0\n0\n",
"2 4\n0 4\n",
"4 1000000000\n0 1100 1000000 1000000000\n",
"4 1000000000\n0 1100 1000000 1010000000\n",
"9 10\n0 3 5 7 100 110 200 272 311\n",
"4 1000010000\n0 1000 1000000 1000000000\n",
"4 1000000000\n0 1100 1100000 1010000000\n",
"9 10\n0 3 5 7 000 110 200 272 311\n",
... | [
"6\n",
"0\n",
"8\n",
"2000000000\n",
"2001000000\n",
"67\n",
"2000010000\n",
"2001100000\n",
"50\n",
"2000010001\n"
] |
CodeContests | Number of tanka
Wishing to die in the spring under the flowers
This is one of the famous tanka poems that Saigyo Hoshi wrote. Tanka is a type of waka poem that has been popular in Japan for a long time, and most of it consists of five phrases and thirty-one sounds of 5, 7, 5, 7, and 7.
By the way, the number 57577 c... | stdin | null | 4,839 | 1 | [
"1\n2\n3\n390\n1124\n1546\n314159265358979323\n0\n"
] | [
"10\n12\n13\n2020\n25252\n57577\n7744444777744474777777774774744777747477444774744744\n"
] | [
"1\n2\n3\n390\n216\n1546\n314159265358979323\n0\n",
"1\n2\n2\n390\n1124\n1546\n314159265358979323\n0\n",
"1\n2\n3\n390\n216\n1546\n31125328462643205\n0\n",
"1\n2\n2\n390\n1124\n1546\n211760204581026131\n0\n",
"1\n2\n3\n104\n216\n1546\n31125328462643205\n0\n",
"1\n0\n2\n390\n1124\n1546\n211760204581026131\... | [
"10\n12\n13\n2020\n599\n57577\n7744444777744474777777774774744777747477444774744744\n",
"10\n12\n12\n2020\n25252\n57577\n7744444777744474777777774774744777747477444774744744\n",
"10\n12\n13\n2020\n599\n57577\n4422424222424224224222242422242224222444442422222\n",
"10\n12\n12\n2020\n25252\n57577\n22422424224244... |
CodeContests | E869120's and square1001's 16-th birthday is coming soon.
Takahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces.
E869120 and square1001 were just about to eat A and B of those pieces, respectively,
when they found a note attached to the cake saying that "the same person should not t... | stdin | null | 2,324 | 1 | [
"11 4\n",
"8 8\n",
"5 4\n"
] | [
":(\n",
"Yay!\n",
"Yay!\n"
] | [
"11 6\n",
"0 8\n",
"5 1\n",
"11 5\n",
"0 9\n",
"8 1\n",
"13 5\n",
"0 18\n",
"8 0\n",
"18 5\n"
] | [
":(\n",
"Yay!\n",
"Yay!\n",
":(\n",
":(\n",
"Yay!\n",
":(\n",
":(\n",
"Yay!\n",
":(\n"
] |
CodeContests | In 20XX AD, a school competition was held. The tournament has finally left only the final competition. You are one of the athletes in the competition.
The competition you participate in is to compete for the time it takes to destroy all the blue objects placed in the space. Athletes are allowed to bring in competition... | stdin | null | 3,016 | 1 | [
"5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n261 -494 -87 -300 123 -463\n386 378 486 -443 -64 299\n",
"5 1\n0 10 0 5 2\n0 20 0 5 12\n0 30 0 5 22\n0 40 0 5 32\n0 50 0 5 42\n... | [
"0\n2\n1\n3\n0\n",
"110\n",
"9\n"
] | [
"5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n310 -494 -87 -300 123 -463\n386 378 486 -443 -64 299\n",
"5 1\n0 10 0 5 2\n0 20 0 6 12\n0 30 0 5 22\n0 40 0 5 32\n0 50 0 5 42\n... | [
"0\n2\n1\n3\n0\n",
"110\n",
"9\n",
"15\n",
"118\n",
"0\n2\n1\n3\n1\n",
"91\n",
"126\n",
"0\n2\n1\n2\n0\n",
"0\n1\n1\n3\n0\n"
] |
CodeContests | Joseph studies at SKIT.He is a fresher he has been given a task and he wants help from you for performing the task.The task is an interesting one.
The tasks is:-
He is provided with a value N, he has to make change for N cents, and he have infinite supply of each of S = { S1, S2, S3, S4}
valued coins, how many ways ... | stdin | null | 4,612 | 1 | [
"10\n2 4 9\n\nSAMPLE\n"
] | [
"3\n"
] | [
"10\n2 4 9\n\nSAMPLF\n",
"68\n2 3 10\n",
"10\n2 8 9\n\nFLPMAS\n",
"68\n4 3 10\n",
"10\n2 18 9\n\nFLPMAS\n",
"68\n4 6 19\n",
"10\n4 18 9\n\nFLPMAS\n",
"68\n2 3 18\n",
"68\n4 2 10\n",
"68\n4 6 9\n"
] | [
"3\n",
"49\n",
"2\n",
"25\n",
"1\n",
"9\n",
"0\n",
"30\n",
"72\n",
"14\n"
] |
CodeContests | Write a program which manipulates a sequence A = {a0, a1, . . . , an−1} with the following operations:
* update(s, t, x): change as, as+1, ..., at to x.
* find(s, t): report the minimum element in as, as+1, ..., at.
Note that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.
Constraints
* 1 ≤ n ≤ 100000... | stdin | null | 3,217 | 1 | [
"1 3\n1 0 0\n0 0 0 5\n1 0 0\n",
"3 5\n0 0 1 1\n0 1 2 3\n0 2 2 2\n1 0 2\n1 1 2\n"
] | [
"2147483647\n5\n",
"1\n2\n"
] | [
"3 5\n0 0 1 1\n0 1 2 5\n0 2 2 2\n1 0 2\n1 1 2\n",
"3 9\n0 0 1 1\n0 1 2 5\n0 2 2 2\n1 0 2\n1 1 2\n",
"3 9\n0 0 1 1\n0 1 2 5\n0 2 2 1\n1 0 2\n1 1 2\n",
"6 5\n0 0 1 1\n0 1 2 5\n0 0 2 2\n1 0 2\n1 1 2\n",
"6 5\n0 0 2 1\n0 1 2 5\n0 2 2 2\n1 0 2\n1 0 2\n",
"1 4\n1 0 0\n0 0 0 5\n1 0 0\n",
"3 9\n0 0 1 1\n0 0 2 5... | [
"1\n2\n",
"1\n2\n2\n2\n2\n2\n",
"1\n1\n1\n1\n1\n1\n",
"2\n2\n",
"1\n1\n",
"2147483647\n5\n5\n",
"2\n2\n2\n2\n2\n2\n",
"2147483647\n5\n5\n5\n5\n5\n",
"2147483647\n",
"2\n"
] |
CodeContests | Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:
* add(i, x): add x to ai.
* getSum(s, t): print the sum of as, as+1,...,at.
Note that the initial values of ai (i = 1, 2, . . . , n) are 0.
Constraints
* 1 ≤ n ≤ 100000
* 1 ≤ q ≤ 100000
* If comi is 0, then 1 ≤ xi... | stdin | null | 2,864 | 1 | [
"3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n"
] | [
"3\n2\n"
] | [
"4 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n",
"4 5\n0 1 1\n0 2 2\n0 1 5\n1 1 2\n1 2 2\n",
"4 5\n0 1 0\n0 2 2\n0 1 5\n1 1 2\n1 2 2\n",
"4 5\n0 1 1\n0 2 4\n0 3 3\n1 1 2\n1 2 2\n",
"4 5\n0 1 1\n0 4 4\n0 3 3\n1 1 2\n1 2 2\n",
"4 5\n0 1 1\n0 2 2\n0 3 9\n1 1 2\n0 2 2\n",
"4 5\n0 1 0\n0 2 2\n0 1 5\n1 1 0\n1 2 3\... | [
"3\n2\n",
"8\n2\n",
"7\n2\n",
"5\n4\n",
"1\n0\n",
"3\n",
"0\n2\n",
"1\n3\n",
"2\n",
"0\n1\n3\n"
] |
CodeContests | Hansa is throwing a birthday party. Seeing the extravagant parties thrown by her friends in the past, Hansa too decided to do something unique. Being a Computer Engineer herself, she knew just how to do it. She sent password-protected e-invites to T of her friends. Along with each of those e-invites there would be a nu... | stdin | null | 1,632 | 1 | [
"5\n27 1\n4 3201011\n6 5\n29 ffarpr\n3 1\n\nSAMPLE\n"
] | [
"1\n14\n5\n49\n1\n"
] | [
"5\n27 1\n4 3201011\n6 5\n29 rpraff\n3 1\n\nSAMPLE\n",
"5\n27 1\n4 3201011\n6 5\n29 rpraff\n3 2\n\nSAMPLE\n",
"20\n24 je6kbgm514608c5g336fl2jmi46fb5h2j250lhcinhhfl4i90ee9jg5g3f6ab263hinmhj5c4i8d0flee0fa55c61lf5mh130354ji6fja6g7f3085jd8fkik5lmjkec983f0j19iimfn969j03a43kifkfjk2g6mfac255kbj83d9gfffbk70i17g7knkllab... | [
"1\n14\n5\n26\n1\n",
"1\n14\n5\n26\n2\n",
"23627\n27495\n917\n46774\n7372\n13302\n26767\n5321\n25608\n15407\n28061\n7014\n48419\n7838\n39643\n13090\n17517\n1716\n3743\n23081\n",
"6369\n11471\n20179\n48058\n8881\n19650\n15296\n23643\n3200\n41130\n",
"6369\n11471\n24111\n48058\n8881\n19650\n15296\n23643\n3200... |
CodeContests | “All Hail The King.”
Middle aged, and overqualified highschool chemistry teacher Walter White has been diagnosed with lung cancer. To make sure his family is financially secure, he teams up with a former student Jesse Pinkman and turns to a life of crime to make and distribute the purest crystal meth on the streets.
... | stdin | null | 4,569 | 1 | [
"2\n2\n3 1\n4\n1 4 6 3\n\nSAMPLE\n"
] | [
"3\n27\n"
] | [
"2\n2\n3 1\n4\n1 4 6 3\n\nSBMPLE\n",
"2\n2\n5 1\n4\n1 4 6 3\n\nSBMPLE\n",
"2\n2\n5 0\n4\n1 4 6 3\n\nSBMPLE\n",
"2\n2\n3 1\n4\n2 4 6 3\n\nSAMPLE\n",
"2\n2\n5 0\n4\n1 5 6 3\n\nSBMPLE\n",
"2\n2\n5 0\n4\n1 1 6 3\n\nSBMPLE\n",
"2\n2\n3 0\n4\n2 4 6 3\n\nSAMPLE\n",
"2\n2\n5 0\n4\n1 6 6 3\n\nSBMPLE\n",
"2\n... | [
"3\n27\n",
"5\n27\n",
"0\n27\n",
"3\n30\n",
"0\n33\n",
"0\n19\n",
"0\n30\n",
"0\n39\n",
"0\n20\n",
"0\n26\n"
] |
CodeContests | You have a deck of N × M cards. Each card in the deck has a rank. The range of ranks is 1 through M, and the deck includes N cards of each rank.
We denote a card with rank m by m here.
You can draw a hand of L cards at random from the deck. If the hand matches the given pattern, some bonus will be rewarded. A pattern... | stdin | null | 3,206 | 1 | [
"1 1 1\na\n3 3 4\na+ * a *\n2 2 3\na a b\n2 2 3\n* * *\n2 2 3\n* b b\n2 2 2\na a\n2 3 3\na a+ a++\n2 6 6\na a+ a++ b b+ b++\n4 13 5\na a * * *\n4 13 5\na a b b *\n4 13 5\na a a * *\n4 13 5\na a+ a++ a+++ a++++\n4 13 5\n* * * * *\n4 13 5\na a a b b\n4 13 5\na a a a *\n7 60 7\na b a b c c *\n7 60 7\n* * * * * * *\n7 ... | [
"1.0000000000\n0.8809523810\n1.0000000000\n1.0000000000\n1.0000000000\n0.3333333333\n0.4000000000\n0.1212121212\n0.4929171669\n0.0492196879\n0.0228091236\n0.0035460338\n1.0000000000\n0.0014405762\n0.0002400960\n0.0002967709\n1.0000000000\n0.0000001022\n0.0000000000\n"
] | [
"1 1 1\na\n3 3 4\na+ * a *\n2 2 3\na a b\n2 2 3\n* * *\n2 2 3\n* b b\n2 2 2\na a\n2 3 3\na a+ a++\n2 6 6\na a+ a++ b b+ b++\n4 13 5\na a * * *\n4 13 5\na a b b *\n4 13 5\na a a * *\n4 13 5\na a+ a++ a+++ a++++\n4 13 5\n* * ) * *\n4 13 5\na a a b b\n4 13 5\na a a a *\n7 60 7\na b a b c c *\n7 60 7\n* * * * * * *\n7 ... | [
"1.000000000\n0.880952381\n1.000000000\n1.000000000\n1.000000000\n0.333333333\n0.400000000\n0.121212121\n0.492917167\n0.049219688\n0.022809124\n0.003546034\n1.000000000\n0.001440576\n0.000240096\n0.000296771\n1.000000000\n0.000000102\n0.000000000\n",
"1.000000000\n0.880952381\n1.000000000\n1.000000000\n1.00000000... |
CodeContests | The main land of Japan called Honshu is an island surrounded by the sea. In such an island, it is natural to ask a question: "Where is the most distant point from the sea?" The answer to this question for Honshu was found in 1996. The most distant point is located in former Usuda Town, Nagano Prefecture, whose distance... | stdin | null | 660 | 1 | [
"4\n0 0\n10000 0\n10000 10000\n0 10000\n3\n0 0\n10000 0\n7000 1000\n6\n0 40\n100 20\n250 40\n250 70\n100 90\n0 70\n3\n0 0\n10000 10000\n5000 5001\n0\n"
] | [
"5000.000000\n494.233641\n34.542948\n0.353553\n"
] | [
"4\n0 0\n10000 0\n10000 10000\n0 10000\n3\n0 0\n10010 0\n7000 1000\n6\n0 40\n100 20\n250 40\n250 70\n100 90\n0 70\n3\n0 0\n10000 10000\n5000 5001\n0\n",
"4\n0 0\n10000 0\n10000 10000\n0 10000\n3\n0 0\n10010 0\n7000 1000\n6\n0 40\n100 20\n250 40\n250 70\n100 90\n0 70\n3\n0 0\n10000 10001\n5000 5001\n0\n",
"4\n0 ... | [
"5000.00000000\n494.25181970\n34.54294846\n0.35355339\n",
"5000.00000000\n494.25181970\n34.54294846\n0.17676786\n",
"5000.00000000\n494.25181970\n34.08197450\n0.17676786\n",
"5000.00000000\n494.25181970\n34.17468475\n0.17676786\n",
"5000.00000000\n494.23364089\n34.22228559\n0.35355339\n",
"5000.00000000\n... |
CodeContests | Four-Coloring
You are given a planar embedding of a connected graph. Each vertex of the graph corresponds to a distinct point with integer coordinates. Each edge between two vertices corresponds to a straight line segment connecting the two points corresponding to the vertices. As the given embedding is planar, the li... | stdin | null | 3,769 | 1 | [
"5 8\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 5\n3 4\n3 5\n4 5\n"
] | [
"1\n2\n2\n1\n3\n"
] | [
"5 9\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 5\n3 4\n3 5\n4 5\n",
"5 9\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 5\n5 4\n4 5\n4 5\n",
"5 9\n0 0\n2 0\n0 2\n2 2\n1 1\n1 2\n1 3\n1 5\n2 4\n2 10\n3 4\n4 5\n4 5\n",
"5 0\n0 0\n4 1\n0 2\n2 2\n1 0\n1 2\n1 3\n1 5\n2 4\n2 2\n3 4\n3 5\n4 5\n",
"5 9\n0 0\n... | [
"1\n2\n2\n1\n3\n",
"1\n3\n2\n1\n2\n",
"1\n2\n2\n1\n2\n",
"1\n1\n1\n1\n1\n",
"1\n3\n1\n1\n2\n",
"1\n1\n1\n1\n",
"1\n1\n1\n1\n1\n1\n",
"1\n1\n1\n1\n1\n1\n1\n1\n1\n",
"1\n1\n1\n1\n1\n1\n1\n",
"1\n1\n1\n"
] |
CodeContests | You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string.
Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S:
1. Reverse the order of the characters in S.
2. Replace each occurrence of `b` by `d`, `d... | stdin | null | 143 | 1 | [
"ppqb\n",
"pdbq\n"
] | [
"No\n",
"Yes\n"
] | [
"qbdp\n",
"dbqp\n",
"bdqp\n",
"bqpp\n",
"pdqb\n",
"dqbp\n",
"pqbd\n",
"pqdb\n",
"bqqp\n",
"pdpb\n"
] | [
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n"
] |
CodeContests | Obesity is cited as the cause of many adult diseases. In the past, with a few exceptions, it was unrelated to high school students. However, it is no longer unrealistic to suffer from lack of exercise due to excessive studying for entrance exams, or to become bulimia nervosa due to stress. It may be a problem that high... | stdin | null | 2,486 | 1 | [
"1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n"
] | [
"1004\n1005\n"
] | [
"1011,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0,1.70\n1005,90.0,1.60\n",
"1010,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1400,80.0,1.70\n1005,90.0,1.60\n",
"1001,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1003,80.0,1.70\n1005,90.0,1.60\n",
"1011,50.0,1.60\n1002,60.0,1.70\n1003,70.0,1.80\n1004,80.0... | [
"1004\n1005\n",
"1400\n1005\n",
"1003\n1005\n",
"1004\n10\n",
"1005\n1005\n",
"1002\n1004\n1005\n",
"1005\n",
"1004\n1015\n",
"0\n1400\n1005\n",
"1072\n1004\n1005\n"
] |
CodeContests | Given an array A of size N. Given Q operations, each operation contains an integer D. In each operation you have to divide all the elements of the array by D.
For example, for each operation with a given D, the new array A would be:
A[0] / D, A[1] / D, A[2] / D, ..... , A[N-1] / D
Finally, after processing all the o... | stdin | null | 3,981 | 1 | [
"5\n50 20 18 27 19\n3\n2\n3\n2\nSAMPLE\n"
] | [
"4 1 1 2 1\n"
] | [
"1000\n384 887 778 916 794 336 387 493 650 422 363 28 691 60 764 927 541 427 173 737 212 369 568 430 783 531 863 124 68 136 930 803 23 59 70 168 394 457 12 43 230 374 422 920 785 538 199 325 316 371 414 527 92 981 957 874 863 171 997 282 306 926 85 328 337 506 847 730 314 858 125 896 583 546 815 368 435 365 44 751 ... | [
"12 27 24 28 24 10 12 15 20 13 11 0 21 1 23 28 16 13 5 23 6 11 17 13 24 16 26 3 2 4 29 25 0 1 2 5 12 14 0 1 7 11 13 28 24 16 6 10 9 11 12 16 2 30 29 27 26 5 31 8 9 28 2 10 10 15 26 22 9 26 3 28 18 17 25 11 13 11 1 23 2 25 8 5 24 18 12 20 23 12 29 1 21 11 23 0 7 18 2 16 24 17 13 11 14 18 3 28 9 15 20 23 9 8 8 13 27 ... |
CodeContests | F: Tea Party
Yun decided to hold a tea party at the company.
The shop sells $ N $ sets of bread, each containing $ A_1, A_2, A_3, \ dots, A_N $.
Yun decided to make a sandwich by combining two breads into a pair.
Yun-san is very careful, so I want to make sure that I don't have any leftover bread.
Calculate how ma... | stdin | null | 1,587 | 1 | [
"5\n2 3 5 6 7\n"
] | [
"10\n"
] | [
"5\n4 3 5 6 7\n",
"5\n4 3 5 10 7\n",
"5\n4 3 5 10 9\n",
"5\n4 6 5 10 9\n",
"5\n4 12 5 10 9\n",
"5\n4 12 5 0 9\n",
"5\n4 12 5 0 3\n",
"5\n1 12 5 0 3\n",
"5\n2 3 3 6 7\n",
"5\n4 3 5 10 17\n"
] | [
"11\n",
"13\n",
"14\n",
"17\n",
"20\n",
"15\n",
"12\n",
"10\n",
"9\n",
"18\n"
] |
CodeContests | You are given positive integers A and B.
Find the K-th largest positive integer that divides both A and B.
The input guarantees that there exists such a number.
Constraints
* All values in input are integers.
* 1 \leq A, B \leq 100
* The K-th largest positive integer that divides both A and B exists.
* K \geq 1
In... | stdin | null | 1,607 | 1 | [
"1 1 1\n",
"100 50 4\n",
"8 12 2\n"
] | [
"1\n",
"5\n",
"2\n"
] | [
"100 50 2\n",
"16 12 2\n",
"12 12 2\n",
"100 45 2\n",
"27 12 1\n",
"16 24 1\n",
"110 50 2\n",
"12 12 3\n",
"27 18 1\n",
"100 50 3\n"
] | [
"25\n",
"2\n",
"6\n",
"1\n",
"3\n",
"8\n",
"5\n",
"4\n",
"9\n",
"10\n"
] |
CodeContests | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.
The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
Constraints
* 0 ≤ a, b ≤ 20000
* No divisions by zero are given.
Input
The input c... | stdin | null | 2,825 | 1 | [
"1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n"
] | [
"3\n38\n26\n10\n108\n"
] | [
"1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n-1 ? 0\n",
"1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 , 81\n-1 ? 0\n",
"1 + 2\n56 - 18\n21 * 2\n100 / 10\n27 , 81\n-1 ? 0\n",
"1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 136\n-1 ? 0\n",
"1 + 2\n56 - 18\n21 * 2\n100 / 10\n9 , 81\n-1 ? 0\n",
"2 + 2\n56 - 18\n13 * 2\n100 / ... | [
"3\n38\n26\n10\n108\n",
"3\n38\n26\n10\n(27, 81)\n",
"3\n38\n42\n10\n(27, 81)\n",
"3\n38\n26\n10\n163\n",
"3\n38\n42\n10\n(9, 81)\n",
"4\n38\n26\n10\n(27, 81)\n",
"4\n38\n26\n10\n(42, 81)\n",
"3\n38\n42\n10\n(3, 81)\n",
"4\n38\n20\n10\n(42, 81)\n",
"3\n38\n42\n10\n(1, 81)\n"
] |
CodeContests | Dr. Akita, who lives in the neighborhood, is a historical researcher in the field and recently discovered a new ancient document about Ono no Komachi.
It is widely known that Ono no Komachi has given General Fukakusa, who wants to be dating, on condition that he keeps going for 100 nights, but he claims that this disc... | stdin | null | 1,028 | 1 | [
"1 1\n2 2\n3 1+2*3-4\n3 1|2^3&4\n3 (1+2)*3\n3 1-1-1-1\n0 #\n"
] | [
"91\n2\n273\n93\n279\n88\n"
] | [
"1 1\n2 2\n6 1+2*3-4\n3 1|2^3&4\n3 (1+2)*3\n3 1-1-1-1\n0 #\n",
"1 1\n2 2\n6 1+2*3-4\n3 1|2^3&4\n4 (1+2)*3\n3 1-1-1-1\n0 #\n",
"1 1\n2 2\n1 1+2*3-4\n3 1|2^3&4\n4 (1+2)*3\n3 1-1-1-1\n0 #\n",
"1 1\n2 2\n1 1+2-3*4\n3 1|2^3&4\n4 (1+2)*3\n3 1-1-1-1\n0 #\n",
"1 1\n2 2\n1 1+2*3-3\n3 1|2^3&4\n4 (1+2)*3\n3 1-1-1-1\n0... | [
"91\n2\n3\n93\n279\n88\n",
"91\n2\n3\n93\n9\n88\n",
"91\n2\n273\n93\n9\n88\n",
"91\n2\n93\n93\n9\n88\n",
"91\n2\n274\n93\n9\n88\n",
"91\n2\n93\n93\n279\n88\n",
"1\n2\n3\n93\n279\n88\n",
"91\n2\n3\n3\n9\n88\n",
"1\n2\n3\n3\n279\n88\n",
"1\n2\n3\n3\n9\n88\n"
] |
CodeContests | You are given a directed graph with N vertices and M edges. The vertices are numbered 1, 2, ..., N, and the edges are numbered 1, 2, ..., M. Edge i points from Vertex a_i to Vertex b_i.
For each edge, determine whether the reversion of that edge would change the number of the strongly connected components in the graph... | stdin | null | 296 | 1 | [
"2 2\n1 2\n2 1\n",
"5 9\n3 2\n3 1\n4 1\n4 2\n3 5\n5 3\n3 4\n1 2\n2 5\n",
"3 3\n1 2\n1 3\n2 3\n"
] | [
"diff\ndiff\n",
"same\nsame\nsame\nsame\nsame\ndiff\ndiff\ndiff\ndiff\n",
"same\ndiff\nsame\n"
] | [
"5 9\n5 2\n3 1\n4 1\n4 2\n3 5\n5 3\n3 4\n1 2\n2 5\n",
"3 2\n1 2\n1 3\n2 3\n",
"6 3\n1 2\n1 3\n2 3\n",
"5 9\n3 2\n3 1\n4 1\n4 2\n3 5\n5 3\n5 4\n1 2\n4 5\n",
"3 2\n1 2\n2 1\n",
"6 3\n1 2\n1 3\n4 3\n",
"5 9\n5 2\n3 1\n4 1\n4 2\n3 5\n5 3\n3 4\n1 2\n1 5\n",
"5 9\n3 2\n3 2\n4 1\n4 2\n3 5\n5 3\n5 4\n1 2\n2 5... | [
"same\nsame\nsame\nsame\nsame\ndiff\ndiff\ndiff\ndiff\n",
"same\nsame\n",
"same\ndiff\nsame\n",
"diff\ndiff\ndiff\ndiff\ndiff\ndiff\ndiff\nsame\ndiff\n",
"diff\ndiff\n",
"same\nsame\nsame\n",
"diff\nsame\ndiff\ndiff\nsame\ndiff\ndiff\ndiff\ndiff\n",
"same\nsame\ndiff\nsame\nsame\ndiff\ndiff\ndiff\ndif... |
CodeContests | Snuke received two matrices A and B as birthday presents. Each of the matrices is an N by N matrix that consists of only 0 and 1.
Then he computed the product of the two matrices, C = AB. Since he performed all computations in modulo two, C was also an N by N matrix that consists of only 0 and 1. For each 1 ≤ i, j ≤ N... | stdin | null | 4,940 | 1 | [
"2\n0 1\n1 0\n",
"10\n1 0 0 1 1 1 0 0 1 0\n0 0 0 1 1 0 0 0 1 0\n0 0 1 1 1 1 1 1 1 1\n0 1 0 1 0 0 0 1 1 0\n0 0 1 0 1 1 1 1 1 1\n1 0 0 0 0 1 0 0 0 0\n1 1 1 0 1 0 0 0 0 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 1 0 0 0 0\n1 0 1 0 0 1 1 1 1 1\n"
] | [
"6\n",
"741992411\n"
] | [
"2\n0 1\n1 -1\n",
"10\n1 0 0 1 1 1 0 0 1 0\n0 0 0 1 1 0 0 0 1 0\n0 0 1 1 1 1 1 1 1 1\n0 1 0 1 0 0 0 1 1 0\n0 0 1 0 1 1 1 1 1 1\n1 0 0 0 0 1 0 0 0 0\n1 1 1 0 1 0 0 0 0 1\n0 0 0 1 0 0 1 0 1 0\n0 0 0 1 1 0 0 0 0 0\n1 0 1 0 0 1 1 1 1 1\n",
"10\n1 0 0 1 1 1 0 0 1 0\n0 0 0 1 1 0 0 0 1 0\n0 0 1 1 1 1 1 1 1 1\n0 1 0 1 ... | [
"6\n",
"741992411\n",
"195790748\n",
"18\n",
"731930254\n",
"58\n",
"158010567\n",
"741992411\n",
"741992411\n",
"741992411\n"
] |
CodeContests | Problem Statement
We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a different English alphabet and typed all the words in the dictionary ... | stdin | null | 155 | 1 | [
"4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacb\nc\nb\nb\n0\n"
] | [
"yes\nno\nyes\nno\n"
] | [
"4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacc\nc\nb\nb\n0\n",
"4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacc\nd\nb\nb\n0\n",
"4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\ncba\nacb\nb\nc\nc\n5\nabc\nacc\nd\nb\nb\n0\n",
"4\nabc\ncab\nb\na\n3\nacb\nac\na\n5\nabc\nacb\nb\nc\nc... | [
"yes\nno\nyes\nno\n",
"yes\nno\nyes\nyes\n",
"yes\nno\nno\nyes\n",
"no\nno\nyes\nno\n",
"yes\nno\nyes\n",
"no\nno\nno\nno\n",
"no\nno\nyes\n",
"no\nno\nno\nyes\n",
"no\nno\nyes\nyes\n",
"yes\nno\nno\nno\n"
] |
CodeContests | This summer, there is a worldwide competition being held in Chef Town and some of the best chefs of the world are participating. The rules of this competition are quite simple.
Each participant needs to bring his or her best dish. The judges will initially assign a score to each of the dishes. Now, several rounds wil... | stdin | null | 4,213 | 1 | [
"1\n2\n1 2\n2\n0 1 2\n1 1\n"
] | [
"2\n"
] | [
"1\n2\n1 3\n2\n0 1 2\n1 1\n",
"1\n2\n1 1\n2\n0 1 2\n1 1\n",
"1\n2\n1 3\n2\n0 1 1\n1 1\n",
"1\n2\n0 1\n2\n0 2 2\n1 0\n",
"1\n4\n0 1\n2\n0 2 2\n1 0\n",
"1\n2\n0 1\n1\n0 1 1\n1 0\n",
"1\n3\n0 1\n2\n0 1 2\n1 0\n",
"1\n6\n0 1\n2\n0 1 2\n1 0\n",
"1\n4\n0 1\n2\n0 1 2\n1 0\n",
"1\n3\n0 1\n2\n0 1 1\n1 0\n"... | [
"2\n",
"1\n",
"Invalid query!\n1\n",
"Invalid query!\n2\n",
"Invalid query!\n4\n",
"Invalid query!\n",
"3\n",
"6\n",
"4\n",
"Invalid query!\n3\n"
] |
CodeContests | Problem
Chocolate company Chinor Choco has decided to build n new stores.
For each store, ask each store manager to prepare two candidates for the place you want to build, and build it in either place.
Chinor Choco sells m types of chocolate, each manufactured at a different factory.
All types of chocolate are sold a... | stdin | null | 2,663 | 1 | [
"2 2\n0 0 6 0\n7 0 3 0\n4 0\n5 0\n",
"2 1\n0 0 5 5\n3 3 6 6\n2 2\n"
] | [
"3.0000000000\n",
"4.2426406871\n"
] | [
"0 2\n0 0 6 0\n7 0 3 0\n4 0\n5 0\n",
"2 1\n0 0 9 5\n3 3 6 6\n2 2\n",
"2 1\n0 0 9 5\n5 1 6 6\n2 2\n",
"2 2\n0 0 11 0\n7 0 3 0\n4 0\n5 0\n",
"2 1\n0 0 9 5\n5 1 6 6\n3 2\n",
"2 1\n0 0 9 2\n3 4 6 6\n2 2\n",
"2 1\n-1 0 9 0\n5 1 4 6\n2 2\n",
"2 2\n0 0 6 0\n5 1 6 6\n2 0\n",
"2 2\n0 0 11 0\n7 1 3 0\n8 0\n5 ... | [
"0.0000000000\n",
"4.2426406871\n",
"5.9907047849\n",
"7.0000000000\n",
"5.8416192530\n",
"5.0644951022\n",
"6.7678289356\n",
"5.1622776602\n",
"8.0000000000\n",
"3.6502815399\n"
] |
CodeContests | Our monk loves food. Hence,he took up position of a manager at Sagar,a restaurant that serves people with delicious food packages. It is a very famous place and people are always queuing up to have one of those packages. Each package has a cost associated with it. The packages are kept as a pile.
The job of a manager... | stdin | null | 5,003 | 1 | [
"6\n1\n2 5\n2 7\n2 9\n1\n1\n\nSAMPLE\n"
] | [
"No Food\n9\n7\n"
] | [
"6\n1\n2 4\n2 7\n2 9\n1\n1\n\nSAMPLE\n",
"6\n1\n2 4\n2 1\n2 9\n1\n1\n\nQAMSLE\n",
"6\n1\n2 -1\n2 7\n2 16\n1\n1\n\nSALPLE\n",
"6\n1\n2 7\n2 2\n2 9\n1\n1\n\nQAMSLE\n",
"6\n1\n2 5\n2 7\n2 5\n1\n1\n\nSAMPLE\n",
"6\n1\n2 4\n2 7\n2 13\n1\n1\n\nSAMQLE\n",
"6\n1\n2 5\n2 7\n2 6\n1\n1\n\nSAMPLE\n",
"6\n1\n2 4\n... | [
"No Food\n9\n7\n",
"No Food\n9\n1\n",
"No Food\n16\n7\n",
"No Food\n9\n2\n",
"No Food\n5\n7\n",
"No Food\n13\n7\n",
"No Food\n6\n7\n",
"No Food\n13\n13\n",
"No Food\n0\n7\n",
"No Food\n1\n1\n"
] |
CodeContests | ``Domino effect'' is a famous play using dominoes. A player sets up a chain of dominoes stood. After a chain is formed, the player topples one end of the dominoes. The first domino topples the second domino, the second topples the third and so on.
You are playing domino effect. Before you finish to set up a chain of d... | stdin | null | 3,611 | 1 | [
"2\n0 0\n15 0\n5 0 1\n10 10 2\n",
"2\n0 0\n10 0\n5 0 1\n9 0 3\n",
"3\n-10 0\n0 0\n0 10\n-1 0 1\n3 0 2\n"
] | [
"5.0\n",
"2.0\n",
"4.072027\n"
] | [
"2\n0 0\n7 0\n5 0 1\n10 10 2\n",
"2\n0 0\n10 0\n5 0 1\n9 0 6\n",
"3\n-5 0\n0 0\n0 10\n-1 0 1\n3 0 2\n",
"3\n-5 0\n0 0\n0 10\n-1 0 1\n3 0 0\n",
"3\n-5 0\n0 0\n0 14\n-1 0 1\n3 0 0\n",
"2\n0 0\n15 0\n9 0 1\n10 10 2\n",
"3\n-10 0\n0 0\n0 10\n-1 0 2\n3 0 2\n",
"2\n0 0\n10 0\n5 0 1\n17 0 6\n",
"3\n-4 0\n0... | [
"5.000000\n",
"0.800000\n",
"4.000000\n",
"11.000000\n",
"15.000000\n",
"6.145199\n",
"4.500000\n",
"2.400000\n",
"3.000000\n",
"9.000000\n"
] |
CodeContests | We have N cards. A number a_i is written on the i-th card.
Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.
The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards... | stdin | null | 693 | 1 | [
"4\n20 18 2 18\n",
"2\n3 1\n",
"3\n2 7 4\n"
] | [
"18\n",
"2\n",
"5\n"
] | [
"4\n20 18 2 12\n",
"2\n2 1\n",
"3\n3 7 4\n",
"4\n20 1 2 12\n",
"2\n2 0\n",
"3\n3 9 4\n",
"4\n20 1 4 12\n",
"2\n2 -1\n",
"2\n4 -1\n",
"4\n20 2 0 12\n"
] | [
"12\n",
"1\n",
"6\n",
"9\n",
"2\n",
"8\n",
"11\n",
"3\n",
"5\n",
"10\n"
] |
CodeContests | There is an undirected connected graph with N vertices numbered 1 through N. The lengths of all edges in this graph are 1. It is known that for each i (1≦i≦N), the distance between vertex 1 and vertex i is A_i, and the distance between vertex 2 and vertex i is B_i. Determine whether there exists such a graph. If it exi... | stdin | null | 2,251 | 1 | [
"3\n0 1\n1 0\n2 2\n",
"4\n0 1\n1 0\n1 1\n2 1\n"
] | [
"-1\n",
"4\n"
] | [
"4\n1 1\n1 0\n1 1\n2 1\n",
"4\n0 1\n1 0\n2 1\n2 1\n",
"4\n2 1\n1 0\n1 1\n2 1\n",
"4\n1 1\n1 1\n1 1\n2 1\n",
"4\n1 2\n1 0\n1 1\n2 1\n",
"4\n1 2\n1 0\n1 1\n0 1\n",
"4\n1 2\n1 0\n0 1\n0 1\n",
"4\n1 2\n1 1\n0 1\n0 1\n",
"4\n1 2\n1 2\n0 1\n0 1\n",
"4\n1 2\n1 2\n0 1\n-1 1\n"
] | [
"-1\n",
"3\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n",
"-1\n"
] |
CodeContests | A:It is a natural number greater than 1 that has no positive divisors other than 1 and itself.
B: It is a number that remains the same when its digits are reversed. It is "symmetrical".
Patrik lives in Palestine. He loves everything starting with P and so numbers also. His friend gave him a number X and asked him t... | stdin | null | 4,494 | 1 | [
"3\n42\n108\n250\n\nSAMPLE\n"
] | [
"101\n131\n313\n"
] | [
"3\n60\n108\n250\n\nSAMPLE\n",
"3\n28\n31\n250\n\nMARPLE\n",
"3\n52\n19\n473\n\nMASPLE\n",
"3\n101\n8\n473\n\nMASEPL\n",
"3\n101\n25\n76\n\nLPERAM\n",
"3\n101\n25\n138\n\nLPERAM\n",
"3\n100\n1\n248\n\nLPERAM\n",
"16\n88\n445\n787\n54\n5\n5345\n68876\n45\n10\n6876\n1442\n346\n11\n554\n53478\n989\n",
... | [
"101\n131\n313\n",
"101\n101\n313\n",
"101\n101\n727\n",
"101\n11\n727\n",
"101\n101\n101\n",
"101\n101\n151\n",
"101\n1\n313\n",
"101\n727\n787\n101\n5\n10301\n70207\n101\n11\n10301\n10301\n353\n11\n727\n70207\n10301\n",
"101\n313\n313\n",
"101\n131\n101\n"
] |
CodeContests | Example
Input
4 1
0 0
3 0
3 3
0 3
1 1
Output
2.0000000000 | stdin | null | 1,783 | 1 | [
"4 1\n0 0\n3 0\n3 3\n0 3\n1 1\n"
] | [
"2.0000000000\n"
] | [
"4 1\n0 0\n6 0\n3 3\n0 3\n1 1\n",
"4 1\n0 0\n6 0\n3 5\n0 3\n1 1\n",
"4 1\n0 0\n3 0\n6 3\n0 3\n1 1\n",
"4 1\n0 0\n6 0\n6 5\n0 3\n1 1\n",
"4 1\n0 0\n6 0\n6 5\n0 6\n1 1\n",
"4 1\n1 0\n6 0\n6 5\n0 6\n1 1\n",
"4 1\n1 0\n6 0\n6 5\n-1 6\n1 1\n",
"4 1\n1 0\n6 0\n6 5\n-1 6\n1 2\n",
"4 1\n1 0\n8 0\n6 5\n-1 6\... | [
"4.666666666667\n",
"6.641025641026\n",
"5.000000000000\n",
"10.583333333333\n",
"12.287878787879\n",
"13.166666666667\n",
"12.897435897436\n",
"10.102564102564\n",
"13.266666666667\n",
"11.826086956522\n"
] |
CodeContests | February Easy Challenge 2015 is underway. Hackerearth welcomes you all and hope that all you awesome coders have a great time. So without wasting much of the time let's begin the contest.
Prime Numbers have always been one of the favourite topics for problem setters. For more information on them you can use see thi... | stdin | null | 2,793 | 1 | [
"4\n7\n10\n14\n11\n\nSAMPLE\n"
] | [
"1\n2\n2\n3\n"
] | [
"82\n9640\n4797\n29790\n23696\n9640\n2691\n3070\n26136\n12309\n11629\n14060\n7053\n6461\n20643\n16255\n120\n28371\n16925\n5789\n29110\n19346\n23993\n25728\n808\n3619\n30858\n5818\n26028\n30529\n5747\n3959\n26956\n29467\n7669\n23043\n28598\n4602\n32326\n2188\n25324\n29731\n31651\n7976\n1085\n11519\n5606\n12314\n1010... | [
"1378\n686\n4256\n3386\n1378\n385\n440\n3734\n1759\n1662\n2010\n1009\n923\n2949\n2323\n18\n4053\n2419\n827\n4160\n2764\n3429\n3676\n116\n517\n4409\n832\n3719\n4362\n821\n567\n3852\n4211\n1097\n3293\n4086\n658\n4618\n314\n3618\n4248\n4523\n1140\n155\n1647\n802\n1760\n1444\n3565\n2245\n487\n1695\n1378\n2700\n240\n322... |
CodeContests | A linear congruential generator produces a series R(⋅) of pseudo-random numbers by the following for- mulas:
<image>
where S, A, C, and M are all parameters. In this problem, 0 ≤ S, A, C ≤ 15 and M = 256.
Now suppose we have some input string I(⋅), where each character in the string is an integer between 0 and (M - ... | stdin | null | 4,243 | 1 | [
"5\n5 4 3 2 1\n5\n7 7 7 7 7\n10\n186 8 42 24 154 40 10 56 122 72\n0\n"
] | [
"0 1 1\n0 0 0\n8 7 14\n"
] | [
"5\n5 4 3 2 1\n5\n7 7 7 7 7\n10\n186 8 42 24 154 40 10 56 122 141\n0\n",
"5\n5 4 3 2 1\n5\n7 12 2 0 7\n10\n372 8 42 18 154 40 10 56 122 141\n0\n",
"5\n5 4 3 4 1\n5\n7 11 7 7 14\n0\n186 8 42 24 154 21 10 56 122 72\n0\n",
"5\n5 4 3 4 1\n5\n13 11 1 7 14\n0\n186 8 64 24 241 21 13 22 122 72\n0\n",
"5\n5 4 5 4 2\... | [
"0 1 1\n0 0 0\n8 7 14\n",
"0 1 1\n6 11 13\n8 7 14\n",
"0 1 1\n0 0 0\n",
"0 1 1\n0 1 2\n",
"0 0 0\n0 1 2\n",
"0 1 1\n0 5 1\n",
"0 1 1\n0 1 3\n",
"0 1 1\n3 8 10\n8 7 14\n",
"0 1 1\n7 15 11\n",
"0 0 0\n15 11 13\n"
] |
CodeContests | We have N switches with "on" and "off" state, and M bulbs. The switches are numbered 1 to N, and the bulbs are numbered 1 to M.
Bulb i is connected to k_i switches: Switch s_{i1}, s_{i2}, ..., and s_{ik_i}. It is lighted when the number of switches that are "on" among these switches is congruent to p_i modulo 2.
How ... | stdin | null | 254 | 1 | [
"2 2\n2 1 2\n1 2\n0 1\n",
"5 2\n3 1 2 5\n2 2 3\n1 0\n",
"2 3\n2 1 2\n1 1\n1 2\n0 0 1\n"
] | [
"1\n",
"8\n",
"0\n"
] | [
"2 2\n2 1 2\n1 2\n0 0\n",
"4 2\n2 1 2\n1 2\n0 1\n",
"5 2\n1 1 2 5\n2 2 3\n1 0\n",
"2 3\n2 1 2\n1 1\n1 2\n0 0 -1\n",
"4 0\n1 1 2\n1 2\n0 1\n",
"1 0\n0 1 4\n1 1\n0 1\n0 0 -1\n",
"9 2\n3 1 2 5\n2 2 3\n1 0\n",
"7 2\n2 1 2\n1 1\n0 1\n",
"8 0\n2 1 2\n1 1\n1 2\n0 0 -1\n",
"6 0\n-4 0 2\n-1 4\n1 0\n0 0 -2\... | [
"1\n",
"4\n",
"8\n",
"0\n",
"16\n",
"2\n",
"128\n",
"32\n",
"256\n",
"64\n"
] |
CodeContests | Your friend gives you an equation A≡X2(modM) and asks you to find an integer solution for X.
However, you know your friend's mischievous nature and suspect that there is no solution to such an equation. Thus, you first want to find out whether there is a solution to it.
You may find this link helpful: http://en.wikip... | stdin | null | 3,628 | 1 | [
"2 \n5 7 \n4 7\n\nSAMPLE\n"
] | [
"NO \nYES\n"
] | [
"2 \n5 7 \n3 7\n\nSAMPLE\n",
"2 \n5 11 \n3 7\n\nSAMPLE\n",
"2 \n5 2 \n0 7\n\nS@MPLE\n",
"2 \n5 1 \n0 7\n\nS@MPLE\n",
"2 \n5 2 \n3 7\n\nSAMPLE\n",
"2 \n5 2 \n3 7\n\nS@MPLE\n",
"2 \n3 1 \n0 7\n\nS@MPLE\n",
"2 \n3 1 \n0 11\n\nS@MPLE\n",
"2 \n3 1 \n0 16\n\nS@MPLE\n",
"2 \n2 1 \n0 1... | [
"NO\nNO\n",
"YES\nNO\n",
"YES\nYES\n",
"NO\nYES\n",
"YES\nNO\n",
"YES\nNO\n",
"NO\nYES\n",
"NO\nYES\n",
"NO\nYES\n",
"NO\nYES\n"
] |
CodeContests | J: City
Santa decides to deliver a present to a city.
The city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel.
The $ X $ th section from the north and the $ Y $ th section from the west are represented by $ (X, Y) $.
Santa mov... | stdin | null | 3,815 | 1 | [
"4 5 2 3\n"
] | [
"Yes\n"
] | [
"4 9 2 3\n",
"3 1 3 12\n",
"4 1 2 3\n",
"2 1 2 3\n",
"2 1 2 4\n",
"3 1 2 4\n",
"3 2 2 4\n",
"3 4 2 4\n",
"4 4 2 4\n",
"4 3 2 4\n"
] | [
"Yes\n",
"No\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n",
"Yes\n"
] |
CodeContests | problem
AOR Ika-chan, who loves feasts, defined "the number of feasts". A feast number is a natural number that includes "$ 51-3 $" in $ 10 $ decimal notation.
$? $ Can be any number from $ 0 $ to $ 9 $.
Find the number of feasts out of the natural numbers below $ N $.
input
$ N $
output
Output the number of fe... | stdin | null | 1,907 | 1 | [
"5124\n"
] | [
"3\n"
] | [
"2935\n",
"5957\n",
"5184\n",
"1221\n",
"2333\n",
"2926\n",
"3847\n",
"6645\n",
"2831\n",
"8530\n"
] | [
"0\n",
"10\n",
"9\n",
"0\n",
"0\n",
"0\n",
"0\n",
"10\n",
"0\n",
"10\n"
] |
CodeContests | Background
The site of Mr. A's house, which lives in a certain city, is surrounded by white walls. Feeling unsatisfied with the wall, Mr. A decided to invite the children in the neighborhood to paint the wall freely. Ask the children to choose their favorite section of the wall and paint it. So how was the wall painte... | stdin | null | 2,971 | 1 | [
"4 2\n0 2\n1 2\n",
"10 3\n2 1\n4 1\n9 2\n",
"5 3\n0 1\n2 1\n3 1\n"
] | [
"3 1\n",
"2 1\n1 2\n",
"2 1\n1 1\n"
] | [
"1 2\n0 2\n1 2\n",
"4 3\n2 1\n4 1\n9 2\n",
"3 3\n0 1\n2 1\n3 1\n",
"4 2\n0 2\n1 4\n",
"10 3\n2 1\n4 1\n9 1\n",
"5 3\n0 1\n2 1\n5 1\n",
"10 3\n0 1\n4 1\n9 2\n",
"8 3\n4 1\n8 1\n11 3\n",
"10 3\n0 1\n7 1\n13 2\n",
"22 3\n1 1\n0 1\n9 2\n"
] | [
"1 1\n",
"3 1\n",
"2 1\n",
"4 1\n",
"1 3\n",
"1 2\n",
"2 1\n1 1\n",
"3 1\n1 1\n",
"2 1\n1 2\n",
"2 2\n"
] |
CodeContests | There is a game called Sim Forest 2013. In this game, the player can become a forest god and raise forest animals.
Animals hatch from eggs and breed. When certain conditions are met, eggs are mutated with a certain probability to give birth to new races of animals.
There is an animal encyclopedia in this game, and wh... | stdin | null | 1,544 | 1 | [
"1 1 3 All All 1 1\n2 37 5 All Night 150 1\n16 2 20 All Day 5 10\n1 14 15 Mon All 20000 100\n0 0 0 None None 0 0\n"
] | [
"1.0000000000\n0.2192439716\n0.9884707850\n0.0649933899\n"
] | [
"1 1 3 All All 1 1\n2 37 2 All Night 150 1\n16 2 20 All Day 5 10\n1 14 15 Mon All 20000 100\n0 0 0 None None 0 0\n",
"1 1 3 Alm All 1 1\n3 37 2 All Night 150 1\n18 2 19 All Day 5 10\n1 14 15 Mno All 23674 100\n0 0 0 None None 0 0\n",
"2 1 3 Alm All 1 1\n3 37 2 All Nifht 150 1\n18 2 19 All Eay 5 10\n1 14 22 Nnn ... | [
"1.000000000\n0.219243972\n0.988470785\n0.064993390\n",
"1.000000000\n0.219243972\n0.988470785\n0.055190860\n",
"1.000000000\n0.219243972\n0.988470785\n0.038279089\n",
"1.000000000\n0.136842187\n0.988470785\n0.064993390\n",
"1.000000000\n0.279464375\n0.988470785\n0.064993390\n",
"1.000000000\n0.219243972\... |
CodeContests | Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality:
a + b + c + d = n
For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
Input
... | stdin | null | 3,319 | 1 | [
"35\n1\n"
] | [
"4\n4\n"
] | [
"35\n2\n",
"35\n3\n",
"35\n4\n",
"35\n8\n",
"35\n15\n",
"35\n26\n",
"35\n0\n",
"35\n-1\n",
"35\n13\n",
"35\n6\n"
] | [
"4\n10\n",
"4\n20\n",
"4\n35\n",
"4\n165\n",
"4\n592\n",
"4\n282\n",
"4\n1\n",
"4\n0\n",
"4\n480\n",
"4\n84\n"
] |
CodeContests | Panda has become a scientist recently. In his laboratory, there are infinite number of chambers where a chamber number K is connected to a chamber number K-1.
The numbering of chambers start from 0. Initially, X number of particles are present in the chamber number 0. The number of particles present in chamber K is ... | stdin | null | 1,960 | 1 | [
"2\n1 3\n2 1\n\nSAMPLE\n"
] | [
"3\n2\n"
] | [
"2\n1 3\n2 1\n\nSAMPLD\n",
"2\n2 3\n2 1\n\nSAMPLD\n",
"2\n2 3\n2 0\n\nRAPMEL\n",
"2\n4 3\n2 0\n\nKEMPAR\n",
"2\n4 1\n0 0\n\nRAPMEK\n",
"2\n4 0\n0 0\n\nSAPMEK\n",
"2\n1 3\n4 1\n\nSAMPLD\n",
"2\n2 5\n2 1\n\nSAMPLD\n",
"2\n2 3\n0 1\n\nRAPMEL\n",
"2\n0 3\n2 0\n\nRAPMEK\n"
] | [
"3\n2\n",
"6\n2\n",
"6\n0\n",
"72\n0\n",
"24\n0\n",
"0\n0\n",
"3\n24\n",
"10\n2\n",
"6\n1\n",
"3\n0\n"
] |
CodeContests | You are a judge of a programming contest. You are preparing a dataset for a graph problem to seek for the cost of the minimum cost path. You've generated some random cases, but they are not interesting. You want to produce a dataset whose answer is a desired value such as the number representing this year 2010. So you ... | stdin | null | 1,539 | 1 | [
"3 3 3\n1 2 3\n2 3 3\n1 3 8\n12 12 2010\n1 2 0\n2 3 3000\n3 4 0\n4 5 3000\n5 6 3000\n6 12 2010\n2 7 100\n7 8 200\n8 9 300\n9 10 400\n10 11 500\n11 6 512\n10 18 1\n1 2 9\n1 3 2\n1 4 6\n2 5 0\n2 6 10\n2 7 2\n3 5 10\n3 6 3\n3 7 10\n4 7 6\n5 8 10\n6 8 2\n6 9 11\n7 9 3\n8 9 9\n8 10 8\n9 10 1\n8 2 1\n0 0 0\n"
] | [
"1\n2\n3\n"
] | [
"3 3 3\n1 2 3\n2 3 3\n1 3 8\n12 12 2010\n1 2 0\n2 3 3000\n3 4 0\n4 5 3000\n5 6 3000\n6 12 2010\n2 7 100\n7 8 200\n8 9 300\n9 10 400\n10 11 500\n11 6 512\n10 18 1\n1 2 7\n1 3 2\n1 4 6\n2 5 0\n2 6 10\n2 7 2\n3 5 10\n3 6 3\n3 7 10\n4 7 6\n5 8 10\n6 8 2\n6 9 11\n7 9 3\n8 9 9\n8 10 8\n9 10 1\n8 2 1\n0 0 0\n",
"3 3 3\n... | [
"1\n2\n3\n",
"1\n2\n2\n",
"1\n1\n2\n",
"1\n3\n2\n",
"1\n1\n3\n",
"1\n3\n3\n",
"1\n2\n1\n",
"1\n4\n2\n",
"1\n3\n1\n",
"1\n1\n1\n"
] |
CodeContests | H: Mercy
Santa Claus found a group doing programming even though it was Christmas.
Santa Claus felt sorry for them, so he decided to give them a cake.
There are $ N $ types of cream, and the taste is $ A_1, A_2, A_3, \ dots, A_N $.
There are $ M $ types of sponges, and the taste is $ B_1, B_2, B_3, \ dots, B_M $.
... | stdin | null | 1,946 | 1 | [
"3 2\n3 1 5\n2 4\n"
] | [
"54\n"
] | [
"3 2\n3 1 5\n2 5\n",
"3 2\n2 1 5\n2 5\n",
"3 2\n2 1 3\n2 5\n",
"3 2\n2 2 3\n2 5\n",
"3 1\n2 4 3\n2 5\n",
"3 2\n2 4 3\n2 4\n",
"3 2\n1 4 3\n2 4\n",
"3 2\n1 4 3\n4 5\n",
"3 2\n0 4 3\n4 1\n",
"3 1\n0 4 3\n4 1\n"
] | [
"63\n",
"56\n",
"42\n",
"49\n",
"18\n",
"54\n",
"48\n",
"72\n",
"35\n",
"28\n"
] |
CodeContests | Panda has started learning about subsets. His professor gave him a simple task. Given a list of numbers, Panda has to choose the subset which gives the maximum product. However, the professor asked Panda only to submit the maximum product obtained by taking exactly two numbers from the list. Please help Panda in findi... | stdin | null | 722 | 1 | [
"2\n2 3\n\nSAMPLE\n"
] | [
"6\n"
] | [
"2\n2 3\n\nTAMPLE\n",
"2\n2 6\n\nTAMPEL\n",
"2\n2 2\n\nTAMPEL\n",
"2\n0 2\n\nTAMPDL\n",
"2\n1 2\n\nTAMPDL\n",
"2\n1 3\n\nTAMPDL\n",
"2\n3 3\n\nLEQMAT\n",
"2\n2 4\n\nDLPMAT\n",
"2\n6 3\n\nMAPSEL\n",
"2\n1 24\n\nTBNPDL\n"
] | [
"6\n",
"12\n",
"4\n",
"0\n",
"2\n",
"3\n",
"9\n",
"8\n",
"18\n",
"24\n"
] |
CodeContests | How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? The knights have to be placed on different squares. A knight can move two squares horizontally and one square vertically, or two squares vertically and one square horizontally. The knights attack ... | stdin | null | 1,871 | 1 | [
"3\n2 2\n2 3\n4 5\n"
] | [
"12\n26\n312\n"
] | [
"3\n2 2\n2 3\n2 5\n",
"3\n2 2\n2 1\n4 5\n",
"3\n4 2\n2 3\n2 5\n",
"3\n4 2\n2 6\n2 5\n",
"3\n2 2\n2 3\n5 5\n",
"3\n2 2\n2 3\n2 6\n",
"3\n2 2\n2 1\n4 6\n",
"3\n8 2\n2 3\n2 5\n",
"3\n2 2\n2 6\n2 5\n",
"3\n1 2\n2 3\n5 5\n"
] | [
"12\n26\n78\n",
"12\n2\n312\n",
"48\n26\n78\n",
"48\n116\n78\n",
"12\n26\n504\n",
"12\n26\n116\n",
"12\n2\n464\n",
"216\n26\n78\n",
"12\n116\n78\n",
"2\n26\n504\n"
] |
CodeContests | Takahashi has an N \times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j). Particularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N).
An integer, 0 or 1, is written on M of the squares in the Takahashi's grid. Three integers a_i,b_i and c_i desc... | stdin | null | 3,156 | 1 | [
"100000 0\n",
"4 8\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1\n",
"4 5\n1 3 1\n2 4 0\n2 3 1\n4 2 1\n4 4 1\n",
"3 5\n1 3 1\n3 3 0\n3 1 0\n2 3 1\n3 2 1\n",
"3 3\n1 1 1\n3 1 0\n2 3 1\n"
] | [
"342016343\n",
"4\n",
"32\n",
"0\n",
"8\n"
] | [
"4 5\n1 3 0\n2 4 0\n2 3 1\n4 2 1\n4 4 1\n",
"2 1\n1 1 1\n3 1 0\n2 3 1\n",
"2 0\n1 1 0\n3 1 0\n2 3 1\n",
"4 0\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1\n",
"3 0\n1 1 1\n5 1 0\n2 6 2\n",
"4 1\n1 1 1\n2 2 0\n0 2 1\n1 4 0\n2 1 0\n1 3 0\n5 4 1\n4 8 1\n",
"3 2\n1 1 1\n2 2 0\n0 2 1\n0 4 1\n2 1 0\... | [
"32\n",
"4\n",
"8\n",
"1024\n",
"64\n",
"512\n",
"16\n",
"838860732\n",
"419430366\n",
"2097152\n"
] |
CodeContests | problem
JOI Shoji manages the time spent at work by employees with a time card. When an employee arrives at the office, he / she uses a dedicated device to stamp the arrival time on the time card. When leaving the office after work, the time of leaving the office is stamped on the time card. The time is handled in a 2... | stdin | null | 4,672 | 1 | [
"9 0 0 18 0 0\n9 0 1 18 0 0\n12 14 52 12 15 30\n",
"None\n"
] | [
"9 0 0\n8 59 59\n0 0 38\n",
"None\n"
] | [
"9 0 0 18 0 0\n9 0 1 18 0 0\n9 14 52 12 15 30\n",
"enoN\n",
"9 0 0 0 0 0\n9 0 1 18 0 0\n9 14 52 12 15 30\n",
"9 0 0 0 0 0\n9 0 1 18 0 0\n8 14 52 12 15 30\n",
"9 0 0 0 0 0\n9 0 1 18 0 0\n8 14 86 12 15 30\n",
"9 0 0 0 0 0\n9 0 1 18 0 0\n8 14 86 10 15 30\n",
"9 0 0 0 0 0\n9 0 0 18 0 0\n8 14 86 10 15 30\n",... | [
"9 0 0\n8 59 59\n3 0 38\n",
"0 0 0\n0 0 0\n0 0 0\n",
"-9 0 0\n8 59 59\n3 0 38\n",
"-9 0 0\n8 59 59\n4 0 38\n",
"-9 0 0\n8 59 59\n4 0 4\n",
"-9 0 0\n8 59 59\n2 0 4\n",
"-9 0 0\n9 0 0\n2 0 4\n",
"-9 0 0\n24 0 0\n2 0 4\n",
"-9 0 0\n24 0 0\n1 59 20\n",
"-8 0 0\n24 0 0\n1 59 20\n"
] |
CodeContests | Making Lunch Boxes
Taro has been hooked on making lunch boxes recently. Taro has obtained a new lunch box recipe book today, and wants to try as many of the recipes listed in the book as possible.
Enough of the ingredients for all the recipes are at hand, but they all are in vacuum packs of two. If only one of them i... | stdin | null | 1,337 | 1 | [
"4 3\n110\n101\n011\n110\n7 1\n1\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n00100\n00010\n6 6\n111111\n011000\n100000\n000010\n100001\n100100\n0 0\n"
] | [
"3\n6\n0\n6\n"
] | [
"4 3\n110\n101\n011\n110\n7 1\n0\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n00100\n00010\n6 6\n111111\n011000\n100000\n000010\n100001\n100100\n0 0\n",
"4 3\n110\n101\n011\n110\n7 1\n0\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n00100\n00010\n6 6\n111111\n011000\n100000\n000011\n100001\n100100\n0 0\n",
"4 3\n110\n111\n011\... | [
"3\n7\n0\n6\n",
"3\n7\n0\n4\n",
"2\n7\n0\n4\n",
"3\n7\n0\n2\n",
"3\n6\n0\n2\n",
"2\n7\n0\n6\n",
"2\n7\n1\n6\n",
"2\n7\n0\n0\n",
"2\n6\n0\n0\n",
"3\n6\n0\n6\n"
] |
CodeContests | In cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, 'a' would be replaced by 'b', 'b' would... | stdin | null | 1,291 | 1 | [
"xlmw mw xli tmgxyvi xlex m xsso mr xli xvmt.\n"
] | [
"this is the picture that i took in the trip.\n"
] | [
"xlmw mw xli tmgxyvi xlex m xsso mr ilx xvmt.\n",
"xlmw mw xli tmgxyvi xlex m ossx mr ilx xvmt.\n",
"xlmw mw xli tmgxyvi xlex m ossx mr ilx xwmt.\n",
"xlmw mw xli tmgxyvi xlex m orsx mr ilx xwmt.\n",
"xlmw mw xli tmgxyvi xlex l orsx mr ilx xwmt.\n",
"wmlx mw xli tmgxyvi xlex l orsx mr ilx xwmt.\n",
"wml... | [
"this is the picture that i took in eht trip.\n",
"this is the picture that i koot in eht trip.\n",
"this is the picture that i koot in eht tsip.\n",
"this is the picture that i knot in eht tsip.\n",
"this is the picture that h knot in eht tsip.\n",
"siht is the picture that h knot in eht tsip.\n",
"sih... |
CodeContests | Alternate Escape
Alice House
Alice and Bob are playing board games. This board game is played using a board with squares in rows H and columns and one frame. In this game, the upper left square of the board is set as the 1st row and 1st column, and the rows are counted downward and the columns are counted to the righ... | stdin | null | 4,681 | 1 | [
"3 3 2 2\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n3 3 2 2\n 1 0 1\n1 0 1 1\n 1 0 0\n0 0 0 0\n 0 0 1\n1 1 0 1\n 1 0 1\n1 3 1 1\n 1 1 1\n1 0 0 1\n 1 0 1\n2 2 1 1\n 1 0\n1 0 0\n 0 0\n0 0 0\n 0 0\n0 0 0 0\n"
] | [
"Yes\nNo\nYes\nNo\n"
] | [
"3 3 2 3\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n3 3 2 2\n 1 0 1\n1 0 1 1\n 1 0 0\n0 0 0 0\n 0 0 1\n1 1 0 1\n 1 0 1\n1 3 1 1\n 1 1 1\n1 0 0 1\n 1 0 1\n2 2 1 1\n 1 0\n1 0 0\n 0 0\n0 0 0\n 0 0\n0 0 0 0\n",
"3 3 2 2\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n3 3 2 1\n 1 0 1\n1 0 ... | [
"Yes\nNo\nYes\nNo\n",
"Yes\nYes\nYes\nNo\n",
"Yes\nNo\nYes\nYes\n",
"Yes\nYes\nNo\nNo\n",
"Yes\nNo\nNo\nNo\n",
"Yes\nNo\nNo\nYes\n",
"Yes\n",
"Yes\nYes\nNo\nYes\n",
"Yes\nNo\nYes\nNo\n",
"Yes\nNo\nYes\nNo\n"
] |
CodeContests | Given the string S and m queries. The i-th query is given by the two strings xi and yi.
For each query, answer the longest substring of the string S, starting with xi and ending with yi.
For the string S, | S | represents the length of S. Also, the fact that the character string T is a substring of the character stri... | stdin | null | 350 | 1 | [
"howistheprogress\n4\nist prog\ns ss\nhow is\nthe progress\n",
"abracadabra\n5\nab a\na a\nb c\nac ca\nz z\n",
"icpcsummertraining\n9\nmm m\nicpc summer\ntrain ing\nsummer mm\ni c\ni i\ng g\ntrain i\nsummer er\n"
] | [
"9\n12\n5\n11\n",
"11\n11\n4\n3\n0\n",
"2\n10\n8\n0\n4\n16\n1\n6\n6\n"
] | [
"howistheprogress\n4\nist prog\ns ss\nhow is\nteh progress\n",
"abracadabsa\n5\nab a\na a\nb c\nac ca\nz z\n",
"icpcsummertraining\n9\nmm m\nicpc summer\ntrain ing\nsummer mm\ni c\ni i\ng f\ntrain i\nsummer er\n",
"howistheprogress\n4\nist prog\ns ss\nohw is\nteh progress\n",
"abracadabsa\n5\nab a\na b\nb c... | [
"9\n12\n5\n0\n",
"11\n11\n4\n3\n0\n",
"2\n10\n8\n0\n4\n16\n0\n6\n6\n",
"9\n12\n0\n0\n",
"11\n9\n4\n3\n0\n",
"9\n2\n0\n0\n",
"11\n5\n4\n3\n0\n",
"11\n10\n8\n0\n4\n16\n0\n6\n6\n",
"11\n5\n5\n3\n0\n",
"11\n10\n0\n0\n4\n16\n0\n6\n6\n"
] |
CodeContests | problem
You are a traveler traveling on the JOI Highway. The JOI Highway is a road that extends straight from east to west, and there are n post towns on the JOI Highway. Numbered. The westernmost post town on the JOI highway is post town 1, and the easternmost post town is post town n.
You have decided to depart fro... | stdin | null | 3,049 | 1 | [
"7 5\n2\n1\n1\n3\n2\n1\n2\n-1\n3\n2\n-3\n"
] | [
"18\n"
] | [
"7 5\n2\n1\n2\n3\n2\n1\n2\n-1\n3\n2\n-3\n",
"7 5\n2\n0\n2\n3\n2\n1\n2\n-1\n3\n2\n-3\n",
"7 5\n2\n1\n1\n3\n2\n1\n2\n-1\n1\n2\n-3\n",
"7 5\n2\n1\n1\n0\n2\n1\n2\n-1\n1\n2\n-3\n",
"7 5\n2\n1\n2\n3\n0\n1\n2\n-1\n3\n2\n-1\n",
"7 5\n1\n0\n2\n3\n2\n1\n2\n-1\n3\n1\n-3\n",
"7 5\n2\n0\n1\n0\n2\n1\n2\n-1\n1\n2\n-3\... | [
"19\n",
"16\n",
"14\n",
"8\n",
"12\n",
"15\n",
"4\n",
"13\n",
"9\n",
"10\n"
] |
CodeContests | You are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.
Write a program which prints:
* "2" if $B$ is in $A$,
* "-2" if $A$ is in $B$,
* "1" if circumference of $A$ and $B$ intersect, and
* "0" if $A$ and $B$ do not... | stdin | null | 4,864 | 1 | [
"2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0\n"
] | [
"2\n0\n"
] | [
"2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622\n",
"2\n0.0 0.0 5.0 0.0 1.5542884595470625 4.0\n0.0 0.0 2.0 4.1 0.0 2.4515674947137622\n",
"2\n3.1147350602004042 10.32674830176415 10.748453312336865 4.001069425760041 6.490549081480047 6.328774266228958\n7.521092820860991 2.963851942354593 7.... | [
"2\n1\n",
"1\n1\n",
"2\n2\n",
"1\n2\n",
"2\n1\n",
"1\n1\n",
"1\n1\n",
"1\n1\n",
"1\n1\n",
"1\n1\n"
] |
CodeContests | You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.
You can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.
You planned to make an apple pie using all of the apples, ... | stdin | null | 1,284 | 1 | [
"5 2\n",
"30 -50\n",
"3 -1\n"
] | [
"18\n",
"-1044\n",
"0\n"
] | [
"5 4\n",
"13 -50\n",
"3 -2\n",
"5 7\n",
"16 -50\n",
"5 -2\n",
"5 9\n",
"23 -50\n",
"4 -2\n",
"8 9\n"
] | [
"26\n",
"-534\n",
"-3\n",
"38\n",
"-645\n",
"0\n",
"46\n",
"-869\n",
"-2\n",
"91\n"
] |
CodeContests | Seeing the fame received by the Fibonacci numbers, the other Natural Numbers were feeling jealous. Therefore, to give them their shot at glory Mr. Non-Fibo now wants you to tell him the N^th- Non Fibonacci Number.
Input:
First line contains T which is the number of test cases.
T lines follow each with an integer N.
O... | stdin | null | 2,393 | 1 | [
"3\n1\n2\n3\n\nSAMPLE\n"
] | [
"4\n6\n7\n"
] | [
"3\n2\n2\n3\n\nSAMPLE\n",
"3\n1\n2\n3\n\nELPMAS\n",
"3\n2\n4\n3\n\nSAMPLE\n",
"3\n2\n2\n1\n\nEMPM@S\n",
"3\n1\n2\n5\n\nELPMAS\n",
"3\n4\n4\n3\n\nSAMPLE\n",
"3\n1\n1\n5\n\nELPMAS\n",
"3\n8\n4\n3\n\nSAMPLE\n",
"3\n8\n6\n3\n\nSAMPME\n",
"3\n8\n6\n6\n\nSAMPME\n"
] | [
"6\n6\n7\n",
"4\n6\n7\n",
"6\n9\n7\n",
"6\n6\n4\n",
"4\n6\n10\n",
"9\n9\n7\n",
"4\n4\n10\n",
"14\n9\n7\n",
"14\n11\n7\n",
"14\n11\n11\n"
] |
CodeContests | Scores of Final Examination
I am a junior high school teacher. The final examination has just finished, and I have all the students' scores of all the subjects. I want to know the highest total score among the students, but it is not an easy task as the student scores are listed separately for each subject. I would li... | stdin | null | 781 | 1 | [
"5 2\n10 20 30 40 50\n15 25 35 45 55\n6 3\n10 20 30 15 25 35\n21 34 11 52 20 18\n31 15 42 10 21 19\n4 2\n0 0 0 0\n0 0 0 0\n0 0\n"
] | [
"105\n83\n0\n"
] | [
"5 2\n10 20 30 40 50\n15 25 35 45 55\n6 3\n10 20 30 15 25 35\n21 34 11 52 20 0\n31 15 42 10 21 19\n4 2\n0 0 0 0\n0 0 0 0\n0 0\n",
"5 2\n10 20 30 40 50\n15 25 35 85 55\n6 3\n10 20 30 15 25 35\n21 34 11 52 20 0\n31 15 42 10 21 10\n4 2\n0 0 0 0\n0 0 0 0\n0 0\n",
"5 2\n10 20 30 40 50\n15 25 35 85 55\n6 3\n10 20 30 ... | [
"105\n83\n0\n",
"125\n83\n0\n",
"125\n77\n0\n",
"125\n69\n0\n",
"159\n83\n0\n",
"105\n75\n0\n",
"105\n80\n0\n",
"105\n77\n0\n",
"159\n83\n1\n",
"125\n64\n0\n"
] |
CodeContests | There are many caves deep in mountains found in the countryside. In legend, each cave has a treasure hidden within the farthest room from the cave's entrance. The Shogun has ordered his Samurais to explore these caves with Karakuri dolls (robots) and to find all treasures. These robots move in the caves and log relativ... | stdin | null | 3,283 | 1 | [
"3\n1 0\n0 1\n-1 0\n1 0\n0 5\n-1 0\n0 -1\n5 0\n0 1\n0 -1\n1 0\n0 -4\n-3 0\n0 3\n2 0\n0 -2\n-1 0\n0 1\n0 -1\n1 0\n0 2\n-2 0\n0 -3\n3 0\n0 4\n-4 0\n0 -5\n-2 0\n0 0\n1 0\n-1 0\n0 0\n2 0\n0 1\n-1 0\n0 1\n-1 0\n0 -2\n0 0\n"
] | [
"6 5\n1 0\n2 1\n"
] | [
"3\n1 0\n0 1\n-1 0\n1 0\n0 5\n-1 0\n0 -1\n5 0\n0 1\n0 -1\n1 0\n0 -4\n-3 0\n0 3\n0 0\n0 -2\n-1 0\n0 1\n0 -1\n1 0\n0 2\n-2 0\n0 -3\n3 0\n0 4\n-4 0\n0 -5\n-2 0\n0 0\n1 0\n-1 0\n0 0\n2 0\n0 1\n-1 0\n0 1\n-1 0\n0 -2\n0 0\n",
"3\n1 0\n0 1\n-1 0\n1 0\n0 5\n-1 0\n0 -1\n5 0\n0 1\n0 -1\n1 0\n0 -4\n-3 0\n0 3\n0 0\n0 -2\n-1 ... | [
"6 5\n-5 -4\n1 0\n",
"6 5\n-5 -5\n1 0\n",
"6 5\n1 0\n2 1\n",
"1 1\n6 4\n-5 -5\n",
"6 5\n-2 0\n2 1\n",
"1 1\n6 3\n-5 -5\n",
"5 6\n-2 0\n2 1\n",
"1 6\n6 -5\n-5 -5\n",
"1 1\n6 4\n-4 -5\n",
"7 5\n1 0\n2 1\n"
] |
CodeContests | Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.
Constraints
* 0 < a, b ≤ 2,000,000,000
* LCM(a, b) ≤ 2,000,000,000
* The number of data sets ≤ 50
Input
Input consists of several data sets. Each data set contains a and b separated by a single spa... | stdin | null | 4,156 | 1 | [
"8 6\n50000000 30000000\n"
] | [
"2 24\n10000000 150000000\n"
] | [
"8 6\n50000000 24597532\n",
"8 6\n88904261 24597532\n",
"14 6\n88904261 24597532\n",
"14 6\n88904261 49076254\n",
"14 4\n88904261 49076254\n",
"8 6\n50000000 25142724\n",
"8 6\n50000000 42267576\n",
"8 6\n162089565 24597532\n",
"14 4\n88904261 24597532\n",
"14 8\n88904261 49076254\n"
] | [
"2 24\n4 307469150000000\n",
"2 24\n1 2186825404883852\n",
"2 42\n1 2186825404883852\n",
"2 42\n1 4363088094518294\n",
"2 28\n1 4363088094518294\n",
"2 24\n4 314284050000000\n",
"2 24\n8 264172350000000\n",
"2 24\n1 3987003261953580\n",
"2 28\n1 2186825404883852\n",
"2 56\n1 4363088094518294\n"
] |
CodeContests | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:
* 1 \leq x,y,z
* x^2 + y^2 + z^2 + xy + yz + zx = n
Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
Constraints
* All values in input are integers.
* 1 \leq N \leq 10^4
Input
Input is given from Sta... | stdin | null | 3,871 | 1 | [
"20\n"
] | [
"0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n"
] | [
"27\n",
"13\n",
"3\n",
"2\n",
"4\n",
"8\n",
"14\n",
"1\n",
"31\n",
"53\n"
] | [
"0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n3\n0\n0\n0\n0\n0\n1\n6\n0\n3\n",
"0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n",
"0\n0\n0\n",
"0\n0\n",
"0\n0\n0\n0\n",
"0\n0\n0\n0\n0\n1\n0\n0\n",
"0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n",
"0\n",
"0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n3\n0\n0\n0\n0\n0\n3\n... |
CodeContests | The rabbit, who successfully defeated the ambushed enemy, succeeded in advancing the hero into the enemy's castle. When the hero released the cats trapped in the castle dungeon, some of them were the hero's. It will help me.
According to the cats, to reach the Demon King in the back of the castle, you will have to go ... | stdin | null | 1,863 | 1 | [
"2 3\n0.900 0.500 0.100\n0.500 0.500 0.500\n"
] | [
"0.372500000000\n"
] | [
"2 3\n0.900 0.500 0.100\n0.500 0.500 0.6797862263528347\n",
"2 3\n0.900 0.500 0.15231283420683542\n0.500 0.500 0.6797862263528347\n",
"2 3\n0.900 0.500 0.15231283420683542\n0.500 1.0377402291803903 0.6797862263528347\n",
"2 3\n0.900 0.500 0.15231283420683542\n0.500 1.0377402291803903 1.0050742674151911\n",
... | [
"0.490259978261\n",
"0.497798058784\n",
"0.680572259361\n",
"0.973438626419\n",
"1.181702127269\n",
"0.953536984148\n",
"1.151526850866\n",
"1.151209398754\n",
"0.000000000000\n",
"0.372500000000\n"
] |
CodeContests | Tapan and Divya have a rectangular shaped chocolate bar with chocolates labeled T, D and U. They want to split the bar into exactly two pieces such that:
Tapan's piece can not contain any chocolate labeled D and similarly, Divya's piece can not contain any chocolate labeled T. All chocolates in each piece must be conn... | stdin | null | 361 | 1 | [
"2 2 4\nUU\nUU\n\nSAMPLE\n"
] | [
"12\n"
] | [
"4 8 13\nUUUUUUUU\nDDDUDDDD\nUUUUUUUU\nUUUUUUUU\n",
"2 2 1\nUU\nUU\n\nSAMPLE\n",
"2 1 1\nUU\nUU\n\nSAMPLE\n",
"1 1 2\nUU\nUU\n\nSPMALE\n",
"3 16 2\nUVUVUUUU\nDDDUDDDD\nUUUUTUUU\nUUUUUUUT\n",
"1 11 1\nUVUVUUUU\nDCDUDDDD\nVUUUTUUT\nTUUUUUUU\n",
"1 20 1\nUVUVUUUU\nDCDUDDDD\nVUUUTUUT\nTUUUUUUU\n",
"4 2 1\... | [
"4\n",
"12\n",
"2\n",
"1\n",
"3\n",
"21\n",
"39\n",
"56\n",
"0\n",
"59\n"
] |
CodeContests | Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
Circle inside a rectangle
Cons... | stdin | null | 4,564 | 1 | [
"5 4 2 2 1\n",
"5 4 2 4 1\n"
] | [
"Yes\n",
"No\n"
] | [
"2 4 2 2 1\n",
"2 8 2 0 0\n",
"5 4 2 0 1\n",
"2 4 2 2 2\n",
"5 8 2 0 1\n",
"2 6 2 2 2\n",
"2 8 2 0 1\n",
"3 6 2 2 2\n",
"0 6 2 2 2\n",
"2 8 1 0 0\n"
] | [
"No\n",
"Yes\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"No\n",
"Yes\n"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.