name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
ankit-and-race-team-10
Coach Ankit is forming a team for the Annual Inter Galactic Relay Race. He has N students that train under him and he knows their strengths. The strength of a student is represented by a positive integer. The coach has to form a team of K students. The strength of a team is defined by the strength of the weakest stude...
{ "input": [], "output": [] }
{ "input": [ "2\n2 1\n5 4\n3 2\n1 0 2\n\nSAMPLE" ], "output": [ "9\n1\n" ] }
{ "input": [ "2\n2 1\n3 4\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n5 5\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n3 0\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n0 5\n3 2\n1 0 2\n\nSAMPLE", "2\n2 2\n3 0\n3 2\n1 0 2\n\nELPMAS", "2\n2 2\n3 -1\n3 2\n1 0 2\n\nELPMAS", "2\n2 2\n5 4\n3 2\n1 0 2\n\nSAMPLE", "2\n2 1\n0 5\...
lexicographically-preceding-permutation
Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given permutation is the lexicographically least permutation, then print the input permutation itself. Input Format: First line is the test c...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n1 3 2\n\nSAMPLE" ], "output": [ "1 2 3" ] }
{ "input": [], "output": [] }
roy-and-wobbly-numbers
Roy is looking for Wobbly Numbers. An N-length wobbly number is of the form "ababababab..." and so on of length N, where a != b. A 3-length wobbly number would be of form "aba". Eg: 101, 121, 131, 252, 646 etc But 111, 222, 999 etc are not 3-length wobbly number, because here a != b condition is not satisfied. ...
{ "input": [], "output": [] }
{ "input": [ "6\n3 1\n3 2\n3 100\n4 3\n4 4\n5 2\n\nSAMPLE" ], "output": [ "101\n121\n-1\n1313\n1414\n12121\n" ] }
{ "input": [ "6\n3 1\n3 2\n5 100\n4 3\n4 4\n5 2\n\nSAMPLE", "6\n6 1\n3 2\n5 100\n4 3\n4 4\n5 2\n\nSAMPLE", "6\n6 1\n3 1\n5 100\n4 3\n4 4\n5 2\n\nSAMPLE", "6\n6 1\n3 1\n5 100\n4 3\n4 5\n5 2\n\nSAMPLE", "6\n11 1\n3 1\n5 100\n4 3\n4 5\n5 2\n\nSAMPLE", "6\n11 1\n3 1\n5 100\n4 3\n4 10\n5 2\n\nSAMPL...
vibhu-and-his-mathematics
In code world all genders are considered equal ( It means their is nothing like male or female). Now their are N distinct persons living in this hypothetical world. Each person can pair up with any other person or can even remain single. One day Vbhu planned to visit code world. Being a maths guy , he always try to b...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n3\n\n\nSAMPLE" ], "output": [ "2\n4\n" ] }
{ "input": [ "2\n1\n3\n\n\nSAMPLE", "2\n2\n3\n\n\nSBMPLE", "2\n2\n2\n\n\nELPMBS", "2\n4\n2\n\n\nELPMBS", "2\n3\n3\n\n\nFLQMBS", "2\n5\n2\n\n\nELPMBS", "2\n3\n1\n\n\nFLQMBS", "2\n1\n5\n\n\nEANPLS", "2\n1\n8\n\n\nEANPLS", "2\n1\n7\n\n\nEANPLS", "2\n1\n4\n\n\nEANPLS", "2\n...
p02610 AIsing Programming Contest 2020 - Camel Train
We have N camels numbered 1,2,\ldots,N. Snuke has decided to make them line up in a row. The happiness of Camel i will be L_i if it is among the K_i frontmost camels, and R_i otherwise. Snuke wants to maximize the total happiness of the camels. Find the maximum possible total happiness of the camel. Solve this probl...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 60\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34" ], "output": [ "25\n221\n1354" ] }
{ "input": [ "3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n19 23 16\n5 90 13\n12 85 70\n19 67 78\n12 16 16\n18 48 28\n5 4 24\n12 97 97\n4 57 87\n19 91 74\n18 100 76\n7 86 46\n9 100 57\n3 76 73\n6 84 93\n1 6 84\n11 75 94\n19 15 3\n12 11 34", "3\n2\n1 5 10\n2 15 5\n3\n2 93 78\n1 71 59\n3 57 96\n19\n1...
p02741 Panasonic Programming Contest 2020 - Kth Term
Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 Constraints * 1 \leq K \leq 32 * All values in input are integers. Input Input is given from Standard Input in the following format: K Output Print ...
{ "input": [], "output": [] }
{ "input": [ "27", "6" ], "output": [ "5", "2" ] }
{ "input": [ "16", "19", "8", "24", "32", "28", "-22", "1", "15", "5", "-9", "-27", "-13", "29", "-20", "001", "8", "1", "32", "5", "15", "24", "-9", "-13", "19", "29", "16", "28", "-20", "-27", ...
p02876 AtCoder Grand Contest 040 - Balance Beam
We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second. Snuke and Ringo will play the following game: * First, Snuke connects the N beams in any order of his choice and m...
{ "input": [], "output": [] }
{ "input": [ "3\n4 1\n5 2\n6 3", "4\n1 5\n4 7\n2 1\n8 4", "2\n3 2\n1 2", "10\n866111664 178537096\n705445072 318106937\n472381277 579910117\n353498483 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n955719384 267238505\n844917655 218662351\n550309930 62731178" ], "output":...
{ "input": [ "3\n1 1\n5 2\n6 3", "4\n1 5\n4 7\n2 1\n6 4", "10\n1375710043 178537096\n705445072 318106937\n472381277 579910117\n353498483 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n955719384 267238505\n844917655 218662351\n550309930 62731178", "10\n1375710043 178537096\n70...
p03010 diverta 2019 Programming Contest 2 - Diverta City
Diverta City is a new city consisting of N towns numbered 1, 2, ..., N. The mayor Ringo is planning to connect every pair of two different towns with a bidirectional road. The length of each road is undecided. A Hamiltonian path is a path that starts at one of the towns and visits each of the other towns exactly once...
{ "input": [], "output": [] }
{ "input": [ "4", "3" ], "output": [ "0 111 157 193\n111 0 224 239\n157 224 0 258\n193 239 258 0", "0 6 15\n6 0 21\n15 21 0" ] }
{ "input": [ "2", "6", "7", "8", "10", "1", "5", "9", "001", "010", "5", "6", "1", "9", "7", "2", "10", "8", "001", "010" ], "output": [ "0 1\n1 0\n", "0 1 2 7 45 512\n1 0 4 14 90 1024\n2 4 0 28 180 2048\n7 14 28 0 315 3584\n4...
p03150 KEYENCE Programming Contest 2019 - KEYENCE String
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string. Constraints * The length of S is between 7 and 100 (inclusive). * S consists of lowerc...
{ "input": [], "output": [] }
{ "input": [ "keyence", "ashlfyha", "keyofscience", "mpyszsbznf" ], "output": [ "YES", "NO", "YES", "NO" ] }
{ "input": [ "ecneyek", "ashkfyha", "eeyofscienck", "mnyszsbzpf", "ecneyel", "arhkfyha", "eeyofsciencj", "mnyszsb{pf", "ecleyen", "arhkyfha", "eeyofscienci", "mnzszsb{pf", "neyelce", "ahfykhra", "eeyofscjenci", "mnzs{sb{pf", "neyemce", "ahfzkhra"...
p03294 AtCoder Beginner Contest 103 - Modulo Summation
You are given N positive integers a_1, a_2, ..., a_N. For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N). Here, X\ mod\ Y denotes the remainder of the division of X by Y. Find the maximum value of f. Constraints * All values in input are integers. * 2 \leq N \leq 3000 * 2 ...
{ "input": [], "output": [] }
{ "input": [ "5\n7 46 11 20 11", "7\n994 518 941 851 647 2 581", "3\n3 4 6" ], "output": [ "90", "4527", "10" ] }
{ "input": [ "5\n7 46 11 17 11", "7\n994 518 941 851 647 2 568", "3\n3 1 6", "5\n7 46 11 17 13", "7\n994 518 941 523 647 2 568", "3\n3 2 6", "5\n7 13 11 17 13", "7\n994 518 941 523 647 1 568", "3\n3 3 6", "5\n7 12 11 17 13", "7\n994 765 941 523 647 1 568", "5\n7 12 11 1...
p03452 AtCoder Regular Contest 090 - People on a Line
There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate. You will given M pieces of information regarding the positions of these people. The i-th piece of...
{ "input": [], "output": [] }
{ "input": [ "3 3\n1 2 1\n2 3 1\n1 3 5", "100 0", "10 3\n8 7 100\n7 9 100\n9 8 100", "3 3\n1 2 1\n2 3 1\n1 3 2", "4 3\n2 1 1\n2 3 5\n3 4 2" ], "output": [ "No", "Yes", "No", "Yes", "Yes" ] }
{ "input": [ "000 0", "10 3\n8 7 000\n7 9 100\n9 8 100", "4 3\n2 1 1\n2 3 3\n3 4 2", "10 3\n8 7 000\n7 9 110\n9 8 100", "4 3\n1 1 1\n2 3 3\n3 4 2", "10 3\n9 7 000\n7 9 110\n9 8 100", "4 3\n1 1 1\n2 3 3\n4 4 2", "10 3\n9 2 000\n7 9 110\n9 8 100", "4 3\n1 1 1\n2 3 3\n4 4 1", "10 ...
p03612 AtCoder Beginner Contest 072 - Derangement
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two adjacent elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this. Constraint...
{ "input": [], "output": [] }
{ "input": [ "5\n1 4 3 5 2", "9\n1 2 4 9 5 8 7 3 6", "2\n1 2", "2\n2 1" ], "output": [ "2", "3", "1", "0" ] }
{ "input": [ "5\n1 4 4 5 2", "9\n1 2 4 9 5 8 7 6 6", "9\n1 2 4 9 5 8 4 6 6", "5\n0 4 4 5 1", "2\n1 0", "2\n1 1", "5\n1 4 4 5 1", "2\n1 -1", "2\n0 2", "9\n2 2 4 9 5 8 4 6 6", "2\n2 2", "2\n0 1", "5\n0 4 4 4 1", "9\n2 2 4 5 5 8 4 6 6", "2\n2 0", "2\n0 0", ...
p03771 AtCoder Grand Contest 012 - Camel and Oases
There are N oases on a number line. The coordinate of the i-th oases from the left is x_i. Camel hopes to visit all these oases. Initially, the volume of the hump on his back is V. When the volume of the hump is v, water of volume at most v can be stored. Water is only supplied at oases. He can get as much water as he...
{ "input": [], "output": [] }
{ "input": [ "7 2\n-10 -4 -2 0 2 4 10", "16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 52 80 81 82 84", "3 2\n1 3 6" ], "output": [ "Impossible\nPossible\nPossible\nPossible\nPossible\nPossible\nImpossible", "Possible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossible\nPossib...
{ "input": [ "7 4\n-10 -4 -2 0 2 4 10", "16 19\n-49 -48 -33 -30 -21 -14 0 15 19 23 44 55 80 81 82 84", "3 2\n1 3 2", "16 19\n-49 -48 -24 -30 -21 -14 0 15 19 23 44 55 80 81 82 84", "5 2\n1 3 2", "16 19\n-49 -48 -24 -30 -28 -14 0 15 19 23 44 55 80 81 82 84", "9 2\n1 3 2", "8 2\n1 0 2", ...
p03940 AtCoder Grand Contest 007 - Shik and Game
Imagine a game played on a line. Initially, the player is located at position 0 with N candies in his possession, and the exit is at position E. There are also N bears in the game. The i-th bear is located at x_i. The maximum moving speed of the player is 1 while the bears do not move at all. When the player gives a c...
{ "input": [], "output": [] }
{ "input": [ "3 9 1\n1 3 8", "2 1000000000 1000000000\n1 999999999", "3 9 3\n1 3 8" ], "output": [ "12", "2999999996", "16" ] }
{ "input": [ "3 9 1\n2 3 8", "2 1000000000 1000000000\n1 199586132", "3 9 3\n1 3 7", "3 9 3\n1 0 7", "2 1000001000 1000000000\n2 199586132", "3 9 5\n1 0 7", "2 1010001000 1000000000\n2 199586132", "2 1010001000 1000001000\n4 125587868", "3 9 1\n1 3 0", "2 1010000000 1000000000\...
p00032 Plastic Board
There is a factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plastic plate. At this factory, we cut out only parallelogram molds, although they vary in size. You have been ordered by your boss to count the number of rectangles and rhombuses produced among the parallelograms t...
{ "input": [], "output": [] }
{ "input": [ "3,4,5\n5,5,8\n4,4,4\n5,4,3" ], "output": [ "1\n2" ] }
{ "input": [ "3,4,5\n5,5,8\n4,5,4\n5,4,3", "3,3,5\n5,5,8\n4,4,4\n5,4,3", "3,4,5\n5,5,8\n4,5,4\n3,4,5", "3,4,5\n8,5,5\n4,5,4\n3,4,5", "3,5,5\n6,5,8\n4,4,5\n5,4,3", "3,3,5\n5,5,8\n3,4,4\n5,4,3", "3,4,5\n8,5,5\n4,5,4\n5,4,3", "4,4,5\n5,5,8\n4,5,4\n3,4,5", "3,4,5\n5,5,8\n4,4,4\n3,4,5",...
p00163 Highway Toll
In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened. For half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17:30 and 19:30 and have a...
{ "input": [], "output": [] }
{ "input": [ "2\n17 25\n4\n17 45\n4\n17 25\n7\n19 35\n0" ], "output": [ "250\n1300" ] }
{ "input": [ "2\n17 25\n4\n17 45\n4\n17 25\n7\n1 35\n0", "2\n19 25\n4\n17 37\n4\n17 47\n7\n0 63\n0", "2\n14 25\n4\n3 37\n4\n17 47\n7\n0 63\n0", "2\n13 25\n3\n17 45\n4\n17 25\n7\n1 35\n0", "2\n14 25\n4\n17 37\n0\n17 47\n7\n0 63\n0", "2\n13 25\n3\n17 45\n4\n17 47\n7\n1 35\n0", "2\n19 25\n4\n...
p00320 Cuboid
The educational program (AHK Education) of the Aiz Broadcasting Corporation broadcasts a program called "Play with Tsukuro" for children. Today is the time to make a box with drawing paper, but I would like to see if the rectangular drawing paper I prepared can make a rectangular parallelepiped. However, do not cut or ...
{ "input": [], "output": [] }
{ "input": [ "2 2\n2 3\n2 3\n2 3\n2 2\n3 2", "2 2\n2 3\n2 3\n2 3\n2 2\n2 2" ], "output": [ "yes", "no" ] }
{ "input": [ "2 2\n2 3\n2 3\n2 3\n2 2\n5 2", "2 2\n2 3\n2 2\n2 3\n2 2\n2 2", "2 2\n2 3\n2 3\n2 2\n2 2\n5 2", "2 2\n2 3\n2 2\n2 3\n2 2\n2 3", "2 2\n2 3\n2 3\n2 2\n2 2\n10 2", "2 2\n2 3\n4 2\n2 3\n2 2\n2 3", "2 2\n2 3\n2 2\n2 2\n2 2\n10 2", "2 2\n2 3\n4 4\n2 3\n2 2\n2 3", "2 2\n2 3\n...
p00490 Best Pizza
problem Chairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could order at the JOI pizza store. Let's call such a pizza the "best pi...
{ "input": [], "output": [] }
{ "input": [ "3\n12 2\n200\n50\n300\n100" ], "output": [ "37" ] }
{ "input": [ "3\n12 2\n200\n50\n300\n110", "3\n17 2\n200\n73\n300\n110", "3\n12 2\n200\n50\n599\n100", "3\n12 2\n200\n73\n575\n110", "3\n17 2\n200\n50\n300\n010", "3\n17 2\n63\n50\n300\n010", "3\n12 2\n200\n54\n506\n110", "3\n17 2\n38\n50\n300\n010", "3\n12 2\n358\n87\n575\n010", ...
p00676 KND is So Sexy
Problem KND is a student programmer at the University of Aizu. His chest is known to be very sexy. <image> For simplicity, the part of the skin that can be seen from the chest is represented by the isosceles triangle ABC in the figure. However, due to the slack in the clothes, the two sides AC and BC (where these l...
{ "input": [], "output": [] }
{ "input": [ "2 2 1\n2 3 1\n3 2 3\n2 3 5" ], "output": [ "3.9681187851\n6.7970540913\n6.5668891783\n13.9527248554" ] }
{ "input": [ "2 2 1\n2 3 1\n3 2 3\n1 3 5", "4 2 1\n2 3 1\n3 2 3\n1 3 5", "2 2 1\n2 3 1\n3 2 5\n1 3 5", "2 2 0\n2 3 1\n3 2 3\n2 3 5", "2 2 1\n2 3 1\n1 2 3\n1 3 5", "4 2 1\n2 3 1\n3 2 3\n1 3 0", "2 2 1\n2 3 1\n1 2 5\n1 3 5", "2 2 0\n2 3 0\n3 2 3\n2 3 5", "3 2 1\n2 3 1\n1 2 3\n1 3 5",...
p00819 Unreliable Message
The King of a little Kingdom on a little island in the Pacific Ocean frequently has childish ideas. One day he said, “You shall make use of a message relaying game when you inform me of something.” In response to the King’s statement, six servants were selected as messengers whose names were Mr. J, Miss C, Mr. E, Mr. A...
{ "input": [], "output": [] }
{ "input": [ "5\nAJMP\naB23d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf" ], "output": [ "32Bad\nAE86\n7\nEC302QTWaEa\nTurnAGundam0isdefferentfr" ] }
{ "input": [ "5\nAJMP\naB33d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf", "5\nAJMP\naB33d\nE\n86AE\nAM\n6\nEPJM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf", "5\nAJMP\naB33d\nE\n86AE\nAM\n0\nEPJM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf", "5\nAJMP\naB33d\nE\n86AE\nAM\n0\nMPJE...
p00950 Infallibly Crack Perplexing Cryptarithm
Example Input ACM Output 0
{ "input": [], "output": [] }
{ "input": [ "ACM" ], "output": [ "0" ] }
{ "input": [ "ABM", "BIB", "1MI", "MCA", "MAC", "M@C", "C@M", "@MC", "?MC", "M?C", "C?M", "CM?", "DM?", "?MD", "@MD", "@ME", "@EM", "@DM", "MD@", "@CM", "@CN", "NC@", "CN@", "@NC", "@OC", "@CO", "C@O", "D@O...
p01083 RedBlue
Story At UZIA High School in the sky city AIZU, the club activities of competitive programming are very active. N Red Coders and n Blue Coders belong to this club. One day, during club activities, Red Coder and Blue Coder formed a pair, and from this club activity, n groups participated in a contest called KCP. At th...
{ "input": [], "output": [] }
{ "input": [ "2\n3 3 2\n8 3 2\n3 0\n3 7\n8 0\n8 7", "2\n3 3 2\n8 3 2\n0 3\n3 7\n8 0\n8 7", "1\n10 10 10\n31 10 10\n15 19\n26 1", "2\n3 3 2\n8 3 2\n0 0\n0 5\n11 0\n11 5" ], "output": [ "10.0000000000", "13.8190642862", "Impossible", "22.0000000000" ] }
{ "input": [ "2\n3 3 2\n8 3 2\n3 0\n3 7\n8 0\n5 7", "2\n3 3 2\n8 3 2\n1 3\n3 7\n8 0\n8 7", "1\n10 10 17\n31 10 10\n15 19\n26 1", "2\n3 3 2\n1 3 2\n0 0\n0 5\n11 0\n11 5", "2\n3 3 2\n8 3 2\n3 -1\n3 7\n8 0\n5 7", "2\n6 3 2\n1 3 1\n0 0\n0 5\n11 -1\n11 5", "2\n3 3 2\n8 7 0\n3 -1\n3 7\n8 0\n5 11...
p01219 Private Teacher
You are working as a private teacher. Since you are giving lessons to many pupils, you are very busy, especially during examination seasons. This season is no exception in that regard. You know days of the week convenient for each pupil, and also know how many lessons you have to give to him or her. You can give just ...
{ "input": [], "output": [] }
{ "input": [ "2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nThursday Friday Saturday Sunday\n0 0" ], "output": [ "Yes\nNo" ] }
{ "input": [ "2 2\n6 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n9 4\nTsurhday Friday Saturday Sunday\n0 0", "2 2\n7 3\nMonday Tuesday Wednesday\n8 4\nThursday Friday Saturday Sunday\n2 2\n7 3\nMonday Tuesday Wednesday\n6 4\nTsurhday Friday aSturday S...
p01353 Rabbit Plays Games!
A rabbit is playing a role-playing game. Just before entering the castle, he was ambushed by an enemy! It was a battle between one hero operated by a rabbit and n enemies. Each character has four stats, health hi, attack power ai, defense power di, and agility si. I = 0 is the information of the main character, 1 ≤ i ...
{ "input": [], "output": [] }
{ "input": [ "1\n1 1 1 1\n10000 10000 10000 10000", "2\n10 3 1 2\n2 4 1 3\n2 2 1 1" ], "output": [ "-1", "4" ] }
{ "input": [ "1\n1 0 1 1\n10000 10000 10000 10000", "2\n10 3 1 2\n2 4 1 3\n1 2 1 1", "2\n10 3 1 2\n2 4 1 3\n1 3 1 1", "2\n10 3 1 2\n3 4 1 3\n1 3 1 1", "2\n10 3 2 2\n3 4 1 3\n1 3 1 1", "1\n1 0 1 1\n10000 10010 10000 10000", "1\n1 0 1 1\n10000 10010 10000 10100", "1\n1 0 1 1\n10000 10010...
p01535 Markup language has Declined
E: Markup language has declined It's been centuries since we humans have been declining slowly. The earth may already belong to "Progurama". Programa-sans with an average height of 170 cm, 7 heads, high intelligence, and loves Kodingu. I have returned to my hometown of Nibunki, becoming an important international civi...
{ "input": [], "output": [] }
{ "input": [ "1\nindex.dml\n<dml><title>Markup language has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index" ], "output": [ "Markup language\n has Declined..\nProgrammers wor" ] }
{ "input": [ "1\nindex.dml\n<dml><title>Markup aangulge has Declined</title><br>Programmers world</dml>\n1\n15 3 0 index", "1\nindex.dml\n<dml><title>Markup aangulge sah Declined</title><br>Programmers world</dml>\n1\n15 3 0 index", "1\nindex.dml\n<dml><title>Markup aanlugge sah Declined</title><br>Progra...
p01691 Disappear Drive
E --Disappear Drive Story The person in D likes basketball, but he likes shooting, so other techniques are crazy. I'm not particularly good at dribbling, and when I enter the opponent's defensive range, I always get the ball stolen. So I decided to come up with a deadly dribble that would surely pull out any opponent...
{ "input": [], "output": [] }
{ "input": [ "1 0\n25 47 10" ], "output": [ "96.2027355887" ] }
{ "input": [ "1 0\n25 47 15", "1 0\n16 47 15", "1 0\n31 47 15", "2 0\n31 47 13", "2 0\n31 47 20", "2 0\n31 47 33", "1 0\n25 38 10", "1 0\n25 61 15", "1 0\n16 57 15", "1 0\n31 18 15", "2 0\n31 47 11", "2 0\n1 47 20", "1 0\n25 58 10", "2 0\n31 49 11", "1 0\n25...
p01835 Donut Decoration
Example Input 3 2 3 1 2 1 2 3 2 3 3 1 Output 1
{ "input": [], "output": [] }
{ "input": [ "3 2\n3\n1 2 1\n2 3 2\n3 3 1" ], "output": [ "1" ] }
{ "input": [ "2 2\n3\n1 2 1\n2 3 2\n3 3 1", "3 2\n1\n1 2 1\n2 3 2\n3 3 1", "2 2\n3\n2 2 1\n2 3 2\n3 3 1", "3 2\n1\n1 1 1\n2 3 2\n3 3 1", "0 2\n3\n1 2 1\n2 3 2\n3 3 1", "0 2\n3\n1 2 1\n2 3 0\n3 3 1", "2 2\n3\n2 2 1\n2 3 4\n3 3 1", "3 2\n1\n1 2 1\n2 3 2\n3 6 1", "3 2\n1\n1 1 1\n2 3 2...
p01970 The Diversity of Prime Factorization
D: The Diversity of Prime Factorization Problem Ebi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \ log $ M) time! But unfortunately, the machine could display only digits and white spaces. In general, we consider the factorization of M as p_1 ^ {e_1} \ times p_2 ...
{ "input": [], "output": [] }
{ "input": [ "3\n2 3 3" ], "output": [ "2" ] }
{ "input": [ "3\n2 3 6", "3\n2 3 11", "3\n3 2 3", "3\n2 5 3", "3\n2 2 3", "3\n2 2 11", "3\n3 2 6", "3\n2 2 13", "3\n4 2 6", "3\n2 2 0", "3\n4 2 2", "3\n3 2 0", "3\n2 2 2", "3\n2 3 2", "3\n2 1 2", "3\n2 1 0", "3\n2 2 1", "3\n4 2 1", "3\n4 3 3"...
p02117 Picnic
Problem Tomorrow is finally the day of the excursion to Maizu Elementary School. Gatcho, who attends Maizu Elementary School, noticed that he had forgotten to buy tomorrow's sweets because he was so excited. Gaccho wants to stick to sweets so that he can enjoy the excursion to the fullest. Gaccho gets a $ X $ yen al...
{ "input": [], "output": [] }
{ "input": [ "3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 0\n1 0 0\n0 1 0", "4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n9 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0", "1 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n0", "2 10 10\n3\n1 10 1\n2 20 2\n3 30 3\n1\n5 200 1\n0 2\n3 0" ...
{ "input": [ "3 10 10\n1\n1 1 1\n1\n3 3 3\n1\n5 5 5\n0 1 1\n1 0 0\n0 1 0", "1 10 3\n3\n1 10 1\n2 20 2\n3 30 3\n0", "2 10 10\n3\n1 10 1\n2 9 2\n3 30 3\n1\n5 200 1\n0 2\n3 0", "4 59 40\n1\n7 6 3\n1\n10 3 9\n2\n14 8 5\n7 6 10\n4\n8 2 9\n1 7 1\n7 7 9\n1 2 3\n0 28 7 26\n14 0 10 24\n9 6 0 21\n9 24 14 0", ...
p02257 Prime Numbers
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of N integers and prints the number of prime numbers in the list. Constraints 1 ≤ N ≤ 10000 2 ≤ an element of the ...
{ "input": [], "output": [] }
{ "input": [ "5\n2\n3\n4\n5\n6", "11\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17" ], "output": [ "3", "4" ] }
{ "input": [ "11\n7\n8\n9\n10\n11\n12\n13\n14\n27\n16\n17", "11\n7\n8\n9\n10\n11\n22\n13\n2\n27\n8\n17", "5\n2\n4\n7\n5\n6", "11\n7\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27", "11\n14\n8\n9\n26\n15\n22\n2\n14\n27\n8\n27", "11\n7\n10\n9\n10\n11\n13\n17\n3\n15\n16\n17", "11\n7\n8\n9\n11\n11\n22\n1...
p02405 Print a Chessboard
Draw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm. .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# .#.#.#.#. .#.#.#.#.# Note that the top left corner should be drawn by '#'. Constraints * 1 ≤ H ≤ 300 * 1...
{ "input": [], "output": [] }
{ "input": [ "3 4\n5 6\n3 3\n2 2\n1 1\n0 0" ], "output": [ "#.#.\n.#.#\n#.#.\n\n#.#.#.\n.#.#.#\n#.#.#.\n.#.#.#\n#.#.#.\n\n#.#\n.#.\n#.#\n\n#.\n.#\n\n#" ] }
{ "input": [ "3 4\n5 6\n3 3\n2 2\n1 0\n0 0", "3 7\n5 6\n3 3\n2 2\n1 0\n0 0", "3 7\n5 6\n3 0\n2 2\n1 0\n0 0", "6 7\n5 6\n3 0\n2 2\n1 0\n0 0", "6 11\n5 6\n3 0\n2 2\n1 0\n0 0", "3 4\n5 6\n2 3\n2 2\n1 1\n0 0", "3 4\n5 6\n3 3\n2 4\n1 0\n0 0", "3 7\n5 6\n4 3\n2 2\n1 0\n0 0", "3 7\n5 5\n3...
anuwta
There are N+1 lights. Lights are placed at (0, 0), (1, 0), (2, 0) ... (N, 0). Initially all the lights are on. You want to turn off all of them one after one. You want to follow a special pattern in turning off the lights. You will start at (0, 0). First, you walk to the right most light that is on, turn it off. Th...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n2" ], "output": [ "2\n5\n" ] }
{ "input": [ "2\n1\n4", "2\n2\n4", "2\n2\n1", "2\n0\n1", "2\n0\n2", "2\n2\n2", "2\n4\n2", "2\n2\n3", "2\n3\n2", "2\n0\n0", "2\n-1\n0", "2\n-1\n-1", "2\n-3\n-1", "2\n-3\n-6", "2\n-4\n0", "2\n-1\n2", "2\n-1\n1", "2\n1\n1", "2\n2\n0", "2\n4\...
chsparr
Chef has a an array A consisting of N elements. He wants to add some elements into the array as per the below mentioned process. After each minute, Chef iterates over the array in order from left to right, and takes every two neighbouring pair of elements, say x and y, he adds a new element x + y in the middle of eleme...
{ "input": [], "output": [] }
{ "input": [ "2\n3 1 1 5\n1 6 9\n3 2 6 7\n1 6 9" ], "output": [ "38\n36" ] }
{ "input": [], "output": [] }
etmx05
Middle Strings Miss Roma has got a new job in a computer agency. To test her skills the manager has appointed her with a small project. She will get a string of any length but of ODD length and what she has to do is finding a center string of length 3 in the original string. For Example: She gets a string 'CANDY' the...
{ "input": [], "output": [] }
{ "input": [ "CANDY", "SOLVING" ], "output": [ "AND", "LVI" ] }
{ "input": [], "output": [] }
laddu
You might have heard about our new goodie distribution program aka the "Laddu Accrual System". This problem is designed to give you a glimpse of its rules. You can read the page once before attempting the problem if you wish, nonetheless we will be providing all the information needed here itself. Laddu Accrual Syste...
{ "input": [], "output": [] }
{ "input": [ "2\n4 INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED\n4 NON_INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED" ], "output": [ "3\n1\n" ] }
{ "input": [ "2\n4 INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED\n1 NON_INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED", "2\n4 INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONTEST_HOSTED\n2 NON_INDIAN\nCONTEST_WON 1\nTOP_CONTRIBUTOR\nBUG_FOUND 100\nCONT...
pcsc1
George is getting tired of the decimal number system. He intends to switch and use the septenary (base 7) number system for his future needs. Write a program to help George start his transformation into the septenary number system by taking in a list of decimal numbers and print out the corresponding septenary number...
{ "input": [], "output": [] }
{ "input": [ "1 2 88 42 99 -1" ], "output": [ "1 2 154 60 201" ] }
{ "input": [ "1 2 101 42 99 -1", "1 2 101 42 33 -1", "1 2 101 36 33 -1", "1 2 101 36 50 -1", "0 2 101 36 50 -1", "1 2 132 42 99 -1", "1 4 101 42 33 -1", "1 2 111 36 33 -1", "1 2 100 36 50 -1", "0 2 101 43 50 -1", "0 2 132 42 99 -1", "1 2 110 36 33 -1", "0 2 101 43 9...
stadium
The bustling town of Siruseri has just one sports stadium. There are a number of schools, colleges, sports associations, etc. that use this stadium as the venue for their sports events. Anyone interested in using the stadium has to apply to the Manager of the stadium indicating both the starting date (a positive inte...
{ "input": [], "output": [] }
{ "input": [ "4\n2 5\n9 7\n15 6\n9 3" ], "output": [ "3" ] }
{ "input": [], "output": [] }
1202_C. You Are Given a WASD-string...
You have a string s — a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands: * 'W' — move one cell up; * 'S' — move one cell down; * 'A' — move one cell left; * 'D' — move one cell right. Let Grid(s) be the grid of minimum possibl...
{ "input": [], "output": [] }
{ "input": [ "3\nDSAWWAW\nD\nWA\n" ], "output": [ "8\n2\n4\n" ] }
{ "input": [ "3\nDSAWWAW\nD\nAW\n", "3\nWSAWDAW\nD\nAW\n", "3\nDAAWWSW\nD\nAW\n", "3\nWAWWASD\nD\nWA\n", "3\nASAWWDW\nD\nWA\n", "3\nWAWWASD\nD\nAW\n", "3\nWSAWDAW\nD\nWA\n", "3\nWDWWASA\nD\nWA\n", "3\nWDWWASA\nD\nAW\n", "3\nWSADWAW\nD\nWA\n", "3\nWWWDASA\nD\nAW\n", "3\n...
1219_H. Function Composition
We are definitely not going to bother you with another generic story when Alice finds about an array or when Alice and Bob play some stupid game. This time you'll get a simple, plain text. First, let us define several things. We define function F on the array A such that F(i, 1) = A[i] and F(i, m) = A[F(i, m - 1)] for...
{ "input": [], "output": [] }
{ "input": [ "10\n2 3 1 5 6 4 2 10 7 7\n5\n10 1\n5 7\n10 6\n1 1\n10 8\n" ], "output": [ "3\n0\n1\n1\n0\n" ] }
{ "input": [ "10\n2 3 1 5 6 4 2 10 7 7\n5\n10 1\n5 7\n19 6\n1 1\n10 8\n", "10\n2 3 1 5 6 4 1 10 7 7\n5\n10 1\n5 7\n19 6\n1 1\n10 8\n", "10\n2 3 1 5 6 4 2 10 7 7\n5\n10 1\n5 7\n10 6\n1 2\n10 8\n", "10\n1 3 1 5 6 4 1 10 7 7\n5\n10 1\n5 7\n19 6\n1 1\n10 8\n", "10\n2 3 1 5 3 4 2 10 7 7\n5\n10 1\n5 7\n...
1431_I. Cyclic Shifts
You are given a matrix consisting of n rows and m columns. The matrix contains lowercase letters of the Latin alphabet. You can perform the following operation any number of times you want to: choose two integers i (1 ≤ i ≤ m) and k (0 < k < n), and shift every column j such that i ≤ j ≤ m cyclically by k. The shift i...
{ "input": [], "output": [] }
{ "input": [ "3 5 4\nabacc\nccbba\nccabc\nabacc\nacbbc\nababa\nacbbc\n", "6 4 4\ndaac\nbcba\nacad\ncbdc\naaaa\nbcbb\ndcdd\nacba\nbbbb\ndbcd\n", "5 10 5\nltjksdyfgg\ncbhpsereqn\nijndtzbzcf\nghgcgeadep\nbfzdgxqmqe\nibgcgzyfep\nbbhdgxqmqg\nltgcgxrzep\nljnpseldgn\nghhpseyzcf\n" ], "output": [ "\n0\n2\...
{ "input": [], "output": [] }
1455_F. String and Operations
You are given a string s consisting of n characters. These characters are among the first k lowercase letters of the Latin alphabet. You have to perform n operations with the string. During the i-th operation, you take the character that initially occupied the i-th position, and perform one of the following actions wi...
{ "input": [], "output": [] }
{ "input": [ "6\n4 2\nbbab\n7 5\ncceddda\n6 5\necdaed\n7 4\ndcdbdaa\n8 3\nccabbaca\n5 7\neabba\n" ], "output": [ "\naaaa\nbaccacd\naabdac\naabacad\naaaaaaaa\nabadb\n" ] }
{ "input": [ "6\n4 2\nbbab\n7 5\ncceddda\n6 5\necdaed\n7 8\ndcdbdaa\n8 3\nccabbaca\n5 7\neabba\n", "6\n4 2\nbbab\n7 5\ncceddda\n6 9\necdaed\n7 8\ndcdbdaa\n8 3\nccabbaca\n5 7\neabba\n", "6\n4 2\nbaab\n7 5\ncceddda\n6 5\necdaed\n7 5\ndcdbdaa\n8 5\nacabbacc\n5 7\neabba\n", "6\n4 2\nbaab\n7 5\ncceddda\n6 ...
1506_F. Triangular Paths
Consider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The k-th layer of the triangle contains k points, numbered from left to right. Each point of an infinite triangle is described by a pair of numbers (r, c) (1 ≤ c ≤ r), where r ...
{ "input": [], "output": [] }
{ "input": [ "4\n3\n1 4 2\n1 3 1\n2\n2 4\n2 3\n2\n1 1000000000\n1 1000000000\n4\n3 10 5 8\n2 5 2 4\n" ], "output": [ "\n0\n1\n999999999\n2\n" ] }
{ "input": [ "4\n3\n1 4 2\n1 3 1\n2\n2 4\n2 3\n2\n1 1100000000\n1 1000000000\n4\n3 10 5 8\n2 5 2 4\n", "4\n3\n1 6 2\n1 3 1\n2\n2 4\n2 3\n2\n1 1100000000\n1 1000000000\n4\n3 10 5 8\n2 5 2 4\n", "4\n3\n1 4 2\n1 3 1\n2\n2 7\n2 3\n2\n1 1100000000\n1 1000000000\n4\n3 10 5 8\n2 5 2 4\n", "4\n3\n1 8 2\n1 3 1...
abc-garfield
Garfield the cat likes candies A LOT. He always keeps a huge stock of it at his home. Today John, his owner, brought home three types of candies. He brought A pieces of Red candy, B pieces of Green candy and C pieces of Blue candy. Garfield is really happy. But the problem is that John won’t allow him to eat all of it ...
{ "input": [], "output": [] }
{ "input": [ "3\n2 1 2 3\n1 1 1 1\n2 1 0 1\n\nSAMPLE" ], "output": [ "9\n4\n4" ] }
{ "input": [], "output": [] }
palin-pairs
Panda has a thing for palindromes. Hence he was a given a problem by his master. The master will give Panda an array of strings S having N strings. Now Panda has to select the Palin Pairs from the given strings . A Palin Pair is defined as : (i,j) is a Palin Pair if Si = reverse(Sj) and i < j Panda wants to k...
{ "input": [], "output": [] }
{ "input": [ "3\nbba\nabb\nabb\n\nSAMPLE" ], "output": [ "2\n" ] }
{ "input": [ "3\nbba\nabb\nabc\n\nSAMPLE", "3\nbba\nabb\nabb\n\nSAMPLF", "3\nbba\nbba\nabc\n\nSAMPLE", "3\nbba\nabb\nabc\n\nSAPMLE", "3\nbba\nabb\nbac\n\nSAPMLE", "3\nbba\nabb\nbba\n\nSAMPLF", "3\nbba\nabb\ncab\n\nSAPMLE", "3\nbba\nabb\ncba\n\nSAMPLF", "3\nbba\naab\ncab\n\nSAPMLE",...
special-matrix-1
You are given a square matrix of size n (it will be an odd integer). Rows are indexed 0 to n-1 from top to bottom and columns are indexed 0 to n-1 form left to right. Matrix consists of only '*' and '.'. '*' appears only once in the matrix while all other positions are occupied by '.' Your task is to convert this matr...
{ "input": [], "output": [] }
{ "input": [ "1\n7\n.......\n.*.....\n.......\n.......\n.......\n.......\n.......\n\nSAMPLE" ], "output": [ "4\n" ] }
{ "input": [ "1\n7\n.......\n.*.....\n.......\n.......\n.......\n.......\n.......\n\nSAMQLE", "1\n5\n.......\n.*.....\n.......\n..-..-.\n.......\n.......\n....../\n\nSALPLE", "1\n7\n....../\n..*..//\n../....\n./-.--.\n....-..\n.......\n./.....\n\nTAMPME", "1\n7\n.......\n.*.....\n.......\n.......\n......
p02574 AtCoder Beginner Contest 177 - Coprime
We have N integers. The i-th number is A_i. \\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N. \\{A_i\\} is said to be setwise coprime when \\{A_i\\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1. Determine if \\{A_i\\} is pairwise coprime, setw...
{ "input": [], "output": [] }
{ "input": [ "3\n6 10 16", "3\n6 10 15", "3\n3 4 5" ], "output": [ "not coprime", "setwise coprime", "pairwise coprime" ] }
{ "input": [ "3\n6 5 15", "3\n4 4 2", "3\n4 3 1", "3\n4 4 5", "3\n4 8 2", "3\n8 8 2", "3\n4 4 1", "3\n4 4 4", "3\n6 8 2", "3\n7 4 4", "3\n6 8 3", "3\n2 4 4", "3\n1 4 4", "3\n2 8 4", "3\n4 8 4", "3\n6 10 3", "3\n4 4 7", "3\n3 5 15", "3\n4 4 8"...
p02705 AtCoder Beginner Contest 163 - Circle Pond
Print the circumference of a circle of radius R. Constraints * 1 \leq R \leq 100 * All values in input are integers. Input Input is given from Standard Input in the following format: R Output Print the circumference of the circle. Your output is considered correct if and only if its absolute or relative error ...
{ "input": [], "output": [] }
{ "input": [ "73", "1" ], "output": [ "458.67252742410977361942", "6.28318530717958623200" ] }
{ "input": [ "8", "0", "4", "-1", "2", "-2", "3", "-4", "6", "-3", "-6", "-9", "-8", "-12", "-5", "7", "-10", "10", "-17", "9", "-7", "15", "-11", "17", "-18", "33", "-31", "66", "-16", "71", "-...
p02834 AtCoder Beginner Contest 148 - Playing Tag on Tree
We have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally. Takahashi is standing at Vertex u, and Aoki is standing at Vertex v. Now, they will play a game of tag as follows: * 1. If Takahashi and Aoki are standing at the same vertex, the game ends. Otherwise, Takahashi moves to a vert...
{ "input": [], "output": [] }
{ "input": [ "2 1 2\n1 2", "5 4 5\n1 2\n1 3\n1 4\n1 5", "5 4 1\n1 2\n2 3\n3 4\n3 5", "9 6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n4 7\n7 8\n8 9" ], "output": [ "0", "1", "2", "5" ] }
{ "input": [ "5 4 5\n1 2\n1 3\n2 4\n1 5", "5 4 1\n1 2\n1 3\n3 4\n3 5", "9 6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n4 7\n4 8\n8 9", "5 4 1\n1 2\n2 3\n1 4\n3 5", "9 6 1\n1 2\n2 4\n3 4\n4 5\n5 6\n4 7\n4 8\n8 9", "9 6 1\n1 2\n2 3\n3 6\n4 5\n7 6\n4 7\n4 7\n8 9", "9 6 1\n1 2\n2 3\n3 8\n6 5\n7 6\n4 7\n4 8\n...
p02971 AtCoder Beginner Contest 134 - Exception Handling
You are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question: * Find the maximum value among the N-1 elements other than A_i in the sequence. Constraints * 2 \leq N \leq 200000 * 1 \leq A_i \leq 200000 * All values in input are integers. Inp...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n5", "3\n1\n4\n3" ], "output": [ "5\n5", "4\n3\n4" ] }
{ "input": [ "2\n5\n4", "3\n1\n0\n3", "2\n3\n4", "3\n1\n0\n2", "2\n4\n4", "3\n1\n0\n1", "2\n4\n0", "3\n1\n2\n1", "3\n1\n3\n1", "3\n1\n3\n2", "3\n1\n2\n2", "3\n1\n4\n2", "3\n3\n4\n2", "3\n2\n4\n4", "3\n2\n3\n4", "3\n2\n3\n7", "3\n2\n6\n7", "3\n2\n...
p03107 AtCoder Beginner Contest 120 - Unification
There are N cubes stacked vertically on a desk. You are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is `0`, and blue if that character is `1`. You can perform the following operation any number of times: choose a red cube and a blue cube that are adjacent...
{ "input": [], "output": [] }
{ "input": [ "0", "0011", "11011010001011" ], "output": [ "0", "4", "12" ] }
{ "input": [ "1", "0010", "11011010001001", "11001010001001", "11001000001001", "1010", "01001000101000", "11011011111101", "0000", "1000", "11001000101001", "1011", "11001010101001", "1100", "01001010101001", "0100", "01001000101001", "0101", ...
p03254 AtCoder Grand Contest 027 - Candy Distribution Again
There are N children, numbered 1, 2, ..., N. Snuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets. For each i (1 \leq i \leq N), Child i will be happy if he/she gets exactly a_i sweets. Snuke is trying to maximize the number of happy ...
{ "input": [], "output": [] }
{ "input": [ "4 1111\n1 10 100 1000", "3 70\n20 30 10", "3 10\n20 30 10", "2 10\n20 20" ], "output": [ "4", "2", "1", "0" ] }
{ "input": [ "3 70\n20 30 5", "3 10\n20 18 10", "2 10\n29 20", "4 1111\n1 5 100 1000", "4 1111\n-1 2 110 1000", "3 70\n20 49 5", "3 10\n20 9 10", "2 10\n30 20", "3 70\n4 49 5", "3 10\n20 4 10", "2 0\n30 20", "3 70\n4 40 5", "3 10\n20 1 10", "2 1\n30 20", "3 ...
p03407 AtCoder Beginner Contest 091 - Two Coins
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. Constraints * All input values a...
{ "input": [], "output": [] }
{ "input": [ "500 100 1000", "19 123 143", "19 123 142", "50 100 120" ], "output": [ "No", "No", "Yes", "Yes" ] }
{ "input": [ "500 000 1000", "31 123 143", "19 123 141", "50 100 127", "500 101 1000", "55 123 143", "1 123 141", "50 000 127", "500 001 1000", "64 123 143", "1 123 281", "50 001 127", "726 101 1000", "64 123 92", "1 229 281", "74 001 127", "726 101 ...
p03570 CODE FESTIVAL 2017 qual C - Yet Another Palindrome Partitioning
We have a string s consisting of lowercase English letters. Snuke is partitioning s into some number of non-empty substrings. Let the subtrings obtained be s_1, s_2, ..., s_N from left to right. (Here, s = s_1 + s_2 + ... + s_N holds.) Snuke wants to satisfy the following condition: * For each i (1 \leq i \leq N), it ...
{ "input": [], "output": [] }
{ "input": [ "byebye", "abcdefghijklmnopqrstuvwxyz", "aabxyyzz", "abcabcxabcx" ], "output": [ "1", "26", "2", "3" ] }
{ "input": [ "byeybe", "zyxwvutsrqponmlkjihgfedcba", "aabwyyzz", "axcabcbabcx", "zyxwvutsrqponmlkjihgfedbba", "aabwyzzz", "eybcxb", "abzwxayz", "ayxwvutsrqponmlkiihgfedbbz", "yccabbcacxa", "ayxwwutsrqponmlkiihgfedbbz", "ayxwwutsrpponmlkiihgfedbbz", "ayxwwutsrpponmmk...
p03725 AtCoder Grand Contest 014 - Closed Rooms
Takahashi is locked within a building. This building consists of H×W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a character A_{i,j}. If A_{i,j}= `#`, the room is locked and cannot be entered; if A_{i,j}= `.`, the r...
{ "input": [], "output": [] }
{ "input": [ "3 3 3\n#.#\n#S.\n###", "3 3 3\n.#\nS.", "3 3 3\n\nS#", "7 7 2\n\n\n...##\nS###\n.#.##\n.###" ], "output": [ "1", "1", "2", "2" ] }
{ "input": [ "2 3 3\n.#\nS.", "7 8 2\n\n\n...##\n###S\n.#.##\n.###", "7 7 2\n\n\n##...\nS###\n.#.##\n.###", "2 3 3\n#.\nS.", "7 7 2\n\n\n##...\nS###\n##.#.\n.###", "2 3 3\n#.\n.S", "7 12 2\n\n\n##...\nS###\n##.#.\n.###", "7 12 2\n\n\n#$...\nS###\n##.#.\n.###", "7 12 2\n\n\n#$...\nS...
p03889 CODE FESTIVAL 2016 Relay (Parallel) - Mirror String
You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d...
{ "input": [], "output": [] }
{ "input": [ "ppqb", "pdbq" ], "output": [ "No", "Yes" ] }
{ "input": [ "qbdp", "dbqp", "bdqp", "bqpp", "pdqb", "dqbp", "pqbd", "pqdb", "bqqp", "pdpb", "pbqd", "dqpb", "bqpq", "pbpd", "dppb", "qpqb", "dpbp", "bpdp", "bqdp", "pqqb", "dpbq", "dpqb", "dbpp", "bdpp", "bpqp", "...
p04048 AtCoder Grand Contest 001 - Mysterious Light
Snuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangle be a, b and c. Inside the triangle, the rifle is placed at the point p on segment ab such that ap ...
{ "input": [], "output": [] }
{ "input": [ "5 2" ], "output": [ "12" ] }
{ "input": [ "5 4", "7 4", "6 1", "9 4", "6 3", "14 4", "8 1", "28 4", "15 2", "28 3", "19 2", "32 2", "29 5", "26 3", "46 1", "46 2", "81 3", "85 3", "10 3", "14 1", "2 1", "11 4", "4 2", "18 4", "28 6", "28 7", ...
p00127 Pocket Pager Input
One day, Taro received a strange email with only the number "519345213244" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, "Oh, I sent it with a pocket bell because I was in a hurry. It's convenient. Nice to meet you!" I got it. You know this cousin, who is always ...
{ "input": [], "output": [] }
{ "input": [ "341143514535\n314\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414" ], "output": [ "naruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend" ] }
{ "input": [ "341143514535\n158\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414", "341143514535\n314\n10141283183115209195186599000583233654691126402\n551544654451431564\n4\n3411\n6363636363\n153414", "341143514535\n158\n1435655535516553113434116522356545...
p00260 Cats Going Straight
There was a large mansion surrounded by high walls. The owner of the mansion loved cats so much that he always prepared delicious food for the occasional cats. The hungry cats jumped over the high walls and rushed straight to the rice that was everywhere in the mansion. One day the husband found some cats lying down i...
{ "input": [], "output": [] }
{ "input": [ "8\n0 0\n3 2\n6 2\n8 6\n6 5\n7 7\n0 4\n3 4\n8\n0 0\n5 3\n5 2\n4 1\n6 1\n8 6\n6 4\n2 4\n0" ], "output": [ "1\n2" ] }
{ "input": [ "8\n0 -1\n3 2\n6 2\n8 6\n6 5\n7 7\n0 4\n3 4\n8\n0 0\n5 3\n5 2\n4 1\n6 1\n8 6\n6 4\n2 4\n0", "8\n0 -1\n3 2\n6 2\n8 6\n6 5\n7 7\n0 4\n3 4\n8\n0 0\n5 3\n4 2\n4 1\n6 1\n8 6\n6 4\n2 4\n0", "8\n0 -1\n3 3\n6 2\n8 6\n6 5\n7 7\n0 4\n3 4\n8\n0 0\n5 3\n5 2\n4 1\n6 1\n8 6\n6 4\n2 4\n0", "8\n0 -1\n3 2...
p00447 Searching Constellation
problem You are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, there is a possibility that extra stars are shown in the photograph other than the stars that make up th...
{ "input": [], "output": [] }
{ "input": [ "5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 9\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\n...
{ "input": [ "5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n10 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 9\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\n254125 362183\...
p00638 Old Bridges
Long long ago, there was a thief. Looking for treasures, he was running about all over the world. One day, he heard a rumor that there were islands that had large amount of treasures, so he decided to head for there. Finally he found n islands that had treasures and one island that had nothing. Most of islands had sea...
{ "input": [], "output": [] }
{ "input": [ "3\n2 3\n3 6\n1 2\n3\n2 3\n3 5\n1 2\n0" ], "output": [ "Yes\nNo" ] }
{ "input": [ "3\n2 3\n3 6\n1 2\n3\n2 3\n3 5\n2 2\n0", "3\n2 3\n3 6\n2 2\n3\n3 3\n3 6\n2 2\n0", "3\n2 1\n3 6\n1 2\n3\n2 3\n3 5\n0 2\n0", "3\n2 5\n0 9\n4 1\n0\n2 0\n3 10\n2 3\n0", "3\n4 5\n3 8\n1 2\n0\n7 3\n3 5\n2 1\n0", "3\n2 3\n3 6\n1 2\n3\n0 3\n3 5\n1 2\n0", "3\n2 3\n3 6\n1 2\n3\n3 3\n3 5...
p00781 Lattice Practices
Once upon a time, there was a king who loved beautiful costumes very much. The king had a special cocoon bed to make excellent cloth of silk. The cocoon bed had 16 small square rooms, forming a 4 × 4 lattice, for 16 silkworms. The cocoon bed can be depicted as follows: <image> The cocoon bed can be divided into 10 re...
{ "input": [], "output": [] }
{ "input": [ "10000 01000 00100 11000 01100 11111 01110 11100 10110 11110\n10101 01000 00000 11001 01100 11101 01110 11100 10110 11010\nEND" ], "output": [ "40\n6" ] }
{ "input": [ "10000 01000 00100 11000 01100 11111 01110 11100 10110 11110\n10101 01000 00000 11001 01100 11001 01110 11100 10110 11010\nEND", "10000 01000 00100 11000 00100 11111 01110 11100 10110 11110\n10101 01000 00000 11001 01100 11001 01110 11100 10110 11010\nEND", "10000 00000 01110 11010 00100 1011...
p00914 Equal Sum Sets
Let us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same set. Specifying the number of set elements and their sum to be k and s, respectively, sets satisfyin...
{ "input": [], "output": [] }
{ "input": [ "9 3 23\n9 3 22\n10 3 28\n16 10 107\n20 8 102\n20 10 105\n20 10 155\n3 4 3\n4 2 11\n0 0 0" ], "output": [ "1\n2\n0\n20\n1542\n5448\n1\n0\n0" ] }
{ "input": [ "9 3 23\n9 3 22\n10 3 28\n16 10 107\n20 8 102\n20 10 105\n20 10 155\n3 5 3\n4 2 11\n0 0 0", "9 3 23\n9 3 22\n10 3 28\n16 10 107\n20 8 102\n20 10 105\n20 20 155\n3 5 3\n4 2 11\n0 0 0", "9 3 23\n9 3 22\n10 3 28\n16 10 107\n20 8 102\n20 8 105\n20 20 155\n3 5 3\n4 2 11\n0 0 0", "9 3 23\n2 3 2...
p01046 Yu-kun Likes a lot of Money
Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves money as much as programming. Yu-kun visited the island where treasures sleep to make money today. Yu-kun has obtained a map of the treasure in advanc...
{ "input": [], "output": [] }
{ "input": [ "3 3 1 10\n@#b\n.#.\n.#.\nb 100", "3 3 1 20\n@*C\n..*\n...\nC 10", "3 3 1 10\n@0.\n...\n...\n0 100" ], "output": [ "0", "0", "100" ] }
{ "input": [], "output": [] }
p01179 Cousin's Aunt
Sarah is a girl who likes reading books. One day, she wondered about the relationship of a family in a mystery novel. The story said, * B is A’s father’s brother’s son, and * C is B’s aunt. Then she asked herself, “So how many degrees of kinship are there between A and C?” There are two possible relationships bet...
{ "input": [], "output": [] }
{ "input": [ "7\nC is A’s father’s brother’s son’s aunt\nC is A’s mother’s brother’s son’s aunt\nC is A’s son’s mother’s mother’s son\nC is A’s aunt’s niece’s aunt’s niece\nC is A’s father’s son’s brother\nC is A’s son’s son’s mother\nC is A" ], "output": [ "5 3\n5 1\n2 2\n6 0\n2 0\n1 1\n0 0" ] }
{ "input": [], "output": [] }
p01316 Differential Pulse Code Modulation
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, ...
{ "input": [], "output": [] }
{ "input": [ "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" ], "output": [ "2\n8\n0\n325125\n65026" ] }
{ "input": [ "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", "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...
p01484 Icy Composer
Time Limit: 8 sec / Memory Limit: 64 MB Example Input 5 3 2 aaaaa aaa aab Output 1 6
{ "input": [], "output": [] }
{ "input": [ "5 3 2\naaaaa\naaa\naab" ], "output": [ "1 6" ] }
{ "input": [ "5 3 2\naaaaa\nbaa\naab", "5 3 2\naaaaa\nabb\naac", "6 3 2\naaaaa\naaa\naab", "6 3 2\naabaa\naaa\naab", "10 3 1\naaaaa\nabb\naab", "5 3 2\nbaaaa\naab\naab", "8 3 2\naaaac\n`ab\naba", "5 1 2\naaaaa\nbaa\naca", "10 0 2\naaaaa\nabb\naab", "7 3 2\nbabaa\naab\naab", ...
p01646 Dictionary
Problem Statement We found a dictionary of the Ancient Civilization Mayo (ACM) during excavation of the ruins. After analysis of the dictionary, we revealed they used a language that had not more than 26 letters. So one of us mapped each letter to a different English alphabet and typed all the words in the dictionary ...
{ "input": [], "output": [] }
{ "input": [ "4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacb\nc\nb\nb\n0" ], "output": [ "yes\nno\nyes\nno" ] }
{ "input": [ "4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacc\nc\nb\nb\n0", "4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\nabc\nacb\nb\nc\nc\n5\nabc\nacc\nd\nb\nb\n0", "4\ncba\ncab\nb\na\n3\nbca\nab\na\n5\ncba\nacb\nb\nc\nc\n5\nabc\nacc\nd\nb\nb\n0", "4\nabc\ncab\nb\na\n3\nacb\nac\na\n5\nab...
p01797 Kimagure Cleaner
Example Input 2 -3 4 L 2 5 ? 3 5 Output 2 L 4 L 3
{ "input": [], "output": [] }
{ "input": [ "2 -3 4\nL 2 5\n? 3 5" ], "output": [ "2\nL 4\nL 3" ] }
{ "input": [], "output": [] }
p01931 Check answers
problem AOR Ika is studying to pass the test. AOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure. 1. Check the correctness of the answer. 2. If the answer is correct, write a circle mark, and if it is incorrect, write a cross mark on the answer sheet. ...
{ "input": [], "output": [] }
{ "input": [ "3\noxx" ], "output": [ "2" ] }
{ "input": [ "3\nnxx", "3\nnwx", "3\nxxo", "3\nxwn", "3\nowx", "3\npxx", "3\npyx", "3\npzx", "3\npzw", "3\npwz", "3\nzwp", "3\nzxp", "3\npxz", "3\nzyp", "3\nyzp", "3\nyzq", "3\nyzr", "3\nxzr", "3\nrzx", "3\nxrz", "3\nwrz", "3\nzrw...
p02069 Universal and Existential Quantifiers
Problem Statement You are given a list of $N$ intervals. The $i$-th interval is $[l_i, r_i)$, which denotes a range of numbers greater than or equal to $l_i$ and strictly less than $r_i$. In this task, you consider the following two numbers: * The minimum integer $x$ such that you can select $x$ intervals from the gi...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02211 Apple Adventure
Apple adventure square1001 and E869120 got lost in the grid world of $ H $ rows and $ W $ rows! Said the god of this world. "When you collect $ K $ apples and they meet, you'll be back in the original world." Upon hearing this word, square1001 decided to collect more than $ K $ of apples and head to the square wher...
{ "input": [], "output": [] }
{ "input": [ "5 5 2\ns..#a\n.#...\na#e.#\n...#a\n.#..." ], "output": [ "14" ] }
{ "input": [ "5 5 2\ns..#a\n.#...\ne#a.#\n...#a\n.#...", "5 5 2\ns..#a\n.#../\n#.a#e\n...#a\n.#...", "5 5 2\nb#..s\n.#/./\ne#a.#\n...#a\n.#...", "5 5 1\ns..#a\n.#...\na#e.#\n...#b\n.#...", "5 5 2\ns.#.a\n.#../\ne#a.#\n...#a\n.#...", "5 5 1\nc#..s\n.#/./\n#.a#e\n...#a\n.#...", "5 5 4\ns..#b...
p02365 Minimum-Cost Arborescence
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...
{ "input": [], "output": [] }
{ "input": [ "4 6 0\n0 1 3\n0 2 2\n2 0 1\n2 3 1\n3 0 1\n3 1 5", "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" ], "output": [ "6", "11" ] }
{ "input": [ "4 6 0\n0 1 3\n0 2 2\n2 0 1\n2 3 2\n3 0 1\n3 1 5", "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", "4 6 0\n0 1 1\n0 2 2\n2 0 1\n2 3 2\n3 0 1\n3 1 5", "4 6 0\n0 1 1\n0 2 2\n3 1 1\n2 3 3\n3 0 0\n0 1 7", "6 10 0\n0 2 7\n0 1 1\n0 3 5\n1 4 9\n2 1 6\n1 3 2\n3...
acdemy
Sherlock Holmes has decided to start a new academy to some of the young lads. He has conducted several tests and finally selected N equally brilliant students.Now he don't know whether to train all the N students or not. Now since Holmes was in a confusion, Watson came up with an idea. He wanted to test the obedience o...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n2 3 5 1 2\n3\n1 2 3" ], "output": [ "3\n3" ] }
{ "input": [], "output": [] }
chefrp
Rupsa recently started to intern under Chef. He gave her N type of ingredients of varying quantity A1, A2, ..., AN respectively to store it. But as she is lazy to arrange them she puts them all in a storage box. Chef comes up with a new recipe and decides to prepare it. He asks Rupsa to get two units of each type ingr...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n2 2\n1\n6" ], "output": [ "4\n2\n" ] }
{ "input": [ "2\n2\n2 1\n1\n6", "2\n2\n2 2\n1\n8", "2\n2\n4 2\n1\n6", "2\n1\n2 1\n1\n1", "2\n3\n3 2\n1\n8", "2\n3\n4 2\n0\n1", "2\n3\n4 7\n0\n6", "2\n3\n5 2\n0\n2", "2\n4\n4 9\n0\n6", "2\n6\n4 11\n0\n6", "2\n0\n2 2\n1\n1", "2\n6\n4 22\n0\n6", "2\n-1\n8 19\n0\n6", ...
donuts
There is new delicious item in Chef's menu - a doughnut chain. Doughnuts connected successively in line forming a chain. Chain of 3 doughnuts Chef has received an urgent order for making a chain of N doughnuts. He noticed that there are exactly N cooked doughnuts in the kitchen, some of which are already connected i...
{ "input": [], "output": [] }
{ "input": [ "2\n11 3\n4 3 4\n6 3\n3 2 1" ], "output": [ "2\n1\n" ] }
{ "input": [ "2\n11 3\n2 3 4\n6 3\n3 2 1", "2\n22 3\n2 0 3\n4 3\n3 2 1", "2\n22 3\n0 0 3\n4 3\n3 2 1", "2\n11 3\n2 3 4\n6 5\n3 2 1", "2\n22 6\n2 3 4\n6 3\n2 2 1", "2\n12 3\n0 0 3\n4 4\n3 1 1", "2\n11 5\n2 3 4\n9 5\n3 2 2", "2\n22 6\n0 3 7\n6 3\n4 2 0", "2\n28 8\n1 0 4\n4 3\n5 2 1",...
ism1
Hackers! Hackers! Everywhere! Some days back your email ID was hacked. Some one read the personal messages and Love Letters you sent to your girl friend. That's a terrible thing, well, you know how are the boys at ISM. So, you have decided that from now onwards you will write Love Letters to your girlfriend in a differ...
{ "input": [], "output": [] }
{ "input": [ "3\ncan you meet me outside ccd today\na\nthis year hard kaur is coming to entertain us" ], "output": [ "nac uoy teem em edistuo dcc yadot\na\nsiht raey drah ruak si gnimoc ot niatretne su" ] }
{ "input": [ "3\ncan you meet me ouuside ccd today\na\nthis year hard kaur is coming to entertain us", "3\ncan you meet me ouuside ccd today\na\nthis xear hard kaur is coming to entertain us", "3\ncan you meet me ouuside ccd uoday\na\nthis xear hard kaur is coming to entertain us", "3\ncan you meet me...
nopc10
Computation of the date either previous or forthcoming dates is quiet easy. But it is quiet difficult to calculate the day from a particular given date. You are required to find a day from a particular date given to you. Input It consists of a single line entry consisting of date in format dd mm yyyy. i.e. the input...
{ "input": [], "output": [] }
{ "input": [ "14 3 2012" ], "output": [ "Wednesday" ] }
{ "input": [ "14 2 2012", "14 4 2012", "14 4 1177", "20 4 1177", "20 4 1433", "20 3 1433", "14 3 1433", "14 3 1186", "14 1 1186", "7 1 1186", "7 2 1186", "7 2 1946", "7 1 1946", "10 1 1946", "10 1 3808", "2 1 3808", "2 1 6973", "0 1 6973", "0...
seg003
Problem description. The problem statement is simple , you are given an array and you have to perform two types of operation on it. Type 1 : update the value of array at the given index. Type 2 : find the maximum sum you can obtained in the given range ( L , R ) by taking any two index i and j , such that ( L <=...
{ "input": [], "output": [] }
{ "input": [ "5 3 \n1 2 3 4 5\n2 1 5\n1 2 5\n2 1 5" ], "output": [ "9 \n10" ] }
{ "input": [], "output": [] }
1451_D. Circle Game
Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first. Consider the 2D plane. There is a token which is initially at (0,0). In one move a player must increase either the x coordinate or the y coordinate of the token by exactly k. In doing so, the...
{ "input": [], "output": [] }
{ "input": [ "5\n2 1\n5 2\n10 3\n25 4\n15441 33\n" ], "output": [ "\nUtkarsh\nAshish\nUtkarsh\nUtkarsh\nAshish\n" ] }
{ "input": [ "5\n2 1\n5 2\n10 3\n25 4\n25479 33\n", "5\n2 1\n9 1\n10 3\n25 4\n25479 33\n", "5\n1 1\n9 1\n10 3\n46 4\n25479 33\n", "5\n2 1\n5 1\n10 3\n25 3\n25479 33\n", "5\n2 1\n9 1\n10 3\n25 4\n25479 57\n", "5\n2 1\n9 1\n11 3\n25 4\n25479 57\n", "5\n2 1\n4 1\n10 3\n46 4\n25479 47\n", ...
530_C. Diophantine equation
You are given an equation A * X + B * Y = C, A, B, C are positive integer coefficients, X and Y are variables which can have positive integer values only. Output the number of solutions of this equation and the solutions themselves. Input The only line of input contains integers A, B and C (1 ≤ A, B, C ≤ 1000), separ...
{ "input": [], "output": [] }
{ "input": [ "3 5 35\n", "3 35 5\n" ], "output": [ "2\n5 4\n10 1\n", "0\n" ] }
{ "input": [], "output": [] }
bhavanas-and-bhuvanas-bet
Bhavana and Bhuvana place bet every time they see something interesting that can occur with a probability 0.5. Both of them place a bet for a higher amount which they don’t posses at that time. But when one wins she demands other for the bet amount. For example if Bhuvana wins she asks bhavana for the bet amount. But...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n10" ], "output": [ "1\n3" ] }
{ "input": [], "output": [] }
cost-of-data-11
Strings can be efficiently stored as a data structure, to have efficient searching methods. A new startup is going to use this method, but they don't have much space. So they want to check beforehand how much memory will be required for their data. Following method describes the way in which this startup's engineers s...
{ "input": [], "output": [] }
{ "input": [ "5\net\neq\nbd\nbe\nbdp\n\nSAMPLE" ], "output": [ "8" ] }
{ "input": [ "5\neu\neq\nbd\nbe\nbdp\n\nSAMPLE", "5\neu\neq\nbd\nbe\ndbp\n\nSAMQLE", "5\neu\neq\nbd\nbd\ndbp\n\nSAMQLE", "5\net\nqe\nbd\ndc\ndbp\n\nSAMQLE", "5\nte\nqe\nbd\ndb\np`d\n\nDAQMKS", "5\neu\neq\nbd\nbe\nbdp\n\nELPMAS", "5\neu\neq\nbd\nbe\nbdp\n\nSAMQLE", "5\neu\nqe\nbd\nbd\nd...
find-the-nth-prime
Given the value of n, print the n'th prime number. Input : A single integer n. Output : A single number which is the n'th prime number. Constraints : 1 ≤ n ≤ 1000 SAMPLE INPUT 2 SAMPLE OUTPUT 3 Explanation The first few prime numbers are: 2,3,5,7. So, the answer is 3.
{ "input": [], "output": [] }
{ "input": [ "2\n\nSAMPLE" ], "output": [ "3\n" ] }
{ "input": [ "2\n\nSBMPLE", "2\n\nSBPMLE", "2\n\nELMPBS", "2\n\nELMPAS", "2\n\nSAPMLE", "2\n\nSAQMLE", "2\n\nELMQAS", "2\n\nELMQBS", "2\n\nELLQBS", "2\n\nEMLQBS", "2\n\nEMLQBT", "2\n\nTBQLME", "2\n\nTCQLME", "2\n\nSCQLME", "2\n\nTCQKME", "2\n\nEMKQCT", ...
max-min
you are given an array of size N. You need to select K elements from the array such that the difference between the max number among selected and the min number among selected array elements should be minimum. Print the minimum difference. INPUT: First line N number i.e., length of array Second line K number Next N l...
{ "input": [], "output": [] }
{ "input": [ "5\n3\n1\n2\n3\n4\n5\n\nSAMPLE" ], "output": [ "2\n" ] }
{ "input": [ "5\n3\n1\n1\n3\n4\n5\n\nSAMPLE", "5\n3\n1\n3\n3\n4\n5\n\nSAMPLE", "5\n4\n1\n1\n3\n5\n5\n\nSAMPLE", "5\n1\n0\n3\n3\n4\n5\n\nQAMRLD", "5\n3\n0\n6\n3\n4\n9\n\nLMRDAQ", "5\n3\n1\n1\n3\n5\n5\n\nSAMPLE", "5\n3\n1\n2\n3\n4\n7\n\nSAMPLE", "5\n3\n1\n3\n3\n4\n5\n\nPAMSLE", "5\n3...
rams-love-for-sita-2
Sita loves chocolate and Ram being his boyfriend wants to give Sita as many chocolates as he can. So, he goes to a chocolate store with Rs. N in his pocket. The price of each chocolate is Rs. C. The store offers a discount that for every M wrappers he gives to the store, he gets one chocolate for free. How many chocola...
{ "input": [], "output": [] }
{ "input": [ "3\n10 2 5\n12 4 4\n6 2 2\n\nSAMPLE" ], "output": [ "6\n3\n5\n" ] }
{ "input": [ "3\n10 2 5\n12 4 8\n6 2 2\n\nSAMPLE", "3\n7 2 5\n12 4 8\n6 2 2\n\nSAMPLF", "3\n7 2 5\n12 4 8\n6 2 4\n\nSAMPLF", "3\n12 2 5\n12 4 8\n6 2 4\n\nSAMPLF", "3\n12 2 5\n2 4 16\n6 2 4\n\nSAMPLF", "3\n12 2 5\n4 4 16\n6 2 4\n\nSAMPLF", "3\n12 2 5\n8 4 16\n6 2 4\n\nSAMPLF", "3\n12 2 ...
the-strongest-string-1-1
Maga and Alex are good at string manipulation problems. Just now they have faced a problem related to string. But it is not a standard string problem. They have no idea to solve it. They need your help. A string is called unique if all characters of string are distinct. String s_1 is called subsequence of string s_2 ...
{ "input": [], "output": [] }
{ "input": [ "5\nabvzx\n\nSAMPLE" ], "output": [ "zx\n" ] }
{ "input": [ "5\nabvzx\n\nSAMOLE", "5\nxbvza\n\nSAMOLE", "5\nxbvya\n\nSAMOLE", "5\nabvxz\n\nSAMOLE", "5\nayvbx\n\nSAMOLE", "5\nzavbw\n\nSAMOLE", "5\nazwaw\n\nSOMALF", "5\nbywaw\n\nSOMALF", "5\nwawyb\n\nSOMALG", "5\nxywab\n\nDTALON", "5\nxw`xb\n\nSOMALE", "5\nb`wyy\n\nCT...
p02548 AtCoder Beginner Contest 179 - A x B + C
Given is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \times B + C = N? Constraints * 2 \leq N \leq 10^6 * All values in input are integers. Input Input is given from Standard Input in the following format: N Output Print the answer. Examples Input 3 Output 3 Input 100 ...
{ "input": [], "output": [] }
{ "input": [ "3", "100", "1000000" ], "output": [ "3", "473", "13969985" ] }
{ "input": [ "4", "101", "5", "001", "8", "6", "2", "110", "10", "13", "111", "12", "17", "9", "7", "14", "16", "11", "22", "26", "18", "19", "24", "43", "23", "44", "72", "32", "20", "15", "33"...
p02679 AtCoder Beginner Contest 168 - ∙ (Bullet)
We have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively. We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time. The i-th and j-th sardines (i \neq j) are on bad terms if and o...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n-1 1\n2 -1", "10\n3 2\n3 2\n-1 1\n2 -1\n-3 -9\n-8 12\n7 7\n8 1\n8 2\n8 4" ], "output": [ "5", "479" ] }
{ "input": [ "3\n1 4\n-1 1\n2 -1", "10\n3 2\n3 2\n-1 1\n2 -1\n-3 -6\n-8 12\n7 7\n8 1\n8 2\n8 4", "3\n2 4\n-1 1\n2 -1", "10\n3 2\n3 2\n-1 1\n2 -1\n-3 -6\n-8 12\n7 1\n8 1\n8 2\n8 4", "3\n2 4\n-2 1\n2 -1", "10\n3 2\n3 0\n-1 1\n2 -1\n-3 -6\n-8 12\n7 1\n8 1\n8 2\n15 5", "10\n3 2\n3 0\n-2 2\n2 -...
p02807 Dwango Programming Contest 6th - Fusing Slimes
There are N slimes standing on a number line. The i-th slime from the left is at position x_i. It is guaruanteed that 1 \leq x_1 < x_2 < \ldots < x_N \leq 10^{9}. Niwango will perform N-1 operations. The i-th operation consists of the following procedures: * Choose an integer k between 1 and N-i (inclusive) with equ...
{ "input": [], "output": [] }
{ "input": [ "12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 982631932", "3\n1 2 3" ], "output": [ "750927044", "5" ] }
{ "input": [ "12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 1765707086", "3\n1 2 5", "12\n161735902 394362112 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 1765707086", "3\n1 3 5", "12\n...
p02943 AtCoder Grand Contest 037 - Reversing and Concatenating
Takahashi has a string S of length N consisting of lowercase English letters. On this string, he will perform the following operation K times: * Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order. * Let S' be some contiguous substring of U with length N, an...
{ "input": [], "output": [] }
{ "input": [ "5 1\nbacba", "10 2\nbbaabbbaab" ], "output": [ "aabca", "aaaabbaabb" ] }
{ "input": [ "5 2\nbacba", "10 2\nbbbabbbaaa", "10 3\nbbaabbbaab", "5 2\nbacaa", "10 2\nbaabbbaabb", "10 2\nbaabbaaabb", "10 2\nbbaaabbbab", "5 1\nbabba", "10 2\nbabbbbaabb", "10 1\nbaabbaaabb", "5 1\nbabbb", "10 2\nbbaabbbbab", "10 1\nbbaaabbaab", "8 5\nbbaaabb...
p03080 ExaWizards 2019 - Red or Blue
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. Constraints * 1 \l...
{ "input": [], "output": [] }
{ "input": [ "4\nRRBR", "4\nBRBR" ], "output": [ "Yes", "No" ] }
{ "input": [ "4\nRBRR", "4\nBBRR", "4\nRRCR", "4\nRRAR", "4\nRARR", "4\nBQBR", "4\nRCRR", "4\nBPBR", "4\nRRRC", "4\nAQBR", "4\nRRRD", "4\nAQBS", "4\nDRRR", "4\nARBS", "4\nERRR", "4\nBQBS", "4\nBPBS", "4\nPBBS", "4\nSBBP", "4\nPBSB", "...
p03225 Tenka1 Programmer Contest - Equilateral
There are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at point (i,j); if that character is `.`, there is no coin at point (i,j). There are no other coins in t...
{ "input": [], "output": [] }
{ "input": [ "5 4\n#.##\n.##.\n#...\n..##\n...#", "13 27\n......#.........#.......#..\n...#.....###..\n..............#####...##...\n...#######......#...#######\n...#.....#.....###...#...#.\n...#######....#.#.#.#.###.#\n..............#.#.#...#.#..\n.#.#.#...###..\n...........#...#...#######\n..#######..#...#.....
{ "input": [ "5 6\n#.##\n.##.\n#...\n..##\n...#", "13 27\n......#.........#.......#..\n...#.....###..\n..............#####...##...\n...#######......#...#######\n...#.....#.....###...#...#.\n...#######....#.#.#.#.###.#\n..............#.#.#...#.#..\n.#.#.#...###..\n...........#...#./.#######\n..#######..#...#.....
p03371 AtCoder Beginner Contest 095 - Half and Half
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr...
{ "input": [], "output": [] }
{ "input": [ "1500 2000 1600 3 2", "1500 2000 500 90000 100000", "1500 2000 1900 3 2" ], "output": [ "7900", "100000000", "8500" ] }
{ "input": [ "1500 1572 1600 3 2", "1500 2445 500 90000 100000", "1500 2000 1615 3 2", "1500 1572 1600 0 2", "1500 2000 1166 3 2", "1500 651 1600 0 2", "1500 3132 752 90000 100000", "1500 2000 1343 3 2", "1500 2000 1343 3 3", "1339 651 1600 0 1", "542 2000 1343 3 3", "1...
p03534 CODE FESTIVAL 2017 Final (Parallel) - Palindrome-phobia
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible. Constraints * 1 \leq |S| \leq 10^5 * S consists of `a`...
{ "input": [], "output": [] }
{ "input": [ "aba", "abac", "babacccabab" ], "output": [ "NO", "YES", "YES" ] }
{ "input": [ "acac", "bacaccbabab", "ccaa", "bacaacbcbab", "babcbcaacab", "bababccacab", "bacaccbabac", "bacaccbaaac", "caaabccacab", "caaaaccacab", "bacaccaaaac", "baa", "caba", "babacccbaab", "aacc", "bacabcbabab", "bacaacccbab", "babcbbaacab",...
p03694 AtCoder Beginner Contest 064 - Traveling AtCoDeer Problem
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 ...
{ "input": [], "output": [] }
{ "input": [ "4\n2 3 7 9", "8\n3 1 4 1 5 9 2 6" ], "output": [ "7", "8" ] }
{ "input": [ "4\n2 3 9 9", "8\n3 1 4 1 5 18 2 6", "4\n2 3 13 9", "4\n4 4 13 9", "8\n3 1 1 1 5 15 1 6", "4\n4 4 8 9", "4\n0 4 8 18", "8\n1 1 1 2 5 14 1 6", "4\n-1 2 4 18", "4\n-1 2 4 31", "8\n0 1 0 2 7 8 1 6", "4\n-1 2 11 6", "8\n1 1 -1 2 -1 0 1 5", "4\n-3 3 7 2"...
p03849 AtCoder Regular Contest 066 - Xor Sum
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7. Constraints * 1≦N≦10^{18...
{ "input": [], "output": [] }
{ "input": [ "3", "1422", "1000000000000000000" ], "output": [ "5", "52277", "787014179" ] }
{ "input": [ "4", "1026", "1000000001000000000", "0", "530", "1100000001000000000", "1", "706", "1100000001000010000", "2", "152", "1100000001001010000", "7", "192", "1100000011001010000", "5", "292", "1100000001001010010", "271", "110100...
p04015 AtCoder Regular Contest 060 - Tak and Cards
Tak has N cards. On the i-th (1 \leq i \leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection? Constraints * 1 \leq N \leq 50 * 1 \leq A \leq 50 * 1 \leq x_...
{ "input": [], "output": [] }
{ "input": [ "4 8\n7 9 8 9", "3 8\n6 6 9", "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3", "8 5\n3 6 2 8 7 6 5 9" ], "output": [ "5", "0", "8589934591", "19" ] }
{ "input": [ "4 8\n7 12 8 9", "3 8\n9 6 9", "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "8 5\n3 6 2 8 7 2 5 9", "3 8\n15 6 9", "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "8 5\n3 6 2 8 7 2 5 16", "33 3\n3 3 3 3 3 3 3 3 3 3 3...
p00100 Sale Result
There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID i, the amount of sales q and the corresponding unit price p. Then, the program should print IDs of employees whose total sales proceeds ...
{ "input": [], "output": [] }
{ "input": [ "4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0" ], "output": [ "1001\n1003\nNA\n2013" ] }
{ "input": [ "4\n1001 2000 520\n80 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0", "4\n0001 2000 520\n80 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0", "4\n0000 2000 520\n80 1800 450\n100...
p00232 Life Game
Taro went to a toy store to buy a game of life made by Aizu Hobby. Life games are played using a board with squares and roulette. As shown in the figure, the board has one start point and one goal point, which are connected by a single grid. First, the pieces are placed in the square at the starting point, and the piec...
{ "input": [], "output": [] }
{ "input": [ "1 2 0\n1\n1 2 1\n1\n1 2 100\n1 2 1\n2\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 60\n0 0 0" ], "output": [ "0\n100\n0\n50\n20" ] }
{ "input": [ "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n2\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 60\n0 0 0", "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n2\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 27\n0 0 0", "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n2\n1 2 100\n2 2 1\n2...
p00395 Maze and Items
Maze & Items is a puzzle game in which the player tries to reach the goal while collecting items. The maze consists of $W \times H$ grids, and some of them are inaccessible to the player depending on the items he/she has now. The score the player earns is defined according to the order of collecting items. The objectiv...
{ "input": [], "output": [] }
{ "input": [ "12 5\n.....S......\n.abcdefghij.\n.0123456789.\n.ABCDEFGHIJ.\n.....T......\n0 1 0 0 0 0 0 0 0 0\n2 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0", "5 6\n..S...
{ "input": [ "12 5\n.....S......\n.abcdefghij.\n.0123456789.\n.ABCDEFGHIJ.\n.....T......\n0 1 0 0 0 0 0 0 0 0\n2 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 -1 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0", "5 6\n.....