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
Problem Nanatsu has x Umaka sticks and y puffs. There are n candy exchangers. Each exchanger i * Nanatsu-kun's Umaka stick ai book and exchanger's Fugashi bi book * Nanatsu-kun's Fugashi ci book and exchanger's pig meso di pieces It will be exchanged only once by either one of the methods. Under this constraint,...
stdin
null
3,568
1
[ "4\n5 0\n5 1 1 1\n2 1 2 1\n4 1 1 1\n3 1 3 1\n", "3\n3 3\n3 2 4 1\n5 1 2 1\n3 1 3 2\n", "3\n3 4\n3 1 3 1\n3 1 4 1\n3 1 2 1\n", "4\n0 0\n1 10 1 10\n2 5 2 5\n3 25 5 6\n1 15 2 20\n" ]
[ "2\n", "3\n", "2\n", "0\n" ]
[ "4\n10 0\n5 1 1 1\n2 1 2 1\n4 1 1 1\n3 1 3 1\n", "3\n3 4\n3 2 4 1\n5 1 2 1\n3 1 3 2\n", "3\n3 4\n3 1 3 1\n3 1 4 1\n3 1 3 1\n", "4\n0 0\n1 10 1 10\n2 5 2 5\n3 25 0 6\n1 15 2 20\n", "4\n0 1\n1 10 1 10\n2 5 4 5\n2 25 0 6\n1 24 2 20\n", "3\n3 5\n2 0 8 1\n5 0 2 -1\n3 2 3 0\n", "3\n3 6\n1 0 6 2\n2 2 0 1\n3 2 ...
[ "2\n", "3\n", "1\n", "6\n", "16\n", "0\n", "5\n", "7\n", "4\n", "11\n" ]
CodeContests
Little Jhool is an addict. No, unlike the usual drug addicts, he's an addict of the good kind: the shopping addict. Some of his friends also call him a shopaholic, though he tries his level best to deny the title given to him by his friends. Now, he has some favorite websites as we already have seen in another question...
stdin
null
1,039
1
[ "3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 0\n2 6 4 3\n\nSAMPLE\n" ]
[ "0\nChick magnet Jhool!\n4\nLucky chap!\n1\nNo more girlfriends!\n" ]
[ "3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 0\n2 6 4 5\n\nSAMPLE\n", "3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 1\n2 6 4 5\n\nSAMPLE\n", "3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 1\n2 3 4 5\n\nSAMPLE\n", "3\n2 1\n4 2\n6 4\n1 6 6 7 1 8\n4 0\n2 6 4 6\n\nSAMPLE\n", "3\n2 1\n4 2\n6 4\n1 6 6 7 2 8\n4 1\n2 6 4 5\n\nSAMPLE\n", "3\n2 1\n4 ...
[ "0\nChick magnet Jhool!\n4\nLucky chap!\n1\nNo more girlfriends!\n", "0\nChick magnet Jhool!\n4\nLucky chap!\n1\nLucky chap!\n", "0\nChick magnet Jhool!\n4\nLucky chap!\n0\nChick magnet Jhool!\n", "0\nChick magnet Jhool!\n4\nLucky chap!\n2\nNo more girlfriends!\n", "0\nChick magnet Jhool!\n3\nChick magnet J...
CodeContests
Yes, you read it right - Little Jhool is back, but no, he's not over his break up, still. And he's sad, broken and depressed; thus, he decided to visit a psychologist. She tells him to think about his pleasant memories of childhood, and stay busy so as to not miss his ex-girlfriend. She asks him about his favorite mem...
stdin
null
211
1
[ "2\n23\n32\n\nSAMPLE\n" ]
[ "-1\n3\n" ]
[ "2\n23\n48\n\nSAMPLE\n", "2\n23\n58\n\nELPMAS\n", "2\n35\n102\n\nELPMAR\n", "2\n35\n96\n\nPMEMAR\n", "2\n58\n96\n\nPMEMAR\n", "2\n26\n8\n\nPMEMAR\n", "2\n56\n8\n\nPMEMAR\n", "2\n106\n96\n\nPMEMAR\n", "2\n35\n22\n\nMARPLE\n", "2\n48\n8\n\nPMAMER\n" ]
[ "-1\n4\n", "-1\n5\n", "-1\n9\n", "-1\n8\n", "5\n8\n", "-1\n-1\n", "5\n-1\n", "9\n8\n", "-1\n2\n", "4\n-1\n" ]
CodeContests
Compare given two sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$ and $B = \\{b_0, b_1, ..., b_{m-1}$ lexicographically. Constraints * $1 \leq n, m \leq 1,000$ * $0 \leq a_i, b_i \leq 1,000$ Input The input is given in the following format. $n$ $a_0 \; a_1, ..., \; a_{n-1}$ $m$ $b_0 \; b_1, ..., \; b_{m-1}$ The num...
stdin
null
4,803
1
[ "3\n1 1 2\n4\n1 1 2 2\n", "3\n1 2 3\n2\n2 4\n", "4\n5 4 7 0\n5\n1 2 3 4 5\n" ]
[ "1\n", "1\n", "0\n" ]
[ "3\n1 1 2\n4\n1 2 2 2\n", "4\n1 4 3 1\n4\n0 4 5 4 2\n", "3\n1 4 3\n2\n2 4\n", "4\n0 4 7 0\n5\n1 2 3 4 5\n", "3\n1 1 2\n4\n1 3 2 2\n", "3\n1 4 3\n2\n2 2\n", "4\n0 4 7 0\n5\n1 2 3 4 1\n", "3\n1 1 2\n4\n1 3 3 2\n", "3\n1 4 3\n3\n2 2\n", "4\n0 4 7 0\n5\n1 2 5 4 1\n" ]
[ "1\n", "0\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n" ]
CodeContests
Little Vaishnavi is bored during the vacation which is going on. Being the only little girl in the neighbourhood she did not have any one else to play with. Her parents are so strict that they will not let her out of the house even to see what the kids from the other houses are playing. So she decided to make a game o...
stdin
null
1,314
1
[ "2\n2 3\n1 0\n\nSAMPLE\n" ]
[ "15\n0\n" ]
[ "2\n3 3\n1 0\n\nSAMPLE\n", "2\n3 3\n1 1\n\nSAMPLE\n", "2\n3 0\n1 1\n\nSAMPLE\n", "2\n5 0\n1 1\n\nSAMPLE\n", "2\n5 0\n1 2\n\nSAMPLE\n", "2\n5 0\n2 1\n\nSMAPLE\n", "2\n5 -1\n2 1\n\nSMAPLE\n", "2\n5 -1\n1 1\n\nSMAPLE\n", "2\n2 -1\n1 1\n\nSMAPLE\n", "2\n2 -2\n1 1\n\nSMAPLE\n" ]
[ "14\n0\n", "14\n8\n", "2\n8\n", "4\n8\n", "4\n16\n", "4\n7\n", "-4\n7\n", "-4\n8\n", "-1\n8\n", "-7\n8\n" ]
CodeContests
Akhil gives Ramesh an array A of length N. Then he asks him to determine if there exists an element in the array such that the sum of the elements on its left is equal to the sum of the elements on its right. If there are no elements to the left/right, then the sum is considered to be zero. Formally, find an i, such th...
stdin
null
1,036
1
[ "2\n3\n1 2 3\n4\n1 2 3 3\n\nSAMPLE\n" ]
[ "NO\nYES\n" ]
[ "10\n500\n75 426 445 272 81 447 129 497 202 275 325 482 284 417 156 432 402 228 37 357 239 418 211 179 6 340 68 368 16 440 263 93 449 491 310 355 68 431 80 257 218 434 328 176 355 221 80 422 45 11 67 467 174 191 4 335 34 465 480 221 395 1 152 325 231 302 153 396 22 489 399 107 466 432 2 468 333 475 292 84 10 194 32...
[ "NO\nYES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\n", "NO\nYES\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nYES\n", "NO\nYES\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nYES\n", "NO\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\n", "NO\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nNO\nYES\n", "NO\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nNO\nNO\n", "NO\nYE...
CodeContests
Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times. * Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`. For example, if you perform an operation for the second letter on `aa...
stdin
null
4,115
1
[ "codefestival\n100\n", "xyz\n4\n", "a\n25\n" ]
[ "aaaafeaaivap\n", "aya\n", "z\n" ]
[ "codefestival\n101\n", "xyz\n1\n", "zyx\n1\n", "cdoeffstival\n101\n", "zyx\n2\n", "cdoeffstival\n111\n", "zyx\n3\n", "lavitsffeodc\n111\n", "xyz\n2\n", "caoeffstivdl\n111\n" ]
[ "aaaafeaaiaal\n", "xya\n", "ayx\n", "aaaaffaaiaal\n", "ayy\n", "aaaaafativam\n", "aax\n", "aaaaaaaaeadg\n", "xaz\n", "aaaaaaativdo\n" ]
CodeContests
Sam is dangerous boy. He like to fight with everyone who is more powerful than him. One day, Sam enters in the meeting of all gangsters of the city. He wants to fight with everyone who is more powerful than him. But one man know his motive and tell to all gangsters about Sam. But gangsters don't know whether the Sam i...
stdin
null
482
1
[ "1\n6 5\n1 3 7 2 6 8\n\nSAMPLE\n" ]
[ "NO 0\n" ]
[ "1\n6 5\n1 3 7 3 6 8\n\nSAMPLE\n", "1\n6 5\n1 3 5 3 1 8\n\nSAMPLE\n", "1\n6 5\n0 3 5 3 6 8\n\nSAMPLE\n", "1\n6 0\n1 3 5 3 0 8\n\nSBMPLE\n", "1\n6 2\n1 3 4 4 6 2\n\nSAMPLE\n", "1\n6 5\n1 3 7 3 1 8\n\nSAMPLE\n", "1\n6 5\n1 3 5 3 1 8\n\nSANPLE\n", "1\n6 5\n2 3 5 3 1 8\n\nSANPLE\n", "1\n6 5\n1 3 4 2 6 8...
[ "NO 0\n", "YES 1\n", "YES 2\n", "YES 5\n", "YES 4\n", "NO 0\n", "YES 1\n", "YES 1\n", "NO 0\n", "NO 0\n" ]
CodeContests
3:33 It's possible for all the digits displayed on a digital clock in the hours:minutes format to be identical. The time shown above (3:33) is an example of such a situation. Other examples are 2:2 and 1:11. Note that the digits of 33:33 are identical, but it is not a valid time on a usual digital clock. The above exam...
stdin
null
4,487
1
[ "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 1\n" ]
[ "19\n20\n10\n11\n10\n1\n" ]
[ "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 2\n", "6\n24 60\n34 50\n1 11\n10 12\n11 10\n1 2\n", "6\n24 60\n34 5\n1 11\n10 12\n11 10\n1 2\n", "6\n24 60\n7 50\n10 11\n10 12\n11 11\n1 1\n", "6\n24 60\n34 50\n10 11\n10 12\n13 11\n1 2\n", "6\n24 60\n34 50\n10 11\n9 12\n11 10\n1 2\n", "6\n24 60\n34 50\n1 11\n18 ...
[ "19\n20\n10\n11\n10\n1\n", "19\n20\n1\n11\n10\n1\n", "19\n8\n1\n11\n10\n1\n", "19\n11\n10\n11\n10\n1\n", "19\n20\n10\n11\n11\n1\n", "19\n20\n10\n10\n10\n1\n", "19\n20\n1\n13\n10\n1\n", "19\n8\n1\n11\n11\n1\n", "19\n20\n10\n10\n11\n1\n", "19\n5\n1\n11\n11\n1\n" ]
CodeContests
Bimal decided to join a non Hill'ffair club because he is not interested in cultural activities at all. He thought that joining a technical club would help him in gaining technical prowess. However, on joining the most technical club that he could find, he realised that most of the work in all technical clubs is not te...
stdin
null
2,317
1
[ "2\n3\n121\n10\n1000000008\n\nSAMPLE\n" ]
[ "121\n1\n" ]
[ "2\n2\n121\n10\n1000000008\n\nSAMPLE\n", "2\n2\n58\n5\n1000000008\n\nSAMPLE\n", "2\n2\n77\n9\n1000000008\n\nSAMPLE\n", "2\n2\n32\n9\n1000000008\n\nASMPLE\n", "2\n2\n32\n17\n339931463\n\nASMPLE\n", "2\n3\n55\n17\n339931463\n\nAMSOEL\n", "2\n3\n55\n17\n227602202\n\nAMSOEL\n", "2\n3\n55\n17\n208809286\n\...
[ "121\n1\n", "58\n1\n", "77\n1\n", "32\n1\n", "32\n339931463\n", "55\n339931463\n", "55\n227602202\n", "55\n208809286\n", "106\n208809286\n", "26\n208809286\n" ]
CodeContests
Professor Hatim is researching the sexual behavior of a rare species of lizard. He assumes that they feature two different genders and that they only interact with lizard of the opposite gender. Each lizard has a integer printed on their back. Given the details of lizard interactions, decide whether the experiment sup...
stdin
null
4,064
1
[ "2\n3 3\n1 2\n2 3\n1 3\n4 2\n1 2\n3 4\n\nSAMPLE\n" ]
[ "Suspicious lizards found!\nNo suspicious lizards found!\n" ]
[ "2\n3 3\n2 2\n2 3\n1 3\n4 2\n1 2\n3 4\n\nSAMPLE\n", "2\n3 3\n1 2\n2 3\n1 3\n8 2\n1 2\n3 3\n", "2\n3 3\n1 3\n2 3\n1 3\n8 2\n1 2\n3 3\n", "2\n3 3\n1 3\n2 3\n1 3\n4 2\n1 2\n3 4\n\nSAMPLE\n", "2\n3 3\n1 2\n2 3\n1 3\n8 2\n1 2\n3 4\n", "2\n3 3\n1 2\n2 3\n1 3\n15 2\n1 2\n3 3\n", "2\n3 3\n1 2\n2 3\n1 3\n6 2\n1 ...
[ "Suspicious lizards found!\nNo suspicious lizards found!\n", "Suspicious lizards found!\nSuspicious lizards found!\n", "No suspicious lizards found!\nSuspicious lizards found!\n", "No suspicious lizards found!\nNo suspicious lizards found!\n", "Suspicious lizards found!\nNo suspicious lizards found!\n", "...
CodeContests
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. <image> An example of a trapezoid Find the area of this trapezoid. Constraints * 1≦a≦100 * 1≦b≦100 * 1≦h≦100 * All input values are integers. * h is even. Input The input is given from Standard Input i...
stdin
null
2,407
1
[ "4\n4\n4\n", "3\n4\n2\n" ]
[ "16\n", "7\n" ]
[ "4\n4\n7\n", "3\n6\n2\n", "4\n8\n7\n", "3\n10\n2\n", "4\n8\n6\n", "3\n10\n3\n", "4\n9\n6\n", "3\n12\n2\n", "4\n5\n6\n", "3\n2\n2\n" ]
[ "28\n", "9\n", "42\n", "13\n", "36\n", "19\n", "39\n", "15\n", "27\n", "5\n" ]
CodeContests
Xsquare got bored playing with the arrays all the time. Therefore he has decided to buy a string S consists of N lower case alphabets. Once he purchased the string, He starts formulating his own terminologies over his string S. Xsquare calls a string str A Balanced String if and only if the characters of the string str...
stdin
null
644
1
[ "3\nelle\njason\nimmi SAMPLE\n" ]
[ "1\n-1\n-1\n" ]
[ "10\ngaagpguggxggpxupuaxxuaxxpuaaxuagxpxuauagauggpupapaauaugaugxugppguggxxagpapxpgpaxuugaggaggxaupxauuxpxgpgaappgpgaaaxpgagpxuauxpauaaxxgaxgaupxppxpaupgguxxggauuaxaapaggxaxpauxgapgxpuuagaxgagppuauxpgaxxagxxxgguxgxpguuppuxxxaxaxuugpaapupapgppguggpuauggppupxpgpgxagagxuxaauaxuuxupuppupupuaxpgpxuppgpxugaupppupxpapgagxp...
[ "-1\n-1\n-1\n-1\n1\n-1\n-1\n-1\n-1\n-1\n", "1\n-1\n-1\n", "-1\n-1\n-1\n", "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n", "-1\n-1\n-1\n-1\n1\n-1\n-1\n-1\n-1\n-1\n", "1\n-1\n-1\n", "-1\n-1\n-1\n-1\n1\n-1\n-1\n-1\n-1\n-1\n", "1\n-1\n-1\n", "1\n-1\n-1\n", "1\n-1\n-1\n" ]
CodeContests
The University of Aizu has a park covered with grass, and there are no trees or buildings that block the sunlight. On sunny summer days, sprinklers installed in the park operate to sprinkle water on the lawn. The frog Pyonkichi lives in this park. Pyonkichi is not good at hot weather, and on summer days when the sun is...
stdin
null
935
1
[ "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 9 0\n0 0\n" ]
[ "OK\nNA\n" ]
[ "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 8 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\n0 0\n", "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\n6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 7 7 7 8 6 9 0\n0 0\n", "6 1\n10\n6 4 3 3 1 2 0 5 4 6 1 8 5 9 7 7 8 6 3 3\n6 1\n10\n6 4 3 3 1 2 0 10 4 6 1 8 5 7 7 7 8...
[ "OK\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n", "OK\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n", "OK\nNA\n", "NA\nNA\n" ]
CodeContests
A long time ago in a galaxy, far, far away, there were N spheres with various radii. Spheres were mirrors, that is, they had reflective surfaces . . . . You are standing at the origin of the galaxy (0, 0, 0), and emit a laser ray to the direction (u,v, w). The ray travels in a straight line. When the laser ray from I...
stdin
null
4,121
1
[ "3\n-20 -20 -24\n100 100 100 30\n10 8 3 5\n-70 -70 -84 5\n4\n0 47 84\n-23 41 42 8\n45 -10 14 19\n-5 28 47 12\n-27 68 34 14\n0\n" ]
[ "79.0940 79.0940 94.9128\n-21.8647 54.9770 34.1761\n" ]
[ "3\n-20 -20 -24\n100 100 100 30\n10 8 3 5\n-70 -70 -84 5\n4\n0 47 74\n-23 41 42 8\n45 -10 14 19\n-5 28 47 12\n-27 68 34 14\n0\n", "3\n-20 -20 -24\n100 100 100 30\n10 8 3 5\n-70 -70 -84 5\n4\n0 47 74\n-23 41 42 8\n45 -10 14 19\n-5 9 47 12\n-27 68 34 14\n0\n", "3\n-20 -20 -24\n100 100 100 30\n10 8 3 5\n-70 -70 -8...
[ "79.094013313127 79.094013313127 94.912815975752\n0.000000000000 23.530954636986 37.048737088021\n", "79.094013313127 79.094013313127 94.912815975752\n0.000000000000 0.000000000000 0.000000000000\n", "79.094013313127 79.094013313127 94.912815975752\n-1.141725736754 24.709238203459 36.124127322003\n", "84.4045...
CodeContests
Two players are playing a game. The game is played on a sequence of positive integer pairs. The players make their moves alternatively. During his move the player chooses a pair and decreases the larger integer in the pair by a positive multiple of the smaller integer in the pair in such a way that both integers in the...
stdin
null
83
1
[ "3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n3 5\n" ]
[ "NO\nNO\nYES\n" ]
[ "3\n1\n2 3\n2\n4 5\n5 6\n2\n2 3\n1 5\n", "3\n1\n2 3\n2\n4 5\n5 6\n1\n2 3\n3 5\n", "3\n1\n1 3\n2\n6 5\n5 6\n1\n2 6\n5 5\n", "3\n1\n2 3\n2\n4 5\n5 3\n1\n2 3\n3 5\n", "3\n1\n2 3\n2\n6 2\n5 6\n1\n2 6\n3 5\n", "3\n1\n2 1\n2\n6 5\n5 6\n1\n2 3\n1 5\n", "3\n1\n2 4\n2\n10 5\n5 6\n1\n2 6\n5 0\n", "3\n1\n2 1\n2\...
[ "NO\nNO\nYES\n", "NO\nNO\nNO\n", "YES\nNO\nYES\n", "NO\nYES\nNO\n", "NO\nYES\nYES\n", "YES\nNO\nNO\n", "YES\nYES\nYES\n", "YES\nYES\nNO\n", "NO\nNO\nNO\n", "NO\nNO\nYES\n" ]
CodeContests
The volume of access to a web service varies from time to time in a day. Also, the hours with the highest volume of access varies from service to service. For example, a service popular in the United States may receive more access in the daytime in the United States, while another service popular in Japan may receive m...
stdin
null
347
1
[ "2\n4 0 1 2 3 4\n2 0 2 1\n0\n" ]
[ "5\n" ]
[ "2\n4 0 1 2 3 4\n2 -1 2 1\n0\n", "2\n4 0 1 2 3 4\n2 1 1 1\n0\n", "2\n4 0 2 2 3 8\n2 -1 2 2\n0\n", "2\n4 0 1 1 3 0\n2 1 1 1\n0\n", "2\n4 0 1 2 0 8\n2 0 2 1\n0\n", "2\n4 0 1 2 0 8\n2 1 3 2\n0\n", "2\n4 0 1 2 0 5\n2 1 3 0\n0\n", "2\n4 0 1 2 0 4\n2 1 3 0\n0\n", "2\n4 0 0 2 0 3\n2 2 2 0\n0\n", "2\n4 0 ...
[ "6\n", "5\n", "10\n", "4\n", "9\n", "11\n", "8\n", "7\n", "3\n", "2\n" ]
CodeContests
There are N students and M checkpoints on the xy-plane. The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j). When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance. T...
stdin
null
22
1
[ "3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 5\n", "2 2\n2 0\n0 0\n-1 0\n1 0\n", "5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n" ]
[ "3\n1\n2\n", "2\n1\n", "5\n4\n3\n2\n1\n" ]
[ "3 4\n10 10\n-10 -10\n3 3\n1 2\n2 3\n3 5\n3 10\n", "2 2\n2 0\n0 0\n-1 -1\n1 0\n", "3 4\n10 10\n-10 -10\n3 3\n1 4\n2 3\n3 5\n3 5\n", "2 2\n2 0\n0 -1\n-1 0\n1 0\n", "5 5\n-100000000 -100000000\n-100000000 100000000\n100000000 -100000000\n100000000 100000000\n0 0\n0 0\n100000000 100000000\n100000000 -100000000...
[ "4\n1\n2\n", "2\n2\n", "3\n1\n2\n", "2\n1\n", "5\n4\n3\n2\n1\n", "1\n1\n", "3\n1\n4\n", "1\n1\n1\n", "5\n4\n3\n4\n1\n", "5\n4\n3\n1\n1\n" ]
CodeContests
Deciphering Characters Image data which are left by a mysterious syndicate were discovered. You are requested to analyze the data. The syndicate members used characters invented independently. A binary image corresponds to one character written in black ink on white paper. Although you found many variant images that ...
stdin
null
2,696
1
[ "3 6\n.#..#.\n#.##.#\n.#..#.\n8 7\n.#####.\n#.....#\n#..#..#\n#.#.#.#\n#..#..#\n#..#..#\n.#####.\n...#...\n3 3\n#..\n...\n#..\n3 3\n#..\n.#.\n#..\n3 3\n...\n...\n...\n3 3\n...\n.#.\n...\n3 3\n.#.\n#.#\n.#.\n3 3\n.#.\n###\n.#.\n7 7\n.#####.\n#.....#\n#..#..#\n#.#.#.#\n#..#..#\n#.....#\n.#####.\n7 7\n.#####.\n#.....#...
[ "yes\nno\nno\nno\nno\nno\nyes\nyes\n" ]
[ "3 6\n.#..#.\n#.##.#\n.#..#.\n8 7\n.#####.\n#.....#\n#..#..#\n#.#.#.#\n#..#..#\n#..#..#\n.#####.\n...#...\n3 3\n#..\n...\n#..\n3 3\n#..\n.#.\n#..\n3 3\n...\n...\n...\n3 3\n-..\n.#.\n...\n3 3\n.#.\n#.#\n.#.\n3 3\n.#.\n###\n.#.\n7 7\n.#####.\n#.....#\n#..#..#\n#.#.#.#\n#..#..#\n#.....#\n.#####.\n7 7\n.#####.\n#.....#...
[ "yes\nno\nno\nno\nno\nno\nyes\nyes\n", "yes\nno\nno\nno\nyes\nno\nyes\nyes\n", "yes\nno\nno\nyes\nno\nno\nyes\nyes\n", "no\nno\nno\nno\nno\nno\nyes\nyes\n", "yes\nno\nno\nyes\nno\nno\nno\nyes\n", "yes\nno\nno\nno\nno\nno\nno\nyes\n", "no\nno\nno\nyes\nno\nno\nno\nyes\n", "no\nno\nno\nno\nyes\nno\nyes\...
CodeContests
There are N points in a D-dimensional space. The coordinates of the i-th point are (X_{i1}, X_{i2}, ..., X_{iD}). The distance between two points with coordinates (y_1, y_2, ..., y_D) and (z_1, z_2, ..., z_D) is \sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}. How many pairs (i, j) (i < j) are there such ...
stdin
null
1,967
1
[ "3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 3\n", "3 2\n1 2\n5 5\n-2 8\n", "5 1\n1\n2\n3\n4\n5\n" ]
[ "2\n", "1\n", "10\n" ]
[ "3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 9 0\n", "1 1\n1\n2\n3\n4\n5\n", "5 1\n0\n2\n3\n4\n5\n", "3 2\n1 8\n5 5\n-2 8\n", "3 2\n1 4\n5 5\n-2 8\n", "3 4\n-3 7 8 2\n-12 1 10 2\n-2 8 13 0\n", "3 2\n2 4\n5 5\n-2 8\n", "0 1\n1\n2\n3\n4\n5\n", "3 4\n-3 7 8 2\n-18 1 10 2\n-2 8 13 0\n", "3 2\n0 4\n5 5\n-2 8\n" ]
[ "1\n", "0\n", "10\n", "2\n", "1\n", "1\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
Welcome to PC Koshien, players. At PC Koshien, competitions are currently being held in a total of three categories: programming category, mobile category, and Ichimai's picture CG category. Given the number of participants in each department, create a program that calculates the total number of participants. Input...
stdin
null
4,550
1
[ "10 10 20\n", "100 0 0\n", "1000 1000 1000\n" ]
[ "40\n", "100\n", "3000\n" ]
[ "20 10 20\n", "100 0 1\n", "0000 1000 1000\n", "5 10 20\n", "110 0 1\n", "0000 0000 1000\n", "6 10 20\n", "110 -1 1\n", "0001 0000 1000\n", "6 10 15\n" ]
[ "50\n", "101\n", "2000\n", "35\n", "111\n", "1000\n", "36\n", "110\n", "1001\n", "31\n" ]
CodeContests
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems....
stdin
null
4,666
1
[ "5\n3 1 4 1 5\n3\n5 4 3\n", "1\n800\n5\n100 100 100 100 100\n", "15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n5 4 3 2 1 2 3 4 5\n", "7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600\n" ]
[ "YES\n", "NO\n", "YES\n", "NO\n" ]
[ "1\n13\n5\n100 100 100 100 100\n", "15\n1 2 2 3 4 3 4 4 8 6 5 3 5 5 7\n9\n7 4 3 2 1 2 3 8 5\n", "15\n1 2 2 3 3 3 4 4 4 4 5 5 5 5 5\n9\n7 4 3 2 1 2 3 4 5\n", "7\n100 200 500 700 238 1600 2000\n6\n100 200 500 700 1600 1600\n", "1\n13\n5\n100 000 100 100 100\n", "15\n1 2 2 3 3 3 4 4 4 4 5 3 5 5 5\n9\n7 4 3 2...
[ "NO\n", "YES\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n" ]
CodeContests
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. Constraints * $0 \leq S \leq 86400$ Input An integer $S$ is given in a line. Output Print $h$, $m$ and $s$ separated by ':'. You do not n...
stdin
null
2,071
1
[ "46979\n" ]
[ "13:2:59\n" ]
[ "71983\n", "477\n", "323\n", "342\n", "574\n", "572\n", "1034\n", "1350\n", "1241\n", "1644\n" ]
[ "19:59:43\n", "0:7:57\n", "0:5:23\n", "0:5:42\n", "0:9:34\n", "0:9:32\n", "0:17:14\n", "0:22:30\n", "0:20:41\n", "0:27:24\n" ]
CodeContests
You have initially a string of N characters, denoted by A1,A2...AN. You have to print the size of the largest subsequence of string A such that all the characters in that subsequence are distinct ie. no two characters in that subsequence should be same. A subsequence of string A is a sequence that can be derived from A...
stdin
null
3,218
1
[ "2\nabc\naba\n" ]
[ "3\n2\n" ]
[ "2\nabd\naba\n", "2\nabc\naaa\n", "2\ncca\naaa\n", "2\nccb\naab\n", "2\nccb\ncba\n", "2\nbbb\nbaa\n", "2\nbbb\naaa\n", "2\ncad\nbad\n", "2\nbbb\nacb\n", "2\nbad\naba\n" ]
[ "3\n2\n", "3\n1\n", "2\n1\n", "2\n2\n", "2\n3\n", "1\n2\n", "1\n1\n", "3\n3\n", "1\n3\n", "3\n2\n" ]
CodeContests
Given is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \times B + C = N? Constraints * 2 \leq N \leq 10^6 * All values in input are integers. Input Input is given from Standard Input in the following format: N Output Print the answer. Examples Input 3 Output 3 Input 100 ...
stdin
null
172
1
[ "3\n", "100\n", "1000000\n" ]
[ "3\n", "473\n", "13969985\n" ]
[ "4\n", "101\n", "5\n", "001\n", "8\n", "6\n", "2\n", "110\n", "10\n", "13\n" ]
[ "5\n", "482\n", "8\n", "0\n", "16\n", "10\n", "1\n", "530\n", "23\n", "35\n" ]
CodeContests
Many of us are familiar with collatz sequence. Know the problem is, There is a fight going between the students of the class they have splitted up into two groups the odd rulers and the even rulers. To resolve this fight sir will randomly pick up the numbers and are written on the board. Teacher stated that if the tota...
stdin
null
3,111
1
[ "2\n3\n4\n\nSAMPLE\n" ]
[ "Even Rules\nOdd Rules\n" ]
[ "2\n5\n4\n\nSAMPLE\n", "2\n9\n4\n\nSAMLOE\n", "2\n5\n8\n\nSBMLPE\n", "2\n13\n4\n\nEAMLNS\n", "2\n8\n3\n\nLSMAPE\n", "2\n13\n8\n\nSNLMAE\n", "2\n4\n2\n\nSBMKPE\n", "2\n28\n2\n\nEPKBOT\n", "2\n2\n2\n\nOTKPEB\n", "2\n5\n4\n\nSAMLPE\n" ]
[ "Odd Rules\nOdd Rules\n", "Even Rules\nOdd Rules\n", "Odd Rules\nEven Rules\n", "Tie\nOdd Rules\n", "Even Rules\nEven Rules\n", "Tie\nEven Rules\n", "Odd Rules\nTie\n", "Even Rules\nTie\n", "Tie\nTie\n", "Odd Rules\nOdd Rules\n" ]
CodeContests
Example Input 2 2 2 4 0 0 0 1 1 0 1 0 1 0 1 1 Output 4
stdin
null
629
1
[ "2 2 2 4\n0 0 0\n1 1 0\n1 0 1\n0 1 1\n" ]
[ "4\n" ]
[ "2 2 4 4\n0 0 0\n1 1 0\n1 0 1\n0 1 1\n", "2 2 4 4\n0 0 -1\n1 1 0\n1 0 1\n0 1 1\n", "2 2 2 4\n0 0 0\n1 0 0\n1 0 1\n0 1 1\n", "2 2 4 4\n0 0 -1\n1 1 0\n2 0 1\n0 1 1\n", "2 2 4 4\n0 1 -1\n1 1 0\n2 0 1\n0 1 1\n", "2 2 4 4\n0 0 1\n1 1 0\n1 0 1\n0 1 1\n", "2 2 4 0\n0 1 -1\n1 1 0\n2 0 1\n0 1 1\n", "2 2 2 4\n0...
[ "3\n", "1\n", "2\n", "1\n", "1\n", "2\n", "1\n", "2\n", "1\n", "1\n" ]
CodeContests
For $n$ lists $L_i$ $(i = 0, 1, ..., n-1)$, perform a sequence of the following operations. * insert($t$, $x$): Insert an integer $x$ at the end of $L_t$. * dump($t$): Print all elements in $L_t$. * splice($s$, $t$): Transfer elements of $L_s$ to the end of $L_t$. $L_s$ becomes empty. In the initial state, $L_i$ $(...
stdin
null
1,467
1
[ "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 1 0\n0 2 6\n1 0\n1 1\n1 2\n" ]
[ "1 2 3 4 5\n\n6\n" ]
[ "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 1 0\n0 2 9\n1 0\n1 1\n1 2\n", "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 2 0\n0 2 6\n1 0\n1 1\n1 2\n", "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 5\n2 2 0\n0 2 6\n1 1\n1 1\n1 2\n", "3 10\n0 0 1\n0 0 2\n0 0 3\n0 1 4\n0 1 8\n2 2 0\n0 2 6\n1 1\n1 1\n1 2\n", "3 10\n0 0 1...
[ "1 2 3 4 5\n\n9\n", "1 2 3\n4 5\n6\n", "4 5\n4 5\n6\n", "4 8\n4 8\n6\n", "1 2 3 4 5\n1 2 3 4 5\n9\n", "4\n4\n6\n", "3 4 5\n3 4 5\n6\n", "1 2 3 4\n\n5 6\n", "2 2 3\n4 5\n6\n", "4 5\n4 5\n7\n" ]
CodeContests
problem AOR Ika-chan visited AOR Co., Ltd. AOR Co., Ltd. is a $ N $ building with no basement floor. AOR Ika started the tour from the $ 1 $ floor and decided to move just $ M $. You can move from the $ i $ floor to the $ i + 1 $ floor, or the $ i --1 $ floor with $ 1 $ movements. However, it cannot be moved to the $ ...
stdin
null
4,405
1
[ "3 5\n" ]
[ "3\n" ]
[ "3 4\n", "3 1\n", "2 1\n", "3 6\n", "4 6\n", "6 9\n", "5 7\n", "7 9\n", "4 9\n", "3 9\n" ]
[ "3\n", "0\n", "1\n", "7\n", "5\n", "27\n", "6\n", "8\n", "39\n", "15\n" ]
CodeContests
Given is a string S. Replace every character in S with `x` and print the result. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Replace every character in S with ...
stdin
null
4,778
1
[ "sardine\n", "xxxx\n", "gone\n" ]
[ "xxxxxxx\n", "xxxx\n", "xxxx\n" ]
[ "sardnie\n", "xxwx\n", "gpne\n", "sardnif\n", "wxwx\n", "gpnd\n", "findras\n", "wwxx\n", "gpnc\n", "findrbs\n" ]
[ "xxxxxxx\n", "xxxx\n", "xxxx\n", "xxxxxxx\n", "xxxx\n", "xxxx\n", "xxxxxxx\n", "xxxx\n", "xxxx\n", "xxxxxxx\n" ]
CodeContests
You have been given an array A of size N consisting of positive integers. You need to find and print the product of all the number in this array Modulo 10^9+7. Input Format: The first line contains a single integer N denoting the size of the array. The next line contains N space separated integers denoting the eleme...
stdin
null
1,393
1
[ "5\n1 2 3 4 5\n\nSAMPLE\n" ]
[ "120\n" ]
[ "5\n1 2 3 3 5\n\nSAMPLE\n", "5\n1 2 3 3 8\n\nSAMPLE\n", "5\n1 2 3 2 5\n\nELPMAS\n", "5\n2 2 3 3 8\n\nSAMPLE\n", "5\n1 2 3 2 6\n\nELPMAS\n", "5\n2 2 3 4 8\n\nSAMPLE\n", "5\n4 2 3 4 8\n\nSAMPLE\n", "5\n4 2 6 4 8\n\nSAMPLE\n", "5\n4 4 3 2 6\n\nELPMAS\n", "5\n6 4 3 2 6\n\nELPMAS\n" ]
[ "90\n", "144\n", "60\n", "288\n", "72\n", "384\n", "768\n", "1536\n", "576\n", "864\n" ]
CodeContests
Bob is travelling from one city to another. In his way, he sees many other cities pass by. What he does instead of learning the full names of the cities, he learns just the first character of the cities. For example, if he passes by "bhopal", he will just remember the 'b'. Given the list of N cities that come in h...
stdin
null
125
1
[ "2\n2\nbhopal\ndelhi\n3\nbhopal\ndelhi\ndehradun\n\nSAMPLE\n" ]
[ "YES\nNO\n" ]
[ "2\n2\nbhopal\ndelhi\n3\nbhopal\neelhi\ndehradun\n\nSAMPLE\n", "100\n4\nlrbbmqb\ncd\nr\nowkk\n7\nid\nqscdxrjmow\nrxsjybldbe\nsarcbyne\ndyggxxp\nlorel\nnmpa\n6\nfwkho\nkmcoqhnw\nkuewhsqmgb\nuqcljj\nvsw\ndkqtbxi\n10\nv\nrr\nlj\ntnsnfwzqfj\nafadr\nwsofsbcnuv\nhffbsaq\nwp\nc\ncehch\n2\nfrkmlnoz\nkpqpxrjx\n9\ntzyxacbh...
[ "YES\nYES\n", "YES\nYES\nNO\nNO\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\nYES\nNO\nYES\nYES\nNO\nYES\nYES\nYES\nNO\nYES\nNO\nNO\nNO\nYES\nYES\nYES\nNO\nNO\nYES\nYES\nNO\nNO\nNO\nYES\nNO\nY...
CodeContests
"What are your shoe sizes?" Suddenly, the doctor asked me when I met him for the first time. "It's 23.5" "Oh, that's a really nice number. It's 2 to the 4th power plus 2 to the 2nd power, 2 to the 1st power, 2 to the 0th power, and 2 to the 1st power." Then the doctor asked. "You, how tall are you?" "Yes, it's 158....
stdin
null
977
1
[ "23.5\n158.1\n-1.0\n" ]
[ "00010111.1000\nNA\n" ]
[ "23.72975180461117\n158.1\n-1.0\n", "23.5\n158.1\n-0.5246083014985048\n", "23.72975180461117\n158.1\n-0.5449258499657357\n", "24.206542817215936\n158.1\n-1.0\n", "24.615346202775605\n158.1\n-1.0\n", "23.72975180461117\n158.6852941341954\n-0.5449258499657357\n", "25.190547978615548\n158.1\n-1.0\n", "24...
[ "NA\nNA\n", "00010111.1000\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n", "NA\nNA\n" ]
CodeContests
The Aiz Archaeological Society has set out to investigate the ruins of the ancient nation Iwashiro, which sinks in the Hibara Sea. The ruins are somewhere in the Hibara Sea. Therefore, I decided to use an exploration radar to roughly mark the location of the ruins by radar exploration from the coastline and estimate ho...
stdin
null
3,883
1
[ "3\n0 3\n1 2\n2 1\n", "2\n0 2\n1 2\n", "2\n0 1\n3 2\n" ]
[ "1.0\n", "1.936\n", "0.0\n" ]
[ "2\n1 2\n1 2\n", "2\n0 1\n4 2\n", "2\n1 2\n0 2\n", "2\n2 2\n0 2\n", "2\n2 2\n0 1\n", "2\n3 2\n0 2\n", "2\n0 2\n0 1\n", "3\n-1 3\n1 2\n2 2\n", "2\n1 1\n0 1\n", "2\n0 3\n1 3\n" ]
[ "2.000000000\n", "0.000000000\n", "1.936491673\n", "1.732050808\n", "0.968245837\n", "1.322875656\n", "1.000000000\n", "1.885618083\n", "0.866025404\n", "2.958039892\n" ]
CodeContests
Aklank is fond of numbers which are divisible by either P1 or P2. He termed those numbers as Bakku numbers. Recently his best friend gave him a range of numbers. Now he is wondering what is the probability of finding Bakku numbers from that range of numbers. Input First line of input contains two integers P1 and P2 (2...
stdin
null
3,380
1
[ "3 5\n2\n1 10\n20 34\n\nSAMPLE\n" ]
[ "0.500000\n0.466667\n" ]
[ "7607 9769\n10\n1 1\n1 100000\n10000 100000\n999 1000\n7607 7607\n1 7605\n15447 10000\n15005 100000\n9 12345\n100000 100000\n", "3 5\n2\n1 10\n20 6\n\nSAMPLE\n", "3 1\n2\n1 10\n20 6\n\nSAMPLE\n", "8317 9769\n10\n1 1\n1 100000\n10000 100000\n999 1000\n7607 7607\n1 7605\n15447 10000\n15005 100000\n9 12345\n1000...
[ "0.000000\n0.000230\n0.000233\n0.000000\n1.000000\n0.000000\n0.000184\n0.000247\n0.000162\n0.000000\n", "0.500000\n0.384615\n", "1.000000\n1.000000\n", "0.000000\n0.000220\n0.000222\n0.000000\n0.000000\n0.000000\n-0.000000\n0.000235\n0.000162\n0.000000\n", "0.000000\n0.000220\n0.000222\n0.000000\n0.000294\n...
CodeContests
Chef is the new king of the country Chefland. As first and most important responsibility he wants to reconstruct the road system of Chefland. There are N (1 to N) cities in the country and each city i has a population Pi. Chef wants to build some bi-directional roads connecting different cities such that each city is c...
stdin
null
4,486
1
[ "2\n2\n5 10\n4\n15 10 7 13\n" ]
[ "50\n266\n" ]
[ "2\n2\n5 5\n4\n15 10 7 13\n", "2\n2\n5 10\n4\n29 10 7 13\n", "2\n2\n5 5\n4\n15 10 12 13\n", "2\n2\n5 10\n4\n29 0 7 13\n", "2\n2\n5 5\n4\n27 10 12 13\n", "2\n2\n2 5\n4\n27 10 12 13\n", "2\n2\n2 5\n4\n27 10 11 13\n", "2\n2\n9 10\n4\n29 0 4 17\n", "2\n2\n2 5\n4\n27 8 11 13\n", "2\n2\n5 10\n4\n19 10 7...
[ "25\n266\n", "50\n364\n", "25\n400\n", "50\n0\n", "25\n520\n", "10\n520\n", "10\n510\n", "90\n0\n", "10\n408\n", "50\n294\n" ]
CodeContests
The Sun is a great heavenly body. The Sun is worshiped by various religions. Bob loves the Sun and loves any object that is similar to the Sun. He noticed that he can find the shape of the Sun in certain graphs. He calls such graphs "Sunny". We define the property "Sunny" mathematically. A graph G=(V,E) with a vertex ...
stdin
null
1,027
1
[ "5 5\n1 2\n2 3\n3 4\n4 5\n1 3\n", "5 5\n1 2\n2 3\n3 4\n4 5\n1 4\n" ]
[ "Yes\n", "No\n" ]
[ "5 5\n1 3\n2 3\n3 4\n4 5\n1 4\n", "5 5\n1 3\n2 3\n3 4\n4 5\n1 2\n", "5 5\n1 2\n4 3\n3 4\n4 5\n1 3\n", "7 5\n1 2\n2 3\n3 4\n4 5\n1 4\n", "5 5\n1 2\n4 3\n3 4\n4 5\n1 2\n", "7 5\n1 2\n2 3\n3 1\n4 5\n1 4\n", "5 5\n1 2\n2 3\n2 4\n4 5\n1 4\n", "5 5\n1 3\n2 3\n1 4\n4 5\n1 4\n", "7 5\n1 2\n2 3\n3 4\n4 5\n1 ...
[ "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
1000000000000001 dogs suddenly appeared under the roof of Roger's house, all of which he decided to keep. The dogs had been numbered 1 through 1000000000000001, but he gave them new names, as follows: * the dogs numbered 1,2,\cdots,26 were respectively given the names `a`, `b`, ..., `z`; * the dogs numbered 27,28,29,\...
stdin
null
1,640
1
[ "27\n", "2\n", "123456789\n" ]
[ "aa\n", "b\n", "jjddja\n" ]
[ "40\n", "1\n", "71095103\n", "51\n", "50389265\n", "4\n", "56744729\n", "3\n", "61759127\n", "6\n" ]
[ "an\n", "a\n", "eynzga\n", "ay\n", "dffxhq\n", "d\n", "dtdmwo\n", "c\n", "eecuqa\n", "f\n" ]
CodeContests
We have two distinct integers A and B. Print the integer K such that |A - K| = |B - K|. If such an integer does not exist, print `IMPOSSIBLE` instead. Constraints * All values in input are integers. * 0 \leq A,\ B \leq 10^9 * A and B are distinct. Input Input is given from Standard Input in the following format: ...
stdin
null
2,204
1
[ "998244353 99824435\n", "0 3\n", "2 16\n" ]
[ "549034394\n", "IMPOSSIBLE\n", "9\n" ]
[ "899758294 99824435\n", "0 4\n", "1349313191 99824435\n", "0 2\n", "1 7\n", "1349313191 6197513\n", "1 13\n", "2563528379 6197513\n", "2563528379 9221341\n", "2563528379 13118121\n" ]
[ "IMPOSSIBLE\n", "2\n", "724568813\n", "1\n", "4\n", "677755352\n", "7\n", "1284862946\n", "1286374860\n", "1288323250\n" ]
CodeContests
You decide to develop a game with your friends. The title of the game is "Battle Town". This is a game with the theme of urban warfare with tanks. As the first step in game development, we decided to develop the following prototype. In this prototype, the only tanks that appear are the player's tanks, not the enemy ta...
stdin
null
1,739
1
[ "4\n4 6\n*.*..*\n*.....\n..-...\n^.*#..\n10\nSRSSRRUSSR\n2 2\n<.\n..\n12\nDDSRRSUUSLLS\n3 5\n>-#**\n.-*#*\n.-**#\n15\nSSSDRSSSDRSSSUU\n5 5\nv****\n*****\n*****\n*****\n*****\n44\nSSSSDDRSDRSRDSULUURSSSSRRRRDSSSSDDLSDLSDLSSD\n" ]
[ "*....*\n......\n..-...\n..>#..\n\n<.\n..\n\n^-#**\n.-.#*\n.-..#\n\n.....\n.***.\n..*..\n..*..\n....v\n" ]
[ "4\n4 6\n*.*..*\n*.....\n...-..\n^.*#..\n10\nSRSSRRUSSR\n2 2\n<.\n..\n12\nDDSRRSUUSLLS\n3 5\n>-#**\n.-*#*\n.-**#\n15\nSSSDRSSSDRSSSUU\n5 5\nv****\n*****\n*****\n*****\n*****\n44\nSSSSDDRSDRSRDSULUURSSSSRRRRDSSSSDDLSDLSDLSSD\n", "4\n4 6\n*.*..*\n*.....\n..-...\n^.*#..\n10\nSRSSRRUSSR\n2 2\n<.\n..\n12\nDDSRRSUUSLLS...
[ "*....*\n......\n..>-..\n...#..\n\n<.\n..\n\n^-#**\n.-.#*\n.-..#\n\n.....\n.***.\n..*..\n..*..\n....v\n", "*....*\n......\n..-...\n..>#..\n\n<.\n..\n\n^-#**\n.-.#*\n.-..#\n\n.....\n.***.\n..*..\n...).\n....v\n", "*....*\n...../\n..-...\n..>#..\n\n<.\n..\n\n^-#**\n.-.#*\n.-..#\n\n.....\n.***.\n..*..\n...).\n.......
CodeContests
Example Input acmicpc tsukuba Output No
stdin
null
235
1
[ "acmicpc\ntsukuba\n" ]
[ "No\n" ]
[ "acmicpc\nttukuba\n", "acmpcic\nttukuba\n", "acmpcid\nttukuba\n", "acmpcid\nttakubu\n", "acmqcid\nttakubu\n", "aciqcmd\nttakubu\n", "aciqcmd\ntt`kubu\n", "aciqcmd\ntu`ktbu\n", "dmcqica\ntu`ktbu\n", "dmcqica\ntu`jtbu\n" ]
[ "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
You are given positive integers A and B. If A is a divisor of B, print A + B; otherwise, print B - A. Constraints * All values in input are integers. * 1 \leq A \leq B \leq 20 Input Input is given from Standard Input in the following format: A B Output If A is a divisor of B, print A + B; otherwise, print B -...
stdin
null
5,051
1
[ "4 12\n", "8 20\n", "1 1\n" ]
[ "16\n", "12\n", "2\n" ]
[ "1 12\n", "4 20\n", "1 0\n", "1 2\n", "4 24\n", "1 -1\n", "6 24\n", "6 36\n", "6 10\n", "6 17\n" ]
[ "13\n", "24\n", "1\n", "3\n", "28\n", "0\n", "30\n", "42\n", "4\n", "11\n" ]
CodeContests
D: The Diversity of Prime Factorization Problem Ebi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \ log $ M) time! But unfortunately, the machine could display only digits and white spaces. In general, we consider the factorization of M as p_1 ^ {e_1} \ times p_2 ...
stdin
null
118
1
[ "3\n2 3 3\n" ]
[ "2\n" ]
[ "3\n2 3 6\n", "3\n2 3 11\n", "3\n3 2 3\n", "3\n2 5 3\n", "3\n2 2 3\n", "3\n2 2 11\n", "3\n3 2 6\n", "3\n2 2 13\n", "3\n4 2 6\n", "3\n2 2 0\n" ]
[ "1\n", "3\n", "0\n", "2\n", "1\n", "1\n", "0\n", "1\n", "0\n", "0\n" ]
CodeContests
N friends of Takahashi has come to a theme park. To ride the most popular roller coaster in the park, you must be at least K centimeters tall. The i-th friend is h_i centimeters tall. How many of the Takahashi's friends can ride the roller coaster? Constraints * 1 \le N \le 10^5 * 1 \le K \le 500 * 1 \le h_i \le 5...
stdin
null
3,271
1
[ "5 1\n100 200 300 400 500\n", "4 150\n150 140 100 200\n", "1 500\n499\n" ]
[ "5\n", "2\n", "0\n" ]
[ "5 1\n100 200 300 467 500\n", "4 150\n151 140 100 200\n", "0 500\n499\n", "1 500\n654\n", "5 2\n000 200 300 467 500\n", "4 112\n150 140 100 200\n", "5 2\n100 200 300 467 500\n", "-1 500\n499\n", "5 2\n100 200 476 467 500\n", "-1 500\n289\n" ]
[ "5\n", "2\n", "0\n", "1\n", "4\n", "3\n", "5\n", "0\n", "5\n", "0\n" ]
CodeContests
Yanagi is a high school student, and she is called "Hime" by her boyfriend who is a ninja fanboy. She likes picture books very much, so she often writes picture books by herself. She always asks you to make her picture book as an assistant. Today, you got asked to help her with making a comic. She sometimes reads her ...
stdin
null
1,978
1
[ "4\n0 0 100 60\n0 60 50 90\n50 60 100 90\n0 90 100 120\n6\n0 0 100 40\n0 40 50 70\n50 40 100 60\n50 60 100 80\n0 70 50 120\n50 80 100 120\n0\n" ]
[ "1\n2\n3\n4\n\n1\n2\n4\n5\n3\n6\n" ]
[ "4\n0 0 100 60\n0 60 50 90\n50 60 100 90\n0 90 100 120\n6\n0 0 100 40\n0 67 50 70\n50 40 100 60\n50 60 100 80\n0 70 50 120\n50 80 100 120\n0\n", "4\n0 0 100 60\n0 60 50 90\n50 60 100 90\n0 90 100 120\n6\n0 0 100 58\n-1 67 50 70\n50 40 100 60\n50 60 100 80\n0 70 50 120\n50 80 100 120\n0\n", "4\n0 0 100 14\n0 60 ...
[ "1\n2\n3\n4\n\n1\n2\n4\n5\n3\n6\n", "1\n2\n3\n4\n\n2\n1\n4\n5\n3\n6\n", "1\n2\n3\n4\n\n1\n2\n5\n6\n3\n4\n", "1\n2\n3\n4\n\n1\n3\n4\n5\n2\n6\n", "1\n2\n3\n4\n\n1\n2\n5\n4\n3\n6\n", "1\n2\n3\n4\n\n1\n2\n3\n5\n4\n6\n", "1\n2\n3\n4\n", "1\n2\n4\n3\n\n1\n2\n4\n5\n3\n6\n", "1\n2\n3\n4\n\n2\n1\n5\n4\n3\n6\...
CodeContests
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the s...
stdin
null
967
1
[ "3\n7\n10\n", "2\n100\n200\n", "14\n12\n112\n" ]
[ "2\n", "2\n", "8\n" ]
[ "3\n7\n15\n", "2\n000\n200\n", "14\n12\n47\n", "2\n000\n217\n", "3\n7\n45\n", "14\n16\n2\n", "3\n7\n76\n", "2\n000\n4\n", "3\n10\n43\n", "14\n12\n183\n" ]
[ "3\n", "100\n", "4\n", "109\n", "7\n", "1\n", "11\n", "2\n", "5\n", "14\n" ]
CodeContests
In the Kingdom of IOI, the wind always blows from sea to land. There are $N + 1$ spots numbered from $0$ to $N$. The wind from Spot $0$ to Spot $N$ in order. Mr. JOI has a house at Spot $N$. The altitude of Spot $0$ is $A_0 = 0$, and the altitude of Spot $i$ ($1 \leq i \leq N$) is $A_i$. The wind blows on the surface ...
stdin
null
3,403
1
[ "3 5 1 2\n0\n4\n1\n8\n1 2 2\n1 1 -2\n2 3 5\n1 2 -1\n1 3 5\n" ]
[ "-5\n-7\n-13\n-13\n-18\n" ]
[ "3 5 1 2\n0\n4\n1\n8\n1 2 2\n1 1 -2\n2 3 5\n1 2 -1\n1 2 5\n", "3 5 1 2\n0\n4\n1\n8\n1 2 2\n1 1 -3\n2 3 5\n1 2 -1\n1 2 5\n", "3 5 1 2\n0\n4\n1\n8\n2 2 2\n1 1 -3\n2 3 5\n1 2 -1\n1 2 5\n", "3 5 1 2\n0\n4\n1\n8\n2 2 2\n1 1 -3\n2 1 5\n1 2 -1\n1 2 5\n", "3 5 1 2\n0\n4\n1\n7\n2 2 2\n1 1 -3\n2 1 5\n1 2 -1\n1 2 5\n"...
[ "-5\n-7\n-13\n-13\n-13\n", "-5\n-8\n-13\n-13\n-13\n", "-7\n-8\n-13\n-13\n-13\n", "-7\n-8\n-8\n-8\n-8\n", "-6\n-7\n-7\n-7\n-7\n", "-14\n-14\n-14\n-14\n-14\n", "-5\n-7\n-13\n-13\n-18\n", "-5\n-8\n-13\n-12\n-13\n", "-14\n-14\n-14\n-14\n", "-6\n-6\n-6\n-6\n-6\n" ]
CodeContests
In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well. For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish. Class B ends w...
stdin
null
5,058
1
[ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#====~\n" ]
[ "A\nB\nNA\n" ]
[ "3\n>'======#======~\n>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~\n", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#===>~\n", "3\n>(======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=\n", "3\n>'======#======~\n>QQ=^=Q=Q=Q=Q=Q=Q=Q=~~\n>'===#==~>=\n", "3\n>'======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=\n"...
[ "A\nB\nNA\n", "A\nNA\nNA\n", "NA\nNA\nNA\n", "A\nNA\nNA\n", "A\nNA\nNA\n", "NA\nNA\nNA\n", "NA\nNA\nNA\n", "NA\nNA\nNA\n", "A\nNA\nNA\n", "NA\nNA\nNA\n" ]
CodeContests
Alice and Bob are fighting over who is a superior debater. However they wish to decide this in a dignified manner. So they decide to fight in the Battle of Words. In each game both get to speak a sentence. Because this is a dignified battle, they do not fight physically, the alphabets in their words do so for them. ...
stdin
null
635
1
[ "3\ni will win\nwill i\ntoday or tomorrow\ntoday or tomorrow and yesterday\ni dare you\nbad day\n\nSAMPLE\n" ]
[ "You win some.\nYou lose some.\nYou draw some.\n" ]
[ "3\ni will win\nwill i\ntoday or tomorrow\nyadot or tomorrow and yesterday\ni dare you\nbad day\n\nSAMPLE\n", "3\nh will win\nwill i\ntoday ro tomorrow\nyadot or tnmorrow adn yesterday\ni dare yot\ncad day\n\nT@LPLE\n", "3\nh will niw\nwill g\nuodby ro tomorwor\nyadot ro tnmorsov nda yetterday\nh card yot\ndac ...
[ "You win some.\nYou lose some.\nYou draw some.\n", "You win some.\nYou draw some.\nYou draw some.\n", "You draw some.\nYou draw some.\nYou draw some.\n", "You draw some.\nYou lose some.\nYou draw some.\n", "You win some.\nYou lose some.\nYou draw some.\n", "You win some.\nYou lose some.\nYou draw some.\n"...
CodeContests
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2...
stdin
null
4,626
1
[ "3 4\n1 1\n2 2\n3 3\n", "10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n" ]
[ "3\n", "1\n" ]
[ "3 4\n1 1\n2 2\n3 2\n", "10 500000\n1 100000\n1 100001\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n", "3 4\n1 1\n2 3\n3 2\n", "3 4\n1 1\n4 3\n3 2\n", "3 5\n2 2\n1 1\n8 3\n", "3 5\n2 2\n1 1\n15 3\n", "10 878093\n1 100000\n1 110001\n1 100000\n1...
[ "3\n", "1\n", "2\n", "4\n", "8\n", "15\n", "100000\n", "5\n", "7\n", "6\n" ]
CodeContests
An open-top box having a square bottom is placed on the floor. You see a number of needles vertically planted on its bottom. You want to place a largest possible spheric balloon touching the box bottom, interfering with none of the side walls nor the needles. Java Specific: Submitted Java programs may not use "java.a...
stdin
null
4,594
1
[ "5 16\n70 66 40\n38 52 20\n40 35 10\n70 30 10\n20 60 10\n1 100\n54 75 200\n1 10\n90 10 1\n1 11\n54 75 200\n3 10\n53 60 1\n61 38 1\n45 48 1\n4 10\n20 20 10\n20 80 10\n80 20 10\n80 80 10\n0 0\n" ]
[ "26.00000\n39.00000\n130.00000\n49.49777\n85.00000\n95.00000\n" ]
[ "5 16\n70 66 40\n38 52 20\n40 35 10\n70 30 10\n20 60 10\n1 100\n54 75 200\n1 10\n90 14 1\n1 11\n54 75 200\n3 10\n53 60 1\n61 38 1\n45 48 1\n4 10\n20 20 10\n20 80 10\n80 20 10\n80 80 10\n0 0\n", "5 19\n70 66 70\n38 52 20\n40 35 10\n70 30 10\n20 60 10\n1 100\n54 75 200\n1 10\n90 14 1\n1 11\n54 75 200\n3 10\n53 60 1...
[ "26.000000\n39.000000\n130.000000\n49.497769\n85.000000\n95.000000\n", "25.432415\n39.000000\n130.000000\n49.497769\n85.000000\n95.000000\n", "25.432415\n39.000000\n130.000000\n49.497769\n85.000000\n99.314575\n", "25.432415\n39.000000\n130.000000\n41.197361\n85.000000\n99.314575\n", "25.432415\n39.000000\n1...
CodeContests
Write a program of the Bubble Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array ...
stdin
null
1,188
1
[ "5\n5 3 2 4 1\n", "6\n5 2 4 6 1 3\n" ]
[ "1 2 3 4 5\n8\n", "1 2 3 4 5 6\n9\n" ]
[ "5\n7 3 2 4 1\n", "6\n5 1 4 6 1 3\n", "5\n7 3 2 3 1\n", "6\n6 1 4 6 1 3\n", "5\n7 3 2 3 0\n", "6\n6 1 3 6 1 3\n", "5\n7 3 4 3 0\n", "6\n8 1 3 6 1 3\n", "5\n7 1 4 3 0\n", "6\n8 1 3 6 2 3\n" ]
[ "1 2 3 4 7\n8\n", "1 1 3 4 5 6\n8\n", "1 2 3 3 7\n8\n", "1 1 3 4 6 6\n8\n", "0 2 3 3 7\n8\n", "1 1 3 3 6 6\n7\n", "0 3 3 4 7\n8\n", "1 1 3 3 6 8\n8\n", "0 1 3 4 7\n8\n", "1 2 3 3 6 8\n8\n" ]
CodeContests
Bob is playing a popular game called "Dungeon". The game is played on a rectangular board consisting of W × H squares. Each square is identified with its column and row number, thus the square located in the x-th column and the y-th row is represented as (x, y). The left-most square in the top row is (0, 0) and the rig...
stdin
null
4,789
1
[ "5 4 4\n0 3\n1 1\n2 2\n2 3\n", "6 6 5\n2 1\n5 2\n3 3\n1 4\n1 5\n", "8 8 4\n6 0\n7 0\n0 6\n0 7\n" ]
[ "2\n", "4\n", "0\n" ]
[ "5 4 4\n0 3\n1 1\n3 2\n2 3\n", "6 6 5\n2 1\n5 2\n3 3\n2 4\n1 5\n", "8 8 4\n12 0\n7 0\n0 6\n0 7\n", "6 6 5\n2 1\n5 2\n1 3\n2 4\n1 5\n", "10 4 2\n0 3\n1 1\n3 3\n2 3\n", "5 4 4\n0 3\n1 1\n2 1\n2 3\n", "10 4 4\n0 3\n1 1\n3 2\n2 3\n", "8 8 4\n12 0\n7 0\n0 6\n0 11\n", "10 4 4\n0 3\n1 1\n3 3\n2 3\n", "6 ...
[ "3\n", "5\n", "0\n", "4\n", "1\n", "2\n", "3\n", "0\n", "3\n", "4\n" ]
CodeContests
Big Chandan is a dire lover of Biryani, especially Old Monk's Biryani. Today, he went over to have some of it. To his surprise, the waiter turns out be to be a coding geek and refuses to serves him unless Chandu solves his two- arrays problem, stated as: Given two non-increasing array of integers A,B i.e A[i] ≥ A[i...
stdin
null
367
1
[ "2\n9\n7 7 3 3 3 2 2 2 1\n8 8 7 7 5 5 4 3 2\n6\n6 5 4 4 4 4\n2 2 2 2 2 2\n\nSAMPLE\n" ]
[ "5\n0\n" ]
[ "2\n9\n7 7 3 3 3 2 2 2 1\n8 8 9 7 5 5 4 3 2\n6\n6 5 4 4 4 4\n2 2 2 2 2 2\n\nSAMPLE\n", "2\n9\n9 7 3 3 3 2 2 2 1\n8 8 9 7 5 5 4 1 2\n6\n6 5 4 4 4 0\n2 2 2 2 2 2\n\nSAMQLE\n", "2\n9\n6 4 3 3 3 2 2 3 1\n8 8 9 7 5 5 4 4 2\n6\n6 16 4 4 4 4\n2 2 2 2 2 2\n\nSAMQLE\n", "2\n9\n9 7 3 3 3 3 2 2 1\n8 8 10 7 5 6 2 2 2\n6\...
[ "5\n0\n", "4\n0\n", "6\n0\n", "3\n0\n", "4\n1\n", "5\n0\n", "5\n0\n", "5\n0\n", "5\n0\n", "5\n0\n" ]
CodeContests
We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in thi...
stdin
null
3,080
1
[ "3\n1 5\n4 2\n6 3\n", "6\n19 92\n64 64\n78 48\n57 33\n73 6\n95 73\n", "4\n1 5\n2 6\n3 7\n4 8\n" ]
[ "7\n", "227\n", "10\n" ]
[ "3\n2 5\n4 2\n6 3\n", "6\n19 92\n64 64\n78 48\n57 33\n142 6\n95 73\n", "4\n1 5\n2 6\n0 7\n4 8\n", "3\n1 5\n4 4\n6 3\n", "6\n19 92\n64 64\n29 48\n57 33\n142 6\n95 73\n", "4\n1 5\n0 6\n0 7\n4 8\n", "6\n19 92\n64 64\n29 48\n57 33\n142 6\n95 15\n", "4\n1 3\n0 6\n0 7\n4 8\n", "6\n19 92\n64 64\n29 48\n57 ...
[ "8\n", "227\n", "7\n", "9\n", "192\n", "5\n", "150\n", "4\n", "147\n", "3\n" ]
CodeContests
[Chopsticks (singular: chopstick) are short, frequently tapered sticks used in pairs of equal length, which are used as the traditional eating utensils of China, Japan, Korea and Vietnam. Originated in ancient China, they can also be found in some areas of Tibet and Nepal that are close to Han Chinese populations, as w...
stdin
null
4,527
1
[ "5 2\n1\n3\n3\n9\n4\n" ]
[ "2\n" ]
[ "5 2\n2\n3\n3\n9\n4\n", "5 2\n6\n0\n3\n9\n6\n", "5 0\n6\n0\n3\n5\n4\n", "5 2\n3\n3\n3\n9\n4\n", "5 2\n6\n3\n3\n9\n4\n", "5 2\n6\n3\n3\n9\n6\n", "5 2\n0\n3\n3\n9\n4\n", "5 2\n2\n3\n3\n9\n3\n", "5 2\n6\n3\n3\n7\n4\n", "5 2\n10\n3\n3\n9\n6\n" ]
[ "2\n", "1\n", "0\n", "2\n", "2\n", "2\n", "1\n", "2\n", "2\n", "2\n" ]
CodeContests
Tunnel formula One day while exploring an abandoned mine, you found a long formula S written in the mine. If you like large numbers, you decide to take out the choke and add `(` or `)` so that the result of the formula calculation is as large as possible. If it has to be a mathematical formula even after adding it, ho...
stdin
null
2,264
1
[ "1-(2+3-4+5)\n" ]
[ "5\n" ]
[ "0-(2+3-4+5)\n", "0-(2+3-3+5)\n", "2-(2+3-4+5)\n", "1-(3+2-4+5)\n", "2-(2-3+4+5)\n", "0-(3+4-4+5)\n", "3+(2-4-4+5)\n", "2-(2+2-4+5)\n", "2+(2-4-4+5)\n", "2-(2+2-5+5)\n" ]
[ "4\n", "3\n", "6\n", "5\n", "12\n", "2\n", "10\n", "7\n", "9\n", "8\n" ]
CodeContests
You are playing a solitaire puzzle called "Connect", which uses several letter tiles. There are R × C empty cells. For each i (1 ≤ i ≤ R), you must put a string si (1 ≤ |si| ≤ C) in the i-th row of the table, without changing the letter order. In other words, you choose an integer sequence {aj} such that 1 ≤ a1 < a2 <...
stdin
null
4,321
1
[ "4 16\nINTERNATIONAL\nCOLLEGIATE\nPROGRAMMING\nCONTEST\n", "2 4\nACM\nICPC\n", "2 9\nPROBLEMF\nCONNECT\n" ]
[ "18\n", "2\n", "6\n" ]
[ "4 16\nINTERNATIONAL\nCOLLEGIATE\nPROGRAMMJNG\nCONTEST\n", "4 16\nLANOITANRETNI\nCOLLEGIATE\nPROGRAMMJNG\nCONTEST\n", "7 16\nLANOIUANRETNI\nCOLLAGIFTE\nPRNGRAMMJNG\nTSETNOC\n", "7 16\nLANOIUANRETNI\nCOGLALIFTE\nPRNGRAMMJNG\nTSETNOC\n", "8 16\nLANOIUANRETNI\nCOGLALIFTE\nPRNGRAMNJNG\nTSETNOC\n", "2 15\nLANO...
[ "18\n", "20\n", "16\n", "14\n", "12\n", "6\n", "0\n", "4\n", "10\n", "2\n" ]
CodeContests
Evil organizations that attempt to conquer the world are everywhere, regardless of age, east or west fiction, non-fiction, but what on earth did they try to conquer the world? I suddenly thought about that because I was also planning to conquer the world. The only reason I want to conquer the world is to show the world...
stdin
null
4,552
1
[ "4\n0.200 3 0.500\n0.100 0 0.400\n0.900 1 1.000\n0.400 2 0.600\n2\n0.600 1 0.800\n0.500 0 1.000\n9\n0.200 7 0.600\n0.400 0 0.500\n0.700 8 1.000\n0.100 4 0.400\n0.200 2 0.600\n0.100 6 0.400\n0.100 5 0.400\n0.600 3 0.900\n0.500 1 0.900\n9\n0.300 8 0.900\n0.700 3 0.800\n0.300 0 0.900\n0.700 6 0.800\n0.200 5 0.700\n0.2...
[ "7.27777777778 1\n2.66666666667 1\n23.98412698413 72\n11.36904761905 4\n" ]
[ "4\n0.200 3 0.500\n0.100 0 0.400\n0.900 1 1.000\n0.400 2 0.600\n2\n0.600 1 0.800\n0.500 0 1.000\n9\n0.200 7 0.600\n0.400 0 0.500\n0.700 8 1.000\n0.100 4 0.400\n0.200 2 0.600\n0.100 6 0.400\n0.18676017117330992 5 0.400\n0.600 3 0.900\n0.500 1 0.900\n9\n0.300 8 0.900\n0.700 3 0.800\n0.300 0 0.900\n0.700 6 0.800\n0.20...
[ "7.277777777778 1\n2.666666666667 1\n19.338587700872 36\n11.369047619048 4\n", "6.023531575498 1\n2.666666666667 1\n19.338587700872 36\n11.369047619048 4\n", "6.023531575498 1\n2.666666666667 1\n18.473345883584 36\n11.369047619048 4\n", "7.277777777778 1\n2.666666666667 1\n23.616230176020 72\n11.369047619048 ...
CodeContests
Find the sum of weights of edges of the Minimum Spanning Tree for a given weighted undirected graph G = (V, E). Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 100,000 * 0 ≤ wi ≤ 10,000 * The graph is connected * There are no parallel edges * There are no self-loops Input |V| |E| s0 t0 w0 s1 t1 w1 : s|E|-1 t|E|-1 w|E|-...
stdin
null
1,629
1
[ "6 9\n0 1 1\n0 2 3\n1 2 1\n1 3 7\n2 4 1\n1 4 3\n3 4 1\n3 5 1\n4 5 6\n", "4 6\n0 1 2\n1 2 1\n2 3 1\n3 0 1\n0 2 3\n1 3 5\n" ]
[ "5\n", "3\n" ]
[ "6 9\n0 1 1\n0 2 3\n1 2 2\n1 3 7\n2 4 1\n1 4 3\n3 4 1\n3 5 1\n4 5 6\n", "4 6\n0 1 2\n1 2 1\n2 3 1\n3 0 1\n0 2 1\n1 3 5\n", "6 9\n0 2 1\n0 2 3\n0 2 2\n1 3 7\n2 4 1\n1 4 3\n3 2 1\n3 5 1\n2 5 6\n", "6 9\n0 1 1\n0 2 3\n1 2 2\n1 3 7\n2 4 1\n1 4 3\n3 4 1\n3 1 1\n4 5 6\n", "6 2\n0 2 1\n0 2 3\n1 2 2\n1 3 7\n2 4 1\n...
[ "6\n", "3\n", "7\n", "10\n", "1\n", "11\n", "2\n", "4\n", "8\n", "9\n" ]
CodeContests
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a bridge. Find the number of the edges that are bridges among the M edges....
stdin
null
4,389
1
[ "3 3\n1 2\n1 3\n2 3\n", "6 5\n1 2\n2 3\n3 4\n4 5\n5 6\n", "7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7\n" ]
[ "0\n", "5\n", "4\n" ]
[ "3 2\n1 2\n1 3\n2 3\n", "6 5\n1 2\n2 3\n3 4\n3 5\n5 6\n", "3 0\n2 2\n1 3\n3 3\n", "6 1\n2 1\n1 1\n1 3\n", "3 2\n2 2\n1 3\n2 3\n", "3 2\n2 1\n1 3\n2 3\n", "6 5\n1 2\n2 3\n3 4\n4 5\n2 6\n", "6 5\n1 4\n2 3\n3 4\n3 5\n5 6\n", "3 2\n2 2\n1 3\n3 3\n", "6 5\n1 4\n2 4\n3 4\n3 5\n5 6\n" ]
[ "2\n", "5\n", "0\n", "1\n", "2\n", "2\n", "5\n", "5\n", "2\n", "5\n" ]
CodeContests
Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently. Input A sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100. Output Print the mode values. If there are se...
stdin
null
2,809
1
[ "5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n" ]
[ "3\n5\n" ]
[ "5\n6\n3\n5\n8\n7\n6\n3\n9\n7\n3\n4\n", "5\n5\n3\n5\n8\n7\n6\n3\n9\n7\n3\n4\n", "5\n3\n3\n1\n15\n7\n6\n6\n16\n2\n1\n4\n", "5\n3\n3\n1\n15\n7\n6\n6\n16\n1\n1\n4\n", "5\n3\n2\n1\n15\n7\n6\n6\n16\n2\n1\n4\n", "5\n5\n1\n1\n15\n7\n6\n6\n16\n2\n2\n4\n", "5\n5\n1\n1\n28\n7\n6\n6\n16\n2\n0\n4\n", "5\n5\n1\n1\...
[ "3\n", "3\n5\n", "1\n3\n6\n", "1\n", "1\n2\n6\n", "1\n2\n5\n6\n", "1\n5\n6\n", "1\n4\n5\n", "5\n", "2\n3\n" ]
CodeContests
Example Input 6 6 3 1 9 4 3 6 1 2 1 4 2 6 5 4 6 5 3 2 Output 17
stdin
null
229
1
[ "6 6\n3\n1\n9\n4\n3\n6\n1 2\n1 4\n2 6\n5 4\n6 5\n3 2\n" ]
[ "17\n" ]
[ "6 6\n3\n1\n7\n4\n3\n6\n1 2\n1 4\n2 6\n5 4\n6 5\n3 2\n", "6 6\n3\n1\n9\n7\n3\n6\n1 2\n1 4\n2 6\n5 4\n6 5\n3 2\n", "6 6\n3\n1\n9\n4\n2\n6\n1 2\n1 4\n2 6\n5 4\n6 5\n3 2\n", "6 6\n3\n1\n7\n4\n3\n6\n1 2\n1 4\n2 6\n5 5\n6 5\n3 2\n", "6 6\n3\n1\n7\n4\n2\n6\n1 2\n1 4\n2 6\n5 5\n6 5\n3 2\n", "6 6\n3\n1\n7\n4\n2\n...
[ "17\n", "20\n", "16\n", "24\n", "23\n", "19\n", "14\n", "15\n", "10\n", "11\n" ]
CodeContests
You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also,...
stdin
null
3,836
1
[ "aba\n4\n", "atcoderandatcodeer\n5\n", "z\n1\n" ]
[ "b\n", "andat\n", "z\n" ]
[ "aba\n5\n", "y\n1\n", "aba\n1\n", "{\n1\n", "|\n1\n", "bba\n4\n", "atcoderandatcodeer\n2\n", "aab\n5\n", "cba\n4\n", "atcoderandatcodeer\n4\n" ]
[ "ba\n", "y\n", "a\n", "{\n", "|\n", "bb\n", "an\n", "b\n", "c\n", "anda\n" ]
CodeContests
Aaron is a vicious criminal. He has repeatedly committed crimes (2 shoplifting, 16 peeping, 256 underwear thieves, 65,536 escapes), but has continued to escape from the police with his extraordinary physical abilities. Bruce is a police officer. Although he does not have outstanding athletic ability, he enjoys photogra...
stdin
null
4,910
1
[ "6\n8\n0 1 0 0 0 0 0 0\n1 0 1 0 0 0 0 0\n0 1 0 1 1 0 0 0\n0 0 1 0 0 0 0 0\n0 0 1 0 0 1 1 0\n0 0 0 0 1 0 0 0\n0 0 0 0 1 0 0 1\n0 0 0 0 0 0 1 0\n3 0\n4\n0 1 1 0\n1 0 0 1\n1 0 0 1\n0 1 1 0\n1 0\n5\n0 1 0 1 0\n1 0 0 1 0\n0 0 0 0 1\n1 1 0 0 0\n0 0 1 0 0\n2 0\n5\n0 1 0 0 1\n1 0 1 1 1\n0 1 0 1 0\n0 1 1 0 1\n1 1 0 1 0\n2 4...
[ "5\ninfinity\ninfinity\n2\ninfinity\n1\n" ]
[ "6\n8\n0 1 0 0 0 0 0 0\n1 0 1 0 0 0 0 0\n0 1 0 1 1 0 0 0\n0 0 1 0 0 0 0 0\n0 0 1 0 0 1 1 0\n0 0 0 0 1 0 0 0\n0 0 0 0 1 0 0 1\n0 0 0 0 0 0 1 0\n3 0\n4\n0 1 1 0\n1 0 0 1\n1 0 0 1\n0 1 1 0\n1 0\n5\n0 1 0 1 0\n1 0 0 1 0\n0 0 0 0 1\n1 1 0 0 0\n0 0 1 0 0\n2 0\n5\n0 1 0 0 1\n1 0 1 1 1\n0 1 0 1 0\n0 1 1 0 1\n1 1 0 1 0\n2 4...
[ "5\ninfinity\ninfinity\n2\ninfinity\n1\n", "5\ninfinity\ninfinity\n2\n2\n1\n", "5\n1\ninfinity\n2\n2\n1\n", "5\n2\ninfinity\n2\ninfinity\n1\n", "5\ninfinity\n2\n2\ninfinity\n1\n", "5\ninfinity\ninfinity\n1\ninfinity\n1\n", "4\n1\ninfinity\n2\n2\n1\n", "4\ninfinity\ninfinity\n2\ninfinity\n1\n", "5\ni...
CodeContests
There is Kannon-do in the mountain behind Ichiro's house. There are 30 steps from the foot to this Kannon-do, and Ichiro goes to Kannon-do almost every day. Ichiro can go up the stairs up to 3 steps with one foot. While playing, I noticed that there are so many types of stair climbing (the number of steps to skip). So...
stdin
null
2,650
1
[ "1\n10\n20\n25\n0\n" ]
[ "1\n1\n34\n701\n" ]
[ "1\n10\n14\n25\n0\n", "1\n10\n14\n23\n0\n", "1\n10\n14\n6\n0\n", "1\n1\n20\n25\n0\n", "1\n10\n14\n24\n0\n", "1\n10\n0\n25\n0\n", "1\n19\n14\n5\n0\n", "1\n18\n0\n25\n0\n", "1\n18\n1\n25\n0\n", "1\n0\n14\n6\n0\n" ]
[ "1\n1\n1\n701\n", "1\n1\n1\n207\n", "1\n1\n1\n1\n", "1\n1\n34\n701\n", "1\n1\n1\n381\n", "1\n1\n", "1\n19\n1\n1\n", "1\n10\n", "1\n10\n1\n701\n", "1\n" ]
CodeContests
Problem statement There is an unsigned $ 2 $ decimal integer $ X $ with $ N $ in digits including Leading-zeros. Output the largest non-negative integer that can be expressed in $ 2 $ base in $ N $ digits where the Hamming distance from $ X $ is $ D $. The Hamming distance between integers expressed in $ 2 $ is the n...
stdin
null
865
1
[ "5\n00001\n3\n" ]
[ "11101\n" ]
[ "5\n00001\n4\n", "5\n00000\n3\n", "5\n00001\n1\n", "5\n10001\n1\n", "5\n10001\n2\n", "5\n10001\n4\n", "5\n10000\n1\n", "5\n00010\n1\n", "5\n00001\n0\n", "5\n00010\n0\n" ]
[ "11111\n", "11100\n", "10001\n", "11001\n", "11101\n", "11110\n", "11000\n", "10010\n", "00001\n", "00010\n" ]
CodeContests
She is an apprentice wizard. She first learned the magic of manipulating time. And she decided to open a liquor store to earn a living. It has to do with the fact that all the inhabitants of the country where she lives love alcohol. Residents especially like sake that has been aged for many years, and its value increas...
stdin
null
701
1
[ "12 3\n2 3 6\n12 4\n1 2 3 6\n0 0\n" ]
[ "6.0000000000\n0.0000000000\n" ]
[ "12 3\n2 3 6\n13 4\n1 2 3 6\n0 0\n", "12 3\n2 3 6\n12 4\n2 2 3 6\n0 0\n", "12 3\n1 4 11\n13 4\n1 2 3 6\n0 0\n", "7 3\n4 1 29\n13 4\n2 2 6 6\n0 0\n", "17 3\n2 4 11\n13 4\n1 2 3 6\n0 0\n", "15 3\n2 6 11\n13 4\n1 2 3 6\n0 0\n", "21 3\n2 3 19\n13 4\n1 2 4 6\n0 0\n", "7 3\n4 1 21\n17 4\n2 3 6 9\n0 0\n", ...
[ "6.0\n0.0\n", "6.0\n6.0\n", "0.0\n0.0\n", "0.0\n6.5\n", "8.5\n0.0\n", "7.5\n0.0\n", "10.5\n0.0\n", "0.0\n8.5\n", "3.5\n8.5\n", "2.5\n0.0\n" ]
CodeContests
View Russian Translation Tom works in a public library in his town. Today, a completely new set of N books is arriving to the library and they have to be placed on shelves, which are initially empty. A single shelf can contain at most 10 books and any two books with titles starting with different letters cannot be pu...
stdin
null
1,838
1
[ "14\nmountains\nmarvelous\nmornings\nfunctions\nmatch\ntopology\nmiracle\nminer\nmathematic\nmisery\nfastfouriertransform\nmother\nmajor\nmasterpiece\n\nSAMPLE\n" ]
[ "4\n" ]
[ "1000\ntfumsrmyoadegxickhab\nddjztukvwtpmdumzuybz\nzmizvpyznukwuocziunj\ngntnlzscuzkpeawoarjm\nsfzpdgshrxwncpdzvfhg\nimqtoqrqxzkeiveqdmym\nuqiijkjaemxwwamypieq\ntadclmjjmtmnafooasgm\nnyvtmaymqmqfjajmeofu\ndnwwsbuqnoamyjoyzizs\nystwgabzcqvqbhhjvyik\nttojlqvkhbdnppfsnlah\necnxakfrbirmunqfqksy\naawpbtlroluwzdmtdwby\ne...
[ "113\n", "4\n", "112\n", "110\n", "5\n", "6\n", "7\n", "8\n", "114\n", "109\n" ]
CodeContests
Milly is at the examination hall where she is reading a question paper. She checked the question paper and discovered that there are N questions in that paper. Each question has some score value. Ideally it's like questions requiring more time have more score value and strangely no two questions on the paper require sa...
stdin
null
2,316
1
[ "5 2\n2 3 9 4 5\n3 5 11 6 7\n5\n3\n\nSAMPLE\n" ]
[ "23\n18\n" ]
[ "1000 1000\n3181 31998 4632 1363 7992 5436 19660 27448 19149 7410 12169 2465 32499 10397 4460 23944 32202 1713 2220 24475 27484 24795 5837 20379 31605 649 25878 20226 12725 26796 9542 3816 26595 32444 27267 5415 3716 11517 3731 23742 23468 7170 30542 21875 23573 20847 20563 1725 6766 2563 3323 23008 20725 29909 180...
[ "11385840\n16558424\n9823224\n12673810\n16670364\n10757043\n9666464\n15155986\n16590427\n12386113\n2507249\n8997091\n15956297\n9206939\n12140952\n15238975\n16225766\n16316695\n15124480\n14613759\n15458625\n16683414\n15145499\n16746962\n5852925\n15458625\n16201705\n16762078\n14882952\n9621217\n16021859\n16565686\n48...
CodeContests
Multiplication of Big Integers Given two integers $A$ and $B$, compute the product, $A \times B$. Input Two integers $A$ and $B$ separated by a space character are given in a line. Output Print the product in a line. Constraints * $-1 \times 10^{1000} \leq A, B \leq 10^{1000}$ Sample Input 1 5 8 Sample Ou...
stdin
null
4,367
1
[ "5 8\n" ]
[ "40\n" ]
[ "5 16\n", "0 16\n", "-1 9\n", "-1 5\n", "-2 5\n", "-2 2\n", "-1 2\n", "-1 3\n", "1 -8\n", "1 -14\n" ]
[ "80\n", "0\n", "-9\n", "-5\n", "-10\n", "-4\n", "-2\n", "-3\n", "-8\n", "-14\n" ]
CodeContests
You are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A + B = C is correct? Input: There are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10^100), each on a separate line of input. Output: Output either "YES", if there is a way to substitute variables A, B and C wit...
stdin
null
1,674
1
[ "1\n2\n3\n\nSAMPLE\n" ]
[ "YES\n" ]
[ "30000000000000\n20000000000000\n10000000001000\n", "10000000000000000000000000000000000000000000000000000000000000000000000\n50000000000000000000000000000000000000000000000000000000000000000000000\n51196368635093263261681246014592887379763580722296941145340984054810539\n", "3000000000000000000000000000000\n206...
[ "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n" ]
CodeContests
A square pyramid of balls consists of square layers of balls stacked on top of each other. The i th (1-based indexing )layer from the top consists of exactly i^2 balls. Image You have received one such beautiful square pyramid on your birthday, with each layer having a unique color. However, being the clumsy doofus yo...
stdin
null
1,231
1
[ "5\n1 2 3 4 5\n\nSAMPLE\n" ]
[ "40\n" ]
[ "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 101 100 10...
[ "427634\n", "35\n", "427624\n", "32\n", "415843\n", "31\n", "415842\n", "415841\n", "415831\n", "415830\n" ]
CodeContests
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1. Constraints * 0 \leq N \...
stdin
null
4,458
1
[ "4\n0 0 1 0 2\n", "3\n0 1 1 2\n", "10\n0 0 1 1 2 3 5 8 13 21 34\n", "2\n0 3 1\n", "1\n1 1\n" ]
[ "10\n", "7\n", "264\n", "-1\n", "-1\n" ]
[ "4\n0 0 0 0 2\n", "3\n0 1 1 1\n", "10\n0 0 1 0 2 3 5 8 13 21 34\n", "2\n0 3 2\n", "10\n0 0 1 0 2 3 5 8 13 23 34\n", "10\n0 0 1 0 3 3 5 8 13 23 34\n", "2\n-1 3 2\n", "10\n0 0 1 1 3 3 5 8 13 23 34\n", "2\n-2 3 2\n", "4\n0 1 0 1 2\n" ]
[ "9\n", "6\n", "294\n", "-1\n", "298\n", "284\n", "7\n", "236\n", "8\n", "10\n" ]
CodeContests
Problem statement There is a tree consisting of $ N $ vertices $ N-1 $ edges, and the $ i $ th edge connects the $ u_i $ and $ v_i $ vertices. Each vertex has a button, and the button at the $ i $ th vertex is called the button $ i $. First, the beauty of the button $ i $ is $ a_i $. Each time you press the button ...
stdin
null
4,407
1
[ "4\n1 2\n1 3\n3 4\n0 3 2 0\n-3 4 5 -1\n" ]
[ "4\n" ]
[ "4\n1 2\n1 3\n1 4\n0 3 2 0\n-3 4 5 -1\n", "4\n1 2\n2 3\n1 4\n0 3 2 0\n-3 4 5 -1\n", "4\n1 2\n1 4\n3 4\n0 3 2 0\n-3 4 5 -1\n", "4\n1 2\n1 3\n1 4\n0 4 2 0\n-3 4 5 -1\n", "4\n1 2\n2 3\n1 4\n0 3 2 0\n-3 2 5 -1\n", "4\n1 2\n1 3\n3 4\n0 3 2 0\n-4 4 5 -1\n", "4\n1 2\n1 4\n3 4\n0 3 3 0\n-3 4 5 -1\n", "4\n1 2\...
[ "9\n", "18\n", "12\n", "10\n", "14\n", "4\n", "7\n", "11\n", "13\n", "8\n" ]
CodeContests
Samu is in super market and in a mood to do a lot of shopping. She needs to buy shirts, pants and shoes for herself and her family. There are N different shops. Each shop contains all these three items but at different prices. Now Samu has a strategy that she won't buy the same item from the current shop if she had alr...
stdin
null
4,813
1
[ "1\n3\n1 50 50\n50 50 50\n1 50 50\n\nSAMPLE\n" ]
[ "52\n" ]
[ "10\n82\n9414 595 5212\n2756 7474 3494\n787 9298 9010\n1897 4914 3531\n2321 8057 2194\n392 6614 2713\n2540 761 9297\n6482 693 4263\n4213 2219 7479\n1705 9724 3161\n1842 4363 7671\n1208 2195 1036\n5718 1227 595\n6438 2392 640\n1683 148 4386\n2071 5238 111\n5621 885 4033\n2265 3147 4948\n6718 6878 9234\n9533 839 2711...
[ "235603\n910909\n1695303\n411943\n1601950\n677986\n1783259\n1857123\n328292\n1882896\n", "2\n", "235603\n910909\n1695710\n411943\n1601950\n677986\n1783259\n1857123\n328292\n1882896\n", "3\n", "4\n", "235603\n910909\n1695710\n411943\n1601950\n677986\n1783259\n1857123\n328292\n1881920\n", "235603\n910909\...
CodeContests
Snuke loves permutations. He is making a permutation of length N. Since he hates the integer K, his permutation will satisfy the following: * Let the permutation be a_1, a_2, ..., a_N. For each i = 1,2,...,N, |a_i - i| \neq K. Among the N! permutations of length N, how many satisfies this condition? Since the ans...
stdin
null
3,161
1
[ "425 48\n", "4 1\n", "4 3\n", "3 1\n", "4 2\n" ]
[ "756765083\n", "5\n", "14\n", "2\n", "9\n" ]
[ "425 69\n", "7 1\n", "6 3\n", "2 1\n", "5 1\n", "319 69\n", "7 2\n", "12 3\n", "319 88\n", "10 2\n" ]
[ "291450503\n", "792\n", "265\n", "1\n", "21\n", "367840871\n", "1106\n", "101011765\n", "843077844\n", "676098\n" ]
CodeContests
Snuke is having a barbeque party. At the party, he will make N servings of Skewer Meal. <image> Example of a serving of Skewer Meal He has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i. Also, he has an infinite supply of ingredients. To make a serving of Skew...
stdin
null
1,613
1
[ "5\n100 1 2 3 14 15 58 58 58 29\n", "2\n1 3 1 2\n" ]
[ "135\n", "3\n" ]
[ "5\n100 1 2 3 14 15 58 58 9 29\n", "2\n1 3 1 1\n", "5\n100 1 2 3 1 15 58 58 9 29\n", "2\n1 2 1 2\n", "5\n100 1 2 3 1 19 40 14 9 29\n", "2\n1 2 0 1\n", "5\n110 1 2 3 1 19 40 14 1 29\n", "5\n110 1 0 3 1 19 40 14 1 29\n", "2\n2 0 0 0\n", "2\n2 -1 0 0\n" ]
[ "105\n", "2\n", "99\n", "3\n", "71\n", "1\n", "64\n", "63\n", "0\n", "-1\n" ]
CodeContests
There is an infinitely long street that runs west to east, which we consider as a number line. There are N roadworks scheduled on this street. The i-th roadwork blocks the point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5. Q people are standing at coordinate 0. The i-th person will start the coordinate 0 ...
stdin
null
3,272
1
[ "4 6\n1 3 2\n7 13 10\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n" ]
[ "2\n2\n10\n-1\n13\n-1\n" ]
[ "4 6\n1 3 2\n7 13 1\n18 20 13\n3 4 2\n0\n1\n2\n3\n5\n8\n", "4 6\n1 4 2\n8 13 1\n18 20 12\n3 4 2\n0\n1\n2\n3\n5\n8\n", "4 5\n1 4 2\n8 13 1\n18 20 12\n3 4 2\n0\n1\n2\n3\n5\n8\n", "4 5\n1 4 0\n8 13 1\n18 20 12\n3 4 2\n0\n1\n2\n3\n5\n8\n", "4 5\n0 4 0\n8 13 1\n18 36 9\n3 4 2\n0\n1\n2\n3\n5\n8\n", "4 6\n1 3 2\...
[ "2\n2\n-1\n-1\n13\n1\n", "2\n2\n-1\n-1\n-1\n1\n", "2\n2\n-1\n-1\n-1\n", "-1\n0\n0\n0\n-1\n", "0\n0\n0\n0\n-1\n", "2\n2\n10\n-1\n-1\n-1\n", "2\n2\n-1\n-1\n1\n", "2\n0\n0\n0\n-1\n", "1\n1\n1\n-1\n-1\n", "2\n10\n10\n-1\n-1\n-1\n" ]
CodeContests
Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs. In this problem, we call the greater number of a twin prime "size of the twin prime." Your task is to crea...
stdin
null
2,056
1
[ "12\n100\n200\n300\n0\n" ]
[ "5 7\n71 73\n197 199\n281 283\n" ]
[ "12\n110\n200\n300\n0\n", "12\n110\n200\n227\n0\n", "12\n110\n200\n329\n0\n", "12\n010\n200\n329\n0\n", "12\n010\n169\n329\n0\n", "12\n100\n200\n482\n0\n", "12\n110\n200\n87\n0\n", "12\n010\n200\n227\n0\n", "12\n110\n200\n239\n0\n", "12\n010\n27\n329\n0\n" ]
[ "5 7\n107 109\n197 199\n281 283\n", "5 7\n107 109\n197 199\n197 199\n", "5 7\n107 109\n197 199\n311 313\n", "5 7\n5 7\n197 199\n311 313\n", "5 7\n5 7\n149 151\n311 313\n", "5 7\n71 73\n197 199\n461 463\n", "5 7\n107 109\n197 199\n71 73\n", "5 7\n5 7\n197 199\n197 199\n", "5 7\n107 109\n197 199\n227 ...
CodeContests
DevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers. You are given the information of DevuLand by an array D of size n. If D[i] is non-negative, it means that there are D[i] villagers in that village. Otherwise, it means t...
stdin
null
1,349
1
[ "3\n2\n5 -5\n2\n-5 5\n3\n1 2 -3\n" ]
[ "5\n5\n4\n" ]
[ "3\n1\n5 -5\n2\n-5 5\n3\n1 2 -3\n", "3\n2\n5 -5\n2\n-5 5\n3\n0 3 -3\n", "3\n1\n5 -5\n1\n-5 5\n2\n1 3 -4\n", "3\n1\n5 -5\n2\n-8 8\n2\n1 2 -3\n", "3\n1\n5 -5\n1\n-5 5\n3\n1 2 -3\n", "3\n2\n5 -5\n2\n-5 5\n2\n1 2 -3\n", "3\n2\n5 -5\n1\n-5 5\n3\n1 2 -3\n", "3\n2\n5 -5\n1\n-5 5\n2\n1 2 -3\n", "3\n1\n5 -5\...
[ "5\n5\n4\n", "5\n5\n3\n", "5\n5\n5\n", "5\n8\n4\n", "5\n5\n4\n", "5\n5\n4\n", "5\n5\n4\n", "5\n5\n4\n", "5\n5\n4\n", "5\n5\n4\n" ]
CodeContests
A: A-Z Cat / A-Z Cat story Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. It's so cute. Aizu Nyan was asked by her friend Joy to take care of her cat. It is a rare cat called A-Z cat. Aizunyan named the A-Z cat he had entrus...
stdin
null
4,362
1
[ "AIZUNYANPEROPERO\n" ]
[ "AZ\n" ]
[ "AOZUNYANPERIPERO\n", "OREQIRMQEAYNUYOA\n", "OREPIREPNAYNUZOA\n", "OREPIRNPEAYNUZOA\n", "OREQIRNPEAYNUZOA\n", "OREQIRMPEAYNUZOA\n", "AOZUNYAEPMRIQERO\n", "OREQIRMQEAYNUZOA\n", "ORFQIRMQEAYNUYOA\n", "OREQIRNQEAYNUYOA\n" ]
[ "AZ\n", "-1\n", "AZ\n", "AZ\n", "AZ\n", "AZ\n", "AZ\n", "AZ\n", "-1\n", "-1\n" ]
CodeContests
The time is 1st January 20000014 Gazu is depressed with his life as he thinks there is nothing unique about him. One day he meets a travelling coder, Gazu tells him why he is depressed, to which coder replies “Everyone is one in a zillion my brother”. The coder explained it like this. Considering every man and woman m...
stdin
null
4,336
1
[ "3\n140\n310\n30\n\nSAMPLE\n" ]
[ "32\n2048\n4\n" ]
[ "3\n245\n310\n30\n\nSAMPLE\n", "3\n245\n260\n30\n\nSAMPLE\n", "3\n241\n364\n30\n\nSAMPLE\n", "3\n140\n310\n30\n\nS@MPLE\n", "3\n111\n260\n30\n\nSAMPLE\n", "3\n241\n205\n30\n\nSAMPLE\n", "3\n382\n364\n30\n\nSAMPLE\n", "3\n286\n205\n30\n\nSAMPKE\n", "3\n517\n205\n30\n\nEJPMAS\n", "3\n517\n158\n30\n\...
[ "512\n2048\n4\n", "512\n512\n4\n", "512\n8192\n4\n", "32\n2048\n4\n", "16\n512\n4\n", "512\n128\n4\n", "8192\n8192\n4\n", "1024\n128\n4\n", "262144\n128\n4\n", "262144\n64\n4\n" ]
CodeContests
Gas stations in the White Tiger service area have $ N $ lanes assigned numbers from $ 1 $ to $ N $. The first car in each lane can refuel. Cars entering the gas station will choose the lane with the fewest cars in line and line up at the end of the line. If there are multiple such lanes, choose the one with the lowest...
stdin
null
1,020
1
[ "2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 1\n0 1\n" ]
[ "1000\n999\n1002\n" ]
[ "2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 1\n1 1\n", "2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n0 2\n1 1\n", "2 7\n1 999\n1 1000\n0 2\n1 1001\n1 1002\n1 2\n1 1\n", "2 7\n1 999\n1 1000\n0 2\n1 1000\n1 1002\n0 1\n0 1\n", "2 7\n1 999\n1 1001\n0 2\n1 1001\n1 1002\n1 2\n1 1\n", "4 7\n1 999\n1 1000\n0 2\n1 000...
[ "1000\n999\n", "1000\n1001\n", "1000\n", "1000\n999\n1002\n", "1001\n", "1000\n999\n0\n", "999\n", "1000\n999\n1953\n", "1\n", "1010\n999\n0\n" ]
CodeContests
Two contries A and B have decided to make a meeting to get acquainted with each other. n ambassadors from A and B will attend the meeting in total. A round table is prepared for in the meeting. The ambassadors are getting seated at the round table, but they have agreed that more than k ambassadors from the same countr...
stdin
null
3,248
1
[ "3 1\n3 2\n3 3\n4 2\n10 5\n1000 500\n0 0\n" ]
[ "0\n2\n4\n2\n90\n570682\n" ]
[ "3 1\n3 2\n3 3\n4 2\n7 5\n1000 500\n0 0\n", "3 1\n3 2\n3 3\n6 2\n7 5\n1000 500\n0 0\n", "3 1\n6 2\n3 3\n6 2\n7 5\n1000 500\n0 0\n", "3 2\n6 2\n3 4\n6 2\n7 5\n1000 500\n0 0\n", "3 1\n6 2\n3 3\n6 2\n7 5\n1000 437\n0 0\n", "3 1\n6 4\n3 3\n6 2\n7 5\n1000 500\n0 0\n", "3 2\n6 2\n3 4\n7 2\n7 5\n1000 500\n0 0\...
[ "0\n2\n4\n2\n16\n570682\n", "0\n2\n4\n5\n16\n570682\n", "0\n5\n4\n5\n16\n570682\n", "2\n5\n4\n5\n16\n570682\n", "0\n5\n4\n5\n16\n905492\n", "0\n10\n4\n5\n16\n570682\n", "2\n5\n4\n4\n16\n570682\n", "0\n5\n4\n5\n3\n905492\n", "1\n10\n4\n5\n16\n570682\n", "2\n5\n4\n4\n16\n470025\n" ]
CodeContests
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. Constraints * 1 \leq K \leq N...
stdin
null
1,247
1
[ "4 4\n1 1 2 2\n", "5 2\n1 1 2 2 5\n", "10 3\n5 1 3 2 4 1 1 2 3 4\n" ]
[ "0\n", "1\n", "3\n" ]
[ "4 4\n0 1 2 2\n", "10 3\n5 1 3 2 4 1 2 2 3 4\n", "10 3\n5 1 3 4 8 1 2 2 3 4\n", "10 3\n3 2 3 4 8 1 2 2 3 4\n", "5 2\n2 1 4 2 1\n", "10 1\n5 1 3 2 4 1 2 2 3 8\n", "10 1\n5 2 3 2 4 1 2 2 3 8\n", "4 4\n0 1 2 4\n", "4 4\n-1 1 2 4\n", "4 4\n-2 1 2 4\n" ]
[ "0\n", "3\n", "4\n", "2\n", "1\n", "7\n", "6\n", "0\n", "0\n", "0\n" ]
CodeContests
Life is not easy. Sometimes it is beyond your control. Now, as contestants of ACM ICPC, you might be just tasting the bitter of life. But don't worry! Do not look only on the dark side of life, but look also on the bright side. Life may be an enjoyable game of chance, like throwing dice. Do or die! Then, at last, you m...
stdin
null
4,674
1
[ "1\nnorth\n3\nnorth\neast\nsouth\n0\n" ]
[ "5\n1\n" ]
[ "1\nnorth\n0\nnorth\neast\nsouth\n0\n", "1\nnorth\n3\nnorth\neasu\nsouth\n0\n", "1\nnorth\n0\nnorth\ntsae\nsouth\n0\n", "1\nnorth\n0\nnorth\ntsae\ntoush\n0\n", "1\nnorth\n0\nnorth\ntsae\ntoush\n1\n", "1\nnorth\n0\nnorth\ntase\ntoush\n1\n", "1\nnorth\n0\nnorht\neast\nsouth\n0\n", "1\nnorth\n0\nnorth\nt...
[ "5\n", "5\n1\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n" ]
CodeContests
Problem Satake doesn't like being bent. For example, I don't like pencils, chopsticks, and bent-shaped houses, and I don't like taking actions such as turning right or left. By the way, Satake who lives on the XY plane is $ N $ shops $ (X_ {1}, Y_ {1}), (X_ {2}, Y_ {2}), \ ldots, (X_ {N} , Y_ {N}) I was asked to shop...
stdin
null
1,947
1
[ "3\n1 0\n0 1\n-2 -1\n", "2\n0 1\n0 -1\n" ]
[ "386.565051\n", "450.00000000\n" ]
[ "3\n1 0\n0 1\n-2 -2\n", "2\n0 1\n-1 -2\n", "2\n0 1\n-1 -3\n", "2\n0 1\n-1 -4\n", "3\n1 1\n0 1\n-2 -1\n", "2\n0 2\n0 -1\n", "2\n1 1\n-1 -3\n", "3\n1 0\n0 1\n-2 0\n", "2\n1 0\n-1 -3\n", "2\n0 2\n1 0\n" ]
[ "405.0000000000\n", "423.4349488229\n", "431.5650511771\n", "435.9637565321\n", "386.5650511771\n", "450.0000000000\n", "378.4349488229\n", "360.0000000000\n", "288.4349488229\n", "270.0000000000\n" ]
CodeContests
Arjit has his own printing press, Bainik Dhaskar (BD). He feels that words on their own simply aren't beautiful enough. So, he wishes to make a Super Manuscript (SM) machine. Now what does this machine do? The SM machine aims to make words as beautiful as they can be by making a word as lexicographically small as possi...
stdin
null
1,035
1
[ "3\nbbbb\naaa\nzxewya\nabcd\nac\nzzzb\n\nSAMPLE\n" ]
[ "aaab\nabcdya\nab\n" ]
[ "3\nbbbb\naaa\nzxewya\nabcd\nca\nzzzb\n\nSAMPLE\n", "3\nbbbb\naaa\nzxewya\ncbad\nca\nzzza\n\nSAMPLE\n", "3\nbbbb\naaa\nzxewya\ncabe\nac\nzzza\n\nSAMPLE\n", "3\nbbbb\naaa\nzxewya\nbbcd\nca\nzzzb\n\nSAMPLE\n", "3\nbbbb\naaa\nzxewya\ncbad\ncb\nzzzb\n\nSAMPLE\n", "3\nbbbb\naaa\nzxewya\ndbad\nca\nzzza\n\nSAMPL...
[ "aaab\nabcdya\nba\n", "aaab\nabcdya\naa\n", "aaab\nabceya\naa\n", "aaab\nbbcdya\nba\n", "aaab\nabcdya\nbb\n", "aaab\nabddya\naa\n", "aaab\nabbdya\naa\n", "aaab\naaceya\naa\n", "aabb\nabddya\naa\n", "aaab\nabbdya\nac\n" ]
CodeContests
Poisonous swamp You are playing a retro role-playing game. The field of this game is a grid of 100 squares vertically and 100 squares horizontally. The cells in the xth column from the left and the yth row from the top of this field are represented as (x, y). The character you control is on one of the squares in the f...
stdin
null
3,734
1
[ "2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 10\n1 1\n100 1\n50 20\n50 80\n51 21\n51 1\n0\n" ]
[ "5\n174\n" ]
[ "2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 10\n1 1\n100 1\n53 20\n50 80\n51 21\n51 1\n0\n", "2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 18\n1 1\n100 1\n53 20\n50 80\n51 21\n51 1\n0\n", "2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 18\n1 1\n100 1\n53 3\n50 80\n51 21\n51 1\n0\n", "2\n3 3 7 7\n3 3\n7 3\n7 7\n5\n1 10 100 10\n...
[ "5\n177\n", "5\n161\n", "5\n171\n", "0\n174\n", "5\n197\n", "4\n171\n", "1\n174\n", "5\n125\n", "4\n172\n", "1\n175\n" ]
CodeContests
Champa loved traveling the world. He loved going from one city to the other. Being the miser that he is, he never wishes spend any money. Champa, instead, jumps from one city to the other. Also he likes trips of high quality. He can start at any city of his choice. Given that he has visited the i^th city, he will not ...
stdin
null
1,597
1
[ "2\n2 4\n2 1\n1 5\n3 \n\nSAMPLE\n" ]
[ "4\n0\n" ]
[ "1\n2 1000\n2 3000000\n", "2\n2 4\n2 1\n1 5\n1 \n\nSAMPLE\n", "1\n2 1000\n4 3000000\n", "1\n2 1000\n3 3000000\n", "1\n2 1000\n1 3627108\n", "2\n2 4\n3 1\n1 5\n3 \n\nSAMPLE\n", "2\n2 5\n2 1\n1 5\n1 \n\nSAMPLE\n", "1\n2 1000\n4 5861512\n", "1\n2 1010\n3 3000000\n", "2\n2 8\n3 1\n1 5\n3 \n\nSAMPLE\n"...
[ "2999998000\n", "4\n0\n", "2999996000\n", "2999997000\n", "3627107000\n", "8\n0\n", "5\n0\n", "5861508000\n", "3029996970\n", "16\n0\n" ]
CodeContests
Little Timmy is exceptionally good at math tables, so his maths teacher decided to make things a bit more interesting. His teacher takes two numbers A and B and merges the tables of A and B in sorted order (ascending order), removing the duplicates and thus creates supertable of A and B and asks Little Timmy the Nth nu...
stdin
null
3,469
1
[ "4\n3 5 2\n3 5 3\n2 3 4\n2 3 6\n\nSAMPLE\n" ]
[ "5\n6\n6\n9\n" ]
[ "4\n3 5 2\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE\n", "4\n3 5 4\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE\n", "4\n3 5 4\n2 5 3\n2 3 4\n2 3 2\n\nSAMPLE\n", "4\n3 5 6\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE\n", "4\n6 5 6\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE\n", "4\n6 5 6\n3 5 4\n2 3 4\n2 3 2\n\nSAMPLE\n", "4\n3 5 2\n3 10 3\n2 3 4\n2 3 6\n\...
[ "5\n6\n6\n3\n", "9\n6\n6\n3\n", "9\n5\n6\n3\n", "12\n6\n6\n3\n", "18\n6\n6\n3\n", "18\n9\n6\n3\n", "5\n9\n6\n9\n", "5\n9\n6\n3\n", "9\n3\n6\n3\n", "18\n4\n6\n3\n" ]
CodeContests
coastline Waves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≤ i ≤ T), a wave from point P to the point exactly xi m rushes in i second...
stdin
null
3,973
1
[ "5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n8\n4\n2\n2\n8\n1\n8\n8\n2\n5\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0\n" ]
[ "3\n0\n11\n5\n" ]
[ "5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n8\n4\n2\n2\n8\n1\n8\n8\n2\n6\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0\n", "5 2 3\n3\n5\n1\n2\n3\n3 100 100\n3\n3\n4\n20 3 8\n3\n2\n6\n1\n9\n1\n0\n4\n2\n2\n8\n1\n8\n8\n2\n6\n3\n4\n3\n8\n7 2 2\n0\n2\n5\n2\n5\n2\n1\n0 0 0\n", "5 2 1\n3\n5\n...
[ "3\n0\n11\n5\n", "3\n0\n9\n5\n", "4\n0\n11\n5\n", "3\n0\n7\n5\n", "3\n0\n19\n5\n", "2\n0\n9\n5\n", "2\n0\n7\n5\n", "3\n0\n5\n5\n", "2\n0\n11\n5\n", "3\n0\n13\n5\n" ]
CodeContests
On the way to Dandi March, Gandhijee carried a mirror with himself. When he reached Dandi, he decided to play a game with the tired people to give them some strength. At each turn of the game he pointed out a person and told him to say a number N(possibly huge) of his choice. The number was called lucky if that equals ...
stdin
null
4,573
1
[ "2\n101\n020\n\nSAMPLE\n" ]
[ "YES\nNO\n" ]
[ "100\n1740948824551711527614232216857618927954312334113883114332134597298167586122324167251171554288490471\n1427793198650286024865090061389344606618496378829119288736948166064439831600905684206820568913977241\n1598407636154209737260165754120014607177773359981881899533777717064100214575610627379024516367048951\n1660...
[ "NO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nYES\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nN...
CodeContests
In McD's Burger, n hungry burger fans are ordering burgers. The ith order is placed by the ith fan at ti time and it takes di time to procees. What is the order in which the fans will get their burgers? Input Format On the first line you will get n, the number of orders. Then n lines will follow. On the (i+1)th line,...
stdin
null
717
1
[ "5\n8 1\n4 2\n5 6\n3 1\n4 3\n\nSAMPLE\n" ]
[ "4 2 5 1 3\n" ]
[ "3\n1 3\n2 3\n6 3\n", "5\n8 1\n4 0\n5 6\n3 1\n4 3\n\nSAMPLE\n", "5\n8 1\n4 0\n1 6\n6 1\n5 3\n\nSAMPLE\n", "5\n8 2\n4 0\n1 6\n6 1\n0 3\n\nSAMPLE\n", "3\n0 5\n2 2\n1 5\n", "5\n8 2\n4 0\n1 1\n8 1\n0 3\n\nSAMPLE\n", "3\n-1 1\n2 1\n1 0\n", "5\n8 2\n8 0\n1 1\n1 1\n0 4\n\nSAMPEL\n", "5\n8 2\n8 0\n1 1\n4 1\...
[ "1 2 3\n", "2 4 5 1 3\n", "2 3 4 5 1\n", "5 2 3 4 1\n", "2 1 3\n", "3 5 2 4 1\n", "1 3 2\n", "3 4 5 2 1\n", "3 5 4 2 1\n", "3 5 2 1 4\n" ]
CodeContests
I decided to play rock-paper-scissors with a group of five good friends. Rock-paper-scissors has three hands: goo, choki, and par. If the game between goo and choki is a match between goo and choki, goo is "winning" and choki is "losing". , Par and Goo have the rule that Par is "winning" and Goo is "losing". If everyon...
stdin
null
4,079
1
[ "1\n2\n3\n2\n1\n1\n2\n2\n2\n1\n0\n" ]
[ "3\n3\n3\n3\n3\n1\n2\n2\n2\n1\n" ]
[ "1\n3\n3\n2\n1\n1\n2\n2\n2\n1\n0\n", "1\n1\n1\n2\n1\n1\n2\n2\n2\n1\n0\n", "1\n2\n3\n2\n1\n1\n1\n2\n2\n1\n0\n", "1\n2\n2\n2\n1\n1\n1\n2\n2\n1\n0\n", "1\n2\n3\n2\n1\n1\n2\n2\n2\n2\n0\n", "1\n3\n1\n2\n1\n1\n2\n1\n2\n1\n0\n", "1\n2\n3\n2\n1\n1\n2\n3\n2\n2\n0\n", "1\n2\n2\n2\n1\n1\n2\n3\n2\n2\n0\n", "1\n...
[ "3\n3\n3\n3\n3\n1\n2\n2\n2\n1\n", "1\n1\n1\n2\n1\n1\n2\n2\n2\n1\n", "3\n3\n3\n3\n3\n1\n1\n2\n2\n1\n", "1\n2\n2\n2\n1\n1\n1\n2\n2\n1\n", "3\n3\n3\n3\n3\n1\n2\n2\n2\n2\n", "3\n3\n3\n3\n3\n1\n2\n1\n2\n1\n", "3\n3\n3\n3\n3\n3\n3\n3\n3\n3\n", "1\n2\n2\n2\n1\n3\n3\n3\n3\n3\n", "1\n1\n2\n2\n1\n3\n3\n3\n3\n...
CodeContests
Problem Statement Kikuchi loves big bicycles. Today he is still riding his favorite bike on the cycling road. There are N towns in the area where he lives. Each town will be called town 1, town 2 ..., town N. The town where he lives is Town 1. Many people in this area have a hobby of cycling, and recently, cycling ro...
stdin
null
3,932
1
[ "3 3\n1 2\n2 3\n3 1\n", "4 4\n1 2\n2 3\n2 4\n3 4\n" ]
[ "No\nNo\nYes\n", "No\nNo\nNo\nNo\n" ]
[ "3 3\n1 2\n2 3\n3 2\n", "4 4\n1 1\n2 3\n2 4\n3 4\n", "4 4\n1 2\n2 3\n2 4\n1 4\n", "4 2\n1 2\n2 3\n2 4\n1 4\n", "4 2\n1 2\n2 1\n2 1\n1 1\n", "4 4\n1 3\n2 2\n2 4\n1 4\n", "4 2\n1 1\n2 2\n2 4\n1 4\n", "4 4\n1 4\n1 2\n2 4\n1 4\n", "3 3\n1 2\n2 1\n3 1\n", "4 3\n1 2\n2 3\n2 1\n1 1\n" ]
[ "No\nNo\nNo\n", "Yes\nNo\nNo\nNo\n", "No\nNo\nNo\nYes\n", "No\nNo\n", "No\nYes\n", "No\nNo\nNo\nNo\n", "Yes\nNo\n", "No\nNo\nYes\nYes\n", "No\nYes\nNo\n", "No\nNo\nYes\n" ]
CodeContests
You are an officer of the Department of Land and Transport in Oykot City. The department has a plan to build a subway network in the city central of Oykot. In the plan, n subway lines are built, and each line has two or more stations. Because of technical problems, a rail track between two stations should be straight ...
stdin
null
782
1
[ "2\n2\n0 0\n10 0\n2\n0 10\n10 10\n2\n2\n0 0\n10 10\n2\n0 10\n10 0\n3\n2\n0 0\n10 10\n2\n0 10\n10 0\n2\n1 0\n1 10\n0\n" ]
[ "1\n2\n3\n" ]
[ "2\n2\n0 0\n10 0\n2\n0 2\n10 10\n2\n2\n0 0\n10 10\n2\n0 10\n10 0\n3\n2\n0 0\n10 10\n2\n0 10\n10 0\n2\n1 0\n1 10\n0\n", "2\n1\n0 1\n10 0\n2\n0 2\n10 10\n2\n2\n0 0\n10 11\n2\n0 10\n4 0\n3\n2\n0 0\n10 10\n2\n0 10\n10 0\n2\n1 0\n1 10\n0\n", "2\n2\n0 1\n10 0\n2\n0 0\n10 10\n2\n2\n1 0\n10 11\n2\n0 10\n4 0\n3\n2\n0 0\...
[ "1\n2\n3\n", "1\n", "2\n2\n3\n", "1\n2\n2\n", "1\n2\n", "2\n", "1\n3\n", "1\n1\n2\n", "1\n2\n3\n", "1\n2\n3\n" ]
CodeContests
The city of Hakodate recently established a commodity exchange market. To participate in the market, each dealer transmits through the Internet an order consisting of his or her name, the type of the order (buy or sell), the name of the commodity, and the quoted price. In this market a deal can be made only if the pri...
stdin
null
702
1
[ "3\nPERLIS SELL A 300\nWILKES BUY A 200\nHAMMING SELL A 100\n4\nBACKUS SELL A 10\nFLOYD BUY A 20\nIVERSON SELL B 30\nBACKUS BUY B 40\n7\nWILKINSON SELL A 500\nMCCARTHY BUY C 300\nWILKINSON SELL C 200\nDIJKSTRA SELL B 100\nBACHMAN BUY A 400\nDIJKSTRA BUY A 600\nWILKINSON SELL A 300\n2\nABCD SELL X 10\nABC BUY X 15\n...
[ "A 150 150 150\n--\nHAMMING 0 150\nPERLIS 0 0\nWILKES 150 0\n----------\nA 15 15 15\nB 35 35 35\n--\nBACKUS 35 15\nFLOYD 15 0\nIVERSON 0 35\n----------\nA 350 450 550\nC 250 250 250\n--\nBACHMAN 350 0\nDIJKSTRA 550 0\nMCCARTHY 250 0\nWILKINSON 0 1150\n----------\nX 12 12 12\n--\nABC 12 0\nABCD 0 12\n----------\n--\...
[ "3\nPERLIS SELL A 300\nWILKES BUY A 200\nHAMMING SELL A 100\n4\nBACKUS SELL A 10\nFLOYD BUY A 20\nIVERSON SELL B 17\nBACKUS BUY B 40\n7\nWILKINSON SELL A 500\nMCCARTHY BUY C 300\nWILKINSON SELL C 200\nDIJKSTRA SELL B 100\nBACHMAN BUY A 400\nDIJKSTRA BUY A 600\nWILKINSON SELL A 300\n2\nABCD SELL X 10\nABC BUY X 15\n...
[ "A 150 150 150\n--\nHAMMING 0 150\nPERLIS 0 0\nWILKES 150 0\n----------\nA 15 15 15\nB 28 28 28\n--\nBACKUS 28 15\nFLOYD 15 0\nIVERSON 0 28\n----------\nA 350 450 550\nC 250 250 250\n--\nBACHMAN 350 0\nDIJKSTRA 550 0\nMCCARTHY 250 0\nWILKINSON 0 1150\n----------\nX 12 12 12\n--\nABC 12 0\nABCD 0 12\n----------\n--\...
CodeContests
This is a story in the epoch of magic. A clan of magicians lived in an artificial island built by magic power. One day, a crisis erupted on the island. An Empire ACM (Atlas Country of Magic) required unconditional surrender to them, otherwise an imperial force attacked by magical missiles to the island. However, they ...
stdin
null
663
1
[ "1 1 1\n10 15 5\n15 10 100\n0 0 0\n" ]
[ "8.000\n409.479\n861.420\n" ]
[ "1 1 1\n10 13 5\n15 10 100\n0 0 0\n", "1 1 1\n10 15 5\n15 10 100\n0 1 0\n", "1 1 1\n9 15 5\n15 10 100\n0 1 0\n", "1 2 1\n9 15 5\n15 10 100\n0 2 0\n", "1 1 1\n10 15 5\n22 10 100\n0 0 0\n", "1 1 1\n10 15 5\n15 10 110\n0 1 0\n", "1 1 1\n9 8 5\n15 10 100\n0 1 0\n", "1 2 1\n9 15 5\n15 10 101\n0 2 0\n", "...
[ "7.9999998509\n347.8845806699\n861.4202571684\n", "7.9999998509\n409.4790475872\n861.4202571684\n", "7.9999998509\n386.7357209858\n861.4202571684\n", "11.3546070534\n386.7357209858\n861.4202571684\n", "7.9999998509\n409.4790475872\n1259.1995174779\n", "7.9999998509\n409.4790475872\n912.1816925251\n", "7...