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
Stellar history 2005.11.5. You are about to engage an enemy spacecraft as the captain of the UAZ Advance spacecraft. Fortunately, the enemy spaceship is still unnoticed. In addition, the space coordinates of the enemy are already known, and the "feather cannon" that emits a powerful straight beam is ready to launch. Af...
stdin
null
3,922
1
[ "-10 6 6\n10 6 6\n0 10 0\n0 10 10\n0 0 10\n", "-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 0 10\n" ]
[ "MISS\n", "HIT\n" ]
[ "-10 6 6\n10 2 6\n0 10 0\n0 10 10\n0 0 10\n", "-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 1 10\n", "-10 6 6\n20 2 6\n0 10 0\n0 10 10\n0 0 10\n", "-10 0 0\n10 0 0\n0 10 0\n0 0 10\n0 1 10\n", "-10 6 6\n20 2 6\n0 10 1\n0 10 10\n0 0 10\n", "-10 -1 0\n10 0 0\n0 10 0\n0 0 10\n0 1 10\n", "-10 6 6\n20 2 6\n1 10 1\n0 1...
[ "MISS\n", "HIT\n", "MISS\n", "HIT\n", "MISS\n", "HIT\n", "MISS\n", "HIT\n", "HIT\n", "HIT\n" ]
CodeContests
Lucy had recently learned the game, called Natural Numbers. The rules of the game are really simple. There are N players. At the same time, every player says one natural number. Let's call the number said by the i-th player Ai. The person with the smallest unique number (that is, the smallest number that was not said b...
stdin
null
3,580
1
[ "2\n5\nKouta 1\nYuka 1\nMayu 3\nLucy 2\nNana 5\n2\nLucy 2\nNana 2\n" ]
[ "Lucy\nNobody wins.\n" ]
[ "2\n5\nKouta 1\nYuka 1\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2\n", "2\n5\nKouta 1\nYuka 0\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2\n", "2\n5\nKouta 2\nakuY 0\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2\n", "2\n5\nKouta 1\nYuka 1\nMayu 3\nLucy 2\nNana 5\n2\nLucy 2\nOana 2\n", "2\n5\nKouta 0\nYuka 1\nMayu...
[ "yucL\nNobody wins.\n", "Yuka\nNobody wins.\n", "akuY\nNobody wins.\n", "Lucy\nNobody wins.\n", "Kouta\nNobody wins.\n", "Kouta\nLucy\n", "Yuk`\nNobody wins.\n", "Ykua\nNobody wins.\n", "Nana\nNobody wins.\n", "Zkua\nNobody wins.\n" ]
CodeContests
Differential pulse code modulation is one of the compression methods mainly used when compressing audio signals. The audio signal is treated as an integer sequence (impulse sequence) on the computer. The integer sequence is a sample of the input signal at regular time intervals and the amplitude recorded. In general, ...
stdin
null
153
1
[ "2 7\n4\n2\n1\n0\n-1\n-2\n-4\n131\n137\n2 7\n4\n2\n1\n0\n-1\n-2\n-4\n131\n123\n10 7\n-4\n-2\n-1\n0\n1\n2\n4\n132\n134\n135\n134\n132\n128\n124\n122\n121\n122\n5 1\n255\n0\n0\n0\n0\n0\n4 1\n0\n255\n0\n255\n0\n0 0\n" ]
[ "2\n8\n0\n325125\n65026\n" ]
[ "2 7\n4\n2\n1\n0\n-1\n-2\n-4\n131\n137\n2 7\n4\n2\n1\n0\n-1\n-2\n-4\n124\n123\n10 7\n-4\n-2\n-1\n0\n1\n2\n4\n132\n134\n135\n134\n132\n128\n124\n122\n121\n122\n5 1\n255\n0\n0\n0\n0\n0\n4 1\n0\n255\n0\n255\n0\n0 0\n", "2 7\n4\n2\n1\n0\n-1\n-2\n-4\n131\n137\n2 7\n4\n2\n1\n0\n-1\n-2\n-4\n124\n123\n10 7\n-4\n-2\n-1\n0...
[ "2\n0\n0\n325125\n65026\n", "2\n0\n0\n293296\n65026\n", "2\n0\n1517\n293296\n65026\n", "26\n0\n1517\n293296\n65026\n", "2\n8\n0\n325125\n64771\n", "10817\n0\n0\n325125\n65026\n", "2\n1156\n0\n293296\n65026\n", "2\n5\n1517\n293296\n65026\n", "26\n6266\n1517\n293296\n65026\n", "26\n0\n1517\n293296\n...
CodeContests
A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters. For example, `arc`, `artistic` and (an empty string) are all subsequences of `artistic`; `abc` and `ci` are not. You are given a string A consisting of lowerca...
stdin
null
4,823
1
[ "frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n", "abcdefghijklmnopqrstuvwxyz\n", "atcoderregularcontest\n" ]
[ "aca\n", "aa\n", "b\n" ]
[ "frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhzktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n", "atcoddrregularcontest\n", "ndrbrvbdmxvrepkflcnpltvcjnmgenquxldpjyhxksyuhnfzpeuwykpxdeiarxojajjhfdiopxqqhyftkzhdgbwnwdzaqwsruizpaksnpuxjqnpegfistofpohzpctur...
[ "aca\n", "b\n", "abb\n", "aba\n", "g\n", "tj\n", "jt\n", "hm\n", "d\n", "jq\n" ]
CodeContests
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No...
stdin
null
293
1
[ "3\n1 2 3\n", "4\n1 2 4 8\n" ]
[ "Yes\n", "No\n" ]
[ "3\n1 2 0\n", "3\n3 2 1\n", "4\n1 2 4 11\n", "3\n0 2 0\n", "4\n0 2 4 11\n", "3\n0 1 0\n", "4\n0 4 4 11\n", "3\n0 1 -1\n", "4\n0 4 4 20\n", "3\n1 2 1\n" ]
[ "No\n", "Yes\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n" ]
CodeContests
Example Input 2 2 1 2 0 3 4 1 Output 2
stdin
null
827
1
[ "2 2\n1 2 0\n3 4 1\n" ]
[ "2\n" ]
[ "2 0\n1 2 0\n3 4 1\n", "3 0\n1 2 1\n6 0 1\n", "0 0\n2 0 1\n5 0 2\n", "4 0\n1 0 1\n5 0 0\n", "2 1\n1 2 1\n3 3 1\n", "8 0\n-2 0 1\n12 2 12\n", "4 1\n1 2 0\n3 6 1\n", "2 1\n1 2 0\n6 1 2\n", "2 0\n1 2 1\n3 4 1\n", "2 0\n1 2 1\n3 0 1\n" ]
[ "10\n", "280\n", "1\n", "15400\n", "6\n", "680445551\n", "2800\n", "4\n", "10\n", "10\n" ]
CodeContests
You are given a grid of N rows and M columns. The square at the i-th row and j-th column will be denoted as (i,j). A nonnegative integer A_{i,j} is written for each square (i,j). You choose some of the squares so that each row and column contains at most K chosen squares. Under this constraint, calculate the maximum v...
stdin
null
3,911
1
[ "3 2\n10 10 1\n10 10 1\n1 1 10\n", "3 1\n5 3 2\n1 4 8\n7 6 9\n" ]
[ "50\nXX.\nXX.\n..X\n", "19\nX..\n..X\n.X.\n" ]
[ "3 1\n10 10 1\n10 10 1\n1 1 10\n", "3 2\n5 10 1\n10 10 1\n1 1 10\n", "1 1\n5 3 2\n1 4 8\n7 6 9\n", "3 2\n5 10 1\n10 6 1\n1 1 10\n", "3 2\n5 10 1\n10 6 1\n1 1 15\n", "1 1\n1 3 2\n1 4 8\n7 12 9\n", "3 1\n18 10 0\n8 10 1\n1 1 10\n", "3 2\n5 10 1\n10 6 1\n1 1 18\n", "2 1\n1 3 2\n1 4 8\n7 12 9\n", "3 1...
[ "30\nX..\n.X.\n..X\n", "45\nXX.\nXX.\n..X\n", "5\nX\n", "41\nXX.\nXX.\n..X\n", "46\nXX.\nXX.\n..X\n", "1\nX\n", "38\nX..\n.X.\n..X\n", "49\nXX.\nXX.\n..X\n", "5\n.X\nX.\n", "21\nX..\n..X\n.X.\n" ]
CodeContests
Many cats live on the campus of a school. Natsume's daily routine is to pet those cats. However, the cats may be capricious and go for a walk off campus. The campus site is a rectangle with each side parallel to the x-axis or y-axis and is surrounded by a fence except for the gate, but cats can freely enter and exit t...
stdin
null
3,930
1
[ "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10\n" ]
[ "2\n2\n" ]
[ "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n41 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10\n", "2\n1 3 6 10\n4\n21 13\n1 15\n10 10\n25 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10\n", "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n55 10\n1 3 20 10\n4\n21 13\n1 15\n10 2\n25 10\n", "2\n1 3 6 10\n4\n21 13\n1 15\n10 10\n25 10\n1...
[ "2\n2\n", "0\n2\n", "2\n1\n", "0\n1\n", "3\n2\n", "2\n0\n", "3\n1\n", "1\n2\n", "3\n3\n", "4\n3\n" ]
CodeContests
Chef likes arrays a lot. Today, he found an array A consisting of N positive integers. Let L denote the sorted (in non-increasing order) list of size N*(N+1)/2 containing the sums of all possible contiguous subarrays of A. Chef is interested in finding the first K elements from the list L. Can you help him in accomplis...
stdin
null
794
1
[ "3 3\n10 2 7\n", "3 4\n1 3 4\n" ]
[ "19 12 10\n", "8 7 4 4\n" ]
[ "3 3\n15 2 7\n", "3 4\n10 2 7\n", "3 4\n1 1 4\n", "3 3\n15 2 6\n", "3 3\n15 1 6\n", "3 5\n15 1 6\n", "3 4\n1 3 1\n", "3 3\n15 2 0\n", "3 5\n10 2 7\n", "3 1\n15 2 6\n" ]
[ "24 17 15\n", "19 12 10 9\n", "6 5 4 2\n", "23 17 15\n", "22 16 15\n", "22 16 15 7 6\n", "5 4 4 3\n", "17 17 15\n", "19 12 10 9 7\n", "23\n" ]
CodeContests
Example Input 8 -10 0 -10 5 -5 5 -5 0 10 0 10 -5 5 -5 5 0 Output 50
stdin
null
4,128
1
[ "8\n-10 0\n-10 5\n-5 5\n-5 0\n10 0\n10 -5\n5 -5\n5 0\n" ]
[ "50\n" ]
[ "8\n-10 0\n-10 5\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0\n", "8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0\n", "8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n4 -5\n5 -5\n5 0\n", "8\n-10 0\n-15 10\n-5 5\n-5 -1\n10 0\n4 -5\n5 -5\n5 0\n", "8\n-10 0\n-10 5\n-5 5\n-5 0\n10 0\n10 -5\n7 -5\n5 0\n", "8\n-10 0\n-10 5...
[ "53\n", "65\n", "55\n", "68\n", "45\n", "50\n", "60\n", "63\n", "58\n", "78\n" ]
CodeContests
You are involved in the development of a certain game. The game is for players to explore randomly generated dungeons. As a specification of the game, I want to show the player the danger level of the dungeon in advance and select whether to search for the generated dungeon or to regenerate a new dungeon. There are n ...
stdin
null
4,280
1
[ "4\n0 1 3\n1 2 5\n1 3 2\n", "6\n0 2 5\n2 1 1\n2 3 10\n3 5 4\n3 4 2\n" ]
[ "23\n", "111\n" ]
[ "6\n0 2 5\n2 1 1\n2 3 10\n3 5 2\n3 4 2\n", "6\n0 2 5\n2 1 0\n2 3 10\n3 5 2\n3 4 2\n", "4\n0 1 3\n0 2 5\n1 3 2\n", "6\n0 2 5\n2 1 1\n2 3 6\n3 5 4\n3 4 2\n", "6\n0 2 5\n2 1 1\n2 3 18\n3 5 2\n3 4 2\n", "6\n0 2 5\n2 1 1\n2 3 6\n3 5 7\n3 4 2\n", "6\n0 2 5\n3 1 1\n2 3 18\n3 5 2\n3 4 2\n", "6\n0 2 5\n2 1 0\n...
[ "107\n", "106\n", "23\n", "75\n", "179\n", "84\n", "160\n", "43\n", "166\n", "168\n" ]
CodeContests
Today, teacher taught Xenny the chapter 'Prime numbers and Composite numbers'. Xenny liked it and being a studious boy, wanted some homework. So teacher gave him a simple task. The task is to find the smallest composite number greater than given no. Xenny was happy to get the simple task. But Xenny didn't get the time ...
stdin
null
1,440
1
[ "2\n3\n8\n\nSAMPLE\n" ]
[ "4\n9\n" ]
[ "1\n4\n", "2\n2\n8\n\nSAMPLE\n", "1\n0\n", "2\n2\n6\n\nSAMPLE\n", "2\n2\n5\n\nSAMPLE\n", "2\n2\n12\n\nSBMOLE\n", "2\n2\n10\n\nLDTMBO\n", "2\n2\n14\n\nLDTMBO\n", "2\n2\n16\n\nKDTMBO\n", "2\n1\n15\n\nKDTMBO\n" ]
[ "6\n", "4\n9\n", "4\n", "4\n8\n", "4\n6\n", "4\n14\n", "4\n12\n", "4\n15\n", "4\n18\n", "4\n16\n" ]
CodeContests
Given a matrix (H × W) which contains only 1 and 0, find the area of the largest rectangle which only contains 0s. Constraints * 1 ≤ H, W ≤ 1,400 Input H W c1,1 c1,2 ... c1,W c2,1 c2,2 ... c2,W : cH,1 cH,2 ... cH,W In the first line, two integers H and W separated by a space character are given. In the following...
stdin
null
198
1
[ "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n" ]
[ "6\n" ]
[ "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 0 0\n0 0 0 1 0\n", "4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 0 1\n0 0 0 1 0\n", "1 5\n0 0 1 0 0\n1 0 0 0 1\n0 0 0 1 0\n0 0 0 1 0\n", "0 5\n0 0 1 -1 0\n1 0 0 0 0\n0 0 0 0 0\n0 0 0 1 0\n", "1 5\n1 0 1 0 1\n2 0 -1 0 1\n0 -1 0 0 0\n0 0 0 1 0\n", "4 5\n1 0 1 1 0\n1 0 0 0 0\n0 0 1 0 0\...
[ "8\n", "6\n", "2\n", "0\n", "1\n", "4\n", "10\n", "9\n", "3\n", "5\n" ]
CodeContests
You are a student looking for a job. Today you had an employment examination for an IT company. They asked you to write an efficient program to perform several operations. First, they showed you an N \times N square matrix and a list of operations. All operations but one modify the matrix, and the last operation output...
stdin
null
4,360
1
[ "2 1 3 6 12 1 2 1 2\nRL\n", "2 1 3 6 12 1 2 1 2\nRH\n", "39989 6 999983 999979 999961 1 1000 1 1000\nSR 1 39989\nSC 1 39989\nRL\nRH\nRR\nRV\n", "2 1 3 6 12 1 2 1 2\nWR 1 1 1\n" ]
[ "676636559\n", "676547189\n", "458797120\n", "676573821\n" ]
[ "2 1 3 2 12 1 2 1 2\nRL\n", "2 1 3 3 12 1 2 1 2\nWR 1 1 1\n", "2 1 3 3 12 1 2 1 2\nWR 2 1 1\n", "2 1 3 3 12 1 2 1 2\nWR 2 1 0\n", "2 1 3 8 12 1 2 1 2\nRL\n", "2 1 3 3 12 2 2 1 2\nWR 1 1 1\n", "2 1 3 2 12 1 2 2 2\nRL\n", "2 1 3 6 12 1 2 1 2\nWR 2 1 0\n", "2 0 3 8 12 1 2 1 2\nRL\n", "2 1 1 3 12 2 2 ...
[ "676759451\n", "676579860\n", "676728567\n", "676728536\n", "676759631\n", "907051837\n", "907051876\n", "676812149\n", "676875641\n", "907051721\n" ]
CodeContests
Problem N ignited fuses and one bomb for each are placed on a vertical H x horizontal W grid. Each fuse and bomb is placed on a pathi consisting of Li cells, and the jth cell of pathi is (pxij, pyij). Each bomb is in the last square of pathi (pxiLi, pyiLi). The fire of the lead wire is in the square (pxi1, pyi1) in th...
stdin
null
4,676
1
[ "3 3 1\n2 2\n2 2 2 2 1\n", "2 2 1\n2 1\n2 1 1 1 2\n", "2 2 1\n2 1\n3 1 1 1 2 2 2\n", "3 3 2\n1 3\n3 2 3 2 2 2 1\n5 2 1 1 1 1 2 2 2 3 2\n" ]
[ "0\n", "-1\n", "1\n", "2\n" ]
[ "3 3 2\n1 3\n3 2 3 2 1 2 1\n5 2 1 1 1 1 2 2 2 3 2\n", "3 3 1\n2 2\n2 2 2 2 2\n", "4 3 2\n1 3\n3 1 3 2 1 2 1\n5 2 1 1 1 1 2 2 2 3 1\n", "2 3 1\n2 1\n3 1 1 1 2 2 2\n", "3 3 1\n2 2\n2 2 3 2 1\n", "3 3 2\n1 3\n3 2 3 2 1 2 1\n5 2 1 1 1 1 2 2 4 3 2\n", "3 4 1\n2 2\n2 2 3 2 1\n", "3 4 1\n2 2\n2 2 3 2 2\n", ...
[ "-1\n", "0\n", "2\n", "1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n" ]
CodeContests
Find the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E). Constraints * 1 ≤ |V| ≤ 100 * 0 ≤ |E| ≤ 1,000 * 0 ≤ wi ≤ 10,000 * G has arborescence(s) with the root r Input |V| |E| r s0 t0 w0 s1 t1 w1 : s|E|-1 t|E|-1 w|E|-1 , where |V| is the...
stdin
null
160
1
[ "4 6 0\n0 1 3\n0 2 2\n2 0 1\n2 3 1\n3 0 1\n3 1 5\n", "6 10 0\n0 2 7\n0 1 1\n0 3 5\n1 4 9\n2 1 6\n1 3 2\n3 4 3\n4 2 2\n2 5 8\n3 5 3\n" ]
[ "6\n", "11\n" ]
[ "4 6 0\n0 1 3\n0 2 2\n2 0 1\n2 3 2\n3 0 1\n3 1 5\n", "6 10 0\n0 2 7\n0 1 1\n0 3 5\n1 4 9\n2 1 6\n1 3 2\n3 4 3\n4 2 2\n1 5 8\n3 5 3\n", "4 6 0\n0 1 1\n0 2 2\n2 0 1\n2 3 2\n3 0 1\n3 1 5\n", "4 6 0\n0 1 1\n0 2 2\n3 1 1\n2 3 3\n3 0 0\n0 1 7\n", "6 10 0\n0 2 7\n0 1 1\n0 3 5\n1 4 9\n2 1 6\n1 3 2\n3 1 3\n4 2 2\n1 ...
[ "7\n", "11\n", "5\n", "6\n", "17\n", "22\n", "3\n", "27\n", "32\n", "9\n" ]
CodeContests
Little Deepu loves positive things in life, positive girlfriends, positive marks. He's, in general a lover of positive things, so for obvious reasons he loves an array which contains positive elements. Anyway, Little Deepu also thinks that not every value in his so called positive array deserves to be valued so high, ...
stdin
null
3,983
1
[]
[]
[ "10\n19 8 17 20 13 2 3 20 30 75\n10\n1\n1\n1\n2\n2\n2\n40\n30\n10\n10\n", "10\n19 10 17 20 13 2 3 20 30 75\n10\n1\n1\n1\n2\n2\n2\n40\n30\n10\n10\n", "10\n19 10 17 20 13 2 3 20 30 75\n9\n1\n1\n1\n2\n2\n2\n40\n30\n10\n10\n", "10\n19 10 17 20 14 2 3 20 30 75\n9\n1\n1\n1\n2\n2\n2\n40\n30\n10\n10\n", "10\n19 10 ...
[ "11 2 10 12 7 1 1 12 22 65\n", "11 4 10 12 7 1 1 12 22 65\n", "12 4 10 13 7 1 1 13 23 66\n", "12 4 10 13 8 1 1 13 23 66\n", "12 4 10 1 8 1 1 13 23 66\n", "12 4 10 0 8 1 1 13 23 66\n", "12 4 10 0 8 1 2 13 23 66\n", "0 2 10 12 7 1 1 12 22 31\n", "12 4 10 13 7 1 1 13 22 65\n", "12 4 10 2 8 1 1 13 23 ...
CodeContests
As a New Year's gift, Dolphin received a string s of length 19. The string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`. Dolphin wants to convert the comma-separated string s into a space-separated string. Write a program to perform th...
stdin
null
4,466
1
[ "haiku,atcoder,tasks\n", "abcde,fghihgf,edcba\n", "happy,newyear,enjoy\n" ]
[ "haiku atcoder tasks\n", "abcde fghihgf edcba\n", "happy newyear enjoy\n" ]
[ "gaiku,atcoder,tasks\n", "abgde,fchihgf,edcba\n", "ha,pypnewyear,enjoy\n", "gaiku,atcoeer,tasks\n", "abcde,fghihcf,edgba\n", "ha,pypnewzear,enjoy\n", "gaiku,atcoeer-tasks\n", "abgde,fchihgf+edcba\n", "hap,ypnewzear,enjoy\n", "gbiku,atcoeer-tasks\n" ]
[ "gaiku atcoder tasks\n", "abgde fchihgf edcba\n", "ha pypnewyear enjoy\n", "gaiku atcoeer tasks\n", "abcde fghihcf edgba\n", "ha pypnewzear enjoy\n", "gaiku atcoeer-tasks\n", "abgde fchihgf+edcba\n", "hap ypnewzear enjoy\n", "gbiku atcoeer-tasks\n" ]
CodeContests
Factorize a given integer n. Constraints * 2 ≤ n ≤ 109 Input n An integer n is given in a line. Output Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s...
stdin
null
4,251
1
[ "12\n", "126\n" ]
[ "12: 2 2 3\n", "126: 2 3 3 7\n" ]
[ "23\n", "7\n", "38\n", "22\n", "30\n", "4\n", "31\n", "6\n", "27\n", "3\n" ]
[ "23: 23\n", "7: 7\n", "38: 2 19\n", "22: 2 11\n", "30: 2 3 5\n", "4: 2 2\n", "31: 31\n", "6: 2 3\n", "27: 3 3 3\n", "3: 3\n" ]
CodeContests
Alice and Bob text each other everyday. Bob, tired of writing long messages has come up with a way to reduce their size. Alice and Bob are both fluent in 2 languages, L1 and L2. A language consists of a collection of distinct words, where each word consists of lowercase letters in the english alphabet. Each word in L1 ...
stdin
null
2,435
1
[ "1 1\namit am\namit\n\nSAMPLE\n" ]
[ "am\n" ]
[ "1 2\na c\nc d\na\n", "1 1\namit am\namit\n\nSAMQLE\n", "1 1\namit bm\namit\n\nSAMPLE\n", "1 2\na c\nb d\nb\n", "1 1\namit an\namit\n\nSALQLE\n", "1 1\namit `m\namit\n\nSAMQLE\n", "1 1\namit ma\namit\n\nSAMPLE\n", "1 1\namit cm\namit\n\nTAMPLE\n", "1 1\namit _m\namit\n\nSAMPLE\n", "1 1\namit al\na...
[ "a\n", "am\n", "bm\n", "b\n", "an\n", "`m\n", "ma\n", "cm\n", "_m\n", "al\n" ]
CodeContests
Some people remain old fashioned and John is one of them. He doesn't like the new smart phones with full keypads and still uses the old keypads which require you to tap a key multiple times to type a single letter. For example, if the keyboard has two keys, one with the letters "adef" and the other one with the letters...
stdin
null
3,505
1
[ "4\n7 3 4 1\n2\n2 2\n\nSAMPLE\n" ]
[ "19\n" ]
[ "50\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 33 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50\n1\n49\n", "50\n1 0 6 4 5 12 17 5 15 4 7 41 1 4 64 16 12 18 19 19 21 22 23 24 25 26 57 28 48 30 34 32 33 16 11 18 59 38 29 40 41 42 43 44 104 46 47 60 53 50\n1\n80\n", ...
[ "-1\n", "21984\n", "22157\n", "22122\n", "22163\n", "22057\n", "21843\n", "21885\n", "22300\n", "21926\n" ]
CodeContests
There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0-th step. He can climb up one or two steps at a time. However, the treads of the a_1-th, a_2-th, a_3-th, \ldots, a_M-th steps are broken, so it is dangerous to set foot on those steps. How many are there to climb ...
stdin
null
17
1
[ "100 5\n1\n23\n45\n67\n89\n", "10 2\n4\n5\n", "6 1\n3\n" ]
[ "608200469\n", "0\n", "4\n" ]
[ "100 5\n1\n23\n45\n47\n89\n", "10 2\n4\n1\n", "4 1\n3\n", "100 3\n1\n23\n45\n47\n89\n", "100 0\n1\n23\n45\n47\n89\n", "10 2\n3\n2\n", "101 0\n0\n35\n44\n58\n89\n", "101 5\n1\n23\n45\n67\n89\n", "6 1\n1\n", "100 5\n1\n23\n21\n47\n89\n" ]
[ "621622238\n", "8\n", "2\n", "733629168\n", "782204094\n", "0\n", "470199269\n", "366077159\n", "5\n", "358254682\n" ]
CodeContests
The grandest stage of all, Wrestlemania XXX recently happened. And with it, happened one of the biggest heartbreaks for the WWE fans around the world. The Undertaker's undefeated streak was finally over. Now as an Undertaker fan, you're disappointed, disheartened and shattered to pieces. And Little Jhool doesn't wan...
stdin
null
4,615
1
[]
[]
[ "43\n70094\n32451\n81996\n94945\n66592\n95666\n56597\n30999\n37838\n69486\n12189\n49843\n99036\n99581\n66047\n25991\n97370\n95747\n24363\n78941\n81920\n32127\n36071\n74224\n59348\n111407\n40357\n44730\n69466\n67521\n34774\n96220\n94847\n74993\n83466\n14454\n99893\n49313\n91338\n62333\n6140\n96093\n75101\n", "43\n...
[ "The streak lives still in our heart!\nThe streak lives still in our heart!\nThe streak lives still in our heart!\nThe streak lives still in our heart!\nThe streak lives still in our heart!\nThe streak lives still in our heart!\nThe streak lives still in our heart!\nThe streak lives still in our heart!\nThe streak ...
CodeContests
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise. Constraints * 0\leq A,B,C\leq 100 * A, B and C are distinct integers. I...
stdin
null
969
1
[ "10 2 4\n", "7 3 1\n", "31 41 59\n", "3 8 5\n" ]
[ "Yes\n", "No\n", "No\n", "Yes\n" ]
[ "8 2 4\n", "3 3 1\n", "31 61 59\n", "3 8 7\n", "1 2 4\n", "4 3 1\n", "31 49 59\n", "6 8 7\n", "1 0 4\n", "4 2 1\n" ]
[ "Yes\n", "No\n", "Yes\n", "Yes\n", "No\n", "No\n", "No\n", "Yes\n", "No\n", "No\n" ]
CodeContests
Process the Q queries below. * You are given two integers A_i and M_i. Determine whether there exists a positive integer K_i not exceeding 2 × 10^{18} such that A_i^{K_i} ≡ K_i (mod M_i), and find one if it exists. Constraints * 1 \leq Q \leq 100 * 0 \leq A_i \leq 10^9(1 \leq i \leq Q) * 1 \leq M_i \leq 10^9(1 \leq ...
stdin
null
1,131
1
[ "3\n177 168\n2028 88772\n123456789 987654321\n", "4\n2 4\n3 8\n9 6\n10 7\n" ]
[ "7953\n234831584\n471523108231963269\n", "4\n11\n9\n2\n" ]
[ "3\n177 168\n2028 149618\n123456789 987654321\n", "3\n177 168\n2028 19211\n123456789 987654321\n", "3\n177 168\n978 19211\n123456789 987654321\n", "3\n177 168\n978 19211\n235722608 987654321\n", "3\n177 168\n978 24407\n235722608 987654321\n", "3\n177 168\n978 24407\n153960391 987654321\n", "3\n177 168\n...
[ "7785\n9268608962\n186066495264926529\n", "7785\n330104641\n186066495264926529\n", "7785\n350275141\n186066495264926529\n", "7785\n350275141\n588596376627917153\n", "7785\n571832581\n588596376627917153\n", "7785\n571832581\n93420696817874593\n", "7785\n449288\n93420696817874593\n", "7785\n449288\n1871...
CodeContests
The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha has decided to teach him Japanese. When counting pencils in Japanese, the counter word "本" follows the number. The pronunciation of this word varies depending on the number. Specifically, the pronunciation of "本" in the phrase "N 本" for a pos...
stdin
null
490
1
[ "16\n", "2\n", "183\n" ]
[ "pon\n", "hon\n", "bon\n" ]
[ "31\n", "4\n", "23\n", "39\n", "49\n", "6\n", "76\n", "62\n", "12\n", "58\n" ]
[ "pon\n", "hon\n", "bon\n", "hon\n", "hon\n", "pon\n", "pon\n", "hon\n", "hon\n", "pon\n" ]
CodeContests
A fisherman named Etadokah awoke in a very small island. He could see calm, beautiful and blue sea around the island. The previous night he had encountered a terrible storm and had reached this uninhabited island. Some wrecks of his ship were spread around him. He found a square wood-frame and a long thread among the w...
stdin
null
1,296
1
[ "2\n0.2000000 0.6000000\n0.3000000 0.8000000\n0.3000000 0.5000000\n0.5000000 0.6000000\n2\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n4\n0.2000000 0.4000000 0.6000000 0.8000000\n0.1000000 0.5000000 0.6000000 0.9000000\n0.2000000 0.4000000 0.6000000 0.8000000\n0.1000000 0.500...
[ "0.215657\n0.111112\n0.078923\n0.279223\n0.348958\n" ]
[ "2\n0.2000000 0.6000000\n0.3000000 0.8000000\n0.3000000 0.5000000\n0.5000000 0.6000000\n2\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n0.3333330 0.6666670\n4\n0.2000000 0.4000000 0.6000000 0.8000000\n0.1000000 0.5000000 0.6000000 0.9000000\n0.2000000 0.4000000 0.6000000 0.8000000\n0.1000000 0.500...
[ "0.215657\n0.111112\n0.078923\n0.279223\n", "0.215657\n0.111112\n0.078923\n0.279223\n0.348958\n", "0.215657\n0.111112\n0.080105\n0.279223\n0.348958\n", "0.333130\n0.111112\n0.078923\n0.279223\n", "0.215657\n0.111112\n0.078923\n0.279223\n0.297941\n", "0.215657\n0.203094\n0.078923\n0.279223\n0.348958\n", ...
CodeContests
A Sky bag to lock accepts only the Prime number (all combination of prime numbers are allowed) except ignoring the leading zero's (0's). If there is prime number like '003' or '103' both of them are considered as the valid codes to unlock the Sky bag, but these are the 3 digit numbers. In a sky bag, the numbered are i...
stdin
null
1,679
1
[ "3\n3 001\n5 45654\n4 1234\n\nSAMPLE\n" ]
[ "1\n3\n2\n" ]
[ "15\n3 001\n5 55555\n4 9955\n2 22\n1 7\n3 001\n5 10101\n4 2468\n2 98\n1 5\n3 401\n5 55254\n4 5432\n5 343\n1 9\n", "30\n3 601\n5 55155\n4 9055\n2 02\n1 7\n3 801\n5 14101\n4 2268\n2 18\n1 1\n3 401\n5 55254\n4 5432\n3 343\n1 9\n3 001\n5 55055\n4 9455\n2 22\n1 7\n3 101\n5 20002\n4 0220\n2 04\n1 8\n3 501\n5 99999\n4 2...
[ "1\n0\n4\n0\n0\n1\n3\n3\n3\n0\n2\n1\n1\n1\n2\n", "2\n1\n2\n0\n0\n2\n4\n2\n2\n1\n2\n1\n1\n1\n2\n1\n0\n3\n0\n0\n2\n0\n0\n1\n1\n1\n10\n2\n1\n1\n", "1\n3\n2\n", "1\n0\n3\n0\n0\n1\n3\n3\n3\n0\n2\n1\n1\n1\n2\n", "1\n0\n3\n0\n0\n1\n3\n0\n3\n0\n2\n1\n1\n1\n2\n", "2\n3\n2\n", "1\n1\n3\n0\n0\n1\n3\n0\n3\n0\n2\n1\...
CodeContests
Ross and Rachel are on a date. Ross, being the super geek he is, takes Rachel to see dinosaur exhibits. Each dinosaur has a name and K attributes which are described by an ordered K-tuple ( A1, A2, A3,..., AK ). Each attribute Ai is an integer between 0 to L inclusive. Ross tells Rachel about N dinosaurs. For each din...
stdin
null
3,584
1
[ "5 3 9 5\nbaryonyx 5 1 7\njobaria 1 2 3\noviraptor 9 7 1\ntroodon 6 9 5\nminmi 7 4 5\n9 7 1\n1 2 3\n5 8 8\n1 2 3\n7 4 5\n\nSAMPLE\n" ]
[ "oviraptor\njobaria\nYou cant fool me :P\njobaria\nminmi\n" ]
[ "5 3 9 5\nbaryonyx 5 1 7\njobbria 1 2 3\noviraptor 9 7 1\ntroodon 6 9 5\nminmi 7 4 5\n9 7 1\n1 2 3\n5 8 8\n1 2 3\n7 4 5\n\nSAMPLE\n", "5 3 9 5\nbaryonyx 5 1 7\njobbria 1 2 3\noviraptor 9 7 1\ntroodon 6 9 5\nminmi 7 4 5\n9 7 1\n1 2 3\n5 8 3\n1 1 3\n7 4 5\n\nSAMPLE\n", "5 3 3 5\nbaryonyx 5 1 7\njobaria 1 2 3\novi...
[ "oviraptor\njobbria\nYou cant fool me :P\njobbria\nminmi\n", "oviraptor\njobbria\nYou cant fool me :P\nYou cant fool me :P\nminmi\n", "oviraptor\njobaria\nYou cant fool me :P\njobaria\nminmi\n", "oviraptor\njobbria\nYou cant fool me :P\njobbria\nYou cant fool me :P\n", "oviraptor\nYou cant fool me :P\nYou c...
CodeContests
Your mother sends you to market to buy some stuff which costs Rs. X, you simply need to find the minimum no. of currency denominations required to complete the transaction. Assume that the seller only takes exactly Rs. X, not more nor less than that. Also assume standard denominations of 1, 2, 5, 10, 20, 50, 100, 500 ...
stdin
null
2,991
1
[ "3\n305\n67\n105\n\nSAMPLE\n" ]
[ "4\n4\n2\n" ]
[ "1000\n30318\n6697\n5426\n10198\n348\n10853\n4268\n29480\n8047\n9300\n10662\n2592\n21013\n19965\n28450\n23691\n13173\n23604\n30893\n16786\n9384\n14343\n9781\n2108\n11302\n13145\n4635\n28980\n6270\n28877\n27017\n30157\n15179\n742\n7942\n67\n20579\n1644\n11079\n31044\n25937\n15377\n20552\n20142\n21766\n25940\n4764\n2...
[ "37\n13\n12\n17\n8\n17\n11\n36\n12\n12\n15\n7\n24\n27\n33\n29\n18\n27\n39\n24\n17\n21\n16\n6\n15\n17\n9\n36\n10\n36\n30\n34\n21\n6\n15\n4\n26\n7\n16\n35\n34\n22\n23\n24\n28\n32\n11\n29\n15\n32\n28\n21\n9\n4\n6\n15\n25\n34\n10\n32\n14\n24\n21\n23\n37\n37\n32\n10\n26\n37\n22\n38\n24\n24\n27\n19\n26\n22\n15\n19\n14\n1...
CodeContests
Tower of JOIOI The JOIOI Tower is a game that uses a disk to be played by one person. This game is played using several disks with the letters J, O, and I written on them. The discs have different diameters, and at the start of the game, these discs are stacked from bottom to top in descending order of diameter. You ...
stdin
null
464
1
[ "6\nJOIIOI\n" ]
[ "2\n" ]
[ "6\nIOIIOJ\n", "6\nIJIJOO\n", "6\nJOIJOI\n", "6\nIOIIJO\n", "6\nOJIIOI\n", "6\nOJJIOI\n", "6\nIOIJJO\n", "6\nIJIIOO\n", "6\nJOIIJO\n", "6\nIOOIJI\n" ]
[ "1\n", "0\n", "2\n", "1\n", "1\n", "1\n", "1\n", "0\n", "1\n", "1\n" ]
CodeContests
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the n...
stdin
null
2
1
[ "4\n47\n74\n477\n4747477\n" ]
[ "2\n2\n3\n23\n" ]
[ "4\n47\n47\n477\n4747477\n", "4\n7\n47\n477\n4747477\n", "4\n4\n47\n477\n4747477\n", "4\n7\n7\n477\n4747477\n", "4\n7\n44\n477\n4747477\n", "4\n44\n74\n477\n4747477\n", "4\n7\n44\n7\n4747477\n", "4\n47\n44\n477\n4747477\n", "4\n47\n4\n477\n4747477\n", "4\n7\n7\n447\n4747477\n" ]
[ "2\n2\n3\n23\n", "0\n2\n3\n23\n", "1\n2\n3\n23\n", "0\n0\n3\n23\n", "0\n3\n3\n23\n", "3\n2\n3\n23\n", "0\n3\n0\n23\n", "2\n3\n3\n23\n", "2\n1\n3\n23\n", "0\n0\n5\n23\n" ]
CodeContests
Roy wants to change his profile picture on Facebook. Now Facebook has some restriction over the dimension of picture that we can upload. Minimum dimension of the picture can be L x L, where L is the length of the side of square. Now Roy has N photos of various dimensions. Dimension of a photo is denoted as W x H wh...
stdin
null
210
1
[ "180\n3\n640 480\n120 300\n180 180\n\nSAMPLE\n" ]
[ "CROP IT\nUPLOAD ANOTHER\nACCEPTED\n" ]
[ "180\n3\n640 480\n120 300\n180 180\n\nSAMELP\n", "180\n3\n640 908\n120 300\n297 180\n\nSAMELP\n", "180\n2\n640 908\n120 300\n297 180\n\nSAMELP\n", "180\n3\n717 340\n241 300\n180 180\n\nSAMELP\n", "180\n2\n972 69\n48 300\n361 180\n\nSALELP\n", "180\n1\n353 480\n120 300\n180 180\n\nSAMPLE\n", "180\n3\n353...
[ "CROP IT\nUPLOAD ANOTHER\nACCEPTED\n", "CROP IT\nUPLOAD ANOTHER\nCROP IT\n", "CROP IT\nUPLOAD ANOTHER\n", "CROP IT\nCROP IT\nACCEPTED\n", "UPLOAD ANOTHER\nUPLOAD ANOTHER\n", "CROP IT\n", "CROP IT\nUPLOAD ANOTHER\nUPLOAD ANOTHER\n", "UPLOAD ANOTHER\nUPLOAD ANOTHER\nACCEPTED\n", "UPLOAD ANOTHER\n", ...
CodeContests
Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n. The Koch curve is well known as a kind of fractals. You can draw a Koch curve in the following algorithm: * Divide a given segment (p1, p2) into three equal segments. * Replace the middle segment by the two sides of...
stdin
null
2,704
1
[ "2\n", "1\n" ]
[ "0.00000000 0.00000000\n11.11111111 0.00000000\n16.66666667 9.62250449\n22.22222222 0.00000000\n33.33333333 0.00000000\n38.88888889 9.62250449\n33.33333333 19.24500897\n44.44444444 19.24500897\n50.00000000 28.86751346\n55.55555556 19.24500897\n66.66666667 19.24500897\n61.11111111 9.62250449\n66.66666667 0.00000000\...
[ "4\n", "0\n", "6\n", "3\n", "5\n", "3\n", "0\n", "4\n", "6\n", "5\n" ]
[ "0 0\n1.23456790123 0.0\n1.85185185185 1.06916716517\n2.46913580247 0.0\n3.7037037037 0.0\n4.32098765432 1.06916716517\n3.7037037037 2.13833433033\n4.93827160494 2.13833433033\n5.55555555556 3.2075014955\n6.17283950617 2.13833433033\n7.40740740741 2.13833433033\n6.79012345679 1.06916716517\n7.40740740741 0.0\n8.641...
CodeContests
Hearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks. There are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks for A_i yen (the currency of Japan) each. What is the minimum amount of money with which he can bu...
stdin
null
2,363
1
[ "4 30\n6 18\n2 5\n3 10\n7 9\n", "1 100000\n1000000000 100000\n", "2 5\n4 9\n2 4\n" ]
[ "130\n", "100000000000000\n", "12\n" ]
[ "4 30\n6 18\n2 6\n3 10\n7 9\n", "2 3\n4 9\n2 4\n", "4 30\n6 18\n2 1\n3 10\n7 9\n", "2 3\n4 9\n4 4\n", "2 6\n4 9\n4 4\n", "2 6\n3 9\n4 4\n", "2 6\n3 9\n2 4\n", "2 6\n3 9\n1 4\n", "2 3\n3 4\n1 6\n", "2 5\n3 4\n1 6\n" ]
[ "126\n", "6\n", "147\n", "12\n", "24\n", "18\n", "14\n", "10\n", "3\n", "5\n" ]
CodeContests
You are in charge of painting the lanes on a 500 meter race track for a forthcoming amateur track event. There are 9 lanes in total which means you must paint 10 lines around the track to delimit these lanes. Fortunately, you have special equipment that will help you paint these lanes very quickly. This equipment has...
stdin
null
4,805
1
[ "3\n2\n1 3 1\n2 5 2\n2\n1 3 1\n2 5 3\n5\n60 60 4\n60 61 5\n61 61 6\n100 100 8\n100 100 9\n" ]
[ "498\n500\n497\n" ]
[ "3\n2\n1 1 1\n2 5 2\n2\n1 3 1\n2 5 3\n5\n60 60 4\n60 61 5\n61 61 6\n100 100 8\n100 100 9\n", "3\n2\n1 3 1\n2 5 2\n2\n1 3 1\n1 5 3\n5\n60 60 4\n60 61 5\n61 61 6\n100 100 8\n100 100 9\n", "3\n2\n1 1 1\n2 5 2\n2\n1 3 1\n2 5 3\n5\n60 60 7\n60 61 5\n61 61 6\n100 100 8\n100 100 9\n", "3\n2\n0 3 1\n2 5 2\n2\n2 3 1\n...
[ "500\n500\n497\n", "498\n500\n497\n", "500\n500\n498\n", "498\n500\n498\n", "500\n500\n499\n", "500\n500\n500\n", "500\n497\n499\n", "500\n497\n500\n", "499\n500\n497\n", "498\n500\n499\n" ]
CodeContests
You have a part to play in the Wars to Come. As everyone knows, Lord Stannis Baratheon (First of His Name, King of the Andals and the First Men, Lord of the Seven Kingdoms and Protector of the Realm) is one true king. Now, he wants to conquer the North. To conquer, he needs to expand his army. And since, Winter is com...
stdin
null
1,522
1
[]
[]
[ "4\n45 15 1 34 \n90\n", "4\n45 34 1 34 \n22\n", "4\n19 20 1 11 \n27\n", "4\n45 34 1 34 \n18\n", "4\n45 34 0 34 \n18\n", "4\n45 34 0 20 \n18\n", "4\n45 34 1 20 \n18\n", "4\n45 34 1 23 \n18\n", "4\n45 34 1 11 \n18\n", "4\n45 20 1 11 \n18\n" ]
[ "3\n", "1\n", "2\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n", "1\n" ]
CodeContests
Wall Painting Here stands a wall made of a number of vertical panels. The panels are not painted yet. You have a number of robots each of which can paint panels in a single color, either red, green, or blue. Each of the robots, when activated, paints panels between a certain position and another certain position in a...
stdin
null
859
1
[ "8 5 10 5\n1 1 7\n3 1 2\n1 5 6\n3 1 4\n3 6 8\n" ]
[ "70\n" ]
[ "8 3 10 5\n1 1 7\n3 1 2\n1 5 6\n3 1 4\n3 6 8\n", "14 3 10 5\n1 2 7\n3 1 2\n2 5 6\n3 1 4\n3 6 8\n", "8 3 9 5\n1 1 7\n3 1 2\n1 5 6\n3 1 4\n3 6 8\n", "14 3 3 5\n1 2 7\n3 1 2\n2 5 6\n3 1 4\n3 6 8\n", "4 3 10 5\n1 2 0\n3 1 2\n2 6 6\n3 1 4\n3 6 2\n", "14 3 3 5\n1 2 6\n3 1 2\n2 5 6\n3 1 4\n3 6 8\n", "14 2 10 2...
[ "70\n", "60\n", "63\n", "18\n", "30\n", "15\n", "10\n", "40\n", "21\n", "91\n" ]
CodeContests
You are a treasure hunter traveling around the world. Finally, you’ve got an ancient text indicating the place where the treasure was hidden. The ancient text looks like a meaningless string of characters at first glance. Actually, the secret place is embedded as the longest repeated subsequence of the text. Well, the...
stdin
null
2,817
1
[ "ABCABCABAB\nZZZZZZZZZZZZ\nEND\n", "ABCABCABAB\nZZZZZZZZZZZZ\n#END\n" ]
[ "ABAB\nZZZZZZ\n", "ABAB\nZZZZZZ\n" ]
[ "ABCABCABAB\nZZZZZZZZZZZZ\nNED\n", "ABCABCABAB\nZZZZZZZZZZZZ\nNDD\n", "ABCABCACAB\nZZZZZZZZZZZZ\nNDD\n", "ABBABCACAB\nZZZZZZZZZZZZ\nNDD\n", "ABBABCACAB\nZ[ZZZZZZZZZZ\nNDD\n", "ABCABCABAB\nZZZZZZZZZZZZ\nNEE\n", "ABBABCACAB\nZZZZZZZZZZZZ\nNED\n", "ABCABCABAB\nZZZZZZZZZZZY\nNEE\n", "BACACBACBA\nZZZZZZZ...
[ "ABAB\nZZZZZZ\n", "ABAB\nZZZZZZ\nD\n", "ACAB\nZZZZZZ\nD\n", "ABB\nZZZZZZ\nD\n", "ABB\nZZZZZ\nD\n", "ABAB\nZZZZZZ\nE\n", "ABB\nZZZZZZ\n", "ABAB\nZZZZZ\nE\n", "BACA\nZZZZZZ\nD\n", "ABB\nZZZZZ\n" ]
CodeContests
Little Stuart has reached the final level of 'Code Hunt', the annual treasure hunt organised by HackerEarth. Now for the final level, Little Stuart has to choose a door from infinite number of doors numbered from 1 to infinity. Out of these only one door contains the grand prize. The clue for finding the correct door i...
stdin
null
4,255
1
[ "2\n3\n10 2 3\n2\n3 5\n\nSAMPLE\n" ]
[ "1\n0\n" ]
[ "2\n3\n10 2 3\n2\n5 5\n\nSAMPLE\n", "2\n3\n10 2 3\n2\n5 4\n\nSAMPLE\n", "2\n3\n13 2 3\n0\n7 4\n\nLAMPTE\n", "2\n1\n10 1 3\n2\n1 1\n\nLPNASE\n", "2\n3\n10 2 1\n2\n5 5\n\nSAMPLE\n", "2\n3\n10 2 2\n0\n7 4\n\nSAMPLE\n", "2\n3\n10 2 5\n2\n5 4\n\nDLPMAS\n", "2\n3\n10 2 3\n2\n7 4\n\nSAMPLE\n", "2\n3\n10 2 ...
[ "1\n1\n", "1\n0\n", "0\n0\n", "0\n1\n", "3\n1\n", "3\n0\n", "2\n0\n", "1\n0\n", "1\n0\n", "1\n0\n" ]
CodeContests
Given are N integers A_1,\ldots,A_N. Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7). Constraints * 2 \leq N \leq 2\times 10^5 * 0 \leq A_i \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the following format: N A_1 \ldot...
stdin
null
805
1
[ "3\n1 2 3\n", "4\n141421356 17320508 22360679 244949\n" ]
[ "11\n", "437235829\n" ]
[ "3\n0 2 3\n", "4\n141421356 17320508 22360679 176612\n", "3\n0 2 0\n", "4\n141421356 17320508 44188846 176612\n", "4\n141421356 15438004 44188846 176612\n", "4\n141421356 15438004 10545868 176612\n", "4\n141421356 22198551 10545868 176612\n", "4\n141421356 22198551 4405286 176612\n", "4\n141421356 5...
[ "6\n", "432841470\n", "0\n", "442072669\n", "24018621\n", "309796111\n", "856634378\n", "907440962\n", "471127930\n", "478491412\n" ]
CodeContests
You have three tasks, all of which need to be completed. First, you can complete any one task at cost 0. Then, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|. Here, |x| denotes the absolute value of x. Find the minimum total cost required to complete all the task. Constrain...
stdin
null
3,876
1
[ "1 6 3\n", "100 100 100\n", "11 5 5\n" ]
[ "5\n", "0\n", "6\n" ]
[ "1 12 3\n", "100 100 000\n", "11 5 2\n", "1 24 3\n", "3 5 2\n", "1 16 4\n", "4 3 2\n", "100 111 000\n", "4 3 0\n", "2 16 7\n" ]
[ "11\n", "100\n", "9\n", "23\n", "3\n", "15\n", "2\n", "111\n", "4\n", "14\n" ]
CodeContests
There are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i). We will repeat the following operation as long as possible: * Choose four integers a, b, c, d (a \neq c, b \neq d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b) and (c, d), and add a dot at...
stdin
null
2,722
1
[ "3\n1 1\n5 1\n5 5\n", "9\n1 1\n2 1\n3 1\n4 1\n5 1\n1 2\n1 3\n1 4\n1 5\n", "2\n10 10\n20 20\n" ]
[ "1\n", "16\n", "0\n" ]
[ "3\n1 1\n5 1\n5 4\n", "9\n1 1\n2 1\n3 1\n4 1\n7 1\n1 2\n1 3\n1 4\n1 5\n", "2\n10 10\n20 1\n", "9\n1 1\n3 1\n3 1\n4 1\n7 1\n1 2\n2 3\n1 4\n1 5\n", "9\n1 1\n3 1\n3 1\n4 1\n7 1\n2 2\n2 3\n1 4\n1 5\n", "9\n1 1\n2 1\n6 1\n4 1\n7 1\n1 2\n2 3\n1 6\n1 6\n", "9\n1 1\n3 1\n3 1\n3 1\n7 1\n2 2\n2 3\n1 4\n1 5\n", ...
[ "1\n", "16\n", "0\n", "8\n", "5\n", "11\n", "2\n", "6\n", "4\n", "-1\n" ]
CodeContests
There are three airports A, B and C, and flights between each pair of airports in both directions. A one-way flight between airports A and B takes P hours, a one-way flight between airports B and C takes Q hours, and a one-way flight between airports C and A takes R hours. Consider a route where we start at one of th...
stdin
null
1,847
1
[ "3 2 3\n", "1 3 4\n" ]
[ "5\n", "4\n" ]
[ "3 1 3\n", "2 3 4\n", "3 1 2\n", "3 1 0\n", "1 1 3\n", "3 0 0\n", "3 0 -1\n", "3 -1 -1\n", "3 -1 -2\n", "0 -4 4\n" ]
[ "4\n", "5\n", "3\n", "1\n", "2\n", "0\n", "-1\n", "-2\n", "-3\n", "-4\n" ]
CodeContests
problem There are n cards with numbers from 1 to n. First, make a pile of cards by stacking them in order so that the top is the number 1 card, the second from the top is the number 2 card, ..., and the bottom is the number n card. <image> Sort the cards by performing the following operation called "shuffle (x, y)...
stdin
null
1,977
1
[ "9\n1\n3 7 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n6 10\n0\n" ]
[ "2\n3\n" ]
[ "9\n1\n3 7 4\n4 5\n12\n3\n3 8 5\n3 8\n2 5\n6 10\n0\n", "9\n1\n2 7 4\n4 5\n12\n3\n3 8 5\n3 8\n2 3\n6 10\n0\n", "9\n1\n3 4 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n9 10\n0\n", "9\n1\n3 7 4\n4 5\n12\n3\n2 8 5\n3 8\n2 7\n6 10\n0\n", "9\n1\n3 6 4\n3 5\n12\n3\n3 8 5\n3 8\n2 5\n9 10\n0\n", "9\n1\n3 7 4\n4 5\n12\n3\n3 8 5...
[ "2\n3\n", "2\n4\n", "0\n3\n", "2\n2\n", "1\n3\n", "2\n1\n", "2\n5\n", "5\n2\n", "2\n0\n", "4\n3\n" ]
CodeContests
There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i. You will land on a square of your choice, then repeat moving to the adjacent square on the right as long as the height of the next square is not greater than that of the current square. Find the maximum numb...
stdin
null
4,266
1
[ "5\n10 4 8 7 3\n", "4\n1 2 3 4\n", "7\n4 4 5 6 6 5 5\n" ]
[ "2\n", "0\n", "3\n" ]
[ "5\n10 4 8 13 3\n", "4\n1 2 3 6\n", "7\n4 4 8 6 6 5 5\n", "7\n7 4 8 6 6 5 8\n", "5\n12 4 8 4 3\n", "5\n10 4 8 12 3\n", "4\n1 2 6 6\n", "7\n7 4 8 6 6 5 5\n", "5\n12 4 8 12 3\n", "4\n1 4 3 6\n" ]
[ "1\n", "0\n", "4\n", "3\n", "2\n", "1\n", "1\n", "4\n", "1\n", "1\n" ]
CodeContests
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string. Constraints * 1 \leq N \leq 10^{4} * 2 \leq |s_i| \leq 10 * s_i consists of uppercase English letters. In...
stdin
null
4,780
1
[ "9\nBEWPVCRWH\nZZNQYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n", "7\nRABYBBE\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n", "3\nABCA\nXBAZ\nBAD\n" ]
[ "4\n", "4\n", "2\n" ]
[ "9\nBEWPVCRWH\nZQNZYIJX\nBAVREA\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n", "7\nEBBYBAR\nJOZ\nBMHQUVA\nBPA\nISU\nMCMABAOBHZ\nSZMEHMA\n", "3\nABCA\nXBAZ\nBAE\n", "3\nACBA\nZABX\nAEB\n", "3\n@DBA\nZAAX\nAEB\n", "9\nBEWPVCRWH\nZQNZYIJX\nAERVAB\nPA\nHJMYITEOX\nBCJHMRMNK\nBP\nQVFABZ\nPRGKSPUNA\n", "...
[ "4\n", "3\n", "2\n", "1\n", "0\n", "4\n", "3\n", "2\n", "4\n", "3\n" ]
CodeContests
Heiankyo is known as a town with a grid of roads. Hokusai, a cat who lives in Heiankyo, has to go from his home to a secret place on the outskirts of town every day for patrol. However, I get tired of following the same path every day, and there is a risk of being followed, so Hokusai wants to use a different route ev...
stdin
null
4,517
1
[ "4\n2 2\n0\n1 1\n2\n0 0 0 1\n0 0 1 0\n4 3\n4\n1 0 0 0\n3 3 4 3\n4 1 4 0\n0 2 0 3\n15 15\n0\n" ]
[ "6\nMiserable Hokusai!\n5\n155117520\n" ]
[ "4\n2 2\n0\n1 2\n2\n0 0 0 1\n0 0 1 0\n4 3\n4\n1 0 0 0\n3 3 4 3\n4 1 4 0\n0 2 0 3\n15 15\n0\n", "4\n2 2\n0\n1 2\n2\n0 0 0 1\n0 0 1 0\n4 3\n4\n1 0 0 0\n3 3 4 3\n4 0 4 0\n0 2 0 3\n15 3\n0\n", "4\n2 2\n0\n0 2\n2\n0 0 0 1\n0 0 1 0\n2 3\n4\n1 0 0 0\n3 3 4 3\n4 0 4 0\n0 2 0 3\n14 3\n0\n", "4\n2 3\n0\n1 1\n2\n0 0 0 1...
[ "6\nMiserable Hokusai!\n5\n155117520\n", "6\nMiserable Hokusai!\n5\n816\n", "6\nMiserable Hokusai!\n5\n680\n", "10\nMiserable Hokusai!\n5\n155117520\n", "6\nMiserable Hokusai!\n11\n155117520\n", "6\nMiserable Hokusai!\n9\n816\n", "10\nMiserable Hokusai!\n5\n680\n", "6\nMiserable Hokusai!\n9\n4\n", "...
CodeContests
There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i. You can rearrange these children just one time in any order you like. When a child who originally occupies the x-th position from the left in the line moves to the y-th position from the left, that child...
stdin
null
291
1
[ "4\n1 3 4 2\n", "6\n8 6 9 1 2 1\n", "6\n5 5 6 1 1 1\n" ]
[ "20\n", "85\n", "58\n" ]
[ "4\n1 4 4 2\n", "6\n8 6 11 1 2 1\n", "6\n5 5 6 0 1 1\n", "4\n1 8 4 2\n", "6\n8 6 22 1 2 1\n", "6\n5 5 9 0 1 1\n", "4\n2 8 4 2\n", "6\n8 6 22 1 1 1\n", "6\n5 0 9 0 1 1\n", "6\n8 6 33 1 1 1\n" ]
[ "22\n", "90\n", "58\n", "30\n", "123\n", "65\n", "32\n", "119\n", "55\n", "152\n" ]
CodeContests
You are situated in an N dimensional grid at position (x1,x2,...,xN). The dimensions of the grid are (D1,D2,...DN). In one step, you can walk one step ahead or behind in any one of the N dimensions. (So there are always 2×N possible different moves). In how many ways can you take M steps such that you do not leave the ...
stdin
null
5,007
1
[ "5\n1 287\n44\n78\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n\nSAMPLE\n" ]
[ "38753340\n587915072\n644474045\n423479916\n320130104\n" ]
[ "10\n1 287\n44\n78\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n1 69\n6\n18\n1 231\n14\n63\n1 236\n13\n30\n1 259\n38\n70\n1 257\n11\n12\n", "5\n1 287\n44\n78\n1 129\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 127\n3\n73\n\nSAMPLE\n", "10\n1 287\n44\n148\n1 236\n25\n87\n1 122\n41\n63\n1 260\n7\n64\n1 1...
[ "38753340\n587915072\n644474045\n423479916\n320130104\n69151240\n846814121\n385120933\n60306396\n306773532\n", "38753340\n732305596\n644474045\n423479916\n320130104\n", "733734127\n587915072\n644474045\n423479916\n320130104\n69151240\n846814121\n385120933\n60306396\n306773532\n", "38753340\n732305596\n6444740...
CodeContests
For a non-negative integer K, we define a fractal of level K as follows: * A fractal of level 0 is a grid with just one white square. * When K > 0, a fractal of level K is a 3^K \times 3^K grid. If we divide this grid into nine 3^{K-1} \times 3^{K-1} subgrids: * The central subgrid consists of only black squares. * Ea...
stdin
null
5,009
1
[ "2\n4 2 7 4\n9 9 1 9\n" ]
[ "5\n8\n" ]
[ "2\n3 2 7 4\n9 9 1 9\n", "2\n3 2 7 4\n9 3 1 9\n", "2\n3 2 7 4\n9 3 1 15\n", "2\n3 2 7 4\n7 3 1 15\n", "2\n3 2 4 4\n7 3 1 15\n", "2\n3 2 4 4\n7 3 1 9\n", "2\n3 2 6 4\n7 3 1 9\n", "2\n3 2 6 4\n4 3 1 9\n", "2\n3 2 6 4\n4 3 2 9\n", "2\n3 2 6 4\n4 3 2 4\n" ]
[ "6\n8\n", "6\n14\n", "6\n20\n", "6\n18\n", "3\n18\n", "3\n12\n", "5\n12\n", "5\n9\n", "5\n8\n", "5\n3\n" ]
CodeContests
Frank explained its friend Felman the algorithm of Euclides to calculate the GCD of two numbers. Then Felman implements it algorithm int gcd(int a, int b) { if (b==0) return a; else return gcd(b,a%b); } and it proposes to Frank that makes it but with a little integer and another integer that has up to 250 d...
stdin
null
1
1
[ "2\n2 6\n10 11\n" ]
[ "2\n1\n" ]
[ "2\n3 6\n10 11\n", "2\n1 3\n10 11\n", "2\n0 6\n10 11\n", "2\n0 6\n0 11\n", "2\n3 6\n8 22\n", "2\n3 6\n8 4\n", "2\n5 2\n10 2\n", "2\n4 10\n8 6\n", "2\n7 14\n8 6\n", "2\n7 14\n8 4\n" ]
[ "3\n1\n", "1\n1\n", "6\n1\n", "6\n11\n", "3\n2\n", "3\n4\n", "1\n2\n", "2\n2\n", "7\n2\n", "7\n4\n" ]
CodeContests
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique. * insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$. * get($key$): Print the value with the specified $...
stdin
null
992
1
[ "8\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n2 red\n1 black\n1 red\n" ]
[ "1\n4\n0\n0\n" ]
[ "8\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 bmue\n2 red\n1 black\n1 red\n", "8\n0 blue 4\n0 red 1\n0 white 5\n1 erd\n1 bmue\n2 red\n1 black\n1 red\n", "8\n0 blue 4\n0 der 1\n0 white 10\n1 etd\n1 bmue\n2 der\n0 black\n1 des\n", "8\n0 blue 4\n0 red 1\n0 white 5\n1 red\n2 blue\n2 red\n1 black\n1 red\n", "8\n0 b...
[ "1\n0\n0\n0\n", "0\n0\n0\n0\n", "0\n0\n", "1\n0\n0\n", "0\n0\n0\n", "0\n", "1\n0\n", "0\n0\n0\n0\n0\n", "0\n4\n0\n0\n", "1\n0\n1\n0\n0\n" ]
CodeContests
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ...
stdin
null
1,870
1
[ "30\n" ]
[ "3 6 9 12 13 15 18 21 23 24 27 30\n" ]
[ "53\n", "9\n", "17\n", "28\n", "7\n", "13\n", "25\n", "18\n", "4\n", "21\n" ]
[ "3 6 9 12 13 15 18 21 23 24 27 30 31 32 33 34 35 36 37 38 39 42 43 45 48 51 53\n", "3 6 9\n", "3 6 9 12 13 15\n", "3 6 9 12 13 15 18 21 23 24 27\n", "3 6\n", "3 6 9 12 13\n", "3 6 9 12 13 15 18 21 23 24\n", "3 6 9 12 13 15 18\n", "3\n", "3 6 9 12 13 15 18 21\n" ]
CodeContests
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. ...
stdin
null
3,957
1
[ "4500\n0\n", "2002\n2017\n" ]
[ "-4500\n", "2032\n" ]
[ "4500\n-1\n", "2002\n1006\n", "4500\n-2\n", "2002\n416\n", "4500\n1\n", "2002\n468\n", "4500\n2\n", "2002\n87\n", "4500\n-4\n", "2002\n33\n" ]
[ "-4502\n", "10\n", "-4504\n", "-1170\n", "-4498\n", "-1066\n", "-4496\n", "-1828\n", "-4508\n", "-1936\n" ]
CodeContests
There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points), and draw (1 point), respectively. Enter the number of teams and the...
stdin
null
2,370
1
[ "4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n" ]
[ "Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0\n" ]
[ "4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 -1 1\n0\n", "4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItalx 1 -1 1\n0\n", "4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nniapS 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 1 1...
[ "Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0\n", "Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItalx,4\nIndia,0\n", "niapS,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0\n", "Spain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItalx,4\nIndia,-3\n", "niapS,7\nJapan,5\nEgyp...
CodeContests
In the good old days, the Internet was free from fears and terrorism. People did not have to worry about any cyber criminals or mad computer scientists. Today, however, you are facing atrocious crackers wherever you are, unless being disconnected. You have to protect yourselves against their attacks. Counting upon you...
stdin
null
2,693
1
[ "2 5\npermit 192168?? ?12??34?\ndeny 19216899 012343?5\n19216711 11233340 HiIamACracker\n19216891 01234345 Hello\n19216899 01234345 HiIamAlsoACracker\n19216809 11200340 World\n00000000 99999999 TheEndOfTheWorld\n1 2\npermit 12345678 23456789\n19216891 01234345 Hello\n12345678 23456789 Hello\n0 0\n" ]
[ "2\n19216891 01234345 Hello\n19216809 11200340 World\n1\n12345678 23456789 Hello\n" ]
[ "2 5\npermit 192168?? ?12??34?\ndeny 19216899 012343?5\n19216711 11233340 HiIamACracker\n19216891 01234345 Hello\n19216899 01234345 HiIbmAlsoACracker\n19216809 11200340 World\n00000000 99999999 TheEndOfTheWorld\n1 2\npermit 12345678 23456789\n19216891 01234345 Hello\n12345678 23456789 Hello\n0 0\n", "2 5\npermit ...
[ "2\n19216891 01234345 Hello\n19216809 11200340 World\n1\n12345678 23456789 Hello\n", "2\n19216891 01234345 Hello\n19216809 11200340 World\n1\n12345678 23456789 Hdllo\n", "1\n19216809 11200340 World\n1\n12345678 23456789 Hdllo\n", "2\n19216899 01234345 HiIbmAlsoACracker\n19216809 11200340 World\n1\n12345678 23...
CodeContests
Taru and Chandu both are getting bored. So Taru thinks to play a game and he gives a number to Chandu and asks him to find the number of combinations formed by divisors in form of prime. For example:- For N = 36 divisor in form of prime are ( 2 , 2 , 3 , 3 ) Number of combinations formed by prime divisor of 36 a...
stdin
null
1,001
1
[ "1\n36\n\nSAMPLE\n" ]
[ "8\n" ]
[ "1\n36\n\nELPMAS\n", "1\n38\n\nELPMBT\n", "1\n61\n\nDKOMBU\n", "1\n45\n\nELPMAT\n", "1\n70\n\nDLPMBT\n", "1\n72\n\nDKPMBU\n", "1\n64\n\nDKOMBU\n", "1\n168\n\nDLPLBT\n", "1\n4\n\nDKBMPT\n", "1\n48\n\nELPMBT\n" ]
[ "8\n", "3\n", "1\n", "5\n", "7\n", "11\n", "6\n", "15\n", "2\n", "9\n" ]
CodeContests
View Russian Translation In this problem the goal is to implement a program managing an elevator designed especially for mathematicians. The elevator can go to any of N floors numbered from 1 to N and it can carry an arbitrary number of people at one time. Initially the elevator is at floor 1, without any people in...
stdin
null
3,382
1
[ "10 2\n1 2 3\n2 6 2\n\nSAMPLE\n" ]
[ "1 3\n" ]
[ "10 2\n1 2 3\n2 1 2\n\nSAMPLE\n", "10 2\n1 2 3\n1 1 2\n\nSAMPLE\n", "5 2\n1 3 3\n1 1 2\n\nSAMPLE\n", "7 2\n1 3 8\n1 1 2\n\nSAMPLE\n", "5 2\n1 3 3\n1 3 2\n\nSAMPKE\n", "22 1\n1 3 8\n1 1 2\n\nSAMPLE\n", "7 2\n1 5 8\n1 1 2\n\nSAMPLE\n", "8 1\n1 3 3\n2 1 2\n\nSAMPLE\n", "5 2\n1 2 3\n1 2 1\n\nSAMPKE\n", ...
[ "1 3\n", "2 5\n", "0 2\n", "4 10\n", "2 2\n", "2 8\n", "8 10\n", "0 0\n", "1 4\n", "2 4\n" ]
CodeContests
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation...
stdin
null
2,639
1
[ "2 3 4\n..#\n", "6 6 8\n..##..\n.#..#.\n....#\n\n....#\n....#\n", "2 3 2\n..#\n", "2 2 3\n", "2 3 2\n..#\n###\n" ]
[ "1\n", "208\n", "5\n", "0\n", "5\n" ]
[ "2 2 4\n..#\n", "4 3 2\n..#\n###\n", "4 3 2\n..#\n$##\n", "2 3 0\n.-#\n", "3 3 0\n/,#\n", "6 3 0\n/,#\n", "6 3 1\n/,#\n", "6 3 0\n/,$\n", "6 2 0\n/,$\n", "1 4 0\n" ]
[ "0\n", "20\n", "16\n", "24\n", "48\n", "384\n", "128\n", "512\n", "256\n", "32\n" ]
CodeContests
Example Input crc 1 Output crc
stdin
null
4,870
1
[ "crc\n1\n" ]
[ "crc\n" ]
[ "crb\n1\n", "bqc\n1\n", "bcq\n2\n", "ccq\n2\n", "cdq\n2\n", "dcq\n2\n", "dcq\n4\n", "qcd\n3\n", "qce\n3\n", "qce\n4\n" ]
[ "bcrcb\n", "bcqcb\n", "bqcqb\n", "NONE\n", "cqdqc\n", "dqcqd\n", "qdcdq\n", "qcdcq\n", "qcecq\n", "qeceq\n" ]
CodeContests
DG (Departmental Gathering) is coming…. As one of the most famous girls in the college everybody is smitten with Harshada and wants to give her roses. But Harshada is only into coders , therefore she sends out word that she would accept roses from the nth guy only if he brings her x roses such that ‘x’ is the nth ...
stdin
null
3,300
1
[ "3\n1\n5\n10\n\nSAMPLE\n" ]
[ "1\n8\n10476\n" ]
[ "3\n1\n5\n10\n\nSAMPKE\n", "3\n1\n5\n18\n\nSBMPKE\n", "3\n1\n6\n10\n\nSAMPLE\n", "3\n1\n8\n10\n\nSBNPKE\n", "3\n1\n4\n10\n\nSAEPKM\n", "3\n1\n4\n18\n\nSAEPKM\n", "3\n1\n4\n1\n\nSAEPKM\n", "3\n1\n5\n20\n\nSAMNLF\n", "3\n1\n16\n10\n\nEQKNBS\n", "3\n1\n4\n7\n\nEQLNBS\n" ]
[ "1\n8\n10476\n", "1\n8\n19377215893777651167043206536157529523359277782016064519251404524\n", "1\n12\n10476\n", "1\n108\n10476\n", "1\n4\n10476\n", "1\n4\n19377215893777651167043206536157529523359277782016064519251404524\n", "1\n4\n1\n", "1\n8\n375476495794069216556083980357827284230304438004757733143...
CodeContests
Problem Statement: Dom and Brian were trying to evade the truck drivers of Verone's gang. They were too fast, too furious for them, and could get away from the truck drivers easily. They decided to race with each other, and divided the city into N checkpoints for the same. Mia was monitoring Dom and Brian throughout t...
stdin
null
3,700
1
[ "3\n1 2 3\n1 2 4\n\nSAMPLE\n" ]
[ "Brian\n2\n" ]
[ "3\n1 2 3\n1 2 4\n\nSAMPKE\n", "3\n1 2 3\n1 4 4\n\nSAMPKE\n", "3\n1 2 3\n0 4 4\n\nSAMPKE\n", "3\n1 0 3\n1 3 4\n\nSAMPKE\n", "3\n1 -1 3\n1 3 4\n\nSAMPKE\n", "3\n1 -1 4\n1 3 4\n\nSAMPKE\n", "3\n1 2 9\n1 2 4\n\nSLLPAE\n", "3\n1 2 11\n1 2 4\n\nSAMPKE\n", "3\n1 2 5\n1 2 8\n\nSLLPAE\n", "3\n1 0 6\n2 5 5...
[ "Brian\n2\n", "Brian\n3\n", "Brian\n4\n", "Dom\n3\n", "Dom\n4\n", "Dom\n5\n", "Dom\n7\n", "Dom\n9\n", "Brian\n6\n", "Dom\n6\n" ]
CodeContests
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). In this contest, a contestant will first select some number of problems to solve. Then, the contestant...
stdin
null
4,349
1
[ "5\n1 1 4 1 1\n2\n3 2\n3 10\n", "12\n1 2 1 3 4 1 2 1 12 3 12 12\n10\n9 3\n11 1\n5 35\n6 15\n12 1\n1 9\n4 3\n10 2\n5 1\n7 6\n" ]
[ "9\n2\n", "34\n35\n5\n11\n35\n17\n25\n26\n28\n21\n" ]
[ "5\n1 1 4 1 1\n2\n3 2\n3 20\n", "12\n1 2 1 3 4 1 2 1 12 3 12 12\n10\n9 3\n11 1\n5 0\n6 15\n12 1\n1 9\n4 3\n10 2\n5 1\n7 6\n", "12\n1 2 1 3 4 1 2 1 12 3 12 12\n10\n9 5\n11 1\n5 0\n6 15\n12 1\n1 9\n4 3\n10 2\n5 1\n7 6\n", "12\n1 2 1 3 4 1 2 1 12 3 12 12\n10\n9 5\n11 1\n5 0\n6 15\n12 1\n1 18\n4 3\n10 2\n5 1\n7 6...
[ "9\n2\n", "34\n35\n29\n11\n35\n17\n25\n26\n28\n21\n", "32\n35\n29\n11\n35\n17\n25\n26\n28\n21\n", "32\n35\n29\n11\n35\n16\n25\n26\n28\n21\n", "32\n35\n29\n11\n35\n16\n25\n24\n28\n21\n", "30\n33\n27\n9\n33\n14\n23\n22\n26\n19\n", "30\n33\n27\n9\n33\n14\n23\n22\n26\n15\n", "10\n2\n", "29\n32\n26\n9\n3...
CodeContests
We have a square grid with H rows and W columns. Snuke wants to write 0 or 1 in each of the squares. Here, all of the following conditions have to be satisfied: * For every row, the smaller of the following is A: the number of 0s contained in the row, and the number of 1s contained in the row. (If these two numbers ar...
stdin
null
4,303
1
[ "3 3 1 1\n", "1 5 2 0\n" ]
[ "100\n010\n001\n", "01010\n" ]
[ "3 3 0 1\n", "1 5 2 -1\n", "3 6 0 1\n", "1 5 4 -1\n", "3 10 0 1\n", "2 5 4 -1\n", "2 6 4 -1\n", "1 5 0 0\n", "3 3 0 2\n", "1 5 2 1\n" ]
[ "111\n000\n000\n", "11000\n", "111111\n000000\n000000\n", "11110\n", "1111111111\n0000000000\n0000000000\n", "11110\n11110\n", "111100\n111100\n", "00000\n", "111\n111\n000\n", "00111\n" ]
CodeContests
There is a tree with N vertices, numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i. Currently, there are A_i stones placed on vertex i. Takahashi and Aoki will play a game using this tree. First, Takahashi will select a vertex and place a piece on it. Then, starting from Takahashi, they wi...
stdin
null
4,193
1
[ "3\n1 2 3\n1 2\n2 3\n", "5\n5 4 1 2 3\n1 2\n1 3\n2 4\n2 5\n", "3\n1 1 1\n1 2\n2 3\n" ]
[ "2\n", "1 2\n", "\n" ]
[ "5\n2 4 1 2 3\n1 2\n1 3\n2 4\n2 5\n", "3\n1 2 1\n1 2\n2 3\n", "3\n1 2 3\n1 2\n1 3\n", "5\n5 4 1 2 3\n1 2\n1 3\n1 4\n3 5\n", "3\n1 2 2\n1 4\n1 3\n", "3\n0 1 1\n1 0\n1 3\n", "5\n1 1 1 3 3\n1 2\n1 3\n2 1\n2 5\n", "5\n2 12 -2 4 3\n1 2\n1 3\n2 8\n4 5\n", "5\n2 1 1 2 5\n1 2\n1 3\n2 4\n2 5\n", "3\n1 0 3\...
[ "1 2\n", "2\n", "2 3\n", "1 5\n", "1\n", "3\n", "5\n", "1 2 4\n", "1 4 5\n", "1 3\n" ]
CodeContests
Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west. Some of the squares have a lotus leaf on it and cannot be entered. The square (i,j) has a lotus leaf on i...
stdin
null
3,390
1
[ "3 5 2\n3 2 3 4\n.....\n.@..@\n..@..\n", "3 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n", "1 6 4\n1 1 1 6\n......\n" ]
[ "5\n", "-1\n", "2\n" ]
[ "2 3 1\n2 1 2 3\n.@.\n.@.\n.@.\n", "3 5 2\n3 2 3 4\n.....\n.@-.@\n..@..\n", "1 6 4\n1 1 1 1\n......\n", "3 5 4\n3 2 3 4\n.....\n.@..@\n..@..\n", "1 6 4\n1 2 1 6\n......\n", "3 5 4\n3 2 1 4\n.....\n.@..@\n..@..\n", "3 3 1\n2 1 2 3\n.@.\n.@/\n.@.\n", "3 3 0\n2 1 2 3\n.@.\n.@.\n.@.\n", "3 3 2\n2 1 2 3\...
[ "-1\n", "5\n", "0\n", "4\n", "1\n", "3\n", "-1\n", "-1\n", "-1\n", "-1\n" ]
CodeContests
Decades have passed since the beginning of AtCoder Beginner Contest. The contests are labeled as `ABC001`, `ABC002`, ... from the first round, but after the 999-th round `ABC999`, a problem occurred: how the future rounds should be labeled? In the end, the labels for the rounds from the 1000-th to the 1998-th are dec...
stdin
null
4,306
1
[ "1000\n", "1481\n", "999\n" ]
[ "ABD\n", "ABD\n", "ABC\n" ]
[ "1001\n", "300\n", "1506\n", "1101\n", "972\n", "260\n", "1111\n", "842\n", "352\n", "0111\n" ]
[ "ABD\n", "ABC\n", "ABD\n", "ABD\n", "ABC\n", "ABC\n", "ABD\n", "ABC\n", "ABC\n", "ABC\n" ]
CodeContests
A tree is one of the most popular data structures in computer science. Tree itself is very elegant, but it is incompatible with current computer architecture. In the current architecture, memory can be regarded as a one-dimensional array. Since a tree is not a one-dimensional structure, cache efficiency may come into q...
stdin
null
4,874
1
[ "3 1\n1\n2\n3 2\n1\n1\n10 4\n1\n1\n2\n3\n3\n4\n4\n4\n5\n0 0\n" ]
[ "Case 1:\n3\n2\n3\nCase 2:\n2\n2\n2\nCase 3:\n2\n2\n2\n2\n2\n2\n2\n2\n2\n3\n" ]
[ "3 1\n1\n2\n3 1\n1\n1\n10 4\n1\n1\n2\n3\n3\n4\n4\n4\n5\n0 0\n", "3 1\n1\n2\n3 1\n1\n1\n10 4\n1\n1\n2\n1\n3\n4\n4\n4\n5\n0 0\n", "3 1\n1\n2\n3 2\n1\n1\n10 4\n1\n2\n2\n3\n3\n4\n4\n4\n5\n0 0\n", "3 1\n1\n1\n3 1\n1\n1\n10 4\n1\n1\n2\n1\n3\n1\n2\n4\n5\n0 0\n", "3 1\n1\n2\n3 1\n1\n2\n10 4\n1\n1\n2\n1\n3\n4\n2\n4\...
[ "Case 1:\n3\n2\n3\nCase 2:\n2\n3\n3\nCase 3:\n2\n2\n2\n2\n2\n2\n2\n2\n2\n3\n", "Case 1:\n3\n2\n3\nCase 2:\n2\n3\n3\nCase 3:\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n", "Case 1:\n3\n2\n3\nCase 2:\n2\n2\n2\nCase 3:\n2\n2\n2\n2\n2\n2\n2\n2\n2\n2\n", "Case 1:\n2\n3\n3\nCase 2:\n2\n3\n3\nCase 3:\n2\n2\n2\n2\n2\n2\n2\n2\n2\n...
CodeContests
Today is the open campus of Z University. Every year during the lunch break on this day, many high school students line up for the school cafeteria. Therefore, the secretariat of Z University decided to predict the maximum distance of the procession. As a result of the preliminary survey, we know the following. * The ...
stdin
null
699
1
[ "3 2\n1\n" ]
[ "3\n" ]
[ "4 2\n1\n", "1 1\n0\n", "4 3\n1\n", "6 2\n1\n", "4 4\n1\n", "5 2\n1\n", "4 4\n2\n", "5 2\n2\n", "4 3\n2\n", "5 0\n2\n" ]
[ "inf\n", "0\n", "inf\n", "inf\n", "inf\n", "inf\n", "inf\n", "inf\n", "inf\n", "inf\n" ]
CodeContests
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy. Constraints * 1 \leq K \leq N \leq 50 * 1 \leq l_i \leq 50 ...
stdin
null
4,784
1
[ "15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n", "5 3\n1 2 3 4 5\n" ]
[ "386\n", "12\n" ]
[ "15 14\n49 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n", "5 5\n1 2 3 4 5\n", "15 14\n49 26 27 21 33 7 42 35 7 5 5 36 39 1 45\n", "5 5\n2 2 3 4 5\n", "15 14\n49 26 27 26 33 7 42 35 7 5 5 36 39 1 45\n", "5 3\n2 2 3 4 5\n", "15 14\n50 26 27 21 41 7 42 35 7 5 5 36 33 1 45\n", "15 14\n49 26 27 21 41 12 42 35 7 ...
[ "385\n", "15\n", "377\n", "16\n", "382\n", "12\n", "380\n", "390\n", "14\n", "372\n" ]
CodeContests
You are given an array a_0, a_1, ..., a_{N-1} of length N. Process Q queries of the following types. * `0 l r b c`: For each i = l, l+1, \dots, {r - 1}, set a_i \gets b \times a_i + c. * `1 l r`: Print \sum_{i = l}^{r - 1} a_i \bmod 998244353. Constraints * 1 \leq N, Q \leq 500000 * 0 \leq a_i, c < 998244353 * 1 \le...
stdin
null
1,481
1
[ "5 7\n1 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 1 3 102 103\n1 2 5\n0 2 5 104 105\n1 0 5\n" ]
[ "15\n404\n41511\n4317767\n" ]
[ "5 7\n1 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 1 5 102 103\n1 2 5\n0 2 5 104 105\n1 0 5\n", "5 7\n1 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 2 5 102 103\n1 2 5\n0 2 5 104 105\n1 0 5\n", "5 7\n2 2 3 4 5\n1 0 5\n0 2 4 100 101\n1 0 3\n0 1 5 102 103\n1 2 5\n0 2 5 104 105\n1 0 5\n", "5 7\n2 2 3 4 5\n1 0 5\n0 2 4 1...
[ "15\n404\n92823\n9654215\n", "15\n404\n92823\n9653910\n", "16\n405\n92823\n9654216\n", "16\n405\n92823\n3806367\n", "15\n404\n92823\n3806366\n", "404\n92823\n3806366\n3806366\n", "13\n402\n92823\n9654011\n", "15\n404\n92823\n9654429\n", "16\n405\n51818\n9654216\n", "17\n604\n113223\n4642766\n" ]
CodeContests
Monk visits a magical place, Makizam. He is greeted by his old friend, Wiz. Wiz happy to see his old friend, gives him a puzzle. He takes him to a room with N keys placed on the floor, the i'th key is of type Xi. The keys are followed by M chests of treasures, the i'th chest is of type Ci. These chests give out gems ...
stdin
null
3,666
1
[ "2\n2 4 1 \n2 3\n5 3 10 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n1 2 5 7\n\nSAMPLE\n" ]
[ "12\n14\n" ]
[ "2\n2 4 1 \n2 3\n5 3 10 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n0 2 5 7\n\nSAMPLE\n", "2\n2 4 1 \n2 3\n5 3 7 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n0 2 5 7\n\nSAMPLE\n", "2\n2 4 1 \n2 3\n5 3 7 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n0 2 2 7\n\nSAMPLE\n", "2\n2 4 1 \n2 3\n5 3 12 2\n1 2 5 2\n3 4 2\n2 3 5\n5 4 10 2\n1 2 5 ...
[ "12\n14\n", "7\n14\n", "7\n11\n", "7\n15\n", "6\n15\n", "7\n10\n", "9\n14\n", "11\n14\n", "14\n14\n", "7\n8\n" ]
CodeContests
Little PandeyG is a curious student, studying in HEgwarts. Being smarter, faster and displaying more zeal for magic than any other student, one by one he managed to impress the three hidden witches of the school. They knew his secret desire to be a warrior, so each of them gave him some super power to use if he's up fo...
stdin
null
3,590
1
[ "5\n1\n2\n3\n4\n5\n\nSAMPLE\n" ]
[ "0\n1\n1\n2\n3\n" ]
[ "10\n41854\n9255\n78975\n63699\n48656\n74074\n29203\n53056\n57317\n41556\n", "100\n802514173\n426795959\n940031406\n178331926\n758516183\n324609619\n697289003\n473088422\n842493325\n678996275\n511809062\n485788833\n821690097\n72858722\n487771337\n461262447\n959779207\n243975131\n850089979\n474130333\n986206719\n2...
[ "16\n12\n12\n16\n15\n17\n14\n14\n17\n12\n", "34\n33\n28\n29\n33\n29\n29\n32\n30\n34\n31\n26\n30\n27\n28\n28\n31\n31\n29\n29\n32\n29\n30\n32\n31\n31\n25\n30\n31\n29\n32\n31\n29\n30\n34\n26\n26\n30\n31\n28\n26\n31\n32\n28\n28\n28\n29\n29\n26\n29\n27\n35\n29\n29\n30\n31\n29\n30\n30\n32\n31\n33\n25\n29\n28\n29\n31\n2...
CodeContests
problem Taro bought 10 books. Later, I tried to find out the price based on the receipt, but the receipt was dirty and I could not read the price of a book. We decided to calculate the price of the book from the total price of 10 books and the prices of the other 9 books. Write a program that outputs the price of the...
stdin
null
3,564
1
[ "9850\n1050\n800\n420\n380\n600\n820\n2400\n1800\n980\n0\n" ]
[ "600\n" ]
[ "9850\n1050\n800\n420\n380\n600\n820\n2400\n2983\n980\n0\n", "9850\n372\n800\n420\n380\n600\n820\n2400\n2983\n980\n0\n", "9850\n372\n800\n420\n380\n600\n820\n2795\n2983\n980\n0\n", "9850\n372\n800\n420\n380\n600\n946\n2795\n2983\n980\n0\n", "9850\n372\n800\n203\n380\n600\n946\n2795\n2983\n980\n0\n", "9850...
[ "-583\n", "95\n", "-300\n", "-426\n", "-209\n", "427\n", "-177\n", "307\n", "-927\n", "-622\n" ]
CodeContests
Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well. Today's training is to perform a very large number of calculations to improve the calculation power and raise awareness. Exponentiation is an operation that easily produces large numbers....
stdin
null
862
1
[ "3\n0\n0\n1000000000\n", "4\n7\n5\n10\n6\n" ]
[ "1000000000\n0\n0\n", "5\n6\n7\n10\n" ]
[ "3\n0\n0\n1000000010\n", "4\n11\n5\n10\n6\n", "4\n6\n5\n10\n6\n", "4\n6\n5\n20\n6\n", "4\n2\n5\n20\n6\n", "4\n2\n5\n10\n6\n", "4\n2\n5\n10\n5\n", "4\n0\n5\n10\n5\n", "4\n0\n7\n10\n5\n", "4\n0\n7\n10\n1\n" ]
[ "1000000010\n0\n0\n", "5\n6\n10\n11\n", "5\n6\n6\n10\n", "5\n6\n6\n20\n", "2\n5\n6\n20\n", "2\n5\n6\n10\n", "2\n5\n5\n10\n", "5\n10\n5\n0\n", "7\n10\n5\n0\n", "7\n10\n1\n0\n" ]
CodeContests
Dutch treat You have organized a party to pray for the good performance of the ICPC 2019 Yokohama Regional Domestic Qualifiers. There are N participants in this party. Since it costs M yen in total to hold this party, we decided to collect M / N yen from each of the N participants. Since M is divisible by N, there is...
stdin
null
4,364
1
[ "3 300\n120 100 80\n3 30\n10 20 5\n4 1000\n100 200 300 400\n5 5\n2523 8430 3 4199 632\n0 0\n" ]
[ "280\n25\n800\n5\n" ]
[ "3 300\n120 100 80\n3 5\n10 20 5\n4 1000\n100 200 300 400\n5 5\n2523 8430 3 4199 632\n0 0\n", "3 300\n120 100 80\n3 5\n10 20 5\n4 1000\n100 260 300 400\n5 5\n2523 8430 3 4199 632\n0 0\n", "3 300\n120 100 80\n2 5\n10 34 5\n4 1000\n100 200 300 400\n5 5\n2523 8430 3 4199 632\n0 0\n", "3 300\n120 101 80\n3 5\n10 ...
[ "280\n3\n800\n5\n", "280\n3\n850\n5\n", "280\n4\n0\n5\n", "280\n3\n709\n5\n", "264\n3\n709\n5\n", "276\n3\n709\n5\n", "276\n3\n709\n4\n", "190\n4\n0\n5\n", "280\n25\n800\n5\n", "280\n3\n800\n0\n" ]
CodeContests
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, an...
stdin
null
2,563
1
[ "2\n2 2\n3 3\n0 0\n1 1\n", "5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n3 7\n", "5\n0 0\n1 1\n5 5\n6 6\n7 7\n2 2\n3 3\n4 4\n8 8\n9 9\n", "3\n0 0\n1 1\n5 2\n2 3\n3 4\n4 5\n", "3\n2 0\n3 1\n1 3\n4 2\n0 4\n5 5\n" ]
[ "0\n", "5\n", "4\n", "2\n", "2\n" ]
[ "2\n2 2\n3 5\n0 0\n1 1\n", "5\n0 0\n7 3\n2 2\n4 8\n1 6\n8 5\n6 9\n5 4\n9 1\n2 7\n", "5\n0 0\n1 1\n5 5\n6 6\n7 11\n2 2\n3 3\n4 4\n8 8\n9 9\n", "3\n0 0\n1 1\n10 2\n2 3\n3 4\n4 5\n", "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n3 3\n2 4\n8 8\n9 16\n", "2\n0 0\n6 -1\n0 0\n1 1\n", "2\n2 2\n3 0\n0 0\n1 1\n", "5\n-1 ...
[ "0\n", "5\n", "4\n", "2\n", "3\n", "1\n", "0\n", "5\n", "4\n", "2\n" ]
CodeContests
Taro is planning a long trip by train during the summer vacation. However, in order for Taro, who is a high school student, to travel as far as possible during the summer vacation, which has only one month, he cannot make a good plan unless he finds the cheapest and the fastest way. Let's create a program to help Taro'...
stdin
null
775
1
[ "6 5\n1 2 200 10\n1 4 400 15\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 5 300 20\n2\n1 5 0\n1 5 1\n0 0\n" ]
[ "450\n35\n" ]
[ "6 5\n1 2 200 10\n1 4 400 15\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 5 300 30\n2\n1 5 0\n1 5 1\n0 0\n", "6 5\n1 2 200 10\n1 4 400 22\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 3 300 30\n2\n1 5 0\n1 5 1\n0 0\n", "6 5\n1 2 200 10\n1 4 158 22\n1 3 250 25\n2 4 100 10\n4 5 150 20\n3 3 300 30\n2\n1 5 0\n1 5 1\n0 0\n", "...
[ "450\n35\n", "450\n40\n", "308\n40\n", "159\n40\n", "221\n40\n", "250\n40\n", "308\n10\n", "250\n30\n", "350\n10\n", "450\n30\n" ]
CodeContests
There is a magical shop owned by The Monk, which consists of magical potions. On the first day there are A number of potions. Let, potions[I] denote the number of potions present in the shop on the I^th day. potions[I] = potions[I-1] * potions[I-1] You, Monk's favorite student love to play around with various type...
stdin
null
4,456
1
[ "5 100\n101\n\nSAMPLE\n" ]
[ "30\n" ]
[ "5 100\n101\n\nASMPLE\n", "5 100\n001\n\nASMPLE\n", "5 110\n001\n\nASMPLE\n", "8 110\n001\n\nASMLPE\n", "8 100\n001\n\nASMLPE\n", "11 100\n001\n\nASMLQE\n", "11 110\n001\n\nMSALQE\n", "11 110\n101\n\nMSALQE\n", "0 110\n100\n\nEQL@SM\n", "1 111\n010\n\nDQL@TL\n" ]
[ "30\n", "25\n", "75\n", "26\n", "96\n", "41\n", "11\n", "22\n", "0\n", "1\n" ]
CodeContests
YOKARI TAMURA is a nationally famous artist. This month YOKARI will be touring live for D days. Divide this country into C different regions when deciding on a tour schedule. YOKARI benefits from performing live in an area, which is represented by a positive integer. As a general rule, YOKARI will perform up to one liv...
stdin
null
1,375
1
[ "5 5 10 2\n1 1 0 1 1\n0 9 1 0 1\n1 1 1 9 1\n1 1 9 0 1\n1 1 1 1 0\n1 1 0 1 1\n0 9 1 0 1\n1 1 1 9 1\n1 1 1 0 1\n1 1 1 1 0\n1 1 10 0\n3\n7\n1 1 5 0\n3\n6\n1 2 10 1\n6 7\n5 6\n2 1 10 1\n4\n8\n3\n7\n2 1 10 0\n4\n8\n3\n7\n2 1 5 0\n4\n8\n3\n6\n0 0 0 0\n" ]
[ "18\n3\n0\n7\n12\n8\n4\n" ]
[ "5 5 10 2\n1 1 0 1 0\n0 9 1 0 1\n1 1 1 9 1\n1 1 9 0 1\n1 1 1 1 0\n1 1 0 1 1\n0 9 1 0 1\n1 1 1 9 1\n1 1 1 0 1\n1 1 1 1 0\n1 1 10 0\n3\n7\n1 1 5 0\n3\n6\n1 2 10 1\n6 7\n5 6\n2 1 10 1\n4\n8\n3\n7\n2 1 10 0\n4\n8\n3\n7\n2 1 5 0\n4\n8\n3\n6\n0 0 0 0\n", "5 5 8 2\n1 1 0 1 0\n0 9 1 0 1\n1 1 1 9 1\n1 1 9 0 1\n1 1 1 1 0\n...
[ "18\n3\n0\n7\n12\n8\n4\n", "16\n3\n0\n7\n12\n8\n4\n", "16\n3\n0\n7\n8\n8\n4\n", "17\n3\n0\n7\n12\n8\n4\n", "18\n3\n0\n7\n12\n8\n7\n", "16\n3\n0\n7\n12\n8\n8\n", "19\n3\n0\n7\n12\n8\n4\n", "10\n3\n0\n7\n12\n8\n4\n", "15\n3\n0\n7\n12\n8\n4\n", "17\n3\n0\n7\n8\n8\n4\n" ]
CodeContests
In the previous problem Chandu bought some unsorted arrays and sorted them (in non-increasing order). Now, he has many sorted arrays to give to his girlfriend. But, the number of sorted arrays are very large so Chandu decided to merge two sorted arrays into one sorted array. But he is too lazy to do that. So, he asked ...
stdin
null
5
1
[ "1\n4 5\n9 7 5 3\n8 6 4 2 0\n\nSAMPLE\n" ]
[ "9 8 7 6 5 4 3 2 0\n" ]
[ "1\n4 5\n9 7 5 3\n8 6 4 1 0\n\nSAMPLE\n", "1\n4 5\n9 7 5 3\n16 6 4 2 0\n\nSAMPLE\n", "1\n4 5\n9 7 5 3\n8 4 4 1 0\n\nSAMPLE\n", "1\n4 5\n9 7 5 1\n8 4 4 1 0\n\nSAMPLE\n", "1\n4 5\n9 7 5 3\n8 6 4 2 1\n\nSAMPLE\n", "1\n4 5\n9 7 5 1\n10 4 4 1 0\n\nSAMPLE\n", "1\n4 5\n9 7 5 1\n8 6 4 2 1\n\nSAMPLE\n", "1\n4 ...
[ "9 8 7 6 5 4 3 1 0\n", "16 9 7 6 5 4 3 2 0\n", "9 8 7 5 4 4 3 1 0\n", "9 8 7 5 4 4 1 1 0\n", "9 8 7 6 5 4 3 2 1\n", "10 9 7 5 4 4 1 1 0\n", "9 8 7 6 5 4 2 1 1\n", "16 10 7 5 4 4 1 1 0\n", "16 10 7 4 4 2 1 1 0\n", "9 8 7 6 5 4 3 2 0\n" ]
CodeContests
It is the final leg of the most famous amazing race. The top 'n' competitors have made it to the final. The final race has just begun. The race has 'm' checkpoints. Each team can reach any of the 'm' checkpoint but after a team reaches a particular checkpoint that checkpoint gets closed and is not open to any other tea...
stdin
null
1,271
1
[ "2 3 1\n0 1\n0 0\n0 10\n27 29\n458 9651\n5 3\n\nSAMPLE\n" ]
[ "4\n" ]
[ "2 3 1\n0 1\n0 0\n0 10\n27 29\n458 9651\n5 3\n\nS@MPLE\n", "2 3 0\n0 1\n0 0\n0 10\n41 29\n458 4196\n5 2\n\nS@MPLE\n", "2 3 1\n0 0\n0 2\n2 10\n41 26\n458 7943\n5 4\n\nS@NPLE\n", "2 3 2\n0 1\n0 2\n2 10\n41 26\n381 7943\n5 4\n\nS@NPLE\n", "2 2 1\n0 1\n0 2\n2 10\n41 29\n458 6028\n5 4\n\nS@NPLE\n", "2 3 1\n0 1...
[ "4\n", "0\n", "5\n", "93\n", "1\n", "6\n", "2\n", "37\n", "12\n", "3\n" ]
CodeContests
Mr. A wants to get to the destination on the Yamanote line. After getting on the train, Mr. A gets up for a minute and sleeps for b minutes repeatedly. It is c minutes after boarding to the destination, and you can get off if you are awake at this time, but on the contrary, if you are sleeping, you will miss it. Also,...
stdin
null
4,479
1
[ "20 20 20\n", "50 40 51\n", "10 10 5\n", "30 30 40\n" ]
[ "20\n", "111\n", "5\n", "-1\n" ]
[ "20 25 20\n", "89 40 51\n", "10 14 5\n", "36 18 15\n", "3 18 15\n", "16 5 4\n", "0 18 15\n", "128 12 16\n", "0 18 12\n", "2 5 4\n" ]
[ "20\n", "51\n", "5\n", "15\n", "255\n", "4\n", "-1\n", "16\n", "72\n", "64\n" ]
CodeContests
A connected directed graph without a cycle is given. (A directed graph is concatenated when it is an undirected graph.) I would like to select one vertex for this graph and determine the capital s. Let T (v) = "the minimum number of" edge inversion "operations required to make all points reachable from v". However, ...
stdin
null
3,251
1
[ "3 2\n0 1\n2 1\n" ]
[ "2 1\n0 2\n" ]
[ "3 4\n0 1\n2 1\n", "3 10\n1 0\n2 0\n", "3 3\n0 1\n2 1\n", "3 6\n0 1\n2 1\n", "3 5\n0 1\n2 1\n", "3 10\n0 1\n2 1\n", "3 12\n0 1\n2 1\n", "3 20\n0 1\n2 1\n", "3 9\n0 1\n2 1\n", "3 8\n0 1\n2 1\n" ]
[ "2 1\n0 2\n", "2 1\n1 2\n", "2 1\n0 2\n", "2 1\n0 2\n", "2 1\n0 2\n", "2 1\n0 2\n", "2 1\n0 2\n", "2 1\n0 2\n", "2 1\n0 2\n", "2 1\n0 2\n" ]
CodeContests
On Unix computers, data is stored in directories. There is one root directory, and this might have several directories contained inside of it, each with different names. These directories might have even more directories contained inside of them, and so on. A directory is uniquely identified by its name and its parent...
stdin
null
3,904
1
[ "2\n0 2\n/home/gcj/finals\n/home/gcj/quals\n2 1\n/chicken\n/chicken/egg\n/chicken\n\nSAMPLE\n" ]
[ "Case #1: 4\nCase #2: 0\n" ]
[ "2\n0 2\n/home/gcj/finals\n/hole/gcj/quals\n2 1\n/chicken\n/chicken/egg\n/chicken\n\nSAMPLE\n", "2\n0 2\n/home/gcj/sinalf\n/home/gcj/quals\n2 1\n/chicken\n/chicken/egg\n/chicken\n\nSAMPLE\n", "2\n0 2\n/home/gcj/finals\n/hole/gcj/quals\n1 1\n/chicken\n/cgicken/egg\n/chicken\n\nSAMPLE\n", "2\n0 2\n/home/gcj/fsn...
[ "Case #1: 6\nCase #2: 0\n", "Case #1: 4\nCase #2: 0\n", "Case #1: 6\nCase #2: 2\n", "Case #1: 5\nCase #2: 0\n", "Case #1: 6\nCase #2: 1\n", "Case #1: 4\nCase #2: 1\n", "Case #1: 4\nCase #2: 2\n", "Case #1: 5\nCase #2: 1\n", "Case #1: 5\nCase #2: 2\n", "Case #1: 6\nCase #2: 3\n" ]
CodeContests
There are various parking lots such as three-dimensional type and tower type in the city to improve the utilization efficiency of the parking lot. In some parking lots, a "two-stage parking device" as shown in the figure is installed in one parking space to secure a parking space for two cars. This two-stage parking de...
stdin
null
4,312
1
[ "3 5\n90\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0\n" ]
[ "2 5 1 4 3\n1 2 4 3\n" ]
[ "3 5\n123\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0\n", "3 5\n123\n52\n82\n84\n124\n2 4\n18\n30\n40\n60\n0 0\n", "1 5\n90\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0\n", "1 5\n90\n52\n82\n84\n70\n2 4\n10\n43\n22\n60\n0 0\n", "3 5\n123\n52\n82\n87\n92\n4 4\n18\n32\n40\n60\n0 0\n", "3 5\n123\n52\n33\n87\n92\n...
[ "2 5 3 4 1\n1 2 4 3\n", "2 4 1 5 3\n1 2 4 3\n", "2 3 1 5 4\n1 2 4 3\n", "2 3 1 5 4\n1 3 4 2\n", "2 4 1 5 3\n1 2 3 4\n", "3 4 1 5 2\n1 2 3 4\n", "2 4 1 5 3\n1 3 2 4\n", "1 2 4 3 5\n1 3 2 4\n", "1 2 3 4 5\n1 3 2 4\n", "2 5 1 4 3\n1 2 4 3\n" ]
CodeContests
Have you ever had an infinite loop when you ran a hard-working program? It would be convenient to be able to determine in advance whether a program will stop executing without having to execute it. Unfortunately, it is not possible to make such a decision for any program in the programming language you normally use. H...
stdin
null
5,020
1
[ "3\n111 SET c 1\n12 SUB c c 2\n777 SET a 4\n", "3\n10 SET c 1\n120 IF c 10\n20 HALT\n", "6\n10 SET c 1\n20 SET i 5\n100 ADD s s i\n110 SUB i i c\n120 IF i 100\n200 HALT\n" ]
[ "a=0\nc=1\n", "inf\n", "c=1\ni=0\ns=15\n" ]
[ "3\n111 SET c 1\n12 SUB c c 4\n777 SET a 4\n", "3\n10 SET c 1\n193 IF c 10\n20 HALT\n", "6\n10 SET c 1\n20 SET h 5\n100 ADD s s i\n110 SUB i i c\n120 IF i 100\n200 HALT\n", "3\n10 SET c 1\n193 IF c 11\n20 HALT\n", "3\n10 SET c 0\n193 IF c 11\n20 HALT\n", "3\n111 SET c 1\n12 SUB c c 2\n777 SET b 4\n", "6...
[ "a=0\nc=1\n", "inf\n", "c=1\nh=5\ni=0\ns=0\n", "c=1\n", "c=0\n", "b=0\nc=1\n", "b=1\nc=0\ni=5\ns=15\n", "a=0\nc=0\n", "c=3\n", "b=3\nc=0\n" ]
CodeContests
Jack is a great mathematician. He loves to solve series. Now Stuart gave a series to Jack and said you have to solve the problem by making a computer program. But Jack doesn't know, how to code. The series is: 1 + (a1).(x)^1 + (a2).(x)^2 + (a3).(x)^3 +........+(an).(x)^n And the problem is find the sum of the a1 + ...
stdin
null
1,122
1
[ "1\n1\n\nSAMPLE\n" ]
[ "1\n" ]
[ "7\n11\n12\n13\n16\n15\n16\n17\n", "1\n2\n\nSAMPLE\n", "7\n11\n6\n13\n16\n15\n16\n17\n", "1\n0\n\nSAMPLE\n", "7\n11\n6\n13\n16\n6\n16\n17\n", "7\n13\n6\n13\n16\n6\n16\n17\n", "1\n1\n\nSAMPME\n", "7\n13\n6\n13\n16\n6\n16\n29\n", "7\n20\n6\n13\n16\n6\n16\n29\n", "7\n20\n6\n13\n16\n11\n16\n29\n" ]
[ "2047\n4095\n8191\n65535\n32767\n65535\n131071\n", "3\n", "2047\n63\n8191\n65535\n32767\n65535\n131071\n", "0\n", "2047\n63\n8191\n65535\n63\n65535\n131071\n", "8191\n63\n8191\n65535\n63\n65535\n131071\n", "1\n", "8191\n63\n8191\n65535\n63\n65535\n536870911\n", "1048575\n63\n8191\n65535\n63\n65535\n...
CodeContests
There are n cities and n − 1 roads, which are trees. Cities are numbered from 1 to n. When city 1 is taken as the root, the parent of city i is pi, and the distance between i and pi is di. Sunuke wants to solve the following problem for each k of 1 or more and n or less. Minimum value of the sum of the distances from ...
stdin
null
3,852
1
[ "10\n4 1\n1 1\n3 1\n3 1\n5 1\n6 1\n6 1\n8 1\n4 1\n", "15\n1 3\n12 5\n5 2\n12 1\n7 5\n5 1\n6 1\n12 1\n11 1\n12 4\n1 1\n5 5\n10 4\n1 2\n" ]
[ "0\n3\n3\n4\n5\n7\n10\n13\n16\n19\n", "0\n3\n9\n13\n14\n21\n22\n29\n31\n37\n41\n41\n47\n56\n59\n" ]
[ "10\n4 1\n1 1\n3 1\n3 1\n5 1\n6 1\n6 1\n8 1\n1 1\n", "15\n1 3\n12 5\n5 2\n12 1\n14 5\n5 1\n6 1\n12 1\n11 1\n12 4\n1 1\n5 5\n10 4\n1 2\n", "15\n1 3\n12 5\n5 2\n12 1\n14 5\n6 1\n6 1\n12 1\n11 1\n12 4\n1 1\n5 5\n10 4\n1 2\n", "15\n1 3\n12 5\n5 2\n12 1\n14 5\n6 1\n6 1\n12 1\n11 1\n5 4\n1 1\n5 5\n3 4\n1 2\n", "1...
[ "0\n3\n3\n4\n5\n7\n10\n13\n16\n19\n", "0\n3\n9\n13\n14\n28\n30\n45\n46\n51\n55\n55\n61\n70\n73\n", "0\n3\n9\n13\n14\n28\n43\n58\n59\n64\n68\n68\n74\n83\n86\n", "0\n3\n9\n13\n14\n28\n43\n58\n59\n65\n70\n70\n76\n85\n88\n", "0\n3\n9\n13\n14\n28\n43\n45\n46\n52\n57\n57\n63\n72\n75\n", "0\n3\n9\n13\n14\n26\n39...
CodeContests
In Square Town, where many people who love squares live, a festival is held to color the town with illuminations that combine square lightning boards. This electric board emits light when electricity is applied, and the plate in contact with the light emitting plate also emits light. Therefore, no matter how many elect...
stdin
null
4,117
1
[ "3\n1\n0 0 0 1 1 1 1 0\n2\n0 0 0 1 1 1 1 0\n100 100 100 200 200 200 200 100\n2\n0 0 0 100 100 100 100 0\n10 10 10 20 20 20 20 10\n2\n1\n30 40 40 50 40 20 20 10\n1\n30 40 40 50 40 20 20 10\n0\n" ]
[ "1\n2\n1\n1\n1\n" ]
[ "3\n1\n0 0 0 1 1 1 1 0\n2\n0 0 0 1 1 1 1 0\n100 100 100 200 200 200 200 100\n2\n0 0 0 100 100 100 100 0\n10 10 10 11 20 20 20 10\n2\n1\n30 40 40 50 40 20 20 10\n1\n30 40 40 50 40 20 20 10\n0\n", "3\n1\n0 0 0 1 1 1 1 -1\n0\n0 0 0 1 1 1 1 0\n100 100 100 200 200 111 200 000\n2\n0 0 0 100 100 100 100 0\n10 10 10 11 2...
[ "1\n2\n1\n1\n1\n", "1\n0\n0\n", "0\n0\n0\n", "1\n2\n2\n1\n1\n", "1\n2\n1\n1\n1\n", "1\n2\n1\n1\n1\n", "1\n2\n1\n1\n1\n", "1\n2\n1\n1\n1\n", "1\n2\n1\n1\n1\n", "1\n2\n1\n1\n1\n" ]
CodeContests
Today Omar has assignment problems from his math professor. Yes, Omar has infinite number of questions that he must solve today. The first problem went something like this. Given N integers in the form of A_i where 1 ≤ i ≤ N, Omar wants to make each number A_i in the N numbers equal to M. To convert a number A_i to ...
stdin
null
3,308
1
[ "1\n4\n1 2 4 5\n\nSAMPLE\n" ]
[ "6\n" ]
[ "1\n4\n0 2 4 5\n\nSAMPLE\n", "1\n4\n0 2 4 3\n\nSAMPME\n", "1\n4\n0 2 4 0\n\nSAMPME\n", "1\n4\n0 2 8 0\n\nSAMPME\n", "1\n4\n0 1 8 0\n\nSAMPME\n", "1\n4\n1 2 4 3\n\nSAMPME\n", "1\n4\n1 2 4 13\n\nSAMPLE\n", "1\n4\n0 2 12 5\n\nSAMPME\n", "1\n4\n2 2 4 3\n\nSAMPME\n", "1\n4\n0 2 12 7\n\nSAMPME\n" ]
[ "7\n", "5\n", "6\n", "10\n", "9\n", "4\n", "14\n", "15\n", "3\n", "17\n" ]
CodeContests
Space Coconut Crab Space coconut crab English text is not available in this practice contest. Ken Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space coconut crab is the largest crustacean in the universe, and it is said that the body length after growth is...
stdin
null
983
1
[ "1\n2\n4\n27\n300\n1250\n0\n" ]
[ "1\n2\n2\n3\n18\n44\n" ]
[ "1\n2\n4\n6\n300\n1250\n0\n", "1\n2\n4\n2\n300\n1250\n0\n", "1\n2\n4\n3\n300\n1250\n0\n", "1\n2\n4\n3\n76\n1250\n0\n", "1\n2\n4\n27\n557\n1250\n0\n", "1\n2\n4\n6\n300\n1687\n0\n", "1\n1\n4\n2\n300\n1250\n0\n", "1\n2\n5\n3\n300\n1250\n0\n", "1\n2\n3\n3\n76\n1250\n0\n", "1\n2\n4\n27\n266\n1250\n0\n"...
[ "1\n2\n2\n4\n18\n44\n", "1\n2\n2\n2\n18\n44\n", "1\n2\n2\n3\n18\n44\n", "1\n2\n2\n3\n10\n44\n", "1\n2\n2\n3\n23\n44\n", "1\n2\n2\n4\n18\n47\n", "1\n1\n2\n2\n18\n44\n", "1\n2\n3\n3\n18\n44\n", "1\n2\n3\n3\n10\n44\n", "1\n2\n2\n3\n14\n44\n" ]
CodeContests
Of the real numbers, those with a circular decimal part and those with a finite number of digits can be expressed as fractions. Given a real number that can be represented by a fraction, write a program that outputs an irreducible fraction equal to that real number (a fraction that cannot be reduced any further). ...
stdin
null
4,041
1
[ "1.0\n", "0.0739\n", "5.2(143)\n", "0.(3)\n" ]
[ "1/1\n", "739/10000\n", "52091/9990\n", "1/3\n" ]
[ "3.2(145)\n", "3.3(145)\n", "5.21(43)\n", "3.3(155)\n", "4.21(43)\n", "4.21(42)\n", "0.(2)\n", "33.(145)\n", "4.21(32)\n", "33.(135)\n" ]
[ "32113/9990\n", "16556/4995\n", "25811/4950\n", "16561/4995\n", "20861/4950\n", "13907/3300\n", "2/9\n", "33112/999\n", "41711/9900\n", "1226/37\n" ]
CodeContests
problem The point $ P $ is placed at the origin on the coordinate plane. I want to move the point $ P $ to a position where the Manhattan distance from the origin is as far as possible. First, the string $ S = s_1s_2 \ cdots s_ {| S |} $ ($ | S | $ is the number of characters in $ S $) is given. The point $ P $ is mo...
stdin
null
3,614
1
[ "RRLUDDD\n2\n" ]
[ "7\n" ]
[ "RRLUDDD\n1\n", "RRLUDDD\n0\n", "RSLUDDD\n4\n", "DDDULRR\n1\n", "RRULDDD\n0\n", "RSLUDDD\n5\n", "DDDULRR\n2\n", "RSLDDDU\n4\n", "DDUDLRR\n2\n", "DSLRDDU\n4\n" ]
[ "5\n", "3\n", "7\n", "5\n", "3\n", "7\n", "7\n", "7\n", "5\n", "7\n" ]
CodeContests
Kancha wants to participate in a new event of Technobyte. Event says that you have to write a number in seven segment display using matchsticks. Please refer to the diagram below for how many sticks are used for each digit !! Now, event coordinator gave kancha a long string. your task is to tell how many matchsticks w...
stdin
null
2,513
1
[]
[]
[ "10\n4523521178603692869044796170148349853679689223589819975621633677282235231443204731632537466129523854\n1302325049960398304982582357280685122562102438321157305518841538649586388982800700181595650321563194\n2512957332786830522308611150628493992503097661520589933615148557772011488860362819786574588314206955\n25840...
[ "489\n512\n500\n485\n494\n483\n476\n485\n498\n485\n", "489\n512\n500\n485\n494\n483\n476\n485\n498\n489\n", "489\n512\n500\n485\n487\n483\n476\n485\n498\n489\n", "472\n512\n500\n485\n487\n483\n476\n485\n498\n489\n", "472\n512\n485\n485\n487\n483\n476\n485\n498\n489\n", "472\n512\n480\n485\n487\n483\n476\n...
CodeContests
There are N robots numbered 1 to N placed on a number line. Robot i is placed at coordinate X_i. When activated, it will travel the distance of D_i in the positive direction, and then it will be removed from the number line. All the robots move at the same speed, and their sizes are ignorable. Takahashi, who is a misc...
stdin
null
2,760
1
[ "2\n1 5\n3 3\n", "3\n6 5\n-1 10\n3 3\n", "20\n-8 1\n26 4\n0 5\n9 1\n19 4\n22 20\n28 27\n11 8\n-3 20\n-25 17\n10 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 29\n29 7\n", "4\n7 10\n-10 3\n4 3\n-4 3\n" ]
[ "3\n", "5\n", "110\n", "16\n" ]
[ "2\n1 5\n4 3\n", "3\n6 5\n-1 7\n3 3\n", "20\n-8 1\n26 4\n0 5\n9 1\n19 4\n22 20\n28 27\n11 8\n-3 20\n-25 17\n13 4\n-18 27\n24 28\n-11 19\n2 27\n-2 18\n-1 12\n-24 29\n31 29\n29 7\n", "4\n7 10\n-1 3\n4 3\n-4 3\n", "3\n0 5\n-1 7\n3 3\n", "20\n-8 1\n26 4\n0 5\n15 1\n19 4\n22 20\n28 27\n11 8\n-3 20\n-25 17\n13 ...
[ "3\n", "6\n", "110\n", "16\n", "4\n", "78\n", "12\n", "84\n", "114\n", "10\n" ]
CodeContests
After Joeffrey chocked to death, Cercei blamed Tyrian for his death. After seeing his love, Shae betrayed him, he demanded trial by combat. Now this combat is not with swords but with logic and problem solving. Tywin will ask Tyrian questions and he have to answer them correctly. Tywin asks him this question: There are...
stdin
null
2,391
1
[ "2\n3 4\n1 1 1\n6 2\n1 0 1 1 0 0\n\nSAMPLE\n" ]
[ "1 1 1\n1 0 0 0 0 0\n" ]
[ "115\n37 8\n1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \n98 51\n1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 \n73 55\n1 1 1 1 1 1 1 1 ...
[ "0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
CodeContests
Mathematician Shikhar has invented a new type of fibonacci series in which fib(1)=a fib(2)=b fib(n)=(fib(n-1)+fib(n-2))%1000000007 for all n>2 and now help him find the nth term of this series. Input contains 3 space separated integers a,b and n. Input 2 4 35 NOTE You do not need to create a program for this ...
stdin
null
1,561
1
[]
[]
[ "2 2 36\n" ]
[ "29860704\n" ]
CodeContests
Takahashi participated in a contest on AtCoder. The contest had N problems. Takahashi made M submissions during the contest. The i-th submission was made for the p_i-th problem and received the verdict S_i (`AC` or `WA`). The number of Takahashi's correct answers is the number of problems on which he received an `A...
stdin
null
4,226
1
[ "6 0\n", "2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n", "100000 3\n7777 AC\n7777 AC\n7777 AC\n" ]
[ "0 0\n", "2 2\n", "1 0\n" ]
[ "100000 3\n7777 AC\n7777 AC\n7777 CA\n", "100000 3\n12676 AC\n7777 AC\n7777 CA\n", "1 0\n", "4 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n", "4 5\n1 WA\n1 AC\n0 WA\n2 AC\n2 WA\n", "100000 3\n6234 AC\n7777 AC\n7777 AC\n", "2 0\n", "2 -1\n", "2 -2\n", "2 -4\n" ]
[ "1 0\n", "2 0\n", "0 0\n", "2 2\n", "2 1\n", "2 0\n", "0 0\n", "0 0\n", "0 0\n", "0 0\n" ]