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
Now that you have won Code Monk and been hired by HackerEarth as a software engineer, you have been assigned to work on their wildly popular programming contest website. HackerEarth is expecting a lot of participants (P) in Code Monk next year, and they want to make sure that the site can support that many people at t...
stdin
null
2,837
1
[ "2\n19 57 3\n24 97 2\n\nSAMPLE\n" ]
[ "Case #1: 0\nCase #2: 2\n" ]
[ "4\n50 700 2\n27 57 3\n1 1000 2\n24 97 2\n", "2\n19 57 3\n24 97 4\n", "2\n19 57 3\n24 97 2\n\nELPMAS\n", "2\n19 101 3\n24 97 4\n", "4\n50 700 2\n54 57 6\n1 1000 2\n41 97 2\n", "2\n19 100 11\n47 97 4\n", "2\n19 57 2\n24 97 2\n", "4\n50 849 2\n27 57 3\n1 1000 2\n24 97 2\n", "2\n8 101 12\n49 73 4\n", ...
[ "Case #1: 2\nCase #2: 0\nCase #3: 4\nCase #4: 2\n", "Case #1: 0\nCase #2: 1\n", "Case #1: 0\nCase #2: 2\n", "Case #1: 1\nCase #2: 1\n", "Case #1: 2\nCase #2: 0\nCase #3: 4\nCase #4: 1\n", "Case #1: 0\nCase #2: 0\n", "Case #1: 1\nCase #2: 2\n", "Case #1: 3\nCase #2: 0\nCase #3: 4\nCase #4: 2\n", "Cas...
CodeContests
Peter is a person with erratic sleep habits. He goes to sleep at twelve o'lock every midnight. He gets up just after one hour of sleep on some days; he may even sleep for twenty-three hours on other days. His sleeping duration changes in a cycle, where he always sleeps for only one hour on the first day of the cycle. ...
stdin
null
508
1
[ "2\n1 23\n3\n1 1\n2 1\n3 1\n0\n" ]
[ "2\n" ]
[ "2\n0 23\n3\n1 1\n2 1\n3 1\n0\n", "2\n0 23\n3\n1 1\n1 1\n3 1\n0\n", "2\n1 23\n3\n1 1\n4 1\n3 1\n0\n", "2\n1 23\n3\n2 1\n10 1\n3 1\n0\n", "2\n0 23\n3\n1 1\n2 1\n3 2\n0\n", "2\n0 23\n3\n1 1\n1 0\n3 1\n0\n", "2\n0 23\n3\n1 2\n1 0\n3 1\n0\n", "2\n0 23\n3\n1 2\n1 0\n3 2\n0\n", "2\n0 5\n3\n1 1\n2 1\n3 1\n...
[ "2\n", "0\n", "1\n", "3\n", "2\n", "0\n", "0\n", "0\n", "2\n", "2\n" ]
CodeContests
Problem At Abandoned University, N waste materials that give off a strong scent are lined up in a row. The waste materials are numbered from 1 to N in order, and the i-th waste material gives off a strong ai scent. At work, Licht was asked to find the sum of the scents of all the waste wood. If the total scent is M o...
stdin
null
2,023
1
[ "4 10 1\n1 2 3 4\n", "4 11 1\n1 2 3 4\n", "6 25 3\n8 5 1 1 2 6\n" ]
[ "0\n", "-1\n", "1\n" ]
[ "4 10 1\n0 2 3 4\n", "6 25 3\n8 5 1 1 2 4\n", "4 10 1\n0 2 6 4\n", "4 21 1\n1 1 7 3\n", "6 25 1\n0 1 0 2 2 8\n", "6 25 3\n8 5 1 0 2 4\n", "8 10 1\n0 2 6 4\n", "6 25 3\n8 5 1 0 2 3\n", "6 25 3\n8 5 1 1 2 3\n", "4 10 0\n1 2 3 4\n" ]
[ "1\n", "-1\n", "0\n", "2\n", "3\n", "-1\n", "0\n", "-1\n", "-1\n", "0\n" ]
CodeContests
Takahashi has a maze, which is a grid of H \times W squares with H horizontal rows and W vertical columns. The square at the i-th row from the top and the j-th column is a "wall" square if S_{ij} is `#`, and a "road" square if S_{ij} is `.`. From a road square, you can move to a horizontally or vertically adjacent ro...
stdin
null
491
1
[ "3 3\n...\n...\n...\n", "3 5\n...#.\n.#.#.\n.#...\n" ]
[ "4\n", "10\n" ]
[ "3 3\n...\n../\n...\n", "0 5\n...#.\n.#.#.\n.#...\n", "0 5\n.#...\n.#.#.\n.#...\n", "0 5\n.#...\n.#.#.\n.$...\n", "0 5\n.#..-\n.#.#.\n.$...\n", "0 5\n.#..-\n.#.#.\n.$..-\n", "-1 5\n.#..-\n.#.#.\n.$..-\n", "0 6\n.#..-\n.#.#.\n.$..-\n", "0 6\n.#..-\n.#.$.\n.$..-\n", "0 6\n.#..-\n.#/$.\n.$..-\n" ]
[ "4\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
A number is called as a lucky number if its decimal representation contains only the lucky digits, 4 and 7. e.g. 47, 744, 4 are lucky numbers, whereas 5, 17, 467 are not. Recently, Na2a found a magic stone. With the help of this stone, he can multiply a number by any lucky number. Also, the magic stone can be used any ...
stdin
null
4,565
1
[ "2\n2 15\n" ]
[ "2\n60\n" ]
[ "2\n2 26\n", "2\n2 3\n", "2\n2 6\n", "2\n2 7\n", "2\n4 26\n", "2\n2 5\n", "2\n1 6\n", "2\n4 7\n", "2\n4 11\n", "2\n4 5\n" ]
[ "2\n26\n", "2\n3\n", "2\n6\n", "2\n7\n", "4\n26\n", "2\n20\n", "1\n6\n", "4\n7\n", "4\n11\n", "4\n20\n" ]
CodeContests
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the...
stdin
null
3,674
1
[ "3\n1 1 1\n", "3\n1 -1 2\n" ]
[ "1\n1 1\n1 0\n", "4\n-1 1\n2 -2\n" ]
[ "3\n0 1 1\n", "3\n2 -1 2\n", "3\n2 0 2\n", "3\n2 0 1\n", "3\n2 1 1\n", "3\n2 1 2\n", "3\n1 1 -1\n", "3\n2 2 2\n", "3\n3 2 2\n", "3\n3 1 0\n" ]
[ "2\n0 1\n1 -1\n", "5\n-1 2\n2 -3\n", "4\n0 2\n2 -2\n", "3\n0 1\n2 -1\n", "2\n1 1\n2 0\n", "3\n1 2\n2 -1\n", "3\n-1 1\n1 -2\n", "2\n2 2\n2 0\n", "3\n2 2\n3 0\n", "4\n0 1\n3 -1\n" ]
CodeContests
Alice: "Hi, Bob! Let's play Nim!" Bob: "Are you serious? I don't want to play it. I know how to win the game." Alice: "Right, there is an algorithm to calculate the optimal move using XOR. How about changing the rule so that a player loses a game if he or she makes the XOR to $0$?" Bob: "It sounds much better now, but ...
stdin
null
4,208
1
[ "2\n1\n1\n", "10\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "5\n1\n2\n3\n4\n5\n" ]
[ "Alice\n", "Alice\n", "Bob\n" ]
[ "2\n0\n1\n", "10\n1\n2\n3\n4\n5\n6\n7\n9\n9\n10\n", "5\n1\n2\n3\n4\n4\n", "10\n2\n2\n3\n4\n5\n6\n7\n9\n9\n10\n", "5\n1\n2\n3\n6\n4\n", "10\n3\n2\n3\n4\n5\n6\n7\n9\n9\n10\n", "5\n0\n2\n3\n6\n4\n", "10\n3\n2\n3\n4\n5\n6\n7\n9\n11\n10\n", "5\n0\n2\n2\n6\n4\n", "10\n3\n2\n3\n4\n5\n6\n7\n9\n10\n10\n" ]
[ "Bob\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n", "Alice\n" ]
CodeContests
Given an array A. Delete an single element from the array such that sum of the differences of adjacent elements should be minimum. For more clarification Sum for an array A having N element is defined as : abs( A[0] - A[1] ) + abs( A[1] - A[2] ) + abs( A[2] - A[3] ) +............ + abs( A[N-2] - A[N-1] ) Inp...
stdin
null
407
1
[ "1\n5\n1 10 20 40 60\n\nSAMPLE\n" ]
[ "4\n" ]
[ "5\n1\n100\n2\n100 1\n2\n1 2\n3\n1 100 2\n3\n1 2 3\n3\n1 5 6\n3\n1 7 8\n3\n8 7 1\n3\n7 8 2\n3\n7 1 8\n", "5\n1\n100\n2\n100 0\n2\n1 2\n3\n1 100 2\n3\n1 0 3\n3\n0 5 3\n3\n1 7 8\n1\n8 7 1\n3\n7 9 2\n3\n7 1 8\n", "1\n5\n1 7 20 40 60\n\nSAMPLE\n", "5\n1\n101\n2\n100 0\n2\n1 2\n2\n1 101 2\n3\n1 0 3\n3\n0 5 3\n3\n1...
[ "0\n0\n0\n1\n0\n", "0\n0\n0\n1\n2\n", "4\n", "0\n0\n0\n0\n2\n", "0\n0\n0\n1\n1\n", "0\n0\n0\n0\n1\n", "0\n0\n0\n2\n2\n", "0\n", "0\n0\n0\n2\n0\n", "2\n" ]
CodeContests
Chef loves to play with arrays by himself. Today, he has an array A consisting of N distinct integers. He wants to perform the following operation on his array A. Select a pair of adjacent integers and remove the larger one of these two. This decreases the array size by 1. Cost of this operation will be equal to the ...
stdin
null
1,792
1
[ "2\n2\n3 4\n3\n4 2 5\n" ]
[ "3\n4\n" ]
[ "2\n2\n3 4\n3\n4 2 9\n", "2\n2\n3 4\n3\n0 2 5\n", "2\n2\n0 4\n3\n4 0 9\n", "2\n2\n0 4\n3\n7 2 9\n", "2\n2\n3 4\n3\n-1 1 5\n", "2\n2\n0 4\n3\n4 1 9\n", "2\n2\n1 4\n3\n4 2 9\n", "2\n2\n-1 4\n3\n4 1 4\n", "2\n2\n1 4\n3\n3 0 4\n", "2\n2\n-1 7\n3\n3 0 4\n" ]
[ "3\n4\n", "3\n0\n", "0\n0\n", "0\n4\n", "3\n-2\n", "0\n2\n", "1\n4\n", "-1\n2\n", "1\n0\n", "-1\n0\n" ]
CodeContests
Problem One day, mo3tthi and tubuann decided to play a game with magic pockets and biscuits. Now there are $ K $ pockets, numbered $ 1,2, \ ldots, K $. The capacity of the $ i $ th pocket is $ M_i $, which initially contains $ N_i $ biscuits. mo3tthi and tubuann start with mo3tthi and perform the following series of o...
stdin
null
2,422
1
[ "1\n2 4\n", "2\n2 3\n3 8\n", "10\n2 8\n5 9\n7 20\n8 41\n23 48\n90 112\n4 5\n7 7\n2344 8923\n1 29\n" ]
[ "mo3tthi\n", "tubuann\n", "mo3tthi\n" ]
[ "1\n2 5\n", "2\n1 3\n3 9\n", "2\n1 3\n3 8\n", "10\n2 8\n5 9\n7 20\n8 41\n23 48\n112 112\n4 5\n7 7\n2344 8923\n1 29\n", "1\n2 6\n", "10\n2 14\n5 9\n7 20\n8 41\n23 48\n112 112\n4 5\n7 7\n2344 8923\n1 29\n", "1\n2 7\n", "10\n2 14\n5 9\n7 20\n12 41\n23 48\n112 112\n4 5\n7 7\n2344 8923\n1 29\n", "1\n1 6\...
[ "mo3tthi\n", "tubuann\n", "mo3tthi\n", "mo3tthi\n", "mo3tthi\n", "mo3tthi\n", "mo3tthi\n", "tubuann\n", "tubuann\n", "mo3tthi\n" ]
CodeContests
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those ...
stdin
null
60
1
[ "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n", "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\n", "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1...
[ "8\n", "23\n", "-2\n" ]
[ "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -1 -2 -1 -1 -1 -1 -1\n", "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -4 -3 4 -2\n", "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -4 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n", "2\n1 1 1 1 1 0 0 0 0 0\n0...
[ "-1\n", "8\n", "-2\n", "0\n", "10\n", "11\n", "23\n", "1\n", "7\n", "12\n" ]
CodeContests
Adam Ivan is working as a system administrator at Soy Group, Inc. He is now facing at a big trouble: a number of computers under his management have been infected by a computer virus. Unfortunately, anti-virus system in his company failed to detect this virus because it was very new. Adam has identified the first comp...
stdin
null
2,416
1
[ "3 2\n1 1 2\n2 2 3\n3 2\n2 3 2\n1 2 1\n0 0\n" ]
[ "3\n1\n" ]
[ "3 2\n1 1 3\n2 2 3\n3 2\n2 3 2\n1 2 1\n0 0\n", "3 2\n1 1 2\n2 2 3\n3 2\n2 3 2\n1 2 0\n0 0\n", "4 2\n1 0 3\n1 2 3\n3 2\n2 3 2\n2 2 1\n0 0\n", "3 2\n1 1 3\n1 2 3\n3 2\n2 1 2\n1 2 0\n0 0\n", "3 2\n1 0 3\n1 2 3\n3 2\n2 1 2\n1 2 0\n0 0\n", "3 2\n1 1 3\n1 2 3\n3 2\n2 3 2\n1 2 1\n0 0\n", "3 2\n1 1 3\n1 2 3\n3 ...
[ "2\n1\n", "3\n1\n", "1\n1\n", "2\n2\n", "1\n2\n", "2\n1\n", "2\n1\n", "2\n1\n", "2\n1\n", "2\n1\n" ]
CodeContests
In this problem you will be given a range 'n', and you are supposed to find all composite numbers within that range. Make your program efficient as time limit of the program is set to 1 second. Choose an efficient algorithm to find all the composite numbers within the range 0 to n. Input n - a single positive Integer...
stdin
null
1,354
1
[ "8\n\nSAMPLE\n" ]
[ "4 6 8\n" ]
[ "8\n\nTAMPLE\n", "8\n\nTAPMLE\n", "8\n\nSAPMLE\n", "8\n\nSAPNLE\n", "8\n\nSNPALE\n", "8\n\nSNAPLE\n", "8\n\nELPANS\n", "8\n\nEKPANS\n", "8\n\nEKPAMS\n", "8\n\nEMPAKS\n" ]
[ "4 6 8\n", "4 6 8\n", "4 6 8\n", "4 6 8\n", "4 6 8\n", "4 6 8\n", "4 6 8\n", "4 6 8\n", "4 6 8\n", "4 6 8\n" ]
CodeContests
Roy has N coin boxes numbered from 1 to N. Every day he selects two indices [L,R] and adds 1 coin to each coin box starting from L to R (both inclusive). He does this for M number of days. After M days, Roy has a query: How many coin boxes have atleast X coins. He has Q such queries. Input: First line contains N ...
stdin
null
684
1
[]
[]
[ "1000\n1000\n282 706\n388 521\n574 934\n410 922\n396 525\n4 550\n48 698\n595 953\n852 861\n3 677\n534 674\n408 417\n615 899\n830 873\n362 393\n989 991\n318 820\n316 708\n712 919\n181 745\n197 728\n765 782\n735 999\n444 697\n452 712\n623 838\n538 849\n480 604\n724 974\n603 650\n487 864\n656 785\n607 870\n249 831\n90...
[ "0\n0\n0\n895\n0\n0\n138\n0\n444\n0\n669\n0\n945\n0\n945\n0\n0\n0\n808\n842\n0\n519\n0\n0\n0\n0\n0\n0\n0\n388\n0\n490\n595\n369\n0\n921\n0\n0\n842\n366\n990\n0\n0\n906\n882\n0\n0\n0\n0\n223\n0\n0\n0\n0\n0\n266\n0\n0\n979\n285\n0\n0\n0\n0\n0\n490\n0\n0\n0\n0\n0\n743\n0\n0\n826\n0\n232\n0\n0\n0\n0\n3\n731\n0\n0\n685\...
CodeContests
Ross, Chandler and Joey are best friends. One day they went to pond and Joey suggest them to play the game "Bamboozle". In this game they have N balls with each numbered from 0-9, but first ball is numbered from 1-9. Ross tells sub-strings 'S' formed by those balls and Chandler throws S stones into the pond. At last, J...
stdin
null
3,103
1
[ "16\n\nSAMPLE\n" ]
[ "23\n" ]
[ "16\n\nELPMAS\n", "16\n\nTAMPLE\n", "16\n\nELPMAT\n", "16\n\nTAMELP\n", "16\n\nFLPMAT\n", "16\n\nFLPTAM\n", "16\n\nFLPTBM\n", "16\n\nFLTPBM\n", "16\n\nMBPTLF\n", "16\n\nMPBTLF\n" ]
[ "23\n", "23\n", "23\n", "23\n", "23\n", "23\n", "23\n", "23\n", "23\n", "23\n" ]
CodeContests
Sumit had borrowed money from many of his batch mates and today he has decided to pay them because he has got lottery today. The amount of lottery is very large. So to count the money he decided to write the amount in Indian system first. In the Indian system the rightmost comma is placed after three rightmost digit...
stdin
null
1,043
1
[ "3\n12345\n54321\n125634\n\nSAMPLE\n" ]
[ "12,345\n54,321\n1,25,634\n" ]
[ "100\n698592418393878689411761587696313175928437347348326627483485536712565561678647431612168692743232947913547413349962773447279799459298488246875377698334683879137956493421365365717745219243792938726113829391935321624356127754296144763969257788962339725137947329338144349453312993997561171882988877593499\n61216868...
[ "6,98,59,24,18,39,38,78,68,94,11,76,15,87,69,63,13,17,59,28,43,73,47,34,83,26,62,74,83,48,55,36,71,25,65,56,16,78,64,74,31,61,21,68,69,27,43,23,29,47,91,35,47,41,33,49,96,27,73,44,72,79,79,94,59,29,84,88,24,68,75,37,76,98,33,46,83,87,91,37,95,64,93,42,13,65,36,57,17,74,52,19,24,37,92,93,87,26,11,38,29,39,19,35,32,1...
CodeContests
There is a stack of N cards, each of which has a non-negative integer written on it. The integer written on the i-th card from the top is A_i. Snuke will repeat the following operation until two cards remain: * Choose three consecutive cards from the stack. * Eat the middle card of the three. * For each of the other ...
stdin
null
4,581
1
[ "10\n3 1 4 1 5 9 2 6 5 3\n", "6\n5 2 4 1 6 9\n", "4\n3 1 4 2\n" ]
[ "115\n", "51\n", "16\n" ]
[ "10\n3 1 4 1 5 9 2 11 5 3\n", "6\n5 2 4 1 1 9\n", "4\n1 1 4 2\n", "10\n3 1 4 1 5 2 2 11 5 3\n", "6\n5 2 4 1 1 15\n", "4\n1 0 4 2\n", "10\n3 1 4 1 5 2 2 11 5 4\n", "6\n5 2 4 1 0 15\n", "4\n1 0 2 2\n", "10\n3 1 4 1 5 2 2 11 0 4\n" ]
[ "130\n", "35\n", "14\n", "110\n", "41\n", "11\n", "111\n", "37\n", "7\n", "95\n" ]
CodeContests
A rank list is a list of ranks of persons in a programming contest. Note that some of the persons might be having same rank. {1, 2}, {1, 2, 2} and {1, 1, 2, 3, 4, 4} are few examples of rank lists whereas {1, 3}, {0, 2}, {1, 2, 4} are not rank lists. Also note that a rank list need not to be sorted e.g. {2, 2, 1} and {...
stdin
null
2,668
1
[ "4\n1 1\n3 6\n3 5\n3 3\n" ]
[ "0\n0\n1\n2\n" ]
[ "4\n1 1\n3 6\n5 5\n3 3\n", "4\n1 1\n3 5\n5 5\n3 3\n", "4\n1 1\n5 5\n5 5\n3 3\n", "4\n1 1\n5 5\n5 5\n3 4\n", "4\n1 1\n3 6\n3 6\n3 3\n", "4\n1 1\n4 5\n5 5\n3 3\n", "4\n1 1\n5 5\n5 10\n3 4\n", "4\n1 1\n3 5\n3 6\n3 3\n", "4\n1 1\n4 5\n5 5\n2 3\n", "4\n1 1\n3 3\n3 6\n3 3\n" ]
[ "0\n0\n4\n2\n", "0\n1\n4\n2\n", "0\n4\n4\n2\n", "0\n4\n4\n1\n", "0\n0\n0\n2\n", "0\n2\n4\n2\n", "0\n4\n2\n1\n", "0\n1\n0\n2\n", "0\n2\n4\n0\n", "0\n2\n0\n2\n" ]
CodeContests
Given are integers N and X. For each integer k between 0 and X (inclusive), find the answer to the following question, then compute the sum of all those answers, modulo 998244353. * Let us repeat the following operation on the integer k. Operation: if the integer is currently odd, subtract 1 from it and divide it by 2...
stdin
null
2,761
1
[ "30\n001110011011011101010111011100\n", "3\n111\n", "6\n110101\n" ]
[ "549320998\n", "40\n", "616\n" ]
[ "30\n001110011011011101010101011100\n", "3\n011\n", "6\n100101\n", "30\n001010011011011101010101011100\n", "3\n001\n", "6\n100100\n", "30\n001010011010011101010101011100\n", "3\n000\n", "6\n101100\n", "30\n001010011010011111010101011100\n" ]
[ "549313318\n", "20\n", "440\n", "515761610\n", "12\n", "428\n", "500033010\n", "6\n", "516\n", "500524530\n" ]
CodeContests
Sherlock Holmes loves mind palaces! We all know that. A mind palace, according to Mr. Holmes is something that lets him retrieve a given memory in the least time posible. For this, he structures his mind palace in a very special way. Let a NxM Matrix denote the mind palace of Mr. Holmes. For fast retrieval he keeps ea...
stdin
null
129
1
[]
[]
[ "5 5\n-993655555 -758584352 -725954642 -696391700 -649643547\n-591473088 -568010221 -432112275 -421496588 -351507172\n-323741602 -232192004 -30134637 -369573 100246476\n156824549 174266331 392354039 601294716 763826005\n768378344 802829330 818988557 992012759 999272829\n8\n156824549\n-758584352\n-993655555\n6012947...
[ "3 0\n0 1\n0 0\n3 3\n0 3\n4 1\n0 0\n2 1\n", "3 0\n0 1\n0 0\n3 3\n-1 -1\n4 1\n0 0\n2 1\n3 2\n1 1\n", "3 0\n0 1\n-1 -1\n3 3\n0 3\n4 1\n0 0\n2 1\n3 2\n1 1\n", "-1 -1\n0 1\n0 0\n3 3\n-1 -1\n4 1\n0 0\n2 1\n3 2\n1 1\n", "3 0\n0 1\n0 0\n3 3\n-1 -1\n4 1\n0 0\n2 1\n-1 -1\n1 1\n", "3 0\n0 1\n0 0\n3 3\n0 3\n4 1\n0 0...
CodeContests
There are N boxes .The i^th box contains ai candies . The frog Om Nom is sitting in box number 1 .Om Nom wants to collect as many candies as he can . However , Om Nom jumps in a peculiar fashion . Om Nom can jump from box number j to box number i only if j | i (j divides i) . Whenever Om Nom lands in a box , he collect...
stdin
null
524
1
[ "5\n2 3 1 4 6\n\nSAMPLE\n" ]
[ "2 5 3 9 8\n" ]
[ "148\n38880 46895 80132 88245 77363 71933 93909 46769 47228 96450 69233 44647 61774 11261 2651 8339 1432 35044 18705 96225 60061 47398 46365 66010 75670 761 554 72235 4523 45330 98606 65055 41605 14463 72441 89080 95196 86470 30643 84208 47641 83918 63079 26874 55998 91126 58574 87423 88981 76839 28924 93922 18747 ...
[ "38880 85775 119012 174020 116243 190945 132789 220789 166240 212693 108113 235592 100654 144050 121663 229128 40312 225989 57585 308918 192850 155511 85245 301602 191913 101415 166794 246255 43403 258023 137486 294183 160617 100238 205230 324672 134076 172245 149655 393126 86521 276768 101959 200894 222238 176901 ...
CodeContests
You are given an integer N. Among the divisors of N! (= 1 \times 2 \times ... \times N), how many Shichi-Go numbers (literally "Seven-Five numbers") are there? Here, a Shichi-Go number is a positive integer that has exactly 75 divisors. Constraints * 1 \leq N \leq 100 * N is an integer. Input Input is given from S...
stdin
null
2,128
1
[ "9\n", "100\n", "10\n" ]
[ "0\n", "543\n", "1\n" ]
[ "11\n", "4\n", "17\n", "20\n", "36\n", "25\n", "14\n", "29\n", "30\n", "46\n" ]
[ "1\n", "0\n", "3\n", "8\n", "42\n", "11\n", "2\n", "32\n", "35\n", "86\n" ]
CodeContests
Example Input 2 10 6 4 4 E 6 4 W Output 2
stdin
null
3,052
1
[ "2 10 6\n4 4 E\n6 4 W\n" ]
[ "2\n" ]
[ "2 19 6\n4 4 E\n6 4 W\n", "2 19 1\n4 4 E\n6 0 W\n", "2 19 6\n4 4 E\n6 0 W\n", "2 19 10\n4 4 E\n6 0 W\n", "3 19 10\n4 4 E\n6 0 W\n", "3 19 10\n4 4 E\n6 -1 W\n", "2 10 9\n4 4 E\n6 4 W\n", "2 28 6\n4 4 E\n6 0 W\n", "1 19 10\n4 4 E\n6 0 W\n", "3 19 5\n4 4 E\n6 -1 W\n" ]
[ "2\n", "1\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n", "1\n", "2\n" ]
CodeContests
It’s still hot every day, but September has already come. It’s autumn according to the calendar. Looking around, I see two red dragonflies at rest on the wall in front of me. It’s autumn indeed. When two red dragonflies’ positional information as measured from the end of the wall is given, make a program to calculate ...
stdin
null
3,843
1
[ "50 25\n", "25 25\n", "20 30\n" ]
[ "25\n", "0\n", "10\n" ]
[ "50 12\n", "25 13\n", "27 30\n", "50 0\n", "25 17\n", "27 22\n", "58 0\n", "25 11\n", "27 37\n", "26 0\n" ]
[ "38\n", "12\n", "3\n", "50\n", "8\n", "5\n", "58\n", "14\n", "10\n", "26\n" ]
CodeContests
PandeyG, a brilliant tennis player, decided to start a tournament in his colony. Now, since PandeyG is overly optimistic and ambitious - he tries to lure in as many people as he can from his colony for them to participate in his very own knockout type tennis tournament. What he fails to realize that, to have a knockout...
stdin
null
1,921
1
[ "2\n7\n3\n\nSAMPLE\n" ]
[ "6\n2\n" ]
[ "2\n7\n2\n\nSAMPLE\n", "2\n7\n4\n\nSAMPLE\n", "2\n10\n4\n\nSAMPLE\n", "2\n6\n4\n\nSAMPLE\n", "2\n6\n5\n\nSAMPLE\n", "2\n10\n5\n\nSAMPLE\n", "2\n10\n1\n\nASMPLE\n", "2\n12\n1\n\nELPMSA\n", "2\n20\n1\n\nELPMSA\n", "2\n9\n1\n\nDKPMSA\n" ]
[ "6\n1\n", "6\n3\n", "9\n3\n", "5\n3\n", "5\n4\n", "9\n4\n", "9\n0\n", "11\n0\n", "19\n0\n", "8\n0\n" ]
CodeContests
There has been marketing warfare among beverage vendors, and they have been working hard for in- crease of their sales. The Kola-Coqua Company is one of the most successful vendors among those: their impressive advertisements toward the world has brought the overwhelming market share of their representative product cal...
stdin
null
1,259
1
[ "6 330\n1 5 10 50 100 500\n7 127\n1 2 4 8 16 32 64\n2 10000\n1000 2000\n0 0\n" ]
[ "2\n1\n4\n" ]
[ "6 330\n1 5 10 50 100 500\n7 127\n1 2 4 8 29 32 64\n2 10000\n1000 2000\n0 0\n", "6 330\n1 5 10 50 100 500\n7 127\n1 2 4 8 16 32 64\n2 10000\n1000 1446\n0 0\n", "6 330\n1 5 10 50 100 500\n7 127\n1 2 0 8 16 32 64\n2 10000\n1000 1446\n0 0\n", "6 330\n1 5 10 50 100 500\n7 127\n1 2 0 8 16 32 64\n2 11000\n1000 1446...
[ "2\n1\n4\n", "2\n1\n10\n", "2\n3\n10\n", "2\n3\n11\n", "4\n1\n10\n", "3\n1\n10\n", "2\n2\n11\n", "2\n2\n10\n", "3\n2\n10\n", "3\n2\n11\n" ]
CodeContests
Equivalent Deformation Two triangles T1 and T2 with the same area are on a plane. Your task is to perform the following operation to T1 several times so that it is exactly superposed on T2. Here, vertices of T1 can be on any of the vertices of T2. Compute the minimum number of operations required to superpose T1 on T2...
stdin
null
4,046
1
[ "0 1\n2 2\n1 0\n1 3\n5 2\n4 3\n\n0 0\n0 1\n1 0\n0 3\n0 2\n1 -1\n\n-5 -4\n0 1\n0 15\n-10 14\n-5 10\n0 -8\n\n-110 221\n-731 525\n-555 -258\n511 -83\n-1000 -737\n66 -562\n\n533 -45\n-525 -450\n-282 -667\n-439 823\n-196 606\n-768 -233\n\n0 0\n0 1\n1 0\n99 1\n100 1\n55 2\n\n354 -289\n89 -79\n256 -166\n131 -196\n-774 -80...
[ "4\n3\n3\n3\n3\n4\n4\n4\n4\nMany\nMany\nMany\nMany\n" ]
[ "0 1\n2 2\n1 0\n1 3\n5 2\n4 3\n\n0 0\n0 1\n1 0\n0 3\n0 2\n1 -1\n\n-5 -4\n0 1\n0 15\n-10 14\n-5 10\n0 -8\n\n-110 221\n-731 525\n-555 -258\n511 -83\n-1000 -737\n66 -562\n\n533 -45\n-525 -450\n-282 -667\n-439 823\n-196 606\n-768 -233\n\n0 0\n0 1\n1 0\n99 1\n100 1\n55 2\n\n354 -289\n89 -79\n256 -166\n131 -196\n-774 -80...
[ "4\n3\n3\n3\n3\n4\n4\n4\n4\nMany\nMany\nMany\nMany\n", "4\n3\n3\n3\n3\n4\nMany\n4\n4\nMany\nMany\nMany\nMany\n", "4\n3\n3\nMany\n3\n4\nMany\n4\n4\nMany\nMany\nMany\nMany\n", "4\n3\n3\nMany\n3\n4\nMany\nMany\n4\nMany\nMany\nMany\nMany\n", "4\n3\n3\nMany\nMany\n4\nMany\nMany\n4\nMany\nMany\nMany\nMany\n", "...
CodeContests
You are given an array containing 2 \times n elements.You have to partition the numbers in to n pairs with the property that partition minimize the maximum sum of a pair. Input First line contains T number of test cases. Next line contain N number of pairs. Next line contain 2*N positive integers represent elemen...
stdin
null
563
1
[ "1\n3\n5 6 2 3 9 8\n\nSAMPLE\n" ]
[ "11\n" ]
[ "1\n3\n0 6 2 3 9 8\n\nSAMPLE\n", "1\n3\n0 6 1 3 9 8\n\nSAMPLE\n", "1\n3\n0 6 1 3 9 11\n\nSAMPLE\n", "1\n3\n5 6 2 4 9 8\n\nSAMPLE\n", "1\n3\n5 6 2 4 9 16\n\nSAMPLE\n", "1\n3\n5 6 2 4 16 16\n\nSAMPLE\n", "1\n3\n5 6 2 4 19 16\n\nSAMPLE\n", "1\n3\n5 5 0 4 19 10\n\nSAMPLE\n", "1\n3\n0 6 1 3 8 0\n\nSANPLE...
[ "10\n", "9\n", "11\n", "12\n", "18\n", "20\n", "21\n", "19\n", "8\n", "14\n" ]
CodeContests
Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence. Input The input consists of multiple datasets. Each data set consists of: n a1 a2 . . an You can assume that 1 ≤ n ≤ 5000 ...
stdin
null
4,548
1
[ "7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n" ]
[ "19\n14\n1001\n" ]
[ "7\n-5\n-2\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n", "7\n-5\n-2\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n1\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n", "7\n-5\n-2\n6\n8\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n1\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n", "7\n-5\...
[ "19\n14\n1001\n", "19\n13\n1001\n", "23\n13\n1001\n", "23\n13\n1000\n", "19\n12\n1001\n", "19\n14\n1000\n", "18\n13\n1001\n", "19\n12\n1000\n", "23\n12\n1000\n", "19\n15\n1001\n" ]
CodeContests
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? Constraints * 1 \leq a, b, c \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: a \ b \ c Output If \sqrt{a} + \sqrt{b} < \sqrt{c}, print `Yes`; otherwise, print `No`. Examples Input 2 3 9 Output No I...
stdin
null
1,164
1
[ "2 3 10\n", "2 3 9\n" ]
[ "Yes\n", "No\n" ]
[ "3 3 10\n", "2 1 9\n", "3 3 14\n", "4 1 9\n", "3 3 13\n", "4 0 9\n", "3 3 0\n", "1 0 9\n", "3 3 -1\n", "0 0 9\n" ]
[ "No\n", "Yes\n", "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "Yes\n", "No\n", "Yes\n" ]
CodeContests
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy s...
stdin
null
884
1
[ "615\n", "217\n" ]
[ "1\n", "0\n" ]
[ "386\n", "0\n", "59\n", "115\n", "10\n", "53\n", "3\n", "84\n", "4\n", "97\n" ]
[ "0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
One day, the teacher came up with the following game. The game uses n cards with one number from 1 to 10 and proceeds as follows. 1. The teacher pastes n cards on the blackboard in a horizontal row so that the numbers can be seen, and declares an integer k (k ≥ 1) to the students. For n cards arranged in a horizontal...
stdin
null
227
1
[ "4 2\n2\n3\n7\n5\n0 0\n" ]
[ "0\n" ]
[ "4 2\n4\n3\n7\n5\n0 0\n", "4 2\n1\n6\n4\n5\n0 0\n", "4 2\n8\n3\n10\n5\n0 0\n", "4 2\n4\n3\n7\n1\n0 0\n", "4 2\n4\n1\n14\n3\n0 0\n", "4 2\n8\n3\n16\n5\n0 0\n", "4 2\n4\n3\n11\n1\n0 0\n", "4 2\n9\n5\n16\n5\n0 0\n", "4 2\n2\n2\n1\n5\n0 0\n", "4 2\n1\n6\n2\n5\n0 0\n" ]
[ "0\n", "6\n", "30\n", "7\n", "14\n", "48\n", "11\n", "64\n", "5\n", "18\n" ]
CodeContests
A tutorial for this problem is now available on our blog. Click here to read it. You are asked to calculate factorials of some small positive integers. Input An integer t, 1 ≤ t ≤ 100, denoting the number of testcases, followed by t lines, each containing a single integer n, 1 ≤ n ≤ 100. Output For each integer n ...
stdin
null
5,035
1
[ "4\n1\n2\n5\n3\n" ]
[ "1\n2\n120\n6\n" ]
[ "4\n2\n2\n5\n3\n", "4\n2\n2\n5\n6\n", "4\n2\n2\n8\n6\n", "4\n2\n2\n2\n6\n", "4\n1\n2\n2\n6\n", "4\n1\n2\n2\n9\n", "4\n2\n2\n2\n9\n", "4\n2\n2\n4\n9\n", "4\n3\n2\n4\n9\n", "4\n3\n2\n4\n3\n" ]
[ "2\n2\n120\n6\n", "2\n2\n120\n720\n", "2\n2\n40320\n720\n", "2\n2\n2\n720\n", "1\n2\n2\n720\n", "1\n2\n2\n362880\n", "2\n2\n2\n362880\n", "2\n2\n24\n362880\n", "6\n2\n24\n362880\n", "6\n2\n24\n6\n" ]
CodeContests
Long long ago, there were several identical columns (or cylinders) built vertically in a big open space near Yokohama (Fig. F-1). In the daytime, the shadows of the columns were moving on the ground as the sun moves in the sky. Each column was very tall so that its shadow was very long. The top view of the shadows is s...
stdin
null
1,937
1
[ "3\n1 1\n3 1\n4 3\n4\n1 1\n2 3\n3 8\n1 9\n8\n1 1\n3 1\n6 1\n1 3\n5 3\n1 7\n3 5\n5 5\n8\n20 7\n1 27\n30 14\n9 6\n17 13\n4 2\n17 7\n8 9\n0\n" ]
[ "2.553590050042226\n0.982793723247329\n1.570796326794896\n2.819842099193151\n1.325817663668032\n2.094395102393196\n2.777613697080149\n0.588002603547568\n" ]
[ "3\n1 1\n3 1\n4 3\n4\n1 1\n2 3\n3 8\n1 9\n8\n1 1\n3 1\n6 1\n1 4\n5 3\n1 7\n3 5\n5 5\n8\n20 7\n1 27\n30 14\n9 6\n17 13\n4 2\n17 7\n8 9\n0\n", "3\n1 1\n3 1\n4 3\n4\n1 1\n2 3\n3 8\n1 9\n8\n1 1\n3 1\n6 1\n1 4\n5 3\n1 7\n3 5\n5 5\n8\n20 7\n1 27\n45 14\n9 6\n17 13\n4 2\n17 7\n8 9\n0\n", "3\n1 1\n3 1\n4 3\n4\n1 1\n2 3...
[ "2.5535900500\n0.9827937232\n1.5707963268\n2.8198420992\n1.3258176637\n2.3005239830\n2.7776136971\n0.5880026035\n", "2.5535900500\n0.9827937232\n1.5707963268\n2.8198420992\n1.3258176637\n2.3005239830\n2.8568622151\n0.5880026035\n", "2.5535900500\n0.9827937232\n1.5707963268\n2.8198420992\n1.3258176637\n2.3005239...
CodeContests
In 2337, people are bored at daily life and have crazy desire of having extraordinary experience. These days,“Dungeon Adventure” is one of the hottest attractions, where brave adventurers risk their lives to kill the evil monsters and save the world. You are a manager of one of such dungeons. Recently you have been re...
stdin
null
2,738
1
[ "50 2 0\n0 0\n49 1\n", "50 2 0\n0 0\n49 0\n", "3 4 4\n1 0 1 1\n1 3 1 4\n1 2 2 2\n2 1 2 3\n0 0\n1 0\n" ]
[ "0\n", "2\n", "6\n" ]
[ "3 4 4\n1 0 1 1\n1 3 1 4\n2 2 2 2\n2 1 2 3\n0 0\n1 0\n", "3 4 4\n1 0 1 1\n1 3 1 4\n2 2 0 2\n2 1 2 3\n0 0\n1 0\n", "3 4 4\n1 0 1 1\n1 3 1 4\n2 2 2 2\n2 1 2 2\n0 0\n1 0\n", "3 7 4\n1 0 1 1\n1 3 1 4\n1 1 2 2\n2 1 2 3\n0 0\n1 0\n", "50 2 0\n0 0\n70 1\n", "50 2 0\n0 1\n49 0\n", "50 2 0\n1 1\n49 0\n", "1 4 ...
[ "6\n", "0\n", "4\n", "2\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
Soma is a fashionable girl. She absolutely loves shiny stones that she can put on as jewellery accessories. She has been collecting stones since her childhood - now she has become really good with identifying which ones are fake and which ones are not. Her King requested for her help in mining precious stones, so she ...
stdin
null
4,567
1
[ "4\nabc\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone\n" ]
[ "3\n2\n1\n0\n" ]
[ "4\nacb\nabcdef\naA\nabAZ\naaa\na\nwhat\nnone\n", "4\nacb\nabcdef\nAa\nabZA\naaa\n`\nwhat\nnone\n", "4\naca\nebcdaf\naA\nAbZa\n`aa\n`\nswha\nnomf\n", "4\nac`\nebcdae\naA\nAbZa\n`aa\n_\nsvha\nnome\n", "4\nac`\nebcdae\naA\nAbZ`\n`aa\n_\nsvha\nemon\n", "4\n`ca\neacdae\naA\nAbZ`\n`aa\n_\nahvs\nmeon\n", "4\n...
[ "3\n2\n1\n0\n", "3\n2\n0\n0\n", "2\n2\n1\n0\n", "2\n2\n0\n0\n", "2\n1\n0\n0\n", "3\n1\n0\n0\n", "3\n0\n0\n0\n", "2\n0\n0\n0\n", "1\n1\n0\n0\n", "1\n0\n0\n0\n" ]
CodeContests
It is vacation time and Panda is in his hometown Pandaland. Panda is very bored so he started studying some interesting properties of natural numbers. Some days later he meet his friend Agham, who is pretty good in mathematics and tells him about interesting properties of natural numbers & ask him to test his skills.So...
stdin
null
3,305
1
[ "2\n1 3\n6 10\n\nSAMPLE\n" ]
[ "1\n1\n" ]
[ "100\n846930886 1804289383\n1681692777 1714636915\n424238335 1957747793\n719885386 1429837752\n596516649 1189641421\n1025202362 1350490027\n783368690 1102520059\n1967513926 2044897763\n1365180540 1540383426\n304089172 1303455736\n35005211 521595368\n294702567 1726956429\n336465782 861021530\n233665123 278722862\n46...
[ "13374\n400\n23649\n10983\n10068\n4731\n5216\n864\n2299\n18665\n16922\n24390\n11000\n1408\n24667\n9260\n11058\n3447\n13148\n15636\n7029\n14439\n2845\n2777\n32912\n20015\n17423\n16351\n5182\n19711\n23035\n1269\n10115\n12020\n4691\n24603\n14077\n5362\n15116\n9499\n19554\n12731\n15564\n21626\n10971\n9767\n5371\n13821\...
CodeContests
Input Format Let the i-th query query_i, the input format is following: N Q p_0 a_0 p_1 a_1 : : p_{N - 1} a_{N - 1} query_0 query_1 : : query_{Q - 1} THe format of query_i is one of the three format: 1 v_i d_i x_i 2 v_i d_i 3 pr_i ar_i Output Format Print the result in one line for each query 2. ...
stdin
null
2,727
1
[ "6 7\n-1 6\n0 5\n0 4\n2 3\n2 2\n1 1\n2 0 1\n1 0 2 1\n2 2 1\n3 3 3\n2 0 3\n3 3 4\n2 1 1\n" ]
[ "15\n12\n30\n8\n" ]
[ "6 7\n-1 6\n0 5\n0 4\n2 3\n2 2\n1 1\n2 0 1\n1 0 2 1\n2 2 1\n3 3 3\n2 0 3\n3 3 4\n2 1 2\n", "6 7\n-1 6\n0 5\n0 4\n2 3\n2 2\n1 1\n2 0 0\n1 0 2 1\n2 2 1\n3 3 3\n2 0 3\n3 3 4\n2 1 2\n", "6 7\n-1 6\n0 5\n0 4\n2 3\n2 0\n1 1\n2 0 1\n1 0 2 1\n2 2 1\n3 3 3\n2 0 3\n3 3 0\n2 1 2\n", "6 7\n-1 6\n0 5\n0 4\n2 3\n2 0\n1 1\n...
[ "15\n12\n30\n8\n", "6\n12\n30\n8\n", "15\n10\n28\n8\n", "6\n10\n28\n8\n", "6\n6\n28\n12\n", "26\n", "26\n11\n", "4\n24\n", "4\n22\n", "4\n" ]
CodeContests
There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with color i. None of the sides were painted in multiple colors. Find the mi...
stdin
null
1,585
1
[ "5\n2\n3\n4\n5\n6\n", "2\n3\n3\n" ]
[ "12\n", "5\n" ]
[ "5\n2\n3\n3\n5\n6\n", "2\n6\n3\n", "2\n6\n2\n", "2\n5\n2\n", "2\n1\n2\n", "2\n1\n3\n", "5\n2\n3\n5\n5\n6\n", "5\n2\n3\n3\n2\n6\n", "2\n8\n3\n", "2\n5\n1\n" ]
[ "11\n", "8\n", "7\n", "6\n", "2\n", "3\n", "13\n", "9\n", "10\n", "5\n" ]
CodeContests
Example Input 2 2 7 3 4 3 2 1 3 1 1 2 2 1 2 2 1 1 2 2 2 1 1 Output 5
stdin
null
4,554
1
[ "2 2 7\n3 4\n3 2\n1 3\n1 1\n2 2\n1 2\n2 1\n1 2\n2 2\n1 1\n" ]
[ "5\n" ]
[ "2 2 7\n5 4\n3 2\n1 3\n1 1\n2 2\n1 2\n2 1\n1 2\n2 2\n1 1\n", "2 2 7\n3 4\n3 2\n1 3\n1 2\n2 2\n1 2\n2 1\n1 2\n2 2\n1 1\n", "4 2 7\n3 4\n3 2\n1 3\n1 1\n2 2\n1 2\n2 1\n1 2\n2 2\n1 1\n", "2 2 7\n3 4\n3 2\n1 3\n1 1\n2 2\n1 2\n2 1\n1 2\n2 4\n1 1\n", "2 2 7\n5 4\n3 3\n1 3\n1 1\n2 2\n1 2\n2 1\n1 2\n2 2\n1 1\n", "...
[ "-1\n", "4\n", "3\n", "5\n", "6\n", "-1\n", "-1\n", "-1\n", "4\n", "-1\n" ]
CodeContests
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are similar when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many ...
stdin
null
812
1
[ "10\n90 52 56 71 44 8 13 30 57 84\n", "2\n2 3\n", "1\n100\n", "3\n3 3 3\n" ]
[ "58921\n", "7\n", "1\n", "26\n" ]
[ "10\n90 101 56 71 44 8 13 30 57 84\n", "2\n2 4\n", "1\n000\n", "3\n3 3 2\n", "10\n41 101 56 71 44 8 13 30 57 84\n", "2\n3 6\n", "1\n011\n", "3\n3 2 0\n", "10\n60 101 56 71 44 8 13 30 114 84\n", "3\n1 1 -1\n" ]
[ "58985\n", "5\n", "1\n", "25\n", "59017\n", "7\n", "2\n", "23\n", "58921\n", "26\n" ]
CodeContests
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or abo...
stdin
null
4,499
1
[ "1333333333\n", "103\n", "1000000000000000000\n" ]
[ "1706\n", "3\n", "3760\n" ]
[ "1925339908\n", "121\n", "1000010000000000000\n", "2918372355\n", "1100010000000000000\n", "1759180116\n", "314793131\n", "385473767\n", "693073999\n", "463707925\n" ]
[ "1743\n", "21\n", "3760\n", "1785\n", "3770\n", "1734\n", "1561\n", "1582\n", "1641\n", "1600\n" ]
CodeContests
There is data of up to 100 characters per line, consisting of half-width alphabetic character strings. Some lines are symmetric (same whether read from the left edge or the right edge). Create a program that reads this data and outputs the number of symmetric strings in it. Note that lines consisting of only one charac...
stdin
null
1,814
1
[ "abcba\nsx\nabcddcba\nrttrd\n" ]
[ "2\n" ]
[ "abcba\nsx\nabcddcba\nrstrd\n", "abcca\nsw\nabcddcba\nrstrd\n", "abcca\nxt\nadcbdcba\nrdsrt\n", "abcba\nsw\nabcddcba\nrstrd\n", "accba\nsw\nabcddcba\nrstrd\n", "accba\nsx\nabcddcba\nrstrd\n", "accba\ntx\nabcddcba\nrstrd\n", "accba\ntx\nabcddcba\nrsdrt\n", "accca\ntx\nabcddcba\nrsdrt\n", "accca\ntx...
[ "2\n", "1\n", "0\n", "2\n", "1\n", "1\n", "1\n", "1\n", "2\n", "2\n" ]
CodeContests
Artistic Crystal Manufacture developed products named Crystal Jails. They are cool ornaments forming a rectangular solid. They consist of colorful crystal cubes. There are bright cores on the center of cubes, which are the origin of the name. The combination of various colored reflections shows fantastic dance of light...
stdin
null
2,025
1
[ "3 3 3 5\n3 2 2\n***\n.*.\n\n.*.\n...\n\n3 2 1\n***\n**.\n\n3 1 3\n..*\n\n.**\n\n**.\n\n3 2 2\n..*\n...\n\n***\n..*\n\n3 1 3\n.**\n\n.**\n\n***\n\n3 3 3 2\n3 3 3\n***\n***\n***\n\n***\n*.*\n***\n\n***\n***\n***\n\n1 1 1\n*\n\n3 2 1 2\n3 1 1\n***\n\n2 2 1\n**\n*.\n\n0 0 0 0\n" ]
[ "Yes\nYes\nNo\n" ]
[ "3 3 3 5\n3 2 2\n***\n.*.\n\n.*.\n-..\n\n3 2 1\n***\n**.\n\n3 1 3\n..*\n\n.**\n\n**.\n\n3 2 2\n..*\n...\n\n***\n..*\n\n3 1 3\n.**\n\n.**\n\n***\n\n3 3 3 2\n3 3 3\n***\n***\n***\n\n***\n*.*\n***\n\n***\n***\n***\n\n1 1 1\n*\n\n3 2 1 2\n3 1 1\n***\n\n2 2 1\n**\n*.\n\n0 0 0 0\n", "3 3 3 5\n3 2 2\n***\n.*.\n\n.*.\n.....
[ "Yes\nYes\nNo\n", "No\nYes\nNo\n", "Yes\nYes\nYes\n", "Yes\nNo\nNo\n", "No\nYes\nYes\n", "Yes\nNo\nYes\n", "Yes\nYes\nNo\n", "Yes\nYes\nNo\n", "Yes\nYes\nNo\n", "Yes\nYes\nNo\n" ]
CodeContests
Time Limit: 8 sec / Memory Limit: 64 MB Example Input 10 10 .....#.... .....#.... .....#.... ######.... .......... ####...... ....###... t..#..#### ...##..... ....#...## 3 0 3 0 5 4 6 Output 2
stdin
null
2,379
1
[ "10 10\n.....#....\n.....#....\n.....#....\n######....\n..........\n####......\n....###...\nt..#..####\n...##.....\n....#...##\n3\n0 3\n0 5\n4 6\n" ]
[ "2\n" ]
[ "10 10\n.....#....\n.....#....\n.....#....\n######....\n..........\n####......\n....###...\nt..#..####\n...##.....\n##...#....\n3\n0 3\n0 5\n4 6\n", "10 10\n.....#....\n.....#....\n.....#-...\n######....\n..........\n####......\n....###...\nt..#..####\n...##.....\n##...#....\n3\n0 3\n0 9\n4 6\n", "10 10\n.....#...
[ "2\n", "3\n", "-1\n", "1\n", "0\n", "2\n", "2\n", "2\n", "2\n", "2\n" ]
CodeContests
There are N integers, A_1, A_2, ..., A_N, written on the blackboard. You will choose one of them and replace it with an integer of your choice between 1 and 10^9 (inclusive), possibly the same as the integer originally written. Find the maximum possible greatest common divisor of the N integers on the blackboard afte...
stdin
null
3,795
1
[ "3\n7 6 8\n", "2\n1000000000 1000000000\n", "3\n12 15 18\n" ]
[ "2\n", "1000000000\n", "6\n" ]
[ "3\n7 6 7\n", "2\n1000010000 1000000000\n", "3\n12 29 18\n", "2\n1000000000 1000001000\n", "3\n4 8 7\n", "2\n1001000000 1000001000\n", "3\n9 28 18\n", "3\n9 28 30\n", "2\n1001100000 1000001100\n", "2\n1101000000 1000001100\n" ]
[ "7\n", "1000010000\n", "6\n", "1000001000\n", "4\n", "1001000000\n", "9\n", "3\n", "1001100000\n", "1101000000\n" ]
CodeContests
For a string S consisting of the uppercase English letters `P` and `D`, let the doctoral and postdoctoral quotient of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, s...
stdin
null
2,878
1
[ "PD?D??P\n", "P?P?\n" ]
[ "PDPDPDP\n", "PDPD\n" ]
[ "PDPD???\n", "?P?P\n", "DDPP???\n", "??PP\n", "DDPO???\n", "??OP\n", "DDPO?>?\n", "??OO\n", "?>?OPDD\n", "@?OP\n" ]
[ "PDPDDDD\n", "DPDP\n", "DDPPDDD\n", "DDPP\n", "DDPODDD\n", "DDOP\n", "DDPOD>D\n", "DDOO\n", "D>DOPDD\n", "@DOP\n" ]
CodeContests
JholiBaba is a student of vnit and he has a craze for rotation. A Roller contest is organized in vnit which JholiBaba wants to win. In the contest, there is one roller which is represented similar to a strip of 1xN blocks. Each block has a number written on it. The roller keeps rotating and you will figure out that aft...
stdin
null
4,925
1
[ "3\n20 30 10\n\nSAMPLE\n" ]
[ "140\n" ]
[ "5\n-12452 90611 67470 -857 -9054\n", "3\n20 42 10\n\nSAMPLE\n", "5\n-12452 158770 67470 -857 -9054\n", "5\n-12452 158770 67470 -1393 -9054\n", "3\n9 42 10\n\nSAMOLE\n", "5\n-16220 158770 67470 -1393 -9054\n", "3\n9 38 10\n\nSAMOLE\n", "5\n-16220 158770 67470 -1393 -8057\n", "3\n9 58 10\n\nSAMOLE\n"...
[ "643473\n", "176\n", "916109\n", "915573\n", "154\n", "904269\n", "142\n", "906263\n", "202\n", "1139238\n" ]
CodeContests
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers. You can assume that a word consists of at most 30 characters, and the page number is less than or equal to 1000. The number of pairs of a word and a page number ...
stdin
null
3,602
1
[ "style 12\neven 25\nintroduction 3\neasy 9\nstyle 7\ndocument 13\nstyle 21\neven 18\n" ]
[ "document\n13\neasy\n9\neven\n18 25\nintroduction\n3\nstyle\n7 12 21\n" ]
[ "style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ndocument 13\nstyle 21\neven 18\n", "style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ntnemucod 13\nstyle 21\neven 18\n", "style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ntnemucod 13\nstyle 21\neven 10\n", "style 12\neven 25\nintroduction 3\neasy 9\nst...
[ "document\n13\neasy\n9\neven\n18 25\nintroduction\n3\nstyle\n9 12 21\n", "easy\n9\neven\n18 25\nintroduction\n3\nstyle\n9 12 21\ntnemucod\n13\n", "easy\n9\neven\n10 25\nintroduction\n3\nstyle\n9 12 21\ntnemucod\n13\n", "easy\n9\neven\n10 25\nintroduction\n3\nstyle\n12 17 21\ntnemucod\n13\n", "easy\n9\neven\...
CodeContests
Bill is a boss of security guards. He has pride in that his men put on wearable computers on their duty. At the same time, it is his headache that capacities of commercially available batteries are far too small to support those computers all day long. His men come back to the office to charge up their batteries and sp...
stdin
null
2,257
1
[ "3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 2 0\n\n4 1000\n80 20 80 20 80 20 80 20 0\n80\n20\n0\n80 20 90\n10 80\n20\n0\n90 10\n0\n\n0 0\n" ]
[ "10\n110\n" ]
[ "3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 2 0\n\n4 1000\n80 20 80 20 80 20 80 20 0\n80\n20\n0\n80 20 90\n10 80\n20\n0\n90 9\n0\n\n0 0\n", "3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 2 0\n\n4 1000\n80 20 80 40 80 20 80 20 0\n80\n20\n0\n80 20 90\n10 80\n20\n0\n90 9\n0\n\n0 0\n", "3 25\n3 1 2 1 4 1 0\n1 1 0\n2 1 3 2 0\n\n4 1000\n...
[ "10\n118\n", "10\n238\n", "10\n152\n", "14\n118\n", "10\n232\n", "17\n118\n", "10\n229\n", "16\n118\n", "9\n229\n", "10\n246\n" ]
CodeContests
C: Shopping-Shopping- story Isono's older sister, Sazoe, decided to cook dinner for Isono and Nakajima, who are playing "that" and "that". Unfortunately, there are only a few ingredients left in the refrigerator, so Sazoe decided to go shopping. Mr. Sazoe is trying to buy some ingredients, but he is so cheerful that ...
stdin
null
3,775
1
[ "3 9 3 2 3\n1 2 3\n1 1 2\n2 3 1\n3 4 2\n4 1 3\n4 1 1\n5 1 1\n6 2 3\n7 2 2\n" ]
[ "6\n" ]
[ "3 9 3 2 3\n1 2 3\n1 2 2\n2 3 1\n3 4 2\n4 1 3\n4 1 1\n5 1 1\n6 2 3\n7 2 2\n", "3 9 6 2 3\n1 2 3\n1 2 2\n2 3 1\n3 4 2\n4 1 3\n4 1 1\n5 1 1\n6 2 2\n7 2 2\n", "3 9 9 2 3\n1 2 3\n1 2 2\n2 3 1\n3 0 2\n4 1 3\n4 1 1\n5 1 2\n6 2 2\n7 2 2\n", "3 9 6 2 3\n1 2 3\n1 2 2\n2 3 1\n3 4 3\n4 1 3\n4 1 1\n5 1 2\n6 2 2\n12 2 2\n...
[ "6\n", "12\n", "18\n", "13\n", "10\n", "3\n", "4\n", "2\n", "1\n", "8\n" ]
CodeContests
On the Internet, data is divided into packets, and each packet is transferred to a destination via a relay device called a router. Each router determines the next router to forward from the destination described in the packet. In addition, a value called TTL (Time To Live) is added to the packet to prevent it from bein...
stdin
null
1,774
1
[ "7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 2\n1 5 3\n1 2 1\n5 1 3\n6 3 3\n1 7 4\n" ]
[ "2\n2\nNA\n3\n3\n3\n" ]
[ "7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 2\n1 5 3\n1 2 0\n5 1 3\n6 3 3\n1 7 4\n", "7\n1 4 2 5 4 6\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 2\n1 3 3\n1 2 0\n5 1 3\n6 3 3\n1 7 4\n", "7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 2\n1 3 6\n1 2 0\n5 1 3\n6 3 1\n1...
[ "2\n2\nNA\n3\n3\n3\n", "2\nNA\nNA\n3\nNA\n3\n", "2\n2\nNA\n3\nNA\n3\n", "2\nNA\nNA\n3\nNA\n2\n", "2\n2\nNA\n3\n3\n2\n", "NA\n2\nNA\n3\n3\n3\n", "2\nNA\nNA\n3\n3\n3\n", "2\nNA\nNA\nNA\nNA\n3\n", "2\n2\nNA\n3\n3\nNA\n", "NA\nNA\nNA\n3\nNA\n3\n" ]
CodeContests
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive. Constraints * The length of W ≤ 10 * W consists of lower cas...
stdin
null
3,375
1
[ "computer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the new era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n" ]
[ "3\n" ]
[ "computer\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and exploit \"knowledge\" for the enw era.\nProvides an outstanding computer environment.\nEND_OF_TEXT\n", "comquter\nNurtures computer scientists and highly-skilled computer engineers\nwho will create and tiolpxe \"kno...
[ "3\n", "0\n", "2\n", "1\n", "3\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
Problem There are $ N $ Amidakuji with 3 vertical lines. No matter which line you start from, the Amidakuji that ends at the starting line is considered a good Amidakuji. You can select one or more Amidakuji and connect them vertically in any order. Output "yes" if you can make a good Amidakuji, otherwise output "no"....
stdin
null
4,916
1
[ "3\n2 0 0\n1 1\n5 1 0 0 1 0\n", "2\n1 1\n1 0\n" ]
[ "yes\n", "no\n" ]
[ "3\n2 0 0\n1 1\n10 1 0 0 1 0\n", "2\n1 1\n3 0\n", "2\n1 1\n2 0\n", "3\n2 0 0\n1 1\n10 1 0 0 2 0\n", "2\n1 0\n2 0\n", "3\n3 0 0\n1 1\n10 1 0 0 2 0\n", "2\n1 1\n2 -1\n", "3\n3 0 0\n1 1\n10 2 0 0 2 0\n", "2\n1 1\n2 -2\n", "3\n3 0 0\n0 1\n10 2 0 0 2 0\n" ]
[ "yes\n", "no\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n", "yes\n" ]
CodeContests
In the Indian Puzzle, one is intended to fill out blanks with numbers and operators in a n by n grid in order to make equalities in the grid true (See Figure 1). <image> Figure 1 A blank cell should be filled out with a number (from 0 to 9 inclusive) or an operator (+, -, ×, ÷, =), and black cells split equaliti...
stdin
null
1,414
1
[ "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 3 1 4 / 8\n1 6\n8..3=2\n2\n2 +\n0 0\n" ]
[ "Yes\nNo\n" ]
[ "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 0 1 4 / 8\n1 6\n8..3=2\n2\n2 +\n0 0\n", "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 3 1 4 / 8\n1 6\n8..3=2\n2\n4 +\n0 0\n", "5 5\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 0 1 4 0 8\n1 6\n8..3=2\n2\n2 +\n0 0\n", "5 3\n4=..2\n+#=#+\n.-2=.\n=#*#=\n.-.=3\n6\n7 0 1 4 ...
[ "No\nNo\n", "Yes\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n", "No\nNo\n" ]
CodeContests
There are a number of ways to shuffle a deck of cards. Riffle shuffle is one such example. The following is how to perform riffle shuffle. There is a deck of n cards. First, we divide it into two decks; deck A which consists of the top half of it and deck B of the bottom half. Deck A will have one more card when n is ...
stdin
null
1,098
1
[ "9 1\n3\n9 4\n1 2 3 4\n" ]
[ "3\n0\n" ]
[ "9 1\n3\n9 4\n1 2 6 4\n", "9 1\n3\n11 4\n1 2 6 4\n", "9 1\n3\n9 4\n1 1 6 6\n", "9 1\n2\n11 4\n1 2 6 4\n", "8 1\n3\n16 4\n1 1 3 4\n", "9 1\n2\n17 4\n1 2 6 4\n", "9 1\n3\n15 4\n2 1 6 6\n", "8 1\n3\n24 4\n1 1 3 4\n", "9 1\n4\n5 4\n1 2 6 4\n", "2 1\n4\n5 4\n1 2 6 4\n" ]
[ "3\n0\n", "3\n10\n", "3\n1\n", "8\n10\n", "3\n15\n", "8\n1\n", "3\n3\n", "3\n13\n", "8\n0\n", "0\n0\n" ]
CodeContests
The cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically verify that the images obtained by shooting each coaster are symmetrical. Each coaster is represent...
stdin
null
1,373
1
[ "1 6\n000000\n000000\n010010\n010010\n000000\n000000\n", "7 8\n00100000\n00011000\n10111101\n01100110\n01000110\n10111101\n00011000\n00100100\n2\n5 3\n1 6\n1\n6 8\n3\n6 8\n3 3\n3 6\n2\n6 3\n6 6\n0\n2\n3 8\n6 8\n", "2 2\n00\n00\n4\n1 1\n1 2\n2 1\n2 2\n" ]
[ "1\n", "3\n", "2\n" ]
[ "1 6\n000000\n000000\n010010\n011010\n000000\n000000\n", "1 2\n00\n00\n4\n1 1\n1 2\n2 1\n2 2\n", "2 0\n00\n00\n4\n1 1\n2 2\n2 1\n2 2\n", "7 8\n00100000\n00011000\n10111101\n01100110\n01000110\n10111101\n00011000\n00100100\n2\n5 3\n0 6\n1\n6 8\n3\n6 8\n3 3\n3 6\n2\n6 3\n6 6\n0\n2\n3 8\n6 8\n", "1 6\n000000\n...
[ "0\n", "1\n", "2\n", "0\n", "0\n", "0\n", "1\n", "0\n", "0\n", "1\n" ]
CodeContests
Despite urging requests of the townspeople, the municipal office cannot afford to improve many of the apparently deficient city amenities under this recession. The city swimming pool is one of the typical examples. It has only two swimming lanes. The Municipal Fitness Agency, under this circumstances, settled usage rul...
stdin
null
384
1
[ "2\n10 30\n15 20\n2\n10 240\n15 160\n3\n2 6\n7 2\n8 2\n4\n2 4\n7 2\n8 2\n18 1\n0\n" ]
[ "600\n4800\n36\n40\n" ]
[ "2\n10 30\n15 20\n2\n10 240\n15 160\n3\n2 6\n7 4\n8 2\n4\n2 4\n7 2\n8 2\n18 1\n0\n", "2\n5 30\n15 20\n2\n10 240\n15 160\n3\n2 6\n7 2\n8 2\n4\n2 4\n7 2\n8 2\n18 1\n0\n", "2\n10 30\n15 17\n2\n10 240\n15 160\n3\n2 6\n7 3\n8 2\n4\n2 4\n7 2\n8 2\n18 1\n0\n", "2\n10 30\n15 17\n2\n10 240\n15 160\n3\n2 6\n7 3\n8 4\n4...
[ "600\n4800\n56\n40\n", "600\n4800\n36\n40\n", "600\n4800\n42\n40\n", "600\n4800\n64\n40\n", "600\n8880\n42\n40\n", "600\n9600\n36\n40\n", "600\n6400\n36\n40\n", "600\n4800\n56\n32\n", "600\n4800\n", "990\n4800\n42\n40\n" ]
CodeContests
Chef Al Gorithm was reading a book about climate and oceans when he encountered the word “glaciological”. He thought it was quite curious, because it has the following interesting property: For every two letters in the word, if the first appears x times and the second appears y times, then |x - y| ≤ 1. Chef Al was happ...
stdin
null
1,994
1
[ "4\nglaciological 1\nteammate 0\npossessions 3\ndefenselessness 3\n" ]
[ "0\n0\n1\n2\n" ]
[ "4\nglaciological 1\nteammate 0\npossessions 3\ndefenselessness 0\n", "4\nglaciological 1\nteammate 0\npossessions 4\ndefenselessness 0\n", "4\nglaciological 1\nteammate 1\npossessions 4\ndefensdlessness 0\n", "4\nlacigoloicalg 2\nteammate 0\npossessions 0\ndefensdnessless 0\n", "4\nlacigoloicalg 4\nteammat...
[ "0\n0\n1\n5\n", "0\n0\n0\n5\n", "0\n0\n0\n7\n", "0\n0\n5\n7\n", "0\n0\n5\n5\n", "0\n0\n5\n3\n", "0\n2\n5\n3\n", "0\n2\n5\n1\n", "0\n2\n5\n0\n", "1\n2\n5\n1\n" ]
CodeContests
Yesterday Oz heard a story about insect colony. The specialty of insects is that they splits sometimes i.e an insect of size A can split into two insects of positive integral sizes B and C such that A = B + C. Also sometimes they attack each other i.e. two insects of sizes P and Q will become R = P XOR Q . You are give...
stdin
null
166
1
[ "2\n2 9 17\n1 1\n\nSAMPLE\n" ]
[ "Yes\nNo\n" ]
[ "10\n75 995991040 148627929 566366239 458028006 823890903 945174886 530827147 546010999 720763988 183796976 748924885 868038355 870234651 273702889 972313979 607688156 495203509 981301128 72001489 10285302 970980434 30653173 738175457 455018413 940530064 537884091 418532701 982359437 761503932 363212677 676520393 1...
[ "No\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nYes\nYes\n", "No\nNo\n", "No\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nNo\nYes\n", "Yes\nNo\n", "No\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nNo\nYes\n", "Yes\nYes\nYes\nNo\nNo\nYes\nNo\nYes\nNo\nYes\n", "No\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nNo\nYes\n", "Yes\nYes\nYes\nNo\nYes\nYe...
CodeContests
G: Almost Infinite Glico problem There is a field where N squares are arranged in a ring. The i-th (1 \ leq i \ leq N-1) cell is ahead of the i + 1th cell. However, if i = N, the next cell is the first cell. The first cell you are in is the first cell. From there, play rock-paper-scissors K times in a row according ...
stdin
null
5,070
1
[ "10 3 2\n3\n6\n6\n" ]
[ "1\n0\n4\n2\n0\n0\n5\n0\n0\n4\n" ]
[ "10 3 2\n3\n10\n6\n", "10 3 2\n3\n10\n9\n", "11 3 2\n3\n10\n9\n", "11 3 2\n3\n17\n9\n", "11 3 2\n3\n17\n16\n", "11 2 2\n3\n17\n16\n", "11 1 2\n3\n17\n16\n", "7 3 2\n3\n6\n6\n", "10 3 2\n3\n16\n6\n", "2 3 2\n3\n10\n9\n" ]
[ "4\n0\n1\n4\n0\n0\n5\n0\n0\n2\n", "4\n0\n2\n4\n0\n0\n1\n0\n1\n4\n", "1\n2\n2\n2\n0\n0\n1\n1\n2\n3\n2\n", "1\n3\n0\n2\n2\n0\n3\n1\n0\n4\n0\n", "3\n1\n0\n2\n0\n2\n3\n0\n2\n2\n1\n", "1\n1\n0\n2\n0\n0\n3\n0\n0\n2\n0\n", "1\n0\n0\n2\n0\n0\n1\n0\n0\n0\n0\n", "1\n0\n4\n2\n0\n4\n5\n", "1\n0\n4\n2\n0\n0\n5\n...
CodeContests
In Storia Kingdom, there is an artifact called "Perfect Sphere" made by a great meister Es. This is handed down for generations in the royal palace as a treasure. Es left a memo and filled mysterious values in it. Within achievements of researches, it has been revealed that the values denote coordinate values. However ...
stdin
null
3,323
1
[ "4 10 8\n0 -10\n3 -7\n0 -4\n-3 -7\n0 0 0\n" ]
[ "-4.146082488326 -9.100000000000\n-7.545870128753 -6.562000000000\n-9.587401146004 -2.842840000000\n-9.903199956975 1.388031200000\n-8.436422775690 5.369056784000\n-5.451089494781 8.383652146880\n-1.484560104812 9.889190123322\n2.749190104024 9.614673877565\n" ]
[ "4 10 8\n0 -10\n3 -10\n0 -4\n-3 -7\n0 0 0\n", "4 10 8\n0 -10\n0 -7\n0 -4\n-3 -7\n0 0 0\n", "4 10 8\n0 -10\n0 -7\n0 -4\n-3 -8\n0 0 0\n", "4 10 8\n0 -10\n0 -7\n0 -6\n-3 -8\n0 0 0\n", "4 10 7\n0 -10\n3 -7\n0 -4\n-3 -7\n0 0 0\n", "4 10 8\n0 -10\n3 -10\n0 -4\n0 -7\n0 0 0\n", "4 10 8\n0 -10\n0 -7\n0 -8\n-3 -8...
[ "-4.146082488326 -9.100000000000\n-7.545870128753 -6.562000000000\n-9.994978960652 -0.316852609465\n-9.639185228818 2.661974478567\n-7.667981981229 6.418882483388\n-4.316541977019 9.020391641200\n2.355217791420 9.718690711972\n5.131853014658 8.582778375092\n", "-4.146082488326 -9.100000000000\n-7.545870128753 -6....
CodeContests
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be po...
stdin
null
3,553
1
[ "3\n2 4 3\n", "12\n100 104 102 105 103 103 101 105 104 102 104 101\n" ]
[ "3\n", "0\n" ]
[ "3\n2 5 3\n", "12\n100 104 102 105 103 103 100 105 104 102 104 101\n", "3\n2 8 3\n", "12\n100 104 102 105 103 103 100 117 104 102 104 101\n", "3\n2 8 2\n", "12\n101 104 102 105 103 103 100 117 104 102 104 101\n", "12\n101 104 102 105 103 103 100 117 104 102 104 111\n", "3\n2 0 4\n", "12\n101 104 102...
[ "4\n", "1\n", "7\n", "11\n", "8\n", "10\n", "20\n", "2\n", "62\n", "52\n" ]
CodeContests
Its vacation time and Panda with two of his best friends Agham and Rishi is in his hometown, Pandaland. One day Panda came across a very delicious dish called PandaCake. He likes it very much and bought 'N' of them from a shop. Now on the day of his arrival i.e. on the first day, he ate only one PandaCake and decided t...
stdin
null
1,759
1
[ "3\n5\n1\n4\n\nSAMPLE\n" ]
[ "4\n1\n3\n" ]
[ "3\n1\n1\n4\n\nSAMPLE\n", "3\n1\n1\n5\n\nSAMPLE\n", "3\n5\n1\n8\n\nSAMPLE\n", "3\n1\n1\n9\n\nSAMPLE\n", "3\n5\n1\n1\n\nSAMPLE\n", "3\n10\n1\n1\n\nSAMPLE\n", "3\n10\n1\n2\n\nSAMPLE\n", "3\n1\n1\n15\n\nSALOEL\n", "3\n2\n1\n15\n\nSALOEL\n", "3\n2\n2\n15\n\nSALOEL\n" ]
[ "1\n1\n3\n", "1\n1\n4\n", "4\n1\n5\n", "1\n1\n5\n", "4\n1\n1\n", "6\n1\n1\n", "6\n1\n2\n", "1\n1\n7\n", "2\n1\n7\n", "2\n2\n7\n" ]
CodeContests
Problem C: Earn Big A group of N people is trying to challenge the following game to earn big money. First, N participants are isolated from each other. From this point, they are not allowed to contact each other, or to leave any information for other participants. The game organizer leads each participant, one by on...
stdin
null
2,898
1
[ "2 1\n", "100 50\n" ]
[ "0.50000000\n", "0.31182782\n" ]
[ "4 1\n", "110 50\n", "4 0\n", "010 50\n", "110 89\n", "110 12\n", "010 4\n", "010 1\n", "3 2\n", "3 1\n" ]
[ "0.041666666667\n", "0.224802593637\n", "0.000000000000\n", "1.000000000000\n", "0.789224893493\n", "0.000000001745\n", "0.174365079365\n", "0.000000275573\n", "0.666666666667\n", "0.166666666667\n" ]
CodeContests
You are given four integers: H, W, h and w (1 ≤ h ≤ H, 1 ≤ w ≤ W). Determine whether there exists a matrix such that all of the following conditions are held, and construct one such matrix if the answer is positive: * The matrix has H rows and W columns. * Each element of the matrix is an integer between -10^9 and 10^...
stdin
null
4,232
1
[ "2 4 1 2\n", "3 4 2 3\n", "3 3 2 2\n" ]
[ "No\n", "Yes\n2 -5 8 7\n3 -5 -4 -5\n2 1 -1 7\n", "Yes\n1 1 1\n1 -4 1\n1 1 1\n" ]
[ "0 4 1 2\n", "3 4 4 3\n", "4 3 2 2\n", "4 3 3 2\n", "3 6 4 2\n", "3 10 4 2\n", "5 10 6 2\n", "5 10 2 2\n", "2 4 4 1\n", "4 2 3 2\n" ]
[ "No\n", "Yes\n1000 1000 1000 1000\n1000 1000 1000 1000\n1000 1000 1000 1000\n", "Yes\n1000 1000 1000\n1000 -3001 1000\n1000 1000 1000\n1000 -3001 1000\n", "Yes\n1000 1000 1000\n1000 1000 1000\n1000 -5001 1000\n1000 1000 1000\n", "Yes\n1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000\n1000 1000 1...
CodeContests
There are n wizards. They are numbered from 1 to n, and the i-th wizard has the magical power ri (1 ≤ i ≤ n). Now they are confronting a powerful wizard, whose enemy's magical power is S. n Wizards are good at fighting together, especially two people. When two wizards cooperate, the magical power is simply the sum, and...
stdin
null
2,175
1
[ "3 7\n1\n3\n10\n0 0\n" ]
[ "2\n" ]
[ "3 7\n1\n6\n10\n0 0\n", "3 11\n0\n3\n10\n0 0\n", "3 7\n2\n6\n10\n0 0\n", "3 7\n1\n0\n5\n0 0\n", "3 7\n0\n3\n10\n0 0\n", "3 7\n1\n3\n16\n0 0\n", "3 7\n1\n3\n25\n0 0\n", "3 11\n0\n3\n18\n0 0\n", "3 7\n1\n1\n25\n0 0\n", "3 11\n0\n3\n20\n0 0\n" ]
[ "2\n", "1\n", "3\n", "0\n", "2\n", "2\n", "2\n", "2\n", "2\n", "2\n" ]
CodeContests
Recently in a class of Computer Networks, little Roy learned to calculate Hamming Distance between two strings of equal length. During practical session, Roy's teacher gave him a string of length L with all distinct characters. Teacher asked him to find the number of permutations of the string such that the hamming di...
stdin
null
3,033
1
[ "3\n#$%\n\nSAMPLE\n" ]
[ "2\n" ]
[ "10\nEDCBA@?>=<\n", "2\n$#\n", "3\n#$%\n\nSAMPLF\n", "10\nEDBBA@?>=<\n", "2\n##\n", "3\n#$%\n\nSFMPLA\n", "10\n<=>?@ABBDE\n", "2\n%#\n", "3\n##%\n\nSFMPLA\n", "10\n<=>??ABBDE\n" ]
[ "1334961\n", "1\n", "2\n", "1334961\n", "1\n", "2\n", "1334961\n", "1\n", "2\n", "1334961\n" ]
CodeContests
There is a tree with N vertices, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N - 1), the i-th edge connects Vertex x_i and y_i. Taro has decided to paint each vertex in white or black, so that any black vertex can be reached from any other black vertex by passing through only black vertices. You are given a p...
stdin
null
1,808
1
[ "3 100\n1 2\n2 3\n", "1 100\n", "10 2\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 2\n1 7\n", "4 100\n1 2\n1 3\n1 4\n" ]
[ "3\n4\n3\n", "1\n", "0\n0\n1\n1\n1\n0\n1\n0\n1\n1\n", "8\n5\n5\n5\n" ]
[ "1 101\n", "3 100\n1 2\n1 3\n", "2 100\n1 2\n1 3\n", "4 101\n1 2\n1 3\n1 4\n", "4 101\n1 2\n1 3\n2 4\n", "4 100\n2 4\n1 3\n1 4\n", "4 101\n1 2\n2 3\n2 4\n", "2 001\n1 2\n2 5\n", "10 2\n8 5\n10 8\n6 5\n1 5\n4 8\n2 10\n3 6\n9 4\n1 7\n", "3 110\n1 2\n2 3\n" ]
[ "1\n", "4\n3\n3\n", "2\n2\n", "8\n5\n5\n5\n", "6\n6\n4\n4\n", "6\n4\n4\n6\n", "5\n8\n5\n5\n", "0\n0\n", "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "3\n4\n3\n" ]
CodeContests
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. Constra...
stdin
null
1,441
1
[ "naohiro\n", "takahashi\n" ]
[ "nao\n", "tak\n" ]
[ "maohiro\n", "sakahashi\n", "orihoam\n", "sbkahashi\n", "ihsahakbs\n", "hhsaiakbr\n", "anphiro\n", "rbkaiashh\n", "onphira\n", "rkbaiashh\n" ]
[ "mao\n", "sak\n", "ori\n", "sbk\n", "ihs\n", "hhs\n", "anp\n", "rbk\n", "onp\n", "rkb\n" ]
CodeContests
There are N towns in Takahashi Kingdom. They are conveniently numbered 1 through N. Takahashi the king is planning to go on a tour of inspection for M days. He will determine a sequence of towns c, and visit town c_i on the i-th day. That is, on the i-th day, he will travel from his current location to town c_i. If he...
stdin
null
696
1
[ "3 3\n", "150 300\n", "300 150\n" ]
[ "2\n", "734286322\n", "0\n" ]
[ "3 5\n", "21 300\n", "300 280\n", "5 5\n", "13 300\n", "5 6\n", "13 146\n", "2 146\n", "1 8\n", "62 300\n" ]
[ "96\n", "213825142\n", "0\n", "24\n", "572293777\n", "600\n", "392822654\n", "923108620\n", "1\n", "765418647\n" ]
CodeContests
Harry was contesting to be the most stylist person in his college. He had to collect maximum points from the judges to be able to win. However there was a problem. The judges were sitting in a line and each pair of adjacent judges had ego issues with each other. So if one judge gave X points to Harry then the next judg...
stdin
null
3,744
1
[ "2\n5\n1 2 3 4 5\n1\n10\n\nSAMPLE\n" ]
[ "Case 1: 9\nCase 2: 10\n" ]
[ "10\n42\n18467 6334 26500 19169 15724 11478 29358 26962 24464 5705 28145 23281 16827 9961 491 2995 11942 4827 5436 32391 14604 3902 153 292 12382 17421 18716 19718 19895 5447 21726 14771 11538 1869 19912 25667 26299 17035 9894 28703 23811 31322\n364\n17673 4664 15141 7711 28253 6868 25547 27644 32662 32757 20037 12...
[ "Case 1: 398704\nCase 2: 3534347\nCase 3: 2299463\nCase 4: 1766127\nCase 5: 1972976\nCase 6: 153033\nCase 7: 4782903\nCase 8: 9251188\nCase 9: 2792408\nCase 10: 1137202\n", "Case 1: 398704\nCase 2: 3534347\nCase 3: 2299463\nCase 4: 1766127\nCase 5: 1972976\nCase 6: 153033\nCase 7: 4782903\nCase 8: 9241089\nCase 9...
CodeContests
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove e...
stdin
null
455
1
[ "1 100000\n1\n", "3 21\n1 2 3\n", "2 5\n2 3\n", "2 4\n2 3\n", "2 7\n2 3\n" ]
[ "Second\n", "First\n", "Second\n", "First\n", "First\n" ]
[ "1 100000\n2\n", "3 21\n1 1 3\n", "2 3\n2 3\n", "2 7\n1 3\n", "1 100000\n4\n", "3 21\n1 1 4\n", "2 4\n2 5\n", "2 1\n1 3\n", "2 4\n3 5\n", "2 2\n1 3\n" ]
[ "Second\n", "First\n", "First\n", "First\n", "Second\n", "First\n", "Second\n", "First\n", "First\n", "Second\n" ]
CodeContests
Fast Forwarding Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his video player. ...
stdin
null
2,932
1
[ "19\n" ]
[ "5\n" ]
[ "0\n", "26\n", "25\n", "23\n", "5\n", "4\n", "1\n", "8\n", "38\n", "47\n" ]
[ "0\n", "6\n", "5\n", "7\n", "3\n", "2\n", "1\n", "4\n", "8\n", "9\n" ]
CodeContests
In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each ci...
stdin
null
1,405
1
[ "2 3\n1 32\n2 63\n1 12\n", "2 3\n2 55\n2 77\n2 99\n" ]
[ "000001000002\n000002000001\n000001000001\n", "000002000001\n000002000002\n000002000003\n" ]
[ "2 3\n1 55\n2 77\n2 99\n", "2 3\n2 32\n2 63\n1 12\n", "2 1\n2 55\n2 77\n2 99\n", "2 2\n2 55\n2 77\n2 99\n", "2 3\n2 55\n2 77\n2 195\n", "2 3\n1 32\n2 63\n1 6\n", "2 3\n2 39\n2 16\n1 12\n", "2 2\n2 55\n2 29\n2 195\n", "2 3\n2 96\n2 77\n2 195\n", "2 1\n1 16\n2 77\n2 195\n" ]
[ "000001000001\n000002000001\n000002000002\n", "000002000001\n000002000002\n000001000001\n", "000002000001\n", "000002000001\n000002000002\n", "000002000001\n000002000002\n000002000003\n", "000001000002\n000002000001\n000001000001\n", "000002000002\n000002000001\n000001000001\n", "000002000002\n0000020...
CodeContests
Andrew R. Klein resides in the city of Yanwoe, and goes to his working place in this city every weekday. He has been totally annoyed with the road traffic of this city. All the roads in this city are one-way, so he has to drive a longer way than he thinks he need. One day, the following thought has come up to Andrew’s...
stdin
null
1,459
1
[ "4\n1 4\n4\n1 2\n2 3\n3 4\n4 1\n0\n" ]
[ "1 4\n" ]
[ "4\n1 4\n4\n1 2\n2 3\n4 4\n4 1\n0\n", "4\n1 3\n4\n1 2\n2 3\n4 4\n4 1\n0\n", "4\n1 1\n4\n1 2\n2 3\n4 4\n4 1\n0\n", "4\n2 3\n4\n1 2\n2 3\n4 4\n4 1\n0\n", "4\n2 1\n4\n1 2\n1 1\n4 2\n4 1\n0\n", "4\n1 4\n4\n1 2\n4 1\n2 3\n4 1\n0\n", "4\n1 4\n4\n1 2\n2 3\n3 4\n4 2\n0\n", "4\n1 2\n4\n1 1\n4 3\n4 1\n4 2\n0\n"...
[ "1 4\n", "2 0\n", "0 0\n", "1 0\n", "1 1\n", "1 2\n", "2 4\n", "2 3\n", "3 0\n", "2 1\n" ]
CodeContests
In Chef's house there are N apples lying in a row on the floor. These apples are numbered from 1 (left most one) to N (right most one). The types of apples are also numbered by positive integers, and the type of apple i is Ti. Chef has recently brought two trained dogs. Both of the dogs are too intelligent to know the ...
stdin
null
1,793
1
[ "5 5\n2 4 3 2 1\n", "5 5\n2 4 9 2 5\n" ]
[ "2\n", "-1\n" ]
[ "5 8\n2 4 3 2 1\n", "5 5\n2 4 3 4 1\n", "5 8\n2 4 5 3 1\n", "4 5\n2 4 3 3 1\n", "3 5\n2 4 9 2 5\n", "5 8\n2 4 3 3 1\n", "3 4\n2 4 9 2 5\n", "5 8\n2 4 4 3 1\n", "5 4\n2 4 9 2 5\n", "5 8\n2 4 4 3 0\n" ]
[ "-1\n", "2\n", "3\n", "1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n" ]
CodeContests
Takahashi is meeting up with Aoki. They have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now. Takahashi will leave his house now and go straight to the place at a speed of S meters per minute. Will he arrive in time? Constraints * 1 \leq D \leq 10000 * 1 \leq T \leq 10...
stdin
null
4,618
1
[ "2000 20 100\n", "10000 1 1\n", "1000 15 80\n" ]
[ "Yes\n", "No\n", "Yes\n" ]
[ "3549 20 100\n", "1000 21 80\n", "11000 1 1\n", "3549 20 110\n", "11000 1 2\n", "1000 21 99\n", "3549 20 111\n", "11000 2 2\n", "1000 21 183\n", "3549 20 101\n" ]
[ "No\n", "Yes\n", "No\n", "No\n", "No\n", "Yes\n", "No\n", "No\n", "Yes\n", "No\n" ]
CodeContests
At the risk of its future, International Cellular Phones Corporation (ICPC) invests its resources in developing new mobile phones, which are planned to be equipped with Web browser, mailer, instant messenger, and many other advanced communication tools. Unless members of ICPC can complete this stiff job, it will eventu...
stdin
null
2,060
1
[ "5\npush\npress\nthe\nbutton\nbottom\n77377843288866\n4\ni\nam\ngoing\ngo\n42646464\n3\na\nb\nc\n333\n0\n" ]
[ "press the button.\n--\ni am going.\ni am go go i.\n--\n--\n" ]
[ "5\npush\npress\nthe\nbutton\nbottom\n77377843288866\n4\ni\nma\ngoing\ngo\n42646464\n3\na\nb\nc\n333\n0\n", "5\npush\npress\neht\nbutton\nbottom\n77377843288866\n4\ni\nam\ngoing\ngo\n42646464\n3\na\nb\nc\n333\n0\n", "5\npush\nsserp\nthe\nbutton\nbottom\n77377843288866\n4\ni\nm`\ngoimg\ngo\n42646464\n3\na\nb\nc\...
[ "press the button.\n--\n--\n--\n", "--\ni am going.\ni am go go i.\n--\n--\n", "sserp the button.\n--\n--\n--\n", "sserp the button.\n--\n--\nd d d.\n--\n", "ssepr the button.\n--\n--\nd d d.\n--\n", "ssepr the button.\n--\n--\n", "ssepr the cutton.\n--\n--\n", "--\n--\n--\n", "--\n--\nd d d.\n--\n"...
CodeContests
Johnny needs to make a rectangular box for his physics class project. He has bought P cm of wire and S cm^2 of special paper. He would like to use all the wire (for the 12 edges) and paper (for the 6 sides) to make the box. What is the largest volume of the box that Johnny can make? Input The first line contains t, th...
stdin
null
397
1
[ "2\n20 14\n20 16\n" ]
[ "3.00\n4.15\n" ]
[ "2\n20 14\n20 14\n", "2\n32 14\n20 14\n", "2\n20 14\n36 14\n", "2\n20 8\n36 14\n", "2\n28 8\n36 14\n", "2\n20 16\n20 14\n", "2\n32 20\n20 14\n", "2\n20 14\n20 10\n", "2\n20 16\n20 10\n", "2\n20 4\n20 10\n" ]
[ "3.0\n3.0\n", "1.63\n3.0\n", "3.0\n1.43\n", "0.88\n1.43\n", "0.6\n1.43\n", "4.15\n3.0\n", "3.43\n3.0\n", "3.0\n1.42\n", "4.15\n1.42\n", "0.21\n1.42\n" ]
CodeContests
Given are an integer K and integers a_1,\dots, a_K. Determine whether a sequence P satisfying below exists. If it exists, find the lexicographically smallest such sequence. * Every term in P is an integer between 1 and K (inclusive). * For each i=1,\dots, K, P contains a_i occurrences of i. * For each term in P, there...
stdin
null
4,301
1
[ "5\n3 1 4 1 5\n", "3\n2 4 3\n", "4\n3 2 3 2\n" ]
[ "-1\n", "2 1 3 2 2 3 1 2 3\n", "1 2 3 4 1 3 1 2 4 3\n" ]
[ "5\n1 1 4 1 5\n", "3\n1 1 1\n", "3\n1 1 2\n", "3\n1 2 2\n", "3\n2 1 2\n", "3\n2 1 1\n", "3\n2 2 4\n", "3\n2 4 4\n", "3\n2 2 1\n", "5\n1 1 1 1 1\n" ]
[ "-1\n", "1 2 3\n", "3 1 2 3\n", "2 3 1 2 3\n", "1 3 2 1 3\n", "1 2 3 1\n", "3 1 2 3 3 1 2 3\n", "2 3 1 2 3 2 3 1 2 3\n", "1 2 3 1 2\n", "1 2 3 4 5\n" ]
CodeContests
There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light...
stdin
null
3,556
1
[ "8 5\n-9 -7 -4 -3 1 2 3 4\n", "5 3\n-30 -10 10 20 50\n", "1 1\n0\n", "3 2\n10 20 30\n" ]
[ "10\n", "40\n", "0\n", "20\n" ]
[ "8 5\n-9 -7 -4 -3 1 2 4 4\n", "5 5\n-30 -10 10 20 50\n", "3 2\n10 18 30\n", "5 3\n-30 -5 10 20 50\n", "3 2\n10 20 43\n", "8 1\n-9 -7 -4 -3 1 2 4 4\n", "5 5\n-30 -10 8 20 76\n", "5 5\n-19 -10 8 20 76\n", "8 4\n-14 -7 -4 -11 1 2 3 4\n", "5 4\n-30 -5 16 20 67\n" ]
[ "10\n", "110\n", "18\n", "30\n", "20\n", "1\n", "136\n", "114\n", "4\n", "70\n" ]
CodeContests
Problem statement N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m. Since the teacher in charge...
stdin
null
2,781
1
[ "3 100\n" ]
[ "0 0 100\n" ]
[ "5 100\n", "5 110\n", "5 111\n", "6 110\n", "9 110\n", "9 100\n", "5 101\n", "10 110\n", "14 110\n", "9 000\n" ]
[ "0 0 0 100 100\n", "0 0 0 110 110\n", "0 0 0 111 111\n", "0 0 0 0 110 110\n", "0 0 0 0 0 110 110 110 110\n", "0 0 0 0 0 100 100 100 100\n", "0 0 0 101 101\n", "0 0 0 0 0 0 110 110 110 110\n", "0 0 0 0 0 0 0 0 110 110 110 110 110 110\n", "0 0 0 0 0 0 0 0 0\n" ]
CodeContests
Find the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X. Constraints * 1 \leq N \leq 3000 * 1 \leq X \leq 2N * N and X are integers. Input Input is given from Standard Input in the following format: N X Output Print the nu...
stdin
null
4,461
1
[ "3 3\n", "8 6\n", "9 13\n", "10 1\n", "314 159\n" ]
[ "14\n", "1179\n", "18402\n", "1024\n", "459765451\n" ]
[ "5 3\n", "1 6\n", "13 13\n", "15 1\n", "56 159\n", "5 1\n", "19 13\n", "15 2\n", "43 159\n", "1 1\n" ]
[ "47\n", "3\n", "762218\n", "32768\n", "554719028\n", "32\n", "51048803\n", "16\n", "298877020\n", "2\n" ]
CodeContests
Three men, A, B and C, are eating sushi together. Initially, there are N pieces of sushi, numbered 1 through N. Here, N is a multiple of 3. Each of the three has likes and dislikes in sushi. A's preference is represented by (a_1,\ ...,\ a_N), a permutation of integers from 1 to N. For each i (1 \leq i \leq N), A's i-t...
stdin
null
2,564
1
[ "3\n1 2 3\n2 3 1\n", "9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "6\n1 2 3 4 5 6\n2 1 4 3 6 5\n", "3\n1 2 3\n1 2 3\n", "6\n1 2 3 4 5 6\n6 5 4 3 2 1\n" ]
[ "2\n", "33600\n", "80\n", "0\n", "160\n" ]
[ "3\n1 2 3\n3 3 1\n", "3\n1 2 0\n3 3 1\n", "3\n1 1 0\n3 3 1\n", "3\n1 2 3\n2 3 0\n", "3\n1 2 3\n3 6 1\n", "3\n0 2 0\n3 3 1\n", "3\n2 2 3\n3 6 1\n", "3\n2 2 3\n1 2 3\n", "3\n1 2 0\n2 3 1\n", "3\n1 2 1\n2 3 0\n" ]
[ "2\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
Nathan O. Davis is running a company. His company owns a web service which has a lot of users. So his office is full of servers, routers and messy LAN cables. He is now very puzzling over the messy cables, because they are causing many kinds of problems. For example, staff working at the company often trip over a cabl...
stdin
null
785
1
[ "3 3 1\n1 1 3 3\n0 0\n1 RRDDLLUU\n" ]
[ "1\n" ]
[ "3 3 0\n1 1 3 3\n0 0\n1 RRDDLLUU\n", "3 3 1\n1 1 1 3\n0 0\n1 RRDDLLUU\n", "3 3 0\n1 1 3 3\n0 0\n0 RRDDLLUU\n", "3 3 0\n1 1 3 3\n0 1\n0 RRDDLLUU\n", "3 3 0\n0 1 3 3\n0 1\n0 RRDDLLUU\n", "3 3 0\n0 1 3 2\n0 1\n0 RRDDLLUU\n", "3 6 0\n0 1 3 2\n0 1\n0 RRDDLLUU\n", "3 3 0\n0 1 3 3\n0 0\n1 RRDDLLUU\n", "3 3...
[ "0\n", "1\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n", "0\n" ]
CodeContests
Takeshi, who loves hot springs, is planning a trip to a hot spring resort on his next long vacation. I would like to travel by connecting to a long-distance bus and reach my destination with as little money as possible. Takeshi, who has savings but is unwilling to pay, decided to consult with his grandfather. The grand...
stdin
null
1,215
1
[ "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 14\n2 3 10\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0\n" ]
[ "5\n0\n7\n" ]
[ "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 14\n2 3 15\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0\n", "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 7\n1 3 9\n1 5 4\n2 3 10\n2 4 15\n3 4 11\n3 5 2\n4 5 9\n4 6 8\n0 0\n", "2 1\n1 2 5\n3 2\n1 2 5\n2 3 5\n6 9\n1 2 13\n1 3 9\n2 5 27\n2 3 10\n2 4 15\n3 4 11\n3 5 2...
[ "5\n0\n7\n", "5\n0\n4\n", "5\n0\n8\n", "3\n0\n7\n", "3\n0\n0\n", "5\n0\n6\n", "3\n0\n8\n", "5\n0\n0\n", "5\n0\n5\n", "2\n0\n0\n" ]
CodeContests
Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDe...
stdin
null
3,997
1
[ "D D\n", "H H\n", "D H\n" ]
[ "H\n", "H\n", "D\n" ]
[ "H I\n", "E H\n", "I H\n", "F H\n", "G H\n", "J H\n", "H J\n", "H G\n", "H K\n", "H F\n" ]
[ "D\n", "D\n", "D\n", "D\n", "D\n", "D\n", "D\n", "D\n", "D\n", "D\n" ]
CodeContests
Taro attempts to tell digits to Hanako by putting straight bars on the floor. Taro wants to express each digit by making one of the forms shown in Figure 1. Since Taro may not have bars of desired lengths, Taro cannot always make forms exactly as shown in Figure 1. Fortunately, Hanako can recognize a form as a digit i...
stdin
null
1,938
1
[ "9\n60 140 200 300\n300 105 330 135\n330 135 250 215\n240 205 250 215\n298 167 285 154\n30 40 30 90\n30 90 150 90\n150 90 150 20\n30 40 150 40\n8\n320 20 300 60\n320 20 380 50\n380 50 240 330\n10 50 40 20\n10 50 110 150\n110 150 180 80\n40 20 37 17\n37 17 27 27\n20\n72 222 132 182\n204 154 204 54\n510 410 520 370\n...
[ "0 1 0 1 0 0 0 0 0 1\n0 0 0 0 0 1 0 1 0 0\n1 0 1 0 2 0 0 0 1 0\n" ]
[ "9\n60 140 200 300\n300 105 330 135\n330 135 250 215\n240 205 250 215\n298 167 285 154\n30 40 30 90\n30 90 150 90\n150 90 150 20\n30 40 150 70\n8\n320 20 300 60\n320 20 380 50\n380 50 240 330\n10 50 40 20\n10 50 110 150\n110 150 180 80\n40 20 37 17\n37 17 27 27\n20\n72 222 132 182\n204 154 204 54\n510 410 520 370\n...
[ "0 1 0 1 0 0 0 0 0 1\n0 0 0 0 0 1 0 1 0 0\n1 0 1 0 2 0 0 0 1 0\n", "0 1 0 1 0 0 0 0 0 1\n0 0 0 0 0 1 0 1 0 0\n1 0 1 0 2 0 1 0 0 0\n", "0 1 0 2 0 0 0 0 0 0\n0 0 0 0 0 1 0 1 0 0\n1 0 1 0 2 0 0 0 1 0\n", "0 2 0 0 0 0 0 1 0 1\n0 0 0 0 0 1 0 1 0 0\n1 0 1 0 2 0 0 0 1 0\n", "0 2 0 0 1 0 0 0 0 1\n0 0 0 0 0 1 0 1 0 ...
CodeContests
Advanced Creative Mobile (ACM) has decided to develop a GUI application to be installed in a new portable computer. As shown in the figure below, the GUI has a nested structure in which it has one main panel, several panels are arranged on it, and some panels are arranged on top of those panels. .. All panels are rect...
stdin
null
2,852
1
[ "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n10 10\n15 15\n40 60\n2 3\n130 80\n0\n" ]
[ "main 2\nmain 2\nmenu 0\nOUT OF MAIN PANEL 1\nprimary 0\n" ]
[ "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n10 10\n15 15\n40 60\n1 3\n130 80\n0\n", "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n9 10\n15 15\n40 60\n1 3\n130 80\n0\n", "5\n<main>10,10,190,150<menu>20,00,72,140</menu><primar...
[ "main 2\nmain 2\nmenu 0\nOUT OF MAIN PANEL 1\nprimary 0\n", "OUT OF MAIN PANEL 1\nmain 2\nmenu 0\nOUT OF MAIN PANEL 1\nprimary 0\n", "main 2\nmain 2\nmain 2\nOUT OF MAIN PANEL 1\nprimary 0\n", "OUT OF MAIN PANEL 1\nmain 2\nmain 2\nOUT OF MAIN PANEL 1\nprimary 0\n", "OUT OF MAIN PANEL 1\nmenu 0\nmenu 0\nOUT ...
CodeContests
Interns Mehta and Sharma are waiting for their "build" to complete. Mehta comes up with an interesting game with an array P of integers of size N. She defines the rules of the game as: Pick a number i from the set {1,2,...N-2}. Remove P[i] from the array. You receive P[i-1]*P[i+1] points for doing this removal. Reindex...
stdin
null
2,280
1
[ "4\n2 3 4 5\n\nSAMPLE\n" ]
[ "25\n" ]
[ "8\n477 744 474 777 447 1370 777 474\n", "4\n2 2 4 5\n\nSAMPLE\n", "8\n561 744 474 777 447 1370 777 474\n", "4\n2 1 4 5\n\nSAMPLE\n", "8\n785 744 474 777 447 1370 642 474\n", "8\n785 744 474 1058 447 1370 642 474\n", "8\n477 744 725 777 447 747 777 474\n", "4\n2 3 4 2\n\nSAMPLE\n", "8\n210 744 474 7...
[ "4262118\n", "20\n", "4417014\n", "18\n", "4830070\n", "5352812\n", "2937051\n", "12\n", "3834726\n", "6352648\n" ]
CodeContests
Problem Given the strings S and Q queries. The i-th query (0 ≤ i ≤ Q-1) is given the closed interval [li, ri] and the string Mi. Output how many character strings Mi exist in the substring from the li character to the ri character of S. Constraints * 1 ≤ | S | ≤ 100000 * 1 ≤ Q ≤ 100000 * 1 ≤ | Mi | ≤ 100000 (0 ≤ i ≤...
stdin
null
2,062
1
[ "aaaaaaaaaa 5\n0 9 aaa\n0 9 aa\n5 9 aaaa\n2 8 aa\n1 2 a\n", "rupcrupc 5\n0 3 rupc\n0 7 rupc\n2 7 ru\n2 7 pc\n1 5 u\n", "abatagaadbura 8\n0 6 a\n6 12 a\n0 6 aa\n0 3 a\n3 5 a\n5 9 a\n1 8 b\n1 12 b\n" ]
[ "8\n9\n2\n6\n2\n", "1\n2\n1\n2\n2\n", "4\n3\n0\n2\n1\n2\n1\n2\n" ]
[ "aaaaaaaaaa 5\n0 9 aaa\n0 9 aa\n5 9 aaaa\n0 8 aa\n1 2 a\n", "rupcrupc 5\n0 3 rupc\n0 7 rupc\n2 7 qu\n2 7 pc\n1 5 u\n", "abatagaadbura 8\n0 6 a\n6 12 a\n0 6 aa\n0 3 `\n3 5 a\n5 9 a\n1 8 b\n1 12 b\n", "rupcrupc 5\n0 3 rupc\n0 7 rupc\n2 7 qu\n2 6 pc\n1 5 u\n", "abatagaadbura 8\n0 6 a\n6 12 a\n0 6 aa\n0 3 `\n3 ...
[ "8\n9\n2\n8\n2\n", "1\n2\n0\n2\n2\n", "4\n3\n0\n0\n1\n2\n1\n2\n", "1\n2\n0\n1\n2\n", "4\n3\n0\n0\n0\n2\n1\n2\n", "1\n2\n0\n0\n2\n", "1\n1\n0\n0\n2\n", "1\n1\n0\n0\n0\n", "0\n1\n0\n0\n0\n", "0\n0\n0\n0\n0\n" ]
CodeContests
Lets call a string which is composed of only 4 and 7 a Lucky String. For example, 47, 444, 44744 are all Lucky Strings of length 2, 3 and 5 respectively, while 45, 767 are not Lucky Strings. Now, consider a sorted list of all the Lucky Strings that can be formed where the sorting is done by the following rule: A stri...
stdin
null
758
1
[ "3\n1\n5\n11\n\nSAMPLE\n" ]
[ "4\n74\n744\n" ]
[ "3\n1\n6\n11\n\nSAMPLE\n", "3\n1\n6\n17\n\nSAMPLE\n", "3\n2\n6\n17\n\nSAMPLE\n", "3\n2\n7\n17\n\nSAMPLF\n", "3\n2\n7\n28\n\nSAMPLF\n", "3\n2\n7\n33\n\nTAMPMF\n", "3\n3\n7\n33\n\nTAMPMF\n", "3\n1\n7\n33\n\nTAMPMF\n", "3\n1\n7\n27\n\nTAMPMF\n", "3\n1\n3\n27\n\nTAMPMF\n" ]
[ "4\n77\n744\n", "4\n77\n4474\n", "7\n77\n4474\n", "7\n444\n4474\n", "7\n444\n7747\n", "7\n444\n44474\n", "44\n444\n44474\n", "4\n444\n44474\n", "4\n444\n7744\n", "4\n44\n7744\n" ]
CodeContests
Heisenberg is very fond of mixing various strings together. But he has storage problem. He wants that his strings use as less space as possible. He has N strings right now. He wants to store them together. To reduce space he can use this property of mixing two strings: Suppose he has string A="abcdef" and B="cdefg...
stdin
null
3,304
1
[ "2\nabcdef\nfghi\n\nSAMPLE\n" ]
[ "9\n" ]
[ "2\nfedcba\nfghi\n\nSAMPLE\n", "2\nabcdef\nfhhi\n\nRAMPLE\n", "2\nfedcba\nfhhi\n\nSAMPLE\n", "2\nfedcba\nfhhi\n\nRAMPLE\n", "2\nabcdef\nfhhi\n\nRALPLE\n", "2\nabcdef\nfhhi\n\nRAPLLE\n", "2\nabcdef\nfhhi\n\nRAPLLF\n", "2\nfedcba\nfhhi\n\nRAPLLF\n", "2\nfedcba\nfhhi\n\nFLLPAR\n", "2\nfedcba\nfhih\n\...
[ "10\n", "9\n", "10\n", "10\n", "9\n", "9\n", "9\n", "10\n", "10\n", "10\n" ]
CodeContests
G: Toss Cut Tree Problem Statement You are given two trees T, U. Each tree has N vertices that are numbered 1 through N. The i-th edge (1 \leq i \leq N-1) of tree T connects vertices a_i and b_i. The i-th edge (1 \leq i \leq N-1) of tree U connects vertices c_i and d_i. The operation described below will be performe...
stdin
null
3,333
1
[ "3\n1 2\n2 3\n1 2\n3 1\n" ]
[ "1\n" ]
[ "3\n1 2\n2 3\n1 2\n3 2\n", "3\n1 2\n2 3\n3 2\n3 1\n", "3\n1 3\n2 3\n1 2\n3 2\n", "3\n1 2\n2 3\n3 2\n1 2\n", "3\n1 2\n2 3\n3 2\n2 1\n", "3\n1 3\n2 3\n3 2\n3 1\n", "3\n1 2\n1 3\n3 2\n2 1\n", "3\n1 3\n2 3\n3 2\n2 1\n", "3\n1 2\n1 3\n3 1\n2 1\n", "3\n1 3\n2 3\n1 2\n3 1\n" ]
[ "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n" ]
CodeContests
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and ...
stdin
null
180
1
[ "4\n2 3 7 9\n", "8\n3 1 4 1 5 9 2 6\n" ]
[ "7\n", "8\n" ]
[ "4\n2 3 9 9\n", "8\n3 1 4 1 5 18 2 6\n", "4\n2 3 13 9\n", "4\n4 4 13 9\n", "8\n3 1 1 1 5 15 1 6\n", "4\n4 4 8 9\n", "4\n0 4 8 18\n", "8\n1 1 1 2 5 14 1 6\n", "4\n-1 2 4 18\n", "4\n-1 2 4 31\n" ]
[ "7\n", "17\n", "11\n", "9\n", "14\n", "5\n", "18\n", "13\n", "19\n", "32\n" ]
CodeContests
There is data that records the customer number of the business partner and the trading date on a monthly basis. Please create a program that reads this month's data and last month's data and outputs the customer number of the company with which you have transactions and the number of transactions for two consecutive mo...
stdin
null
2,526
1
[ "123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5\n" ]
[ "56 2\n123 3\n" ]
[ "123,10\n56,12\n35,14\n\n123,3\n56,4\n123,5\n", "123,10\n56,12\n45,13\n\n113,4\n56,4\n123,5\n", "132,10\n56,12\n45,13\n\n113,4\n56,4\n123,5\n", "123,10\n51,62\n34,14\n\n124,3\n56,4\n123,5\n", "123,10\n65,12\n34,14\n\n123,3\n56,4\n123,5\n", "123,10\n57,12\n35,14\n\n123,3\n57,4\n123,5\n", "0032,1\n56,12\n...
[ "56 2\n123 3\n", "56 2\n123 2\n", "56 2\n", "123 2\n", "123 3\n", "57 2\n123 3\n", "32 2\n56 2\n", "32 2\n", "56 2\n213 2\n", "56 2\n123 3\n" ]
CodeContests
Create a program that inputs the vertex information of two polygons inscribed in one circle and outputs the magnitude relationship of their areas. Assume that each vertex of the X-side is numbered counterclockwise from 1 to X (the figure shows an example when X = 4). However, the given polygon assumes that the center ...
stdin
null
1,174
1
[ "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n50\n25\n75\n0\n" ]
[ "0\n1\n2\n" ]
[ "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n50\n29\n75\n0\n", "4\n30\n125\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6\n30\n50\n6\n29\n75\n0\n", "4\n30\n84\n75\n4\n30\n125\n75\n5\n30\n125\n75\n65\n4\n30\n125\n75\n4\n30\n125\n75\n6...
[ "0\n1\n2\n", "0\n1\n1\n", "2\n1\n2\n", "0\n2\n2\n", "1\n1\n1\n", "0\n2\n1\n", "1\n1\n2\n", "2\n2\n1\n", "2\n2\n2\n", "1\n2\n1\n" ]
CodeContests
You are given an two integers i and j such that i ≤ j. Task is to find the sum of all integers from i to j (both inclusive). For example: i = 3 j = 5 then sum from i to j will be 3+4+5 = 12 Input: Single line containing two space separated integers i and j. Output: Print out the sum of integers from i to j (bo...
stdin
null
3,588
1
[ "99 1000000000000\n\nSAMPLE\n" ]
[ "500000000000499999995149\n" ]
[ "99 1000000000010\n", "99 1000000000100\n\nSAMPLE\n", "77 1000000000000\n", "21 1000000000000\n", "21 1100000000000\n", "117 1000000000100\n\nT@MPLE\n", "117 0000000000100\n\nT@MPLE\n", "99 1000000000000\n\nSAMPLD\n", "77 1000010000000\n", "21 1010000000000\n" ]
[ "500000000010499999995204\n", "500000000100500000000199\n", "500000000000499999997074\n", "500000000000499999999790\n", "605000000000549999999790\n", "500000000100499999998264\n", "-1736\n", "500000000000499999995149\n", "500010000050500004997074\n", "510050000000504999999790\n" ]
CodeContests
There are two (6-sided) dice: a red die and a blue die. When a red die is rolled, it shows i with probability p_i percents, and when a blue die is rolled, it shows j with probability q_j percents. Petr and tourist are playing the following game. Both players know the probabilistic distributions of the two dice. First,...
stdin
null
4,507
1
[ "10 20 20 10 20 20\n20 20 20 10 10 20\n", "25 25 25 25 0 0\n0 0 0 0 50 50\n" ]
[ "0.550000000000\n", "1.000000000000\n" ]
[ "4 20 20 10 20 20\n20 20 20 10 10 20\n", "25 25 25 25 0 1\n0 0 0 0 50 50\n", "25 25 25 18 -1 0\n0 0 0 0 50 50\n", "25 25 25 18 -1 1\n0 0 0 0 50 50\n", "25 25 25 16 -1 1\n0 0 0 0 50 50\n", "30 25 25 16 -1 1\n0 0 0 0 50 50\n", "30 8 25 16 -1 1\n0 0 0 0 50 50\n", "30 8 33 16 -1 1\n0 0 0 0 50 50\n", "13...
[ "0.550000000\n", "1.000000000\n", "0.930000000\n", "0.931372549\n", "0.911764706\n", "0.960784314\n", "0.794117647\n", "0.872549020\n", "0.882352941\n", "0.852941176\n" ]