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
Find the number of the possible tuples of sequences (A_0,A_1,...,A_N) that satisfy all of the following conditions, modulo M: * For every i (0\leq i\leq N), A_i is a sequence of length i consisting of integers between 1 and K (inclusive); * For every i (1\leq i\leq N), A_{i-1} is a subsequence of A_i, that is, there e...
stdin
null
4,269
1
[ "2 2 100\n", "4 3 999999999\n", "150 150 998244353\n" ]
[ "5\n", "358\n", "186248260\n" ]
[ "4 2 100\n", "4 3 1692604129\n", "4 1 100\n", "4 0 1692604129\n", "2 2 110\n", "2 3 100\n", "300 150 998244353\n", "4 4 1692604129\n", "1 2 110\n", "3 3 110\n" ]
[ "52\n", "358\n", "1\n", "0\n", "5\n", "12\n", "274662407\n", "1304\n", "2\n", "60\n" ]
CodeContests
The city of Kyoto is a famous tourist destination for old temples and shrines. Ikta came to Kyoto sightseeing with a few friends, but as a result of all acting freely, they all got lost. So Ikta decided to think about where to meet in order to meet everyone as soon as possible. Kyoto's roads run innumerably at inter...
stdin
null
3,411
1
[ "4\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-100000000 -100000000\n", "2\n0 0\n0 1\n", "3\n5 10\n-10 0\n3 -10\n" ]
[ "200000000\n", "0.5\n", "14\n" ]
[ "4\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-195738494 -100000000\n", "2\n-1 0\n0 1\n", "3\n4 10\n-10 0\n3 -10\n", "4\n100000000 100000000\n100000000 -100000000\n-100000000 100000000\n-79841941 -100000000\n", "2\n-1 0\n0 2\n", "3\n8 10\n-10 0\n3 -10\n", "4\n100000000 100000000\n...
[ "247869247.000000000000\n", "1.000000000000\n", "13.500000000000\n", "200000000.000000000000\n", "1.500000000000\n", "15.500000000000\n", "200000050.000000000000\n", "14.000000000000\n", "200500050.000000000000\n", "11.500000000000\n" ]
CodeContests
Gilbert is the network admin of Ginkgo company. His boss is mad about the messy network cables on the floor. He finally walked up to Gilbert and asked the lazy network admin to illustrate how computers and switches are connected. Since he is a programmer, he is very reluctant to move throughout the office and examine c...
stdin
null
2,334
1
[ "4\n 0 2 2 2\n 2 0 2 2\n 2 2 0 2\n 2 2 2 0\n4\n 0 2 4 4\n 2 0 4 4\n 4 4 0 2\n 4 4 2 0\n2\n 0 12\n 12 0\n0\n", "4\n0 2 2 2\n2 0 2 2\n2 2 0 2\n2 2 2 0\n4\n0 2 4 4\n2 0 4 4\n4 4 0 2\n4 4 2 0\n2\n0 12\n12 0\n0\n" ]
[ "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n" ]
[ "4\n 0 2 2 2\n 2 0 2 2\n 2 2 0 2\n 2 2 2 0\n4\n 0 2 4 4\n 2 0 4 4\n 4 4 0 2\n 4 4 2 1\n2\n 0 12\n 12 0\n0\n", "4\n 0 2 2 2\n 2 0 2 2\n 2 2 -1 2\n 2 2 2 0\n4\n 0 2 4 4\n 2 0 4 4\n 4 4 0 2\n 4 4 2 2\n0\n 0 12\n 12 -1\n0\n", "4...
[ "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n", "4\n", "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n", "4\n2 3 3\n2 2 2 2...
CodeContests
When a boy was cleaning up after his grand father passing, he found an old paper: <image> In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing ...
stdin
null
697
1
[ "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n" ]
[ "171\n-302\n" ]
[ "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n5,59\n0,0\n", "56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0\n", "56,65\n97,54\n64,-4\n65,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0\n", "56,65\n97,54\n64,-4\n65,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n85,5...
[ "181\n-212\n", "180\n-297\n", "189\n-301\n", "190\n-291\n", "178\n-301\n", "188\n-283\n", "185\n-293\n", "172\n-301\n", "189\n-283\n", "171\n-290\n" ]
CodeContests
In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed. Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicograph...
stdin
null
4,938
1
[ "2 4\n", "5 14\n", "3 2\n" ]
[ "1 2 2 2\n", "3 3 3 3 3 3 3 3 3 3 3 3 2 2\n", "2 1\n" ]
[ "0 4\n", "8 14\n", "0 14\n", "1 14\n", "2 14\n", "2 1\n", "0 1\n", "2 5\n", "2 26\n", "2 2\n" ]
[ "0 0 0 0\n", "4 8 8 8 8 8 8 8 8 8 8 8 8 8\n", "0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "1 1 1 1 1 1 1\n", "1 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "1\n", "0\n", "1 2 2 2 2\n", "1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "1 2\n" ]
CodeContests
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n div...
stdin
null
538
1
[ "87654\n30\n", "87654\n138\n", "87654\n45678\n", "31415926535\n1\n", "1\n31415926535\n" ]
[ "10\n", "100\n", "-1\n", "31415926535\n", "-1\n" ]
[ "87654\n60\n", "87654\n178\n", "87654\n26288\n", "31415926535\n2\n", "1\n40483159044\n", "87654\n58\n", "87654\n92\n", "87654\n15577\n", "31415926535\n4\n", "87654\n114\n" ]
[ "40\n", "1152\n", "30684\n", "31415926534\n", "-1\n", "21900\n", "43782\n", "72078\n", "31415926532\n", "61\n" ]
CodeContests
Little Dipu is a small kid and like all the other kids, he likes to play, but he plays with numbers (He is extraordinary you know). Now-a-days Dipu has some extra interest in odd numbers. So, he says that a number N is interesting if it has odd number of divisors. Now Dipu turns to you and asks you to tell him how many...
stdin
null
1,836
1
[ "2\n1 3\n6 10\n\nSAMPLE\n" ]
[ "1\n1\n" ]
[ "11\n16 169\n36 255\n4 290\n24 441\n48 624\n120 1682\n101 15625\n122 1599\n226 577\n484 484\n1717 1717\n", "10002\n293 342\n37 319\n402 620\n156 781\n297 671\n121 957\n716 899\n492 982\n800 866\n168 402\n507 882\n154 293\n299 303\n586 591\n413 763\n580 674\n462 863\n493 780\n118 924\n508 832\n106 651\n124 555\n37...
[ "10\n10\n16\n17\n18\n31\n115\n28\n9\n1\n0\n", "1\n11\n4\n15\n8\n20\n3\n9\n1\n8\n7\n5\n0\n0\n7\n1\n8\n5\n20\n6\n15\n12\n19\n18\n9\n1\n7\n2\n8\n12\n3\n12\n1\n18\n6\n3\n12\n15\n14\n0\n7\n3\n3\n11\n17\n7\n7\n17\n19\n8\n6\n2\n0\n4\n16\n4\n15\n4\n14\n8\n5\n8\n2\n20\n19\n17\n5\n9\n2\n2\n9\n12\n2\n19\n2\n10\n13\n1\n6\n8\...
CodeContests
For positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x). "k!" means factorial: k! = 1 * 2 * .. * k Chef wants to calculate F(p1) + F(p2) + ... + F(pn). As answer could be large, help him, calculate value modulo m. Input First line contains two integers n and m. Next line c...
stdin
null
279
1
[ "5 7\n1 2 3 4 5\n" ]
[ "6\n" ]
[ "5 7\n1 2 3 4 4\n", "5 13\n1 2 3 4 4\n", "5 13\n1 2 0 4 4\n", "5 7\n1 2 3 4 3\n", "5 13\n1 4 3 4 4\n", "5 13\n1 3 0 4 4\n", "5 13\n1 3 0 4 6\n", "5 7\n1 0 0 5 4\n", "5 6\n0 2 4 4 6\n", "1 13\n1 17 0 4 6\n" ]
[ "1\n", "8\n", "6\n", "2\n", "0\n", "10\n", "11\n", "3\n", "4\n", "9\n" ]
CodeContests
WARNING Large input/output files. Use faster I/O. It's Galactik Football time! The Galactik Football Assosiation (GFA) has announced a football tournament between all the teams of all the planets in the galaxy (say N). Teams like Snow Kids, Shadows, Xenons, Red Tigers, Wambas, Pirates, etc. are in total enthusiasm and ...
stdin
null
595
1
[ "6 6\n1 2\n2 3\n1 3\n4 5\n5 6\n4 6\n1\n3\n5\n2\n4\n6\n", "3 1\n2 3\n1\n-1\n-1\n" ]
[ "3\n", "-1\n" ]
[ "6 6\n1 2\n2 5\n1 3\n4 5\n5 6\n4 6\n1\n3\n5\n2\n4\n6\n", "3 1\n3 3\n1\n-1\n-1\n", "6 6\n1 2\n2 3\n1 3\n4 5\n5 6\n4 6\n1\n3\n5\n2\n4\n1\n", "6 6\n1 2\n2 3\n1 3\n4 5\n5 6\n4 6\n1\n3\n8\n2\n4\n6\n", "6 6\n1 4\n1 5\n1 3\n4 5\n5 6\n4 6\n1\n3\n5\n2\n4\n6\n", "3 1\n3 3\n1\n0\n0\n", "6 6\n2 2\n1 5\n1 3\n4 5\n5 ...
[ "0\n", "-1\n", "2\n", "3\n", "4\n", "1\n", "6\n", "7\n", "5\n", "9\n" ]
CodeContests
Ringo Kingdom Congress is voting on a bill. N members are present, and the i-th member (1 ≤ i ≤ N) has w_i white ballots and b_i blue ballots. Each member i will put all the w_i white ballots into the box if he/she is in favor of the bill, and put all the b_i blue ballots into the box if he/she is not in favor of the ...
stdin
null
4,270
1
[ "5 60\n6 3\n5 9\n3 4\n7 8\n4 7\n", "4 75\n1 1\n1 1\n1 1\n1 1\n", "4 75\n1 1\n1 1\n1 1\n100 1\n" ]
[ "3\n", "3\n", "1\n" ]
[ "5 60\n6 3\n5 9\n3 4\n7 0\n4 7\n", "4 17\n1 1\n1 1\n1 1\n000 1\n", "4 75\n1 1\n1 1\n1 1\n000 2\n", "2 93\n8 3\n8 8\n3 3\n7 8\n4 7\n", "5 87\n6 3\n5 9\n3 4\n7 8\n4 7\n", "4 75\n1 1\n1 1\n1 1\n000 1\n", "5 60\n11 3\n5 9\n3 4\n7 0\n4 7\n", "5 60\n11 3\n5 9\n3 4\n13 0\n4 7\n", "4 17\n1 1\n1 1\n1 1\n001 ...
[ "3\n", "1\n", "4\n", "2\n", "5\n", "3\n", "3\n", "3\n", "1\n", "1\n" ]
CodeContests
D: XORANDORBAN Problem Statement You are given a positive integer N. Your task is to determine a set S of 2^N integers satisfying the following conditions: * All the integers in S are at least 0 and less than 2^{N+1}. * All the integers in S are distinct. * You are also given three integers X, A, and O, where 0 \le...
stdin
null
4,170
1
[ "2 6 1 5\n" ]
[ "Yes\n0 3 4 7\n" ]
[ "2 6 0 5\n", "2 6 0 6\n", "2 5 0 4\n", "2 5 1 1\n", "2 5 1 0\n", "2 4 1 4\n", "2 4 0 3\n", "3 5 1 1\n", "3 5 1 0\n", "2 4 2 4\n" ]
[ "Yes\n2 3 6 7\n", "No\n", "Yes\n1 3 5 7\n", "Yes\n0 2 4 6\n", "Yes\n2 4 5 6\n", "Yes\n0 2 5 7\n", "Yes\n4 5 6 7\n", "Yes\n0 2 4 6 8 10 12 14\n", "Yes\n2 4 5 6 8 10 12 14\n", "Yes\n0 1 6 7\n" ]
CodeContests
You are given a connected undirected simple graph, which has N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i connects vertices A_i and B_i. Your task is to find a path that satisfies the following conditions: * The path traverses two or more vertices. * The...
stdin
null
1,771
1
[ "5 6\n1 3\n1 4\n2 3\n1 5\n3 5\n2 4\n", "7 8\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n3 5\n2 6\n" ]
[ "4\n2 3 1 4\n", "7\n1 2 3 4 5 6 7\n" ]
[ "7 8\n1 4\n2 3\n3 4\n4 5\n5 6\n6 7\n3 5\n2 6\n", "5 6\n1 3\n1 4\n2 3\n1 5\n3 5\n3 4\n", "7 8\n1 4\n2 4\n3 4\n4 5\n5 6\n6 7\n3 5\n2 6\n", "7 8\n1 4\n2 3\n3 4\n4 1\n5 6\n1 7\n3 6\n2 6\n", "5 6\n1 3\n1 4\n2 3\n1 5\n2 5\n3 4\n", "7 7\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n3 5\n2 6\n", "7 8\n1 4\n3 3\n3 4\n4 5\n5 6\...
[ "6\n5 6 2 3 4 1\n", "4\n2 3 1 4\n", "6\n3 5 6 2 4 1\n", "7\n5 6 2 3 4 1 7\n", "5\n5 2 3 1 4\n", "7\n7 6 5 4 3 2 1\n", "6\n7 6 5 3 4 1\n", "6\n7 6 2 3 4 1\n", "6\n5 6 3 4 1 7\n", "5\n4 2 3 1 5\n" ]
CodeContests
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible. <image> We wil...
stdin
null
4,511
1
[ "5\n5\n0\n" ]
[ "5\n4 1\n3 2\n3 1 1\n2 2 1\n2 1 1 1\n1 1 1 1 1\n5\n4 1\n3 2\n3 1 1\n2 2 1\n2 1 1 1\n1 1 1 1 1\n" ]
[ "5\n8\n0\n", "5\n6\n0\n", "5\n7\n0\n", "5\n4\n0\n", "5\n3\n0\n", "5\n0\n0\n", "5\n9\n0\n", "5\n14\n0\n", "5\n1\n0\n", "5\n2\n0\n" ]
[ "5\n4 1\n3 2\n3 1 1\n2 2 1\n2 1 1 1\n1 1 1 1 1\n8\n7 1\n6 2\n6 1 1\n5 3\n5 2 1\n5 1 1 1\n4 4\n4 3 1\n4 2 2\n4 2 1 1\n4 1 1 1 1\n3 3 2\n3 3 1 1\n3 2 2 1\n3 2 1 1 1\n3 1 1 1 1 1\n2 2 2 2\n2 2 2 1 1\n2 2 1 1 1 1\n2 1 1 1 1 1 1\n1 1 1 1 1 1 1 1\n", "5\n4 1\n3 2\n3 1 1\n2 2 1\n2 1 1 1\n1 1 1 1 1\n6\n5 1\n4 2\n4 1 1\n3...
CodeContests
Snuke is buying a lamp. The light of the lamp can be adjusted to m levels of brightness, represented by integers from 1 through m, by the two buttons on the remote control. The first button is a "forward" button. When this button is pressed, the brightness level is increased by 1, except when the brightness level is m...
stdin
null
2,405
1
[ "4 6\n1 5 1 4\n", "10 10\n10 9 8 7 6 5 4 3 2 1\n" ]
[ "5\n", "45\n" ]
[ "10 10\n10 9 8 7 6 7 4 3 2 1\n", "4 8\n1 5 1 4\n", "10 10\n10 9 8 7 1 7 4 3 2 1\n", "4 8\n1 5 1 5\n", "2 10\n10 9 8 7 1 7 4 3 2 1\n", "1 8\n1 5 2 1\n", "4 19\n10 9 3 9 2 14 4 0 4 1\n", "7 19\n10 9 3 9 2 14 4 0 4 1\n", "7 19\n2 9 3 9 2 14 4 0 4 1\n", "7 19\n2 9 3 18 2 14 4 0 4 1\n" ]
[ "39\n", "7\n", "36\n", "6\n", "1\n", "0\n", "14\n", "32\n", "31\n", "34\n" ]
CodeContests
After a furious battle Pirate Jack won a battle against Captain Luthur. Pirate Jack found a golden chest from Luthur's treasures. But the problem is that Luthur's coders have locked this chest. You have found the function which Luthurs Coders wrote to lock this chest: void hack(string s) { for(int i = s.length()-1...
stdin
null
1,999
1
[ "hack\n\nSAMPLE\n" ]
[ "-105 -98 -100 -108\n" ]
[ "hkca\n", "hkba\n", "hjca\n\nSAMPLE\n", "hbka\n", "hbkb\n", "hbjb\n", "bkbh\n", "bkbi\n", "bibk\n", "ackh\n\nELNPAR\n" ]
[ "-105 -108 -100 -98\n", "-105 -108 -99 -98\n", "-105 -107 -100 -98\n", "-105 -99 -108 -98\n", "-105 -99 -108 -99\n", "-105 -99 -107 -99\n", "-99 -108 -99 -105\n", "-99 -108 -99 -106\n", "-99 -106 -99 -108\n", "-98 -100 -108 -105\n" ]
CodeContests
You are now in a bookshop with your friend Alice to buy a book, "The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money from Alice in case the amount you have falls short of the price. If the amount you receive from Alice s...
stdin
null
1,453
1
[ "5000 3000 4500\n", "1000 3000 3000\n", "500 1000 2000\n" ]
[ "0\n", "2000\n", "NA\n" ]
[ "5000 3000 4771\n", "1000 3000 1844\n", "20 1000 2000\n", "1000 3000 1508\n", "1000 3000 2582\n", "1001 6683 2582\n", "0001 7742 2582\n", "0101 7742 2582\n", "0011 7619 2582\n", "1011 7619 2582\n" ]
[ "0\n", "844\n", "NA\n", "508\n", "1582\n", "1581\n", "2581\n", "2481\n", "2571\n", "1571\n" ]
CodeContests
Let us see how search engines work. Consider the following simple auto complete feature. When you type some characters in the text bar, the engine automatically gives best matching options among it's database. Your job is simple. Given an incomplete search text, output the best search result. Each entry in engine's da...
stdin
null
3,750
1
[ "2 1\nhackerearth 10\nhackerrank 9\nhacker\n\nSAMPLE\n" ]
[ "10\n" ]
[ "2 1\nhackerearth 10\nhackerrank 11\nhacker\n\nSAMPLE\n", "2 1\nhackerearth 10\nhackerrank 20\nhacker\n\nSAMPLE\n", "2 1\nhackerearth 10\nhackerrank 20\nhadker\n\nSAMPLE\n", "1 2\nhackdrearth 10\nhackerranl 27\neadkhr\n\nSAMPLE\n", "2 1\nhackerearth 0\nhackerrank 21\nhacker\n\nELPMAS\n", "0 3\nhackdrearth...
[ "11\n", "20\n", "-1\n", "-1\n-1\n", "21\n", "-1\n-1\n-1\n", "9\n", "-1\n", "-1\n", "-1\n" ]
CodeContests
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen at ...
stdin
null
2,480
1
[ "3\n100000\n30000\n20000\n", "2\n1\n2\n" ]
[ "second\n", "first\n" ]
[ "3\n100000\n30000\n29639\n", "2\n0\n2\n", "2\n1\n0\n", "3\n000000\n30000\n29639\n", "2\n1\n1\n", "3\n000001\n30000\n29639\n", "2\n2\n1\n", "3\n000011\n30000\n29639\n", "3\n000010\n30000\n29639\n", "2\n2\n2\n" ]
[ "first\n", "second\n", "first\n", "first\n", "first\n", "first\n", "first\n", "first\n", "first\n", "second\n" ]
CodeContests
problem Hanako is playing with n (4 ≤ n ≤ 10) cards side by side. Each card has one integer between 1 and 99. Hanako chose k cards (2 ≤ k ≤ 4) from these cards and arranged them in a horizontal row to make an integer. How many kinds of integers can Hanako make in total? For example, consider that you are given five c...
stdin
null
700
1
[ "4\n2\n1\n2\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0\n" ]
[ "7\n68\n" ]
[ "4\n2\n1\n3\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0\n", "4\n2\n1\n3\n12\n1\n6\n3\n11\n2\n12\n7\n2\n1\n0\n0\n", "4\n2\n0\n5\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0\n", "4\n2\n1\n3\n12\n1\n6\n3\n9\n2\n12\n7\n2\n1\n0\n0\n", "4\n1\n1\n3\n12\n1\n6\n3\n9\n2\n12\n7\n2\n1\n0\n0\n", "4\n2\n1\n1\n12\n1\n6\n3\n72\n2\n...
[ "7\n68\n", "7\n61\n", "12\n68\n", "7\n71\n", "3\n71\n", "3\n68\n", "24\n68\n", "4\n68\n", "24\n71\n", "3\n72\n" ]
CodeContests
In the year 20XX, mankind is hit by an unprecedented crisis. The power balance between the sun and the moon was broken by the total eclipse of the sun, and the end is looming! To save the world, the secret society called "Sun and Moon" decided to perform the ritual to balance the power of the sun and the moon called "R...
stdin
null
1,461
1
[ "2\n1 1\n0 -1\n", "9\n2 1\n1 -1\n1 -1\n1 -1\n1 -1\n0 1\n0 1\n0 1\n0 1\n" ]
[ "No\n", "Yes 2\n" ]
[ "2\n1 1\n1 -1\n", "9\n2 1\n1 -1\n1 -1\n1 -1\n1 -1\n0 1\n0 1\n0 2\n0 1\n", "9\n2 1\n1 -1\n1 -1\n1 -1\n1 -1\n0 1\n0 0\n0 2\n0 1\n", "2\n1 1\n1 -2\n", "9\n2 1\n1 -1\n1 -1\n1 -1\n2 -1\n0 1\n0 1\n0 2\n0 1\n", "2\n1 0\n1 -2\n", "9\n2 1\n1 -1\n0 -1\n1 -1\n2 -1\n0 1\n0 1\n0 2\n0 1\n", "2\n1 0\n1 -3\n", "9\n...
[ "Yes 1\n", "No\n", "Yes 2\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "Yes 1\n" ]
CodeContests
Find the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter. Constraints * 2\leq K\leq 100 * K is an integer. Input Input is given from Standard Input in the following format: K Output Print the number of ways to...
stdin
null
4,151
1
[ "6\n", "50\n", "11\n", "3\n" ]
[ "9\n", "625\n", "30\n", "2\n" ]
[ "2\n", "59\n", "14\n", "0\n", "104\n", "7\n", "4\n", "51\n", "5\n", "10\n" ]
[ "1\n", "870\n", "49\n", "0\n", "2704\n", "12\n", "4\n", "650\n", "6\n", "25\n" ]
CodeContests
D: Sontaku (Surmise) Some twins like even numbers. Count how many even numbers are in $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $. input The integer $ N $ is given on the first line. On the second line, $ N $ integers $ A_1, A_2, A_3, \ dots, A_N $ are given, separated by blanks. output Output an even number. ...
stdin
null
3,175
1
[ "5\n4 3 5 2 6\n" ]
[ "3\n" ]
[ "5\n4 3 5 2 8\n", "5\n4 3 1 2 9\n", "5\n5 12 0 2 18\n", "5\n2 12 0 2 18\n", "5\n5 3 5 2 11\n", "5\n1 47 1 5 9\n", "5\n4 3 1 2 8\n", "5\n4 6 1 2 9\n", "5\n4 12 1 2 9\n", "5\n5 12 1 2 9\n" ]
[ "3\n", "2\n", "4\n", "5\n", "1\n", "0\n", "3\n", "3\n", "3\n", "2\n" ]
CodeContests
You have obtained the Izua Japanese dictionary, which is the official language of Izua, and the Izua alphabet (list of letters). There are N types of letters in the Izua alphabet. The order of the words that appear in the Izua Japanese dictionary is in the alphabetical order of Izua. Looking at the dictionary, I found...
stdin
null
3,642
1
[ "3\n2\n1 2\n2 3\n4\n2\n2 3\n2 4\n0\n" ]
[ "3\n4\n" ]
[ "3\n2\n1 2\n2 1\n4\n2\n2 3\n2 4\n0\n", "3\n2\n1 2\n2 1\n4\n2\n2 2\n2 4\n0\n", "3\n2\n1 2\n3 1\n4\n2\n2 2\n2 4\n0\n", "3\n2\n1 2\n3 1\n4\n2\n2 2\n1 4\n0\n", "3\n2\n1 2\n2 1\n4\n2\n2 2\n4 4\n0\n", "3\n2\n1 1\n3 1\n4\n2\n2 2\n1 4\n0\n", "3\n2\n1 2\n1 1\n4\n2\n2 3\n2 4\n0\n", "3\n2\n1 2\n3 1\n4\n2\n4 2\n2...
[ "0\n4\n", "0\n5\n", "4\n5\n", "4\n21\n", "0\n0\n", "5\n21\n", "2\n4\n", "4\n0\n", "4\n19\n", "2\n0\n" ]
CodeContests
Problem: You are given n natural numbers a1,a2,a3…… an. Let SOD of a number be defined as the Sum of Digits of that number. Compute the value of { [ SOD(a1) + SOD(a2) + …….. SOD(an) ] % 9 } – { [ SOD( a1 + a2 + ….. an ) ] % 9 } Input: The first line consists of the value of n. Next n lines are such that the i th li...
stdin
null
1,161
1
[ "3\n1\n2\n3\n\nSAMPLE\n" ]
[ "0\n" ]
[ "5066\n6776320\n44\n91507131\n67679\n300\n85\n103702790\n550\n10237169730\n9526527231\n558013\n294966651\n25\n72347\n210\n2\n9082\n8\n14576958\n55155303\n27\n1094955151\n8591228067\n5219679\n23661\n60\n1914849\n37540\n1945\n95667644\n173280\n82547\n4833069122\n9684449087\n899\n696846786\n4\n2621873\n1050500\n865485...
[ "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
B: Tetris problem Consider a board consisting of a rectangle with 4 squares x 10 squares. A square of 1 square x 1 square is called a block. Tetromino is a combination of four blocks, and there are the following seven types (and those that have been rotated 90 degrees arbitrarily). <image> Now, consider the situat...
stdin
null
1,425
1
[ "2 3\n##.\n.##\n2 3\n#..\n###\n1 4\n####\n2 3\n###\n.#.\n2\n####....##\n####...###\n####..####\n####...###\n###..#####\n###...####\n###...####\n###....###\n" ]
[ "Yes\nYes\n" ]
[ "2 3\n##.\n.##\n2 3\n#..\n###\n1 4\n####\n2 3\n###\n.#.\n2\n####....##\n####...###\n####..####\n###...####\n###..#####\n###...####\n###...####\n###....###\n", "2 3\n##.\n.##\n2 3\n..#\n###\n1 4\n####\n2 3\n###\n.#.\n2\n####....##\n####...#\"#\n####..####\n###...####\n###..#####\n###...####\n###...####\n###....###...
[ "No\nYes\n", "No\nNo\n", "No\n", "Yes\nNo\n", "No\nYes\n", "No\nYes\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n" ]
CodeContests
Write a program which replace all the lower-case letters of a given text with the corresponding captital letters. Input A text including lower-case letters, periods, and space is given in a line. The number of characters in the text is less than or equal to 200. Output Print the converted text. Example Input t...
stdin
null
3,046
1
[ "this is a pen.\n" ]
[ "THIS IS A PEN.\n" ]
[ "this is b pen.\n", "tiis is b pen.\n", "tiis is a pen.\n", "tiis it a pen.\n", "tiis it a pem.\n", "tiis it a .mep\n", "tiis it b .mep\n", "tiis it b pem.\n", "tiis it b qem.\n", "tiis ti b qem.\n" ]
[ "THIS IS B PEN.\n", "TIIS IS B PEN.\n", "TIIS IS A PEN.\n", "TIIS IT A PEN.\n", "TIIS IT A PEM.\n", "TIIS IT A .MEP\n", "TIIS IT B .MEP\n", "TIIS IT B PEM.\n", "TIIS IT B QEM.\n", "TIIS TI B QEM.\n" ]
CodeContests
You are given a square matrix of size n (it will be an odd integer). Rows are indexed 0 to n-1 from top to bottom and columns are indexed 0 to n-1 form left to right. Matrix consists of only '*' and '.'. '*' appears only once in the matrix while all other positions are occupied by '.' Your task is to convert this matr...
stdin
null
132
1
[ "1\n7\n.......\n.*.....\n.......\n.......\n.......\n.......\n.......\n\nSAMPLE\n" ]
[ "4\n" ]
[ "1\n7\n.......\n.*.....\n.......\n.......\n.......\n.......\n.......\n\nSAMQLE\n", "1\n5\n.......\n.*.....\n.......\n..-..-.\n.......\n.......\n....../\n\nSALPLE\n", "1\n7\n....../\n..*..//\n../....\n./-.--.\n....-..\n.......\n./.....\n\nTAMPME\n", "1\n7\n.......\n.*.....\n.......\n.......\n.......\n.......\n...
[ "4\n", "2\n", "3\n", "4\n", "4\n", "4\n", "4\n", "4\n", "4\n", "4\n" ]
CodeContests
I bought food at the store to make a lunch box to eat at lunch. At the store, I only got an elongated bag to put food in, so I had to stack all the food vertically and put it in the bag. I want to pack the bag with the heavy ones down so that it won't fall over, but some foods are soft and will collapse if I put a heav...
stdin
null
4,000
1
[ "4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 100 500\nchocolate 50 350\ncookie 30 80\npurin 40 400\ncracker 40 160\n0\n" ]
[ "apple\ncake\nsandwich\ncheese\nkanzume\npurin\nchocolate\nonigiri\nonigiri\nanpan\nmikan\ncracker\ncookie\n" ]
[ "4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan 70 280\nmikan 50 80\nkanzume 100 500\nchocolaue 50 350\ncookie 30 80\npurin 40 400\ncracker 40 160\n0\n", "4\nsandwich 80 120\napple 50 200\ncheese 20 40\ncake 100 100\n9\nonigiri 80 300\nonigiri 80 300\nanpan ...
[ "apple\ncake\nsandwich\ncheese\nkanzume\npurin\nchocolaue\nonigiri\nonigiri\nanpan\nmikan\ncracker\ncookie\n", "apple\ncake\nsandwich\ncheese\nkanzume\npurin\nchocolate\nonigiri\nonigiri\nanpan\nmikan\ncracker\ncookie\n", "apple\ncake\nsandwich\ncheese\nkanyume\npurin\nchocolaue\nonigiri\nonigiri\nanpan\nmikan\...
CodeContests
In AD 3456, the earth is too small for hundreds of billions of people to live in peace. Interstellar Colonization Project with Cubes (ICPC) is a project that tries to move people on the earth to space colonies to ameliorate the problem. ICPC obtained funding from governments and manufactured space colonies very quickly...
stdin
null
1,619
1
[ "0 0 0 3 3 3\n###\n###\n###\n###\n###\n###\n###\n###\n###\n3 3 0 0 0 3\n#..\n###\n###\n###\n###\n###\n#.#\n###\n###\n0 0 2 2 2 2\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n0 1 2 2 1 1\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n3 2 0 2 3 2\n###\n..#\n...\n..#\n...\n.#.\n..#\n..#\n.##\n0 0 0 0 0 0\n" ]
[ "6.70820393249936941515\n6.47870866461907457534\n2.82842712474619029095\n2.23606797749978980505\n2.82842712474619029095\n" ]
[ "0 0 0 3 3 3\n###\n###\n###\n###\n###\n###\n###\n###\n###\n3 3 0 0 0 3\n$..\n###\n###\n###\n###\n###\n#.#\n###\n###\n0 0 2 2 2 2\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n0 1 2 2 1 1\n...\n...\n...\n.#.\n#..\n...\n##.\n##.\n...\n3 2 0 2 3 2\n###\n..#\n...\n..#\n...\n.#.\n..#\n..#\n.##\n0 0 0 0 0 0\n", "0 0 0 ...
[ "6.70820393249936852698\n6.47870866461907457534\n2.82842712474619029095\n2.23606797749978980505\n2.82842712474619029095\n", "6.70820393249936852698\n6.47870866461907457534\n2.82842712474619029095\n2.82842712474619029095\n2.82842712474619029095\n", "6.70820393249936852698\n6.43397840021017941581\n2.8284271247461...
CodeContests
A direced graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable. Constraints * 1 ≤ |V| ≤ 10,000 * 0 ≤ |E| ≤ 30,000 * 1 ≤ Q ≤ 100,000 Input A directed graph G(V, E) and a sequence of...
stdin
null
1,706
1
[ "5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n" ]
[ "1\n0\n1\n1\n" ]
[ "5 6\n0 1\n1 0\n0 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n", "5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 0\n3 4\n", "5 6\n0 1\n1 0\n1 2\n2 4\n4 0\n3 2\n4\n0 1\n0 3\n2 0\n3 4\n", "5 6\n0 1\n1 0\n1 2\n2 4\n1 1\n3 2\n4\n0 1\n0 3\n2 0\n3 4\n", "7 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n1 2\n0 3\n2 3\n3 4\n"...
[ "1\n0\n1\n1\n", "1\n0\n0\n1\n", "1\n0\n1\n0\n", "1\n0\n0\n0\n", "0\n0\n1\n1\n", "0\n0\n0\n0\n", "1\n1\n1\n0\n", "1\n0\n0\n", "0\n0\n1\n0\n", "1\n1\n0\n0\n" ]
CodeContests
D: Shiritori Compression problem Ebi-chan and Kana-chan did a shiritori. Ebi-chan is looking at the memo of the word that came out in Shiritori. Ebi-chan wants to remove redundant continuous subsequences from this word sequence w_1, w_2, ..., w_N until they no longer exist. The redundant continuous subsequence that ...
stdin
null
1,343
1
[ "7\nbanana\nat\ntomb\nbus\nsound\ndoes\nsome\n" ]
[ "2\n" ]
[ "7\nbanana\nta\ntomb\nbus\nsound\ndoes\nsome\n", "7\nananab\nta\nsomb\nbus\nsound\ndoes\nsemo\n", "7\nbanaoa\nta\ntomb\nbus\nsound\ndoes\nsome\n", "7\nbanaoa\nta\nuomb\nbus\nsound\ndoes\nsome\n", "7\nbanaoa\nua\ntomb\nbus\nsound\ndoes\nsome\n", "7\nbanaoa\nua\ntomb\nbus\nspund\ndoes\nsome\n", "7\nbanaoa...
[ "2\n", "3\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n" ]
CodeContests
Ikshu and his class Ikshu's class is very fond of playing games. Their teacher tied them with many ropes with each other, Such that each student is tied with exactly one rope. It means that if students 2 and 3 are connected and 2 is connected to 4 as well then 2,3 and 4 must be sharing the same rope. Now, teacher ask...
stdin
null
362
1
[ "5 2\n1 2\n3 4\n\nSAMPLE\n" ]
[ "4\n" ]
[ "5 2\n0 2\n3 4\n\nSAMPLE\n", "7 0\n0 2\n3 4\n\nSAMPLE\n", "7 2\n0 0\n3 4\n\nSAMPLE\n", "5 2\n1 4\n3 4\n\nSAMPLE\n", "7 2\n0 2\n3 4\n\nSAMPLE\n", "7 0\n0 2\n3 4\n\nELPMAS\n", "0 0\n0 2\n3 4\n\nELPMAS\n", "0 0\n0 2\n1 4\n\nELPMAS\n", "0 0\n0 2\n1 5\n\nELPMAS\n", "0 0\n0 0\n1 5\n\nELPMAS\n" ]
[ "4\n", "1\n", "2\n", "6\n", "4\n", "1\n", "1\n", "1\n", "1\n", "1\n" ]
CodeContests
Have you ever implemented a program adding two big integers that cannot be represented by the primitive data type of your programming language? The algorithm is just simulation of the column addition method that we have been taught in elementary school. Sometimes we forget the carry and the result is incorrect. In th...
stdin
null
2,708
1
[ "3\n1\n2\n3\n" ]
[ "0.45\n0.945\n1.4445\n" ]
[ "3\n1\n2\n5\n", "3\n1\n2\n6\n", "3\n1\n1\n6\n", "3\n1\n2\n11\n", "3\n1\n1\n11\n", "3\n1\n0\n11\n", "3\n1\n0\n9\n", "3\n1\n0\n16\n", "3\n0\n0\n16\n", "3\n0\n0\n32\n" ]
[ "0.45\n0.945\n2.444445\n", "0.45\n0.945\n2.9444445\n", "0.45\n0.45\n2.9444445\n", "0.45\n0.945\n5.44444444445\n", "0.45\n0.45\n5.44444444445\n", "0.45\n0.0\n5.44444444445\n", "0.45\n0.0\n4.4444444445\n", "0.45\n0.0\n7.94444444444\n", "0.0\n0.0\n7.94444444444\n", "0.0\n0.0\n15.9444444444\n" ]
CodeContests
There are N piles of candies on the table. The piles are numbered 1 through N. At first, pile i contains a_i candies. Snuke and Ciel are playing a game. They take alternating turns. Snuke goes first. In each turn, the current player must perform one of the following two operations: 1. Choose a pile with the largest n...
stdin
null
4,941
1
[ "3\n1 2 1\n", "2\n1 3\n", "3\n1 2 3\n" ]
[ "First\n", "First\n", "Second\n" ]
[ "3\n1 0 1\n", "2\n0 3\n", "3\n1 1 3\n", "3\n2 0 1\n", "3\n1 1 4\n", "3\n3 0 1\n", "3\n1 0 4\n", "3\n5 0 1\n", "3\n0 0 4\n", "3\n1 0 2\n" ]
[ "First\n", "Second\n", "Second\n", "First\n", "First\n", "First\n", "First\n", "First\n", "First\n", "First\n" ]
CodeContests
In April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it is difficult to breed, so the production volume is small and the price is high. <image> Relative...
stdin
null
1,331
1
[ "48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5680 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558 1396 187 17\n279 88677 4522 514 14\n0\n" ]
[ "28 20\n7 13\n15 33\nNA\n97 0\n12 44\nNA\nNA\n" ]
[ "48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5680 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558 1396 187 17\n279 88677 2825 514 14\n0\n", "48 9297 240 126 32\n20 3010 157 141 7\n30 117002 5843 962 15\n8 1673 1712 190 22\n64 8478 87 54 307\n23 5477 117 92 12\n50 7558 1396 187 17\n2...
[ "28 20\n7 13\n15 33\nNA\n97 0\n12 44\nNA\nNA\n", "28 20\n7 13\n15 30\nNA\n97 0\n12 44\nNA\nNA\n", "28 20\n7 13\n15 30\nNA\n47 17\n12 44\nNA\nNA\n", "28 20\n7 13\n15 30\nNA\n47 17\n12 92\nNA\nNA\n", "28 20\n7 16\n15 30\nNA\n47 17\n12 92\nNA\nNA\n", "28 20\n7 16\n7 25\nNA\n47 17\n12 92\nNA\nNA\n", "28 20\...
CodeContests
Given is a positive integer N. Find the number of pairs (A, B) of positive integers not greater than N that satisfy the following condition: * When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B. Con...
stdin
null
2,399
1
[ "2020\n", "200000\n", "25\n", "100\n", "1\n" ]
[ "40812\n", "400000008\n", "17\n", "108\n", "1\n" ]
[ "73\n", "3093\n", "50\n", "101\n", "0\n", "11\n", "1020\n", "78\n", "001\n", "6\n" ]
[ "63\n", "95976\n", "33\n", "113\n", "0\n", "12\n", "10412\n", "72\n", "1\n", "6\n" ]
CodeContests
In order to pass the entrance examination tomorrow, Taro has to study for T more hours. Fortunately, he can leap to World B where time passes X times as fast as it does in our world (World A). While (X \times t) hours pass in World B, t hours pass in World A. How many hours will pass in World A while Taro studies fo...
stdin
null
1,285
1
[ "1 100\n", "99 1\n", "8 3\n" ]
[ "0.0100000000\n", "99.0000000000\n", "2.6666666667\n" ]
[ "8 2\n", "8 4\n", "8 6\n", "8 9\n", "14 9\n", "14 4\n", "14 5\n", "13 5\n", "13 9\n", "13 18\n" ]
[ "4.0\n", "2.0\n", "1.33333333333\n", "0.888888888889\n", "1.55555555556\n", "3.5\n", "2.8\n", "2.6\n", "1.44444444444\n", "0.722222222222\n" ]
CodeContests
Bridge Construction Planning There is a city consisting of many small islands, and the citizens live in these islands. Citizens feel inconvenience in requiring ferry rides between these islands. The city mayor decided to build bridges connecting all the islands. The city has two construction companies, A and B. The m...
stdin
null
1,738
1
[ "4 5 2\n1 2 2 A\n1 3 2 A\n1 4 2 A\n2 3 1 B\n3 4 1 B\n5 8 2\n1 2 1 A\n2 3 1 A\n3 4 3 A\n4 5 3 A\n1 2 5 B\n2 3 5 B\n3 4 8 B\n4 5 8 B\n5 5 1\n1 2 1 A\n2 3 1 A\n3 4 1 A\n4 5 1 B\n3 5 1 B\n4 5 3\n1 2 2 A\n2 4 3 B\n3 4 4 B\n2 3 5 A\n3 1 6 A\n0 0 0\n" ]
[ "5\n16\n-1\n-1\n" ]
[ "4 5 2\n1 2 2 A\n1 3 2 A\n1 4 2 A\n2 3 1 B\n3 4 1 B\n5 8 2\n1 2 1 A\n2 3 1 A\n3 4 3 A\n4 5 3 A\n1 2 5 B\n2 5 5 B\n3 4 8 B\n4 5 8 B\n5 5 1\n1 2 1 A\n2 3 1 A\n3 4 1 A\n4 5 1 B\n3 5 1 B\n4 5 3\n1 2 2 A\n2 4 3 B\n3 4 4 B\n2 3 5 A\n3 1 6 A\n0 0 0\n", "4 5 2\n1 2 2 A\n1 3 2 A\n1 4 2 A\n2 3 1 B\n3 4 1 B\n5 8 2\n1 2 1 A\...
[ "5\n14\n-1\n-1\n", "5\n16\n-1\n-1\n", "5\n17\n-1\n-1\n", "4\n17\n-1\n-1\n", "5\n15\n-1\n-1\n", "5\n12\n-1\n-1\n", "5\n-1\n-1\n-1\n", "3\n17\n-1\n-1\n", "7\n14\n-1\n-1\n", "5\n10\n-1\n-1\n" ]
CodeContests
Takahashi is playing with N cards. The i-th card has an integer X_i on it. Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions: * The integers on the two cards are the same. * The sum of the integers on the two cards is a multiple of M. Find the maximum numb...
stdin
null
4,863
1
[ "7 5\n3 1 4 1 5 9 2\n", "15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 99 99\n" ]
[ "3\n", "6\n" ]
[ "7 5\n3 1 4 1 5 9 3\n", "15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 83 99\n", "15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 83 56\n", "15 10\n1 5 6 10 11 11 11 20 21 25 25 26 99 124 99\n", "7 5\n3 1 4 1 5 8 3\n", "15 10\n1 5 6 10 11 11 11 20 21 1 25 26 99 124 99\n", "7 8\n4 2 5 1 5 9 3\n", "7 5\n3 1 4 1...
[ "3\n", "5\n", "4\n", "6\n", "2\n", "7\n", "1\n", "3\n", "3\n", "3\n" ]
CodeContests
There is an ice cream shop named Ten Ice Cream. At this store, we always have 10 types of ice cream on the shelves. The store manager creates a daily graph showing how well ice cream is selling for reference in product development. For such a store manager, you decided to create a program that displays the number of e...
stdin
null
4,469
1
[ "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0\n" ]
[ "*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n" ]
[ "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n4\n2\n3\n9\n1\n5\n0\n", "15\n2\n6\n7\n0\n0\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0\n", "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n4\n2\n3\n9\n1\n2\n0\n", "15\n2\n6\n7\n0\n0\n9\n8\n7\n3\n8\n9\n8\n8\n2\n2\n3\n9\n1\n5\n0\n", "15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9...
[ "*\n*\n**\n*\n**\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n", "**\n-\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n", "*\n*\n**\n*\n**\n-\n*\n**\n***\n**\n-\n*\n*\n-\n-\n-\n-\n-\n-\n*\n", "**\n-\n***\n*\n-\n-\n*\n**\n****\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*\n", "*\n*\n**\n*\n**\n-\n*\n*...
CodeContests
The state space of the output of this problem (and as a matter of fact, all the problems in this Cook-Off) is - 2 to the power T - where T is the number of test cases (so be extra careful!). Each test case consists of T lines consisting of "YES" or "NO". If a test case accurately represents the output that you would pr...
stdin
null
955
1
[ "2\nNO\nNO\nNO\nYES\n" ]
[ "NO\nYES\n" ]
[ "2\nNO\nON\nNO\nYES\n", "2\nNN\nNL\nON\nXES\n", "2\nNO\nNN\nNO\nYES\n", "2\nNN\nON\nNO\nYES\n", "2\nNN\nOM\nNO\nYES\n", "2\nNN\nOL\nNO\nYES\n", "2\nNN\nMO\nNO\nYES\n", "2\nNO\nMN\nNO\nYES\n", "2\nNN\nNL\nNO\nYES\n", "2\nNN\nMN\nNO\nYES\n" ]
[ "NO\nYES\n", "NO\nNO\n", "NO\nYES\n", "NO\nYES\n", "NO\nYES\n", "NO\nYES\n", "NO\nYES\n", "NO\nYES\n", "NO\nYES\n", "NO\nYES\n" ]
CodeContests
Example Input 2 5 6 1000000000 2 Output 4 5 6 0 6 0 0 5 0 3 1000000000 0 0 2 999999999 0
stdin
null
2,655
1
[ "2\n5 6\n1000000000 2\n" ]
[ "4\n5 6\n0 6\n0 0\n5 0\n3\n1000000000 0\n0 2\n999999999 0\n" ]
[ "2\n5 6\n1001000000 2\n", "2\n5 6\n1001100000 2\n", "2\n5 6\n1001000000 3\n", "2\n5 1\n1001100000 2\n", "2\n5 6\n1011000000 3\n", "2\n5 1\n1001100000 4\n", "2\n5 1\n0001100000 4\n", "2\n5 1\n0001100000 1\n", "2\n5 1\n0001100001 1\n", "2\n10 6\n1001100000 2\n" ]
[ "3\n0 0\n5 6\n1 1\n3\n0 0\n1001000000 2\n1 0\n", "3\n0 0\n5 6\n1 1\n3\n0 0\n1001100000 2\n1 0\n", "3\n0 0\n5 6\n1 1\n3\n0 0\n1001000000 3\n333666667 1\n", "3\n0 0\n5 1\n1 0\n3\n0 0\n1001100000 2\n1 0\n", "3\n0 0\n5 6\n1 1\n3\n0 0\n1011000000 3\n1 0\n", "3\n0 0\n5 1\n1 0\n3\n0 0\n1001100000 4\n1 0\n", "3...
CodeContests
Problem A large-scale joint party is held every year at Aizu University. This year, N men and M women will participate. Males are assigned IDs from 0 to N-1, and females are assigned IDs from 0 to M-1. At this joint party, you will be presented with the IDs of your "loved person" and "moderately favorite person". Eac...
stdin
null
3,928
1
[ "3 3\n3\n0 0\n1 1\n2 2\n2\n1 0\n2 1\n3\n1 1\n2 2\n0 1\n2\n1 0\n2 0\n", "5 5\n5\n4 1\n2 2\n1 4\n1 3\n4 2\n5\n1 1\n1 2\n3 3\n3 0\n3 4\n5\n2 3\n2 2\n0 3\n0 2\n4 1\n5\n2 0\n4 0\n1 0\n4 3\n2 1\n" ]
[ "2 0 0\n", "2 1 0\n" ]
[ "3 3\n3\n0 0\n1 1\n2 2\n2\n1 0\n2 1\n3\n1 1\n2 2\n0 1\n2\n0 0\n2 0\n", "3 3\n3\n0 0\n2 1\n2 2\n2\n1 0\n2 1\n3\n1 1\n2 2\n0 1\n2\n1 0\n2 0\n", "5 5\n5\n4 1\n0 2\n1 4\n1 3\n4 2\n5\n1 1\n1 2\n3 3\n3 0\n3 4\n5\n2 3\n2 2\n0 3\n1 2\n4 1\n5\n2 0\n4 0\n1 0\n4 0\n2 1\n", "5 5\n5\n4 1\n3 2\n1 4\n1 3\n4 2\n5\n1 1\n1 2\n...
[ "2 1 0\n", "1 1 0\n", "1 2 0\n", "2 0 0\n", "1 3 0\n", "1 0 0\n", "3 0 0\n", "1 1 1\n", "2 1 1\n", "0 2 0\n" ]
CodeContests
A Bingo game is played by one gamemaster and several players. At the beginning of a game, each player is given a card with M × M numbers in a matrix (See Figure 10). <image> As the game proceeds, the gamemaster announces a series of numbers one by one. Each player punches a hole in his card on the announced number, i...
stdin
null
3,768
1
[ "4 3\n10 25 11 20 6 2 1 15 23\n5 21 3 12 23 17 7 26 2\n8 18 4 22 13 27 16 5 11\n19 9 24 2 11 5 14 28 16\n4 3\n12 13 20 24 28 32 15 16 17\n12 13 21 25 29 33 16 17 18\n12 13 22 26 30 34 17 18 15\n12 13 23 27 31 35 18 15 16\n4 3\n11 12 13 14 15 16 17 18 19\n21 22 23 24 25 26 27 28 29\n31 32 33 34 35 36 37 38 39\n41 42...
[ "5\n4\n12\n0\n" ]
[ "4 3\n10 25 11 20 6 2 1 15 23\n5 21 1 12 23 17 7 26 2\n8 18 4 22 13 27 16 5 11\n19 9 24 2 11 5 14 28 16\n4 3\n12 13 20 24 28 32 15 16 17\n12 13 21 25 29 33 16 17 18\n12 13 22 26 30 34 17 18 15\n12 13 23 27 31 35 18 15 16\n4 3\n11 12 13 14 15 16 17 18 19\n21 22 23 24 25 26 27 28 29\n31 32 33 34 35 36 37 38 39\n41 42...
[ "5\n4\n12\n0\n", "5\n4\n11\n0\n", "5\n4\n11\n9\n", "5\n4\n11\n8\n", "5\n4\n12\n8\n", "5\n5\n12\n8\n", "6\n5\n12\n8\n", "6\n4\n12\n0\n", "5\n5\n12\n0\n", "5\n4\n10\n8\n" ]
CodeContests
You are a programmer who loves pretty girl games (a sub-genre of dating simulation games). A game, which is titled "Floatable Heart" and was released last Friday, has arrived at your home just now. This game has multiple stories. When you complete all of those stories, you can get a special figure of the main heroine, ...
stdin
null
2,497
1
[ "2\n1 2 2\n0\n" ]
[ "2\n" ]
[ "2\n1 2 2\n-1\n", "2\n1 3 3\n-1\n", "2\n1 3 5\n-2\n", "2\n1 2 4\n0\n", "2\n1 3 0\n0\n", "2\n1 3 1\n-2\n", "2\n1 2 8\n0\n", "2\n1 3 6\n0\n", "2\n1 3 9\n-7\n", "2\n1 3 7\n0\n" ]
[ "2\n", "3\n", "5\n", "4\n", "0\n", "1\n", "8\n", "6\n", "9\n", "7\n" ]
CodeContests
There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is empty. In the beginning, Snuke stands on Square A, and Fnuke stand...
stdin
null
3,992
1
[ "7 1 3 7 6\n.#..#..\n", "7 1 3 6 7\n.#..#..\n", "15 1 3 15 13\n...#.#...#.#...\n" ]
[ "No\n", "Yes\n", "Yes\n" ]
[ "9 1 3 7 6\n.#..#..\n", "15 1 3 15 11\n...#.#...#.#...\n", "4 1 3 7 6\n.#..#..\n", "8 1 3 7 6\n.#..#..\n", "15 0 3 15 13\n...#.#...#.#...\n", "15 0 3 15 11\n...#.#...#.#...\n", "1 1 3 7 6\n.#..#..\n", "15 1 3 15 7\n...#.#...#.#...\n", "8 1 4 7 6\n.#..#..\n", "15 0 6 15 13\n...#.#...#.#...\n" ]
[ "No\n", "Yes\n", "No\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n", "No\n", "Yes\n" ]
CodeContests
A number can be called v-number if the sum of the lower half of the array is equal to the sum of the upper half of the array. EXAMPLE: if num = 1221 sum of lower half = 3 sum of upper half = 3 then it can be called as v-number INPUT: First line consists of number of test cases T. Next T lines consists of a number...
stdin
null
3,035
1
[ "2\n12\n1230\n\nSAMPLE\n" ]
[ "NO\nYES\n" ]
[ "4\n1797\n1245789652314562114563414556521414\n11111111111111111111111111111111111111111111111111\n4785632124584233245478996321\n", "2\n13\n1230\n\nSAMPLE\n", "5\n457896663332211445588744552112255478993321254646356\n55668877442266554411221122445566224477886655\n784132368474166365474565214556475132484741\n3559055...
[ "NO\nNO\nYES\nNO\n", "NO\nYES\n", "NO\nYES\nNO\nNO\nYES\n", "NO\nNO\n", "NO\nYES\nNO\nNO\nNO\n", "NO\nNO\nNO\nNO\n", "YES\nNO\nYES\nNO\n", "NO\nNO\nNO\nNO\nNO\n", "YES\nNO\n", "YES\nNO\nNO\nNO\n" ]
CodeContests
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. Constraints * c is a lowercase English letter. Input The input is given from Standard Input in the following format: c Output If c is a vowel, print `vowel`. Oth...
stdin
null
3,719
1
[ "s\n", "z\n", "a\n" ]
[ "consonant\n", "consonant\n", "vowel\n" ]
[ "t\n", "o\n", "y\n", "`\n", "r\n", "x\n", "b\n", "q\n", "w\n", "_\n" ]
[ "consonant\n", "vowel\n", "consonant\n", "consonant\n", "consonant\n", "consonant\n", "consonant\n", "consonant\n", "consonant\n", "consonant\n" ]
CodeContests
How many multiples of d are there among the integers between L and R (inclusive)? Constraints * All values in input are integers. * 1 \leq L \leq R \leq 100 * 1 \leq d \leq 100 Input Input is given from Standard Input in the following format: L R d Output Print the number of multiples of d among the integers b...
stdin
null
2,799
1
[ "1 100 1\n", "6 20 7\n", "5 10 2\n" ]
[ "100\n", "2\n", "3\n" ]
[ "1 100 2\n", "9 20 7\n", "5 10 1\n", "9 20 3\n", "5 4 1\n", "9 31 3\n", "2 4 1\n", "9 21 3\n", "2 3 1\n", "2 10 1\n" ]
[ "50\n", "1\n", "6\n", "4\n", "0\n", "8\n", "3\n", "5\n", "2\n", "9\n" ]
CodeContests
The goal of the 8 puzzle problem is to complete pieces on $3 \times 3$ cells where one of the cells is empty space. In this problem, the space is represented by 0 and pieces are represented by integers from 1 to 8 as shown below. 1 3 0 4 2 5 7 8 6 You can move a piece toward the empty space at one step. Your goal ...
stdin
null
3,061
1
[ "1 3 0\n4 2 5\n7 8 6\n" ]
[ "4\n" ]
[ "1 4 0\n5 2 3\n7 8 6\n" ]
[ "14\n" ]
CodeContests
The dark lord wants to send armies of imps to assault Hogwarts in the first wave of offense. The imps are accustomed to fight in communities and will not fight separately. Communities are sent to battle such that the size of each community sent must be greater than the previous community sent to increase pressure on Ho...
stdin
null
922
1
[ "2\n3\n1 2 2\n2\n9 2\n\nSAMPLE\n" ]
[ "1 2 2\n2 9\n" ]
[ "10\n100\n5644 1134 9689 3313 8924 5073 6948 8330 4393 1486 440 9499 890 9913 6345 3036 206 8377 377 3492 1677 740 8766 3218 9196 1020 9381 8174 1041 766 8823 1199 1001 1303 3404 2095 1991 538 7069 1340 6013 4241 9102 463 1647 6592 6347 6690 9254 6528 5122 1934 6435 4202 9074 2067 261 6257 466 1180 6044 2534 5622 1...
[ "125 206 261 377 414 440 463 466 538 740 766 890 936 1001 1020 1041 1041 1134 1180 1199 1303 1340 1383 1486 1647 1677 1759 1827 1899 1934 1991 2067 2095 2125 2174 2204 2375 2534 2551 2574 2626 2635 3036 3218 3313 3365 3404 3424 3492 3510 3777 3895 4202 4241 4393 4419 4469 4758 4932 4973 5073 5122 5198 5476 5622 564...
CodeContests
problem There is a simple concatenated undirected graph with $ N $ vertices and $ M $ edges. The vertices are numbered $ 1, 2, \ dots, N $. The edges are numbered $ 1, 2, \ dots, M $, and the edge $ i $ connects the vertices $ a_i $ and $ b_i $. Also, the edge $ i $ disappears at time $ t_i $. It takes a unit time to ...
stdin
null
4,443
1
[ "5 4 2\n1 2 2\n2 3 1\n1 4 2\n4 5 1\n" ]
[ "8\n" ]
[ "5 4 2\n1 2 2\n4 3 1\n1 4 2\n4 5 1\n", "5 4 4\n1 2 2\n2 3 1\n1 4 2\n4 5 1\n", "5 4 2\n1 2 2\n2 3 2\n1 4 2\n4 5 1\n", "5 4 2\n1 2 1\n1 3 1\n1 4 2\n4 5 1\n", "5 4 2\n1 2 1\n1 3 1\n1 4 1\n4 5 1\n", "5 4 4\n1 2 2\n4 3 1\n1 4 2\n4 5 2\n", "5 4 4\n1 2 4\n2 3 1\n1 4 2\n4 5 1\n", "5 4 8\n1 2 2\n1 3 1\n1 4 2\n...
[ "8\n", "10\n", "9\n", "7\n", "6\n", "11\n", "12\n", "14\n", "18\n", "13\n" ]
CodeContests
Problem Statement Circles Island is known for its mysterious shape: it is a completely flat island with its shape being a union of circles whose centers are on the $x$-axis and their inside regions. The King of Circles Island plans to build a large square on Circles Island in order to celebrate the fiftieth anniversa...
stdin
null
3,370
1
[ "2\n0 8\n10 8\n2\n0 7\n10 7\n0\n" ]
[ "12.489995996796796\n9.899494936611665\n" ]
[ "2\n0 8\n10 8\n0\n0 7\n10 7\n0\n", "2\n0 8\n1 8\n0\n0 7\n10 7\n0\n", "2\n0 8\n20 8\n2\n0 7\n10 7\n0\n", "2\n0 8\n1 3\n0\n0 8\n10 1\n1\n", "2\n1 13\n1 8\n0\n0 0\n10 1\n1\n", "2\n1 14\n1 8\n0\n0 0\n10 1\n1\n", "2\n0 16\n0 8\n0\n0 7\n10 7\n0\n", "2\n0 6\n0 4\n0\n0 7\n10 3\n-1\n", "2\n0 8\n10 8\n2\n0 7\...
[ "12.489996\n", "11.802655\n", "11.313708\n9.899495\n", "11.313708\n", "18.384776\n", "19.798990\n", "22.627417\n", "8.485281\n", "12.489996\n19.798990\n", "15.556349\n" ]
CodeContests
There is a directed graph G with N vertices and M edges. The vertices are numbered 1, 2, \ldots, N, and for each i (1 \leq i \leq M), the i-th directed edge goes from Vertex x_i to y_i. G does not contain directed cycles. Find the length of the longest directed path in G. Here, the length of a directed path is the num...
stdin
null
3,353
1
[ "6 3\n2 3\n4 5\n5 6\n", "5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3\n", "4 5\n1 2\n1 3\n3 2\n2 4\n3 4\n" ]
[ "2\n", "3\n", "3\n" ]
[ "6 3\n2 6\n4 5\n5 6\n", "6 3\n2 6\n4 6\n5 6\n", "6 3\n4 3\n3 5\n5 6\n", "4 0\n1 2\n1 3\n3 2\n2 4\n3 4\n", "7 3\n2 3\n4 5\n5 6\n", "7 3\n2 3\n1 5\n5 6\n", "11 3\n2 3\n4 5\n5 6\n", "4 5\n1 2\n1 4\n3 2\n2 4\n3 4\n", "6 3\n2 6\n4 5\n4 6\n", "7 1\n2 3\n4 5\n5 6\n" ]
[ "2\n", "1\n", "3\n", "0\n", "2\n", "2\n", "2\n", "2\n", "1\n", "1\n" ]
CodeContests
"IT can do almost everything using codes", a Arjun(a CS Student) says to his mathematics' teacher. Mathematics teacher gives a very simple problem to solve using codes but Arjun got stuck. The problem was find out all those pairs of two numbers whose multiplication is divisible by their sum, i.e. You are given a numb...
stdin
null
3,302
1
[ "2\n2\n15\n\nSAMPLE\n" ]
[ "0\n4\n" ]
[ "2\n2\n15\n\nPAMSLE\n", "2\n8\n15\n\nPLNFAT\n", "2\n8\n21\n\nPLNFAT\n", "2\n8\n11\n\nPLNFAT\n", "2\n8\n5\n\nPLNFAS\n", "2\n15\n3\n\nPLOFAS\n", "2\n2\n4\n\nOLQ@FS\n", "2\n15\n7\n\nSF?QLO\n", "2\n12\n6\n\nSF@QLO\n", "2\n12\n5\n\nSF@QLO\n" ]
[ "0\n4\n", "1\n4\n", "1\n6\n", "1\n1\n", "1\n0\n", "4\n0\n", "0\n0\n", "4\n1\n", "3\n1\n", "3\n0\n" ]
CodeContests
Vectors have their directions and two vectors make an angle between them. Given a set of three-dimensional vectors, your task is to find the pair among them that makes the smallest angle. Input The input is a sequence of datasets. A dataset specifies a set of three-dimensional vectors, some of which are directly gi...
stdin
null
4,398
1
[ "4 0 2013 1124\n1 1 1\n2 2 2\n2 1 1\n1 2 1\n2 100 131832453 129800231\n42 40 46\n42 40 46\n0 100000 7004674 484521438\n0 0 0 0\n" ]
[ "1 1 1 1 2 1\n42 40 46 83 79 91\n92 92 79 99 99 85\n" ]
[ "4 0 2013 1124\n1 1 1\n2 2 2\n2 1 1\n1 2 1\n2 100 131832453 129800231\n42 0 46\n42 40 46\n0 100000 7004674 484521438\n0 0 0 0\n", "4 0 2013 1124\n1 1 1\n2 2 2\n3 1 1\n1 2 1\n2 100 131832453 129800231\n42 0 46\n42 40 48\n0 100000 7004674 484521438\n0 0 0 0\n", "4 0 2013 1124\n1 1 1\n2 2 2\n2 1 1\n1 2 1\n2 100 13...
[ "1 1 1 1 2 1\n42 40 46 83 79 91\n92 92 79 99 99 85\n", "1 1 1 1 2 1\n19 28 30 37 55 59\n92 92 79 99 99 85\n", "1 1 1 1 2 1\n42 40 46 83 79 91\n96 96 97 97 97 98\n", "1 2 1 2 2 2\n19 28 30 37 55 59\n92 92 79 99 99 85\n", "1 1 1 2 1 2\n42 40 46 83 79 91\n96 96 97 97 97 98\n", "1 1 1 1 2 1\n24 18 45 47 35 89...
CodeContests
Lots of geeky customers visit our chef's restaurant everyday. So, when asked to fill the feedback form, these customers represent the feedback using a binary string (i.e a string that contains only characters '0' and '1'. Now since chef is not that great in deciphering binary strings, he has decided the following crit...
stdin
null
793
1
[ "2\n11111110\n10101010101010\n" ]
[ "Bad\nGood\n" ]
[ "2\n11101110\n10101010101010\n", "2\n11111110\n10101010111010\n", "2\n01010010\n10000000111111\n", "2\n11111111\n11000001111100\n", "2\n11101110\n10101010111010\n", "2\n11111110\n10100010111010\n", "2\n01111110\n10100010111010\n", "2\n01111010\n10100010111010\n", "2\n01111010\n10100010111011\n", "...
[ "Good\nGood\n", "Bad\nGood\n", "Good\nBad\n", "Bad\nBad\n", "Good\nGood\n", "Bad\nGood\n", "Bad\nGood\n", "Good\nGood\n", "Good\nGood\n", "Good\nGood\n" ]
CodeContests
The Monk wants to teach all its disciples a lesson about patience, since they are always in a hurry to do something crazy. To teach them this, he gives them a list of N numbers, which may or may not be distinct. The students are supposed to solve a simple Mathematical equation based on the array of these N numbers. g(x...
stdin
null
2,474
1
[ "2\n2 6\n\nSAMPLE\n" ]
[ "144\n" ]
[ "30\n317 36 191 843 289 107 41 1032 265 649 447 806 891 730 371 351 7 102 394 549 630 624 85 955 757 841 967 377 932 309\n", "2\n468 470\n", "2\n4 6\n\nSAMPLE\n", "30\n317 36 191 843 289 107 41 1032 265 649 447 806 891 730 371 351 7 22 394 549 630 624 85 955 757 841 967 377 932 309\n", "2\n89 470\n", "2\n...
[ "762777211\n", "382401264\n", "576\n", "27265672\n", "41830\n", "12\n", "715198537\n", "59274\n", "5832\n", "228967785\n" ]
CodeContests
Snuke loves flags. Snuke is placing N flags on a line. The i-th flag can be placed at either coordinate x_i or coordinate y_i. Snuke thinks that the flags look nicer when the smallest distance between two of them, d, is larger. Find the maximum possible value of d. Constraints * 2 ≤ N ≤ 10^{4} * 1 ≤ x_i, y_i ≤ 10^...
stdin
null
4,037
1
[ "5\n2 2\n2 2\n2 2\n2 2\n2 2\n", "3\n1 3\n2 5\n1 9\n", "22\n93 6440\n78 6647\n862 11\n8306 9689\n798 99\n801 521\n188 206\n6079 971\n4559 209\n50 94\n92 6270\n5403 560\n803 83\n1855 99\n42 504\n75 484\n629 11\n92 122\n3359 37\n28 16\n648 14\n11 269\n" ]
[ "0\n", "4\n", "17\n" ]
[ "5\n2 2\n2 2\n2 0\n2 2\n2 2\n", "3\n1 3\n2 5\n2 9\n", "22\n93 6440\n78 6647\n1028 11\n8306 9689\n798 99\n801 521\n188 206\n6079 971\n4559 209\n50 94\n92 6270\n5403 560\n803 83\n1855 99\n42 504\n75 484\n629 11\n92 122\n3359 37\n28 16\n648 14\n11 269\n", "3\n2 3\n2 5\n2 9\n", "3\n3 3\n2 5\n2 16\n", "22\n93 ...
[ "0\n", "4\n", "17\n", "3\n", "2\n", "26\n", "28\n", "22\n", "1\n", "5\n" ]
CodeContests
You are given a string S of length N consisting of lowercase English letters. Process Q queries of the following two types: * Type 1: change the i_q-th character of S to c_q. (Do nothing if the i_q-th character is already c_q.) * Type 2: answer the number of different characters occurring in the substring of S betwee...
stdin
null
3,270
1
[ "7\nabcdbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n" ]
[ "3\n1\n5\n" ]
[ "7\nabcdbbd\n6\n2 3 6\n1 5 y\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n", "7\nabccbbd\n6\n2 3 6\n1 5 y\n2 1 1\n1 4 a\n1 7 d\n2 0 7\n", "7\nabdcbbd\n6\n2 3 6\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 0 7\n", "7\nabcdbbd\n6\n2 3 0\n1 5 z\n2 1 1\n1 4 a\n1 7 d\n2 1 7\n", "7\nabccbbd\n6\n2 3 5\n1 5 z\n2 1 1\n1 5 a\n1 7 d\n2 0 7\n", "...
[ "3\n1\n5\n", "2\n1\n5\n", "3\n1\n4\n", "0\n1\n5\n", "2\n1\n4\n", "0\n1\n4\n", "3\n0\n5\n", "4\n1\n5\n", "3\n1\n3\n", "0\n1\n0\n" ]
CodeContests
Paul was the most famous character in Tekken-3. Of course he went to college and stuff. In one of the exams he wasn't able to answer a question which asked to check if a tuple of 3 non negative integers constituted a Primitive Pythagorian Triplet or not. Paul was not able to answer it correctly and henceforth, he coul...
stdin
null
3,941
1
[ "4\n3 4 5\n10 8 6\n9 2 5\n12 5 13\n\nSAMPLE\n" ]
[ "YES\nNO\nNO\nYES\n" ]
[ "100\n130 0 130\n8938 6200 6439\n1059 816 676\n2421 621 2340\n9530 7280 6150\n9997 9228 3845\n68 60 32\n1412 0 1412\n9 0 9\n769 600 481\n3740 1760 3300\n91 84 35\n156 144 60\n1525 1365 681\n5 4 3\n400 384 113\n1844 1520 1044\n3256 0 3256\n1586 864 1330\n710 0 710\n10 0 10\n6 -1 6\n13 0 13\n64 0 64\n170 154 72\n266 ...
[ "NO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nNO\nYES\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\nYES\nNO\nNO\nNO\nYES\nNO\nNO\nNO\nYES\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\nYES\nNO\nNO\nNO\nNO\nNO\n...
CodeContests
You are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all subarrays obtained must be sorted in either non-decreasing or non-increasing order. At least how many subarrays do you need to divide A into? Constraints * 1 \leq N \leq 10^5 * 1 \leq A_i \leq 10^9 * Each A_i ...
stdin
null
2,250
1
[ "6\n1 2 3 2 2 1\n", "9\n1 2 1 2 1 2 1 2 1\n", "7\n1 2 3 2 1 999999999 1000000000\n" ]
[ "2\n", "5\n", "3\n" ]
[ "6\n1 2 3 2 0 1\n", "9\n1 2 1 2 2 2 1 2 1\n", "6\n1 2 3 2 0 0\n", "9\n0 1 0 -1 2 7 2 -1 0\n", "7\n1 2 3 2 1 999999999 1000000100\n", "9\n1 2 1 2 2 2 2 2 1\n", "7\n1 4 3 2 1 999999999 1000000100\n", "6\n0 2 3 2 0 0\n", "9\n1 2 0 2 2 2 2 2 1\n", "7\n1 4 3 4 1 999999999 1000000100\n" ]
[ "3\n", "4\n", "2\n", "5\n", "3\n", "3\n", "3\n", "2\n", "3\n", "3\n" ]
CodeContests
For given two circles $c1$ and $c2$, print 4 if they do not cross (there are 4 common tangent lines), 3 if they are circumscribed (there are 3 common tangent lines), 2 if they intersect (there are 2 common tangent lines), 1 if a circle is inscribed in another (there are 1 common tangent line), 0 if ...
stdin
null
1,948
1
[ "0 0 1\n1 0 2\n", "1 2 1\n3 2 2\n", "0 0 1\n0 0 2\n", "1 2 1\n4 2 2\n", "1 1 1\n6 2 2\n" ]
[ "1\n", "2\n", "0\n", "3\n", "4\n" ]
[ "0 0 0\n1 0 2\n", "1 2 1\n3 4 2\n", "1 2 0\n4 2 2\n", "0 0 1\n0 1 2\n", "0 0 0\n0 0 2\n", "1 1 1\n9 2 2\n", "0 1 0\n0 0 2\n", "1 2 1\n5 4 2\n", "-1 0 0\n0 0 2\n", "1 2 0\n0 2 2\n" ]
[ "0\n", "2\n", "4\n", "1\n", "0\n", "4\n", "0\n", "4\n", "0\n", "0\n" ]
CodeContests
Given are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists. * Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i chara...
stdin
null
3,232
1
[ "contest\nsentence\n", "contest\nson\n", "contest\nprogramming\n" ]
[ "33\n", "10\n", "-1\n" ]
[ "toncest\nsentence\n", "csnteot\nson\n", "contest\nprogrammhng\n", "vtaletn\ntnn\n", "ntelatv\ntnn\n", "mlstvdc\nmsm\n", "toncest\nsentemce\n", "csnoett\nson\n", "eontcst\nprogrammhng\n", "tsecnot\nsentemce\n" ]
[ "33\n", "10\n", "-1\n", "14\n", "15\n", "8\n", "-1\n", "10\n", "-1\n", "-1\n" ]
CodeContests
Today Oz is playing with his game-board. He has N coins of type-1 and M coins of type-2. Also the game-board has N squares of type-1 and M squares of type-2. In this game Oz must place one coin into each square. After placing all coins Oz will get a score based on his coin placement strategy . His score calculation i...
stdin
null
3,187
1
[ "2\n3 4 500 800 600\n1 5 10 -20 -30\n\nSAMPLE\n" ]
[ "4700\n-90\n" ]
[ "2\n3 4 611 800 600\n1 5 10 -20 -30\n\nSAMPLE\n", "2\n3 7 611 800 600\n1 5 10 -20 -30\n\nSAMPLE\n", "2\n6 7 611 800 600\n1 5 10 -20 -30\n\nSAMPLE\n", "2\n5 7 611 800 600\n1 5 10 -20 -30\n\nSAMPLE\n", "2\n9 7 611 800 600\n1 5 10 -20 -29\n\nSAMPLE\n", "2\n9 7 611 852 600\n1 5 10 -20 -29\n\nSAMPLE\n", "2\n...
[ "5033\n-90\n", "7433\n-90\n", "9266\n-90\n", "8655\n-90\n", "11099\n-90\n", "11463\n-90\n", "9622\n-90\n", "14048\n-90\n", "18484\n-90\n", "18484\n-100\n" ]
CodeContests
You are given a string S of length 2N consisting of lowercase English letters. There are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition? * The string obtained by reading the characters painted red from left to right is equal to the string obtained by r...
stdin
null
2,644
1
[ "4\ncabaacba\n", "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "11\nmippiisssisssiipsspiim\n", "4\nabcdefgh\n" ]
[ "4\n", "9075135300\n", "504\n", "0\n" ]
[ "4\ncacaabba\n", "4\nacbaacab\n", "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`aaaa\n", "11\nmippiisstisssiipsspiim\n", "4\nhgfedcba\n", "4\nabbaacac\n", "18\naaaaaaaaaaaaaaaaaaaaaaabaaaaaaa`aaaa\n", "11\nmippiissuisssiipsspiim\n", "4\nhgfbdcea\n", "4\nacbaacac\n" ]
[ "0\n", "4\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants! Vlad built up his own playlist. The playlist consists of N songs, each has a unique positi...
stdin
null
995
1
[ "3\n4\n1 3 4 2\n2\n5\n1 2 3 9 4\n5\n5\n1 2 3 9 4 \n1\n" ]
[ "3\n4\n1\n" ]
[ "3\n4\n1 3 4 2\n2\n5\n1 2 3 9 4\n5\n5\n1 2 3 9 4 \n2\n", "3\n4\n1 3 7 2\n1\n5\n1 2 0 9 4\n5\n5\n1 2 3 9 4 \n2\n", "3\n4\n1 3 4 2\n1\n5\n1 2 0 2 4\n5\n5\n1 2 3 9 4 \n2\n", "3\n4\n1 3 4 2\n2\n5\n1 2 3 9 8\n5\n5\n1 2 3 9 4 \n1\n", "3\n4\n1 3 4 2\n1\n5\n1 2 0 9 4\n5\n5\n1 2 3 1 4 \n2\n", "3\n4\n1 3 4 2\n0\n5\...
[ "3\n4\n2\n", "1\n4\n2\n", "1\n5\n2\n", "3\n4\n1\n", "1\n4\n3\n", "2\n4\n2\n", "2\n4\n3\n", "2\n5\n3\n", "1\n4\n1\n", "1\n4\n4\n" ]
CodeContests
You are given a list of names. Your task is to find all the distinct names in the list and after that find the frequency count of all these distinct names in the origninal list. We are interested in the maximum value of the frequency. You have to print this maximum frequency. If, the maximum value of the frequency occ...
stdin
null
2,083
1
[ "8\nveronica\nbill\nmark\nveronica\nbill\nkevin\nhillary\njack\n\nSAMPLE\n" ]
[ "4\n" ]
[ "100\namit\nabcdefghijklmnopqrstuvwxyzabcdefgghhhhhhh\naaaaaaaaaaaaaaaaaaaaa\nrrrrrrrrrrrrrrrr\nbbbbbb\ncvbdeffgggggg\ndefgrhtrblrbrgllbrfklbkfblmflbkm\neight\naaaaaaaaaaaaaaarrrrrr\nai\nrewf\nprateek\namit\nabcdefghijklmnopqrstuvwxyzabcdefgghhhhhhh\naaaaaaaaaaaaaaaaaaaaa\nrrrrrrrrrrrrrrrr\nbbbbbb\ncvbdeffgggggg\nd...
[ "36\n", "340\n", "4\n", "306\n", "27\n", "2\n", "272\n", "238\n", "18\n", "9\n" ]
CodeContests
Kuru Kuru Door Round and round door The ICPC (Intelligent Circular Perfect Cleaner), a fully automatic circular vacuum cleaner developed by ACM (Automatic Cleaning Machine) in 2011, has a function to automatically start during the day and clean dust in places where you have passed. In addition, this ICPC also has a f...
stdin
null
1,986
1
[ "3\n1 4\n-5 5\n5 -5\n10\n1 10\n-10 5\n5 -10\n5\n3 5\n-20 0\n20 0\n8\n1 9\n-14 58\n6 24\n2\n2 8\n-57 -113\n42 -31\n4\n1 4\n-4 -5\n4 5\n0\n" ]
[ "17.5032106371\n41.3850388846\n-1\n102.0656847372\n178.1399151364\n19.5548716821\n" ]
[ "3\n1 4\n-5 5\n5 -5\n10\n1 10\n-10 5\n5 -10\n5\n3 5\n-20 0\n20 0\n8\n1 9\n-14 58\n6 24\n2\n2 8\n-57 -113\n42 -31\n4\n1 4\n-4 -5\n4 0\n0\n", "3\n1 4\n-5 5\n2 -5\n10\n1 10\n-10 5\n5 -10\n5\n3 5\n-20 0\n20 0\n8\n1 9\n-14 58\n6 24\n2\n2 8\n-57 -113\n42 -31\n4\n1 4\n-4 -5\n4 0\n0\n", "3\n1 4\n-5 5\n2 -5\n10\n1 10\n-...
[ "17.5032106371\n41.3850388846\n-1\n102.0656847372\n178.1399151364\n14.3709245301\n", "18.4111262049\n41.3850388846\n-1\n102.0656847372\n178.1399151364\n14.3709245301\n", "18.4111262049\n41.3850388846\n-1\n102.0656847372\n178.1399151364\n16.3449368120\n", "18.4111262049\n41.3850388846\n-1\n102.0656847372\n168....
CodeContests
Shik's job is very boring. At day 0, his boss gives him a string S_0 of length N which consists of only lowercase English letters. In the i-th day after day 0, Shik's job is to copy the string S_{i-1} to a string S_i. We denote the j-th letter of S_i as S_i[j]. Shik is inexperienced in this job. In each day, when he i...
stdin
null
1,172
1
[ "5\nabcde\nabcde\n", "5\nabcde\nbbbbb\n", "4\nacaa\naaca\n", "5\nabcde\naaacc\n" ]
[ "0\n", "-1\n", "2\n", "2\n" ]
[ "5\nabcde\nabdde\n", "4\naacb\naacb\n", "5\nabcde\nbbbba\n", "4\nbcaa\naaca\n", "5\nabcde\naaacb\n", "5\nabcde\nabddd\n", "5\nacbde\nbbbba\n", "4\nbcaa\naacb\n", "5\nabcde\nbcaaa\n", "5\nabcde\nbbddd\n" ]
[ "-1\n", "0\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n" ]
CodeContests
Things are heated up between the Finance team and the Marketing team, and they decide to have one-on-one fifa matches to settle it once and for all. Jha, being an intern, won’t play (it’s a battle of legends, after all) and has been given one job: to fix matches in the "hope" that he’ll match players of similar skill ...
stdin
null
487
1
[ "3\n8 5 3\n8 5 3\n\nSAMPLE\n" ]
[ "200\n" ]
[ "4\n1 10 7 4\n15 3 8 10\n", "3\n8 2 3\n8 5 3\n\nSAMPLE\n", "4\n1 10 7 4\n6 3 8 10\n", "4\n1 9 7 3\n6 3 8 10\n", "4\n1 1 7 3\n11 5 8 18\n", "4\n2 14 26 9\n19 3 -1 0\n", "4\n1 10 7 4\n6 0 8 4\n", "4\n1 10 7 4\n15 3 8 3\n", "3\n8 5 3\n8 5 3\n\nSAMPLF\n", "4\n1 10 7 4\n13 3 8 10\n" ]
[ "200\n", "150\n", "300\n", "250\n", "100\n", "400\n", "350\n", "300\n", "200\n", "200\n" ]
CodeContests
It was the last day of the summer camp you strayed into the labyrinth on the way to Komaba Campus, the University of Tokyo. The contest has just begun. Your teammates must impatiently wait for you. So you have to escape from this labyrinth as soon as possible. The labyrinth is represented by a grid map. Initially, each...
stdin
null
4,049
1
[ "6 6\n\n_|A%#\nB#_|#\n^BBa#\nB&A##\n\n2\n\n*|*.#\n.#.|#\n*.**#\n...##\n\n\n*|*.#\n*#.|#\n..**#\n..*##\n", "8 3\n\n%||Aa&#\n\n2\n\n*||*..#\n\n\n.||*.*#\n", "3 5\n\n%#\n^#\n&#\n\n0\n", "3 4\n\n%#\n&#\n\n0\n", "6 6\n######\n#_|A%#\n#B#_|#\n#^BBa#\n#B&A##\n######\n2\n######\n#*|*.#\n#.#.|#\n#*.**#\n#...##\n####...
[ "21\n", "7\n", "-1\n", "1\n", "21\n" ]
[ "5 6\n\n_|A%#\nB#_|#\n^BBa#\nB&A##\n\n2\n\n*|*.#\n.#.|#\n*.**#\n...##\n\n\n*|*.#\n*#.|#\n..**#\n..*##\n", "9 3\n\n%||Aa&#\n\n2\n\n*||*..#\n\n\n.||*.*#\n", "3 4\n\n#%\n#&\n\n0\n", "6 6\n######\n#_|A%#\n#C#_|#\n#^BBa#\n#B&A##\n######\n2\n######\n#)|*.#\n#.#.|#\n#*.**#\n#...##\n$#####\n######\n#*|*.#\n#*#.|#\n#....
[ "-1\n", "7\n", "1\n", "10\n", "5\n", "3\n", "4\n", "2\n", "-1\n", "-1\n" ]
CodeContests
There are N routers. The cost of the wires required in connecting two routers, i and j, is R[i]+R[j] where R[i] is the number of slots in the i-th router and i!=j. You need to build a network, such that there is a path between every pair of routers. Find the minimum cost of building such a network.The connection betwee...
stdin
null
5,038
1
[ "2\n2\n1 2\n3\n1 1 1\n\nSAMPLE\n" ]
[ "3\n4\n" ]
[ "5\n42\n18468 6335 26501 19170 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437 32392 14605 3903 154 293 12383 17422 18717 19719 19896 5448 21727 14772 11539 1870 19913 25668 26300 17036 9895 28704 23812 31323 \n334\n17674 4665 15142 7712 28254 6869 25548 27645 32663 32758 20038 12...
[ "671736\n5531463\n16399906\n16648413\n1998000000000\n", "3\n5\n", "671736\n5526920\n16399906\n16648413\n1998000000000\n", "3\n6\n", "671736\n5526920\n16399906\n16648413\n1998001000000\n", "2\n6\n", "671736\n5526920\n16406902\n16648413\n1998001000000\n", "671736\n5526920\n16406902\n16649108\n1998001000...
CodeContests
Problem statement You and AOR Ika are preparing for a graph problem in competitive programming. Generating input cases is AOR Ika-chan's job. The input case for that problem is a directed graph of the $ N $ vertices. The vertices are numbered from $ 1 $ to $ N $. Edges may contain self-loops, but not multiple edges. ...
stdin
null
3,017
1
[ "3\n1 2 0 0\n1 2 0 0\n" ]
[ "YES\n0 1 0\n0 0 1\n0 0 0\n" ]
[ "3\n1 2 0 0\n1 2 1 0\n", "3\n1 2 0 0\n1 2 1 -1\n", "3\n1 2 0 0\n2 2 1 0\n", "3\n1 2 0 0\n2 2 2 0\n", "3\n1 2 0 0\n2 2 0 0\n", "3\n1 1 0 0\n2 2 0 0\n", "3\n1 2 1 0\n2 2 0 0\n", "3\n1 2 1 0\n3 2 0 0\n", "3\n2 2 1 0\n3 2 0 0\n", "3\n2 2 1 0\n3 2 0 1\n" ]
[ "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n", "NO\n" ]
CodeContests
Chef has a nice complete binary tree in his garden. Complete means that each node has exactly two sons, so the tree is infinite. Yesterday he had enumerated the nodes of the tree in such a way: Let's call the nodes' level a number of nodes that occur on the way to this node from the root, including this node. This wa...
stdin
null
478
1
[ "4\nlrl\nrll\nr\nlllr\n" ]
[ "10\n14\n4\n13\n" ]
[ "4\nrll\nrll\nr\nlllr\n", "4\nlrl\nrll\nr\nrlll\n", "4\nlrl\nrll\nr\nllrl\n", "4\nrll\nllr\nr\nlllr\n", "4\nrll\nrll\nr\nllrl\n", "4\nrll\nllr\nr\nrlll\n", "4\nllr\nllr\nr\nrlll\n", "4\nllr\nrll\nr\nrlll\n", "4\nrll\nrll\nr\nrlll\n", "4\nllr\nrll\nr\nlllr\n" ]
[ "14\n14\n4\n13\n", "10\n14\n4\n27\n", "10\n14\n4\n15\n", "14\n8\n4\n13\n", "14\n14\n4\n15\n", "14\n8\n4\n27\n", "8\n8\n4\n27\n", "8\n14\n4\n27\n", "14\n14\n4\n27\n", "8\n14\n4\n13\n" ]
CodeContests
There are N stations in the city where JOI lives, and they are numbered 1, 2, ..., and N, respectively. In addition, there are M railway lines, numbered 1, 2, ..., and M, respectively. The railway line i (1 \ leq i \ leq M) connects station A_i and station B_i in both directions, and the fare is C_i yen. JOI lives nea...
stdin
null
67
1
[ "6 6\n1 6\n1 4\n1 2 1\n2 3 1\n3 5 1\n2 4 3\n4 5 2\n5 6 1\n" ]
[ "2\n" ]
[ "6 6\n1 6\n1 4\n1 2 1\n2 3 1\n2 5 1\n2 4 3\n4 5 2\n5 6 1\n", "11 6\n1 6\n1 4\n1 2 1\n4 3 1\n2 5 1\n2 4 3\n4 5 0\n5 6 1\n", "11 6\n1 1\n1 2\n1 2 1\n4 3 1\n2 5 1\n2 4 3\n4 5 0\n5 6 1\n", "11 6\n2 6\n1 4\n1 2 1\n4 3 1\n2 5 1\n2 4 3\n4 5 2\n5 6 1\n", "14 6\n1 1\n1 4\n1 2 1\n2 3 1\n2 5 1\n2 4 3\n4 5 2\n5 6 1\n",...
[ "2\n", "0\n", "1\n", "3\n", "4\n", "5\n", "6\n", "2\n", "2\n", "0\n" ]
CodeContests
Chef loves research! Now he is looking for subarray of maximal length with non-zero product. Chef has an array A with N elements: A1, A2, ..., AN. Subarray Aij of array A is elements from index i to index j: Ai, Ai+1, ..., Aj. Product of subarray Aij is product of all its elements (from ith to jth). Input First li...
stdin
null
1,992
1
[ "1\n0\n", "6\n1 0 2 3 0 4\n", "3\n1 0 1\n" ]
[ "0\n", "2\n", "1\n" ]
[ "6\n1 0 2 3 0 6\n", "3\n2 0 1\n", "3\n1 1 1\n", "3\n0 0 0\n", "6\n1 0 2 5 0 6\n", "3\n3 0 1\n", "3\n1 0 2\n", "6\n0 0 2 3 0 6\n", "6\n1 0 2 0 0 6\n", "3\n1 0 3\n" ]
[ "2\n", "1\n", "3\n", "0\n", "2\n", "1\n", "1\n", "2\n", "1\n", "1\n" ]
CodeContests
Given is an integer sequence A_1, ..., A_N of length N. We will choose exactly \left\lfloor \frac{N}{2} \right\rfloor elements from this sequence so that no two adjacent elements are chosen. Find the maximum possible sum of the chosen elements. Here \lfloor x \rfloor denotes the greatest integer not greater than x. ...
stdin
null
1,965
1
[ "27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 57 24 -70 -93 69 -99 59 57 -49\n", "5\n-1000 -100 -10 0 10\n", "6\n1 2 3 4 5 6\n", "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n" ]
[ "295\n", "0\n", "12\n", "5000000000\n" ]
[ "27\n18 -28 18 28 -45 90 -45 23 -53 60 28 -74 -71 35 -26 -62 49 -77 33 24 -70 -93 69 -99 59 57 -49\n", "5\n-1156 -100 -10 0 10\n", "6\n1 2 6 4 5 6\n", "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 0000000000 1000000000 1000000000 1000000000\n", "27\n18 -28 18 28 -45 90 -45 23 -53 60...
[ "271\n", "0\n", "13\n", "5000000000\n", "277\n", "7\n", "18\n", "5000001000\n", "267\n", "17\n" ]
CodeContests
You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money for many years. The two rooms are of the same size and arrangement...
stdin
null
4,004
1
[ "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n3 25 10000\n5 15 5000\n22 300 5500\n10 295 9000\n7 7 6000\n8\n32 251 2261\n123 281 1339\n211 235 5641\n162 217 7273\n22 139 7851\n194 198 9190\n119 274 878\n122 173 8640\n0\n" ]
[ "30\n25500\n38595\n" ]
[ "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n3 25 10000\n5 15 5000\n22 300 5500\n10 295 9000\n7 7 6000\n8\n32 251 2261\n123 281 1339\n211 235 5641\n162 217 7273\n22 158 7851\n194 198 9190\n119 274 878\n122 173 8640\n0\n", "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n3 25 10000\n5 15 5000\n22 300 5500\n1...
[ "30\n25500\n38595\n", "30\n25500\n32954\n", "30\n25000\n32954\n", "30\n25000\n25681\n", "33\n25000\n25681\n", "23\n25000\n25681\n", "30\n30500\n32954\n", "33\n25000\n29367\n", "40\n25000\n25681\n", "30\n30452\n32954\n" ]
CodeContests
Polo, the Penguin, likes numbers. He says that the goodness of a number is itself multiplied by the number of digits in it's decimal representation. For example, the goodness of the integer 474 is 474*3 = 1422. Help him to count the sum of goodness of all integers from L to R, inclusive. Since the answer can be too lar...
stdin
null
2,074
1
[ "1\n9 12\n" ]
[ "75\n" ]
[ "1\n9 16\n", "1\n9 24\n", "1\n6 24\n", "1\n8 24\n", "1\n12 24\n", "1\n10 24\n", "1\n10 39\n", "1\n10 78\n", "1\n10 88\n", "1\n10 38\n" ]
[ "191\n", "519\n", "540\n", "527\n", "468\n", "510\n", "1470\n", "6072\n", "7742\n", "1392\n" ]
CodeContests
We have N+M balls, each of which has an integer written on it. It is known that: * The numbers written on N of the balls are even. * The numbers written on M of the balls are odd. Find the number of ways to choose two of the N+M balls (disregarding order) so that the sum of the numbers written on them is even. It c...
stdin
null
3,037
1
[ "13 3\n", "1 1\n", "4 3\n", "2 1\n", "0 3\n" ]
[ "81\n", "0\n", "9\n", "1\n", "3\n" ]
[ "13 5\n", "1 2\n", "4 0\n", "0 5\n", "13 6\n", "1 3\n", "0 0\n", "2 2\n", "4 6\n", "2 3\n" ]
[ "88\n", "1\n", "6\n", "10\n", "93\n", "3\n", "0\n", "2\n", "21\n", "4\n" ]
CodeContests
You are given an array of N integers A[1] , A[2] , ... , A[N] . You have to answer Q queries. Each query consists of 3 integers L, R and K. For each query, you have to find the value of the Skipping Sum in the following manner : def skipping_sum(L,R,K) : sum = 0 while L ≤ R : ...
stdin
null
3,708
1
[ "8 6\n5 4 2 1 7 9 10 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n3 7 3\n3 7 4\n\nSAMPLE\n" ]
[ "47\n24\n1\n19\n11\n12\n" ]
[ "8 6\n5 4 2 1 7 9 12 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n3 7 3\n3 7 4\n\nSAMPLE\n", "8 6\n5 4 2 1 7 9 12 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n5 7 3\n3 7 4\n\nSAMPLE\n", "8 3\n5 4 2 1 7 9 12 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n5 7 3\n3 7 4\n\nSAMPLE\n", "8 6\n5 4 2 1 7 9 10 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n3 5 3\n3 7 4\n\nSAMPL...
[ "49\n26\n1\n21\n11\n14\n", "49\n26\n1\n21\n7\n14\n", "49\n26\n1\n", "47\n24\n1\n19\n2\n12\n", "49\n26\n12\n21\n11\n14\n", "48\n25\n1\n", "47\n24\n1\n19\n2\n29\n", "49\n26\n12\n19\n11\n14\n", "48\n25\n4\n", "49\n26\n12\n19\n2\n14\n" ]
CodeContests
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. Constraints * The length of the input string < 1200 Input A string is given in a line. Output Print the converted string in a line. Note that you do not need to convert any characters other than alphabetical lett...
stdin
null
1,071
1
[ "fAIR, LATER, OCCASIONALLY CLOUDY.\n" ]
[ "Fair, later, occasionally cloudy.\n" ]
[ "f@IR, LATER, OCCASIONALLY CLOUDY.\n", "f@IR, LATER, YLLANOISACCO CLOUDY.\n", "f@IR, LATER, OLLANOISACCY CLOUDY.\n", "f@IR, LATER, OLKANOISACCY CLOUDY.\n", ",RI@f LATER, OLKANOISACCY CLOUDY.\n", ",RI@f KATER, OLKANOISACCY CLOUDY.\n", ",RI@g KATER, OLKANOISACCY CLOUDY.\n", ",RI@g KATER, OLKANOISACCY CL...
[ "F@ir, later, occasionally cloudy.\n", "F@ir, later, yllanoisacco cloudy.\n", "F@ir, later, ollanoisaccy cloudy.\n", "F@ir, later, olkanoisaccy cloudy.\n", ",ri@F later, olkanoisaccy cloudy.\n", ",ri@F kater, olkanoisaccy cloudy.\n", ",ri@G kater, olkanoisaccy cloudy.\n", ",ri@G kater, olkanoisaccy cl...
CodeContests
Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only. Chef's canvas is N millimeters long and is initially all white. For simplicity, colors will be re...
stdin
null
1,709
1
[ "3\n4\n1 5 5 5\n4\n1 1 1 5\n3\n5 5 2\n" ]
[ "Yes\nYes\nNo\n" ]
[ "3\n4\n1 5 5 5\n3\n1 1 1 5\n3\n5 5 2\n", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n5 5 2\n", "3\n4\n1 10 5 5\n3\n1 2 1 5\n3\n1 1 3\n", "3\n4\n1 5 5 6\n4\n1 1 1 5\n3\n5 5 2\n", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n5 5 3\n", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n5 1 3\n", "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n1 1 3\n", "3\n4\n2 5 5 5...
[ "Yes\nYes\nNo\n", "Yes\nNo\nNo\n", "No\nNo\nNo\n", "No\nYes\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "Yes\nNo\nNo\n", "No\nYes\nNo\n", "No\nNo\nNo\n" ]
CodeContests
In the Bitwise Kingdom, located somewhere in the universe, there are exactly 2N citizens living and each of them has a unique identification string that represents his or her class in the society. An identification string is a binary string of length N which consists of characters ‘0’ or ‘1’. The order of classes is de...
stdin
null
4,086
1
[ "3 3\n3 5\n0 0\n" ]
[ "010\n011\n" ]
[ "3 3\n4 5\n0 0\n", "3 3\n3 5\n0 -1\n", "3 3\n3 4\n0 0\n", "3 3\n2 4\n0 0\n", "3 3\n0 4\n0 0\n", "3 6\n3 5\n0 0\n", "3 3\n3 6\n0 -1\n", "3 5\n3 4\n0 0\n", "5 3\n0 4\n0 0\n", "6 3\n2 4\n0 1\n" ]
[ "010\n1000\n", "010\n011\n", "010\n100\n", "010\n11\n", "010\n", "101\n011\n", "010\n101\n", "011\n100\n", "00010\n", "000010\n11\n" ]
CodeContests
For given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n. Input n An integer n (1 ≤ n ≤ 1000000000). Output The number of totatives in a line. Examples Input 6 Output 2 Input 1000000 Output 400000
stdin
null
1,427
1
[ "1000000\n", "6\n" ]
[ "400000\n", "2\n" ]
[ "1000100\n", "5\n", "1000101\n", "1000001\n", "1000011\n", "16\n", "1010011\n", "31\n", "61\n", "59\n" ]
[ "391680\n", "4\n", "666732\n", "990000\n", "666672\n", "8\n", "976500\n", "30\n", "60\n", "58\n" ]
CodeContests
We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. For each k=1, ..., N, solve the problem below: * Consider writing a number on each vertex in the tree in the following manner: * First, write 1 on Vertex k. * Then, for each of the numbers 2, ..., N in this order, w...
stdin
null
2,046
1
[ "3\n1 2\n1 3\n", "2\n1 2\n", "5\n1 2\n2 3\n3 4\n3 5\n", "8\n1 2\n2 3\n3 4\n3 5\n3 6\n6 7\n6 8\n" ]
[ "2\n1\n1\n", "1\n1\n", "2\n8\n12\n3\n3\n", "40\n280\n840\n120\n120\n504\n72\n72\n" ]
[ "5\n1 2\n1 3\n3 4\n3 5\n", "5\n1 2\n1 4\n3 4\n3 5\n", "5\n1 2\n1 4\n5 4\n3 5\n", "3\n2 3\n1 3\n", "5\n1 2\n2 3\n2 4\n3 5\n", "5\n1 2\n1 5\n3 4\n3 5\n", "5\n1 2\n1 5\n5 4\n3 5\n", "5\n1 2\n2 3\n1 4\n3 5\n", "5\n1 2\n1 5\n2 4\n3 5\n", "5\n1 3\n2 3\n1 4\n3 5\n" ]
[ "8\n2\n12\n3\n3\n", "4\n1\n4\n6\n1\n", "4\n1\n1\n6\n4\n", "1\n1\n2\n", "3\n12\n8\n3\n2\n", "4\n1\n4\n1\n6\n", "8\n2\n3\n3\n12\n", "4\n6\n4\n1\n1\n", "6\n4\n1\n1\n4\n", "8\n3\n12\n2\n3\n" ]
CodeContests
B: Hokkaido University Hard Note Please note that the question settings are the same as question A, except for the constraints. story Homura-chan, who passed Hokkaido University and is excited about the beginning of a new life. But in front of her, a huge campus awaits ... "Eh ... I'm not in time for the next clas...
stdin
null
1,227
1
[ "3 3\nB.B\n..B\n.BB\n" ]
[ "4\n" ]
[ "3 3\nB.B\nB..\n.BB\n", "2 3\nB.B\nB..\n.BB\n", "1 3\nB-B\n..B\n.BA\n", "1 1\nB-B\n..B\n.BA\n", "1 3\nBB.\nB..\n.AA\n", "3 3\nB.B\nB..\nBB.\n", "3 3\nB.B\nC..\nBB.\n", "3 3\nB/B\nC..\nBB.\n", "3 3\nB0B\nC..\nBB.\n", "3 3\nB0B\nC..\n.BB\n" ]
[ "4\n", "3\n", "2\n", "0\n", "1\n", "4\n", "4\n", "4\n", "4\n", "4\n" ]
CodeContests
Darshak (Dark) likes to get fruits from trees a lot,he always like to eat those natural fruits directly from the tree. Today he has an infinite full binary tree (each node has exactly two child's) with special properties. Dark's tree has the following special properties : Each node of the tree has a value of goodness....
stdin
null
4,807
1
[ "2\n1 5\n4 4\n\nSAMPLE\n" ]
[ "-6\n4\n" ]
[ "1500\n4289384 87\n1692778 16\n2747794 36\n4885387 93\n1516650 22\n202363 28\n3368691 60\n4897764 27\n180541 27\n4089173 37\n5212 69\n4702568 30\n1465783 31\n3722863 24\n174068 36\n1513930 3\n634023 59\n4133070 68\n4961394 57\n3175012 43\n1176230 74\n4484422 20\n3413785 38\n4575199 25\n4798316 71\n4566414 27\n27760...
[ "8426981\n1216489\n5425280\n9694152\n3030274\n366409\n6684825\n9795156\n-56444\n8145299\n7895\n9258027\n2931312\n7328715\n255705\n3002632\n593023\n8134965\n9147269\n6349604\n2347740\n4483304\n6400836\n6290610\n9537856\n9095729\n5545531\n3517897\n5608176\n5812599\n1595703\n4953811\n5299869\n1101328\n1299391\n3130960...
CodeContests
You are working as a night watchman in an office building. Your task is to check whether all the lights in the building are turned off after all the office workers in the building have left the office. If there are lights that are turned on, you must turn off those lights. This task is not as easy as it sounds to be be...
stdin
null
425
1
[ "1 1 1\n1\n2 2 1\n1 1\n1 1\n3 2 1\n1 0 1\n0 1 0\n3 3 1\n1 0 1\n0 1 0\n1 0 1\n4 4 2\n1 1 0 1\n0 0 0 1\n1 0 1 1\n1 0 0 0\n5 5 1\n1 1 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n5 5 2\n0 0 0 0 0\n0 0 0 0 0\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 0 0\n11 11 3\n0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0...
[ "1\n1\n0\n1\n0\n0\n1\n1\n0\n1\n" ]
[ "1 1 1\n1\n2 2 1\n1 1\n1 1\n3 2 1\n1 0 1\n0 1 0\n3 3 1\n1 0 1\n0 1 0\n1 0 1\n4 4 2\n1 1 0 1\n0 0 0 1\n1 0 1 1\n1 0 0 0\n5 5 1\n1 1 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n5 5 2\n0 0 0 0 0\n0 0 0 0 0\n0 0 1 0 0\n0 0 0 0 0\n0 0 0 0 0\n11 11 3\n0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0...
[ "1\n1\n0\n1\n0\n0\n1\n1\n0\n1\n", "1\n1\n0\n1\n0\n0\n1\n1\n0\n0\n", "1\n1\n0\n1\n0\n0\n1\n0\n0\n1\n", "1\n1\n0\n1\n0\n0\n1\n0\n0\n0\n", "1\n1\n0\n1\n0\n0\n0\n0\n0\n0\n", "1\n1\n0\n1\n0\n0\n1\n1\n1\n", "1\n1\n0\n1\n0\n0\n1\n0\n", "1\n1\n0\n1\n0\n0\n1\n0\n1\n", "1\n1\n0\n1\n0\n0\n0\n0\n", "1\n1\n0\n...
CodeContests
There are N cats. We number them from 1 through N. Each of the cats wears a hat. Cat i says: "there are exactly a_i different colors among the N - 1 hats worn by the cats except me." Determine whether there exists a sequence of colors of the hats that is consistent with the remarks of the cats. Constraints * 2 ≤ N ...
stdin
null
3,237
1
[ "5\n4 3 4 3 4\n", "3\n1 1 2\n", "5\n3 3 3 3 3\n", "3\n1 2 2\n", "4\n2 2 2 2\n" ]
[ "No\n", "No\n", "No\n", "Yes\n", "Yes\n" ]
[ "3\n1 1 3\n", "5\n3 4 3 4 3\n", "5\n3 4 3 3 3\n", "3\n0 2 2\n", "4\n2 4 2 2\n", "3\n4 2 2\n", "3\n1 0 3\n", "3\n0 2 4\n", "4\n2 4 4 2\n", "3\n4 0 2\n" ]
[ "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
Problem statement Jota knows only the characters from `a` to` z` and the addition symbol `+`. Jota has an older sister, Tachiko. In addition to that, Tatsuko knows multiplication `*`, parentheses `(`, `)`, and integers (numbers) between `1` and` 9`. However, I don't know how to use multiple parentheses and how to mult...
stdin
null
2,538
1
[ "5\na+a+a\n" ]
[ "3\n" ]
[ "5\nb+a+a\n", "5\nb+b+b\n", "5\na+a+b\n", "5\na+b+b\n", "5\nb+b+a\n", "5\nc+a+a\n", "5\nb+a+b\n", "5\nc+a+b\n", "5\na+c+b\n", "5\nd+a+a\n" ]
[ "5\n", "3\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n", "5\n" ]
CodeContests
You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7: * The string does not contain characters other than `A`, `C`, `G` and `T`. * The string does not contain `AGC` as a substring. * The condition above cannot be violated by swapping two adjacent chara...
stdin
null
3,079
1
[ "4\n", "3\n", "100\n" ]
[ "230\n", "61\n", "388130742\n" ]
[ "5\n", "6\n", "8\n", "15\n", "12\n", "9\n", "14\n", "7\n", "13\n", "20\n" ]
[ "865\n", "3247\n", "45719\n", "478366600\n", "9058467\n", "171531\n", "127504505\n", "12185\n", "33985227\n", "580025381\n" ]
CodeContests
In AtCoder City, there are three stations numbered 1, 2, and 3. Each of these stations is operated by one of the two railway companies, A and B. A string S of length 3 represents which company operates each station. If S_i is `A`, Company A operates Station i; if S_i is `B`, Company B operates Station i. To improve t...
stdin
null
4,893
1
[ "ABA\n", "BBA\n", "BBB\n" ]
[ "Yes\n", "Yes\n", "No\n" ]
[ "AAB\n", "AAA\n", "ABB\n", "BAA\n", "BAB\n", "BAA\n", "BAB\n", "AAA\n", "AAB\n", "ABB\n" ]
[ "Yes\n", "No\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "Yes\n", "No\n", "Yes\n", "Yes\n" ]
CodeContests
Problem You bought a tree-shaped lighting fixture called a tree light. This luminaire has n contacts, each numbered from 0 to n-1. Each contact consists of a light bulb that can express 10 levels of brightness and a device for switching the state of the light bulb. Initially, the brightness of the bulbs at all contac...
stdin
null
2,743
1
[ "7 5\n0 1\n1 2\n1 3\n0 4\n4 5\n4 6\n1 0 0 9\n2 0 0 5\n2 1 5 8\n1 0 5 8\n1 0 8 8\n", "7 5\n0 1\n1 2\n2 3\n0 4\n4 5\n5 6\n2 1 0 5\n2 4 0 6\n2 3 5 6\n2 5 6 5\n1 0 0 5\n" ]
[ "7\n7\n3\n", "5\n" ]
[ "7 5\n0 1\n1 2\n2 3\n0 4\n2 5\n5 6\n2 1 0 5\n2 4 0 6\n2 3 5 6\n2 5 6 5\n1 0 0 5\n", "7 5\n0 1\n1 2\n2 3\n0 4\n2 5\n5 6\n2 1 0 2\n2 4 0 6\n2 3 5 6\n2 5 6 5\n1 0 0 5\n", "7 5\n0 1\n1 2\n2 3\n0 4\n4 5\n3 6\n2 1 0 5\n2 4 0 6\n2 3 5 6\n2 5 6 5\n1 0 0 5\n", "7 5\n0 1\n1 2\n2 3\n0 4\n3 5\n5 6\n2 1 0 2\n2 4 0 6\n2 3 ...
[ "5\n", "6\n", "4\n", "7\n", "2\n", "1\n", "0\n3\n", "4\n4\n4\n4\n", "0\n5\n", "3\n" ]
CodeContests
Problem At the boys' school where Bit-kun attends, a Kippo game is played during the lunch break. This school's Kippo game is famous for being a little strange. First, prepare a $ N $ book ticket. The length of the $ i $ first ticket is $ a_i $. The first move and the second move eat Kippo alternately. If you eat a gr...
stdin
null
3,137
1
[ "3 5\n10 8 4\n", "4 10\n3 8 5 2\n", "2 25\n19 19\n", "1 1\n2\n" ]
[ "First\n", "Second\n", "Second\n", "First\n" ]
[ "3 5\n10 16 4\n", "2 25\n3 29\n", "2 25\n19 29\n", "2 25\n15 29\n", "3 5\n10 8 6\n", "4 10\n3 8 0 2\n", "1 1\n4\n", "3 5\n10 16 6\n", "2 30\n19 29\n", "2 25\n7 29\n" ]
[ "First\n", "Second\n", "First\n", "First\n", "First\n", "First\n", "First\n", "First\n", "First\n", "First\n" ]
CodeContests
The fearless Ikta has finally hunted down the infamous Count Big Bridge! Count Bigbridge is now trapped in a rectangular room w meters wide and h meters deep, waiting for his end. If you select a corner of the room and take the coordinate system so that the width direction is the x-axis and the depth direction is the ...
stdin
null
2,340
1
[ "2 3 1000 1000 1 1 1 2\n", "10 10 1 11 3 3 7 7\n", "10 10 1 10 3 3 7 7\n" ]
[ "523598775681\n", "5\n", "1\n" ]
[ "2 3 1001 1000 1 1 1 2\n", "16 10 1 10 3 3 7 7\n", "2 3 1001 1000 1 2 1 2\n", "16 10 1 10 3 3 2 7\n", "2 3 1000 1000 1 2 1 2\n", "2 3 1000 1000 1 2 0 2\n", "2 3 1000 1010 1 2 0 2\n", "16 10 0 7 3 3 2 8\n", "2 2 1000 1000 1 1 1 2\n", "10 10 1 22 3 3 7 7\n" ]
[ "524646496019\n", "1\n", "524646494212\n", "2\n", "523598773383\n", "523598775160\n", "534123111276\n", "0\n", "785398163232\n", "15\n" ]
CodeContests
Given n integers a1, a2,…, an and n integers p1, p2,…, pn, integer m. The operation of selecting the kth integer ak with a probability of pk [%] is performed for each k (1 ≤ k ≤ n), and 0 or more and n or less integers are selected. Find the expected number of integers between 1 and m that are divisible by at least one...
stdin
null
3,773
1
[ "2 15\n3 5\n50 50\n", "4 100\n2 3 5 7\n80 60 40 20\n", "4 210\n2 3 5 7\n80 60 40 20\n" ]
[ "3.75\n", "57.352\n", "119.9136\n" ]
[ "2 15\n3 5\n50 72\n", "4 100\n1 3 5 7\n80 60 40 20\n", "4 210\n2 2 5 7\n80 60 40 20\n", "2 15\n3 5\n32 72\n", "4 100\n1 3 8 7\n80 60 40 20\n", "2 210\n2 2 5 7\n80 60 40 20\n", "2 15\n3 5\n32 64\n", "4 100\n1 3 14 7\n80 60 40 20\n", "2 115\n2 2 5 7\n80 60 40 20\n", "2 7\n3 5\n32 64\n" ]
[ "4.300000000\n", "85.704000000\n", "108.652800000\n", "3.529600000\n", "85.176000000\n", "12.232500000\n", "3.315200000\n", "84.795200000\n", "6.640500000\n", "1.280000000\n" ]
CodeContests
Cosmic market, commonly known as Kozumike, is the largest coterie spot sale in the universe. Doujin lovers of all genres gather at Kozumike. In recent years, the number of visitors to Kozumike has been increasing. If everyone can enter from the beginning, it will be very crowded and dangerous, so admission is restricte...
stdin
null
3,050
1
[ "5 5 5\n0 0 1\n0 0 0\n0 2 0\n1 2 1\n0 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 0\n0 3 0\n1 2 1\n0 4 0\n0 1 1\n0 0 0\n" ]
[ "4\n13\n8\n" ]
[ "5 5 5\n0 0 1\n0 0 0\n0 2 0\n1 2 1\n0 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 1\n0 3 0\n1 2 1\n0 4 0\n0 1 1\n0 0 0\n", "5 5 5\n0 0 2\n0 0 0\n0 2 0\n1 2 1\n0 0 0\n5 5 5\n1 4 0\n0 1 1\n0 4 1\n1 3 0\n0 3 1\n5 5 5\n1 0 0\n0 3 0\n1 2 1\n0 4 0\n0 1 1\n0 0 0\n", "5 5 5\n0 0 1\n0 0 0\n0 2 0\n1 2 1\n0 ...
[ "4\n13\n10\n", "4\n13\n8\n", "4\n13\n7\n", "4\n9\n8\n", "4\n4\n8\n", "4\n7\n8\n", "4\n8\n8\n", "4\n7\n3\n", "4\n12\n8\n", "4\n4\n3\n" ]
CodeContests
Peter P. Pepper is facing a difficulty. After fierce battles with the Principality of Croode, the Aaronbarc Kingdom, for which he serves, had the last laugh in the end. Peter had done great service in the war, and the king decided to give him a big reward. But alas, the mean king gave him a hard question to try his in...
stdin
null
308
1
[ "7 1 2 2 2 2 2 2\n0\n" ]
[ "0.942809\n" ]
[ "7 1 2 2 2 2 2 4\n0\n", "7 1 2 2 1 2 2 0\n0\n", "7 1 2 3 2 2 2 2\n0\n", "7 1 2 2 1 2 1 0\n0\n", "7 1 2 3 2 3 2 2\n0\n", "7 1 2 3 2 3 4 2\n0\n", "7 1 2 3 4 3 4 2\n0\n", "7 1 3 3 4 3 4 2\n0\n", "7 1 3 0 4 3 4 2\n0\n", "7 1 3 0 4 3 4 4\n0\n" ]
[ "0.552770798\n", "0.311804782\n", "0.866025404\n", "0.276385399\n", "1.142609100\n", "1.404358296\n", "1.837117307\n", "2.808716591\n", "0.953793595\n", "1.823839052\n" ]