name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p00061 Rank Checker | The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers, and the ranking is given in descending order of the number of correct ans... | {
"input": [],
"output": []
} | {
"input": [
"1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n5"
],
"output": [
"2\n2\n3\n3"
]
} | {
"input": [
"1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n1",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n2\n4\n1",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n0\n2\n4\n1",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n2\n4\n0",
"1,20\n2,20\n3,30\n4,10\n5,10\n0,26\n0,0\n1\n3\n4\n0",
"1,20\... |
p00192 Multistory Parking Lot | 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... | {
"input": [],
"output": []
} | {
"input": [
"3 5\n90\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0"
],
"output": [
"2 5 1 4 3\n1 2 4 3"
]
} | {
"input": [
"3 5\n123\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0",
"3 5\n123\n52\n82\n84\n124\n2 4\n18\n30\n40\n60\n0 0",
"1 5\n90\n52\n82\n84\n70\n2 4\n10\n30\n40\n60\n0 0",
"1 5\n90\n52\n82\n84\n70\n2 4\n10\n43\n22\n60\n0 0",
"3 5\n123\n52\n82\n87\n92\n4 4\n18\n32\n40\n60\n0 0",
"3 5\n123\n5... |
p00347 Forecast of Forces | Nobuo-kun and Shizuo-kun are playing a game of competing for territories on a rectangular island. As shown in Fig. 1 below, the entire island is made up of square compartments divided in a grid pattern, and the profits and losses resulting from these are indicated by integers.
<image>
In this game, move one piece t... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n5 3 2 -5 2\n2 -4 2 8 -4\n2 3 -7 6 7\n3 -4 10 -3 -3",
"2 1\n-2 1",
"2 2\n2 -3\n3 -1"
],
"output": [
"5",
"1",
"3"
]
} | {
"input": [
"5 4\n5 6 2 -5 2\n2 -4 2 8 -4\n2 3 -7 6 7\n3 -4 10 -3 -3",
"0 1\n-2 1",
"5 4\n5 6 2 -5 2\n2 -4 2 8 -4\n2 3 -7 6 7\n1 -4 10 -3 -3",
"1 1\n-2 1",
"5 4\n5 6 2 -5 2\n2 -4 2 13 -4\n2 3 -7 6 7\n1 -4 10 -3 -3",
"5 4\n1 6 2 -5 2\n2 -4 2 13 -4\n2 3 -7 6 7\n1 -4 10 -3 -3",
"1 1\n-1 2",
... |
p00543 Swapping Bibs | problem
N students from JOI High School are lined up in a row from east to west. The i-th student from the western end of the column is student i. Each student has a bib with one integer. Initially, the integer Ai is written on the number of student i.
There are M batons, and the batons are numbered from 1 to M. For ... | {
"input": [],
"output": []
} | {
"input": [
"6 4\n3\n2\n8\n3\n1\n5"
],
"output": [
"2\n3\n1\n8\n5\n3"
]
} | {
"input": [
"6 4\n3\n2\n11\n3\n1\n5",
"6 4\n3\n0\n11\n3\n1\n5",
"1 4\n3\n0\n11\n3\n1\n5",
"1 8\n5\n0\n4\n2\n2\n9",
"6 4\n3\n2\n8\n0\n1\n5",
"6 4\n3\n2\n11\n0\n1\n5",
"6 4\n3\n0\n11\n3\n0\n5",
"2 4\n3\n0\n11\n3\n1\n5",
"1 4\n2\n0\n11\n2\n2\n9",
"6 4\n3\n2\n4\n0\n1\n5",
"6 4... |
p00707 The Secret Number | Your job is to find out the secret number hidden in a matrix, each of whose element is a digit ('0'-'9') or a letter ('A'-'Z'). You can see an example matrix in Figure 1.
<image>
Figure 1: A Matrix
The secret number and other non-secret ones are coded in a matrix as sequences of digits in a decimal format. You shoul... | {
"input": [],
"output": []
} | {
"input": [
"7 4\n9R2A993\n0E314A0\n8A900DE\n820R037\n6 7\nJH03HE\nID7722\n0DA1AH\n30C9G5\n99971A\nCA7EAI\nAHLBEM\n20 2\nA1234567891234CBDEGH\nBDEDF908034265091499\n0 0"
],
"output": [
"23900037\n771971\n12345908034265091499"
]
} | {
"input": [
"7 4\n9R2A993\n0E314A0\n8A900DE\n820R037\n6 7\nJH03HE\nID7722\n0DA1AH\n30C9G5\n99971A\nCA7EAI\nAHLBEM\n20 2\nHGEDBC4321987654321A\nBDEDF908034265091499\n0 0",
"7 4\n9R2A993\n0E314A0\n8A900DE\n820R037\n6 7\nJI03HE\nID7722\n0DA1AH\n30C9G5\n99971A\nCA7EAI\nAHLBEM\n20 2\nA1234567891234CBDEGH\nBDEDF90... |
p00846 How I Mathematician Wonder What You Are! | After counting so many stars in the sky in his childhood, Isaac, now an astronomer and a mathematician, uses a big astronomical telescope and lets his image processing program count stars. The hardest part of the program is to judge if a shining object in the sky is really a star. As a mathematician, the only way he kn... | {
"input": [],
"output": []
} | {
"input": [
"6\n66 13\n96 61\n76 98\n13 94\n4 0\n45 68\n8\n27 21\n55 14\n93 12\n56 95\n15 48\n38 46\n51 65\n64 31\n0"
],
"output": [
"1\n0"
]
} | {
"input": [
"6\n66 13\n96 61\n76 98\n13 94\n4 0\n45 68\n8\n27 21\n55 14\n93 12\n56 95\n15 48\n38 46\n51 65\n35 31\n0",
"6\n66 13\n96 61\n76 98\n13 133\n4 0\n45 44\n8\n27 21\n55 14\n60 12\n18 95\n15 48\n38 10\n51 65\n15 31\n0",
"6\n38 10\n96 61\n76 98\n13 94\n4 0\n45 110\n8\n27 14\n55 12\n174 12\n2 95\n15... |
p00978 Sixth Sense | Sixth Sense
Ms. Future is gifted with precognition. Naturally, she is excellent at some card games since she can correctly foresee every player's actions, except her own. Today, she accepted a challenge from a reckless gambler Mr. Past. They agreed to play a simple two-player trick-taking card game.
Cards for the gam... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2 3 4 5\n1 2 3 4 5"
],
"output": [
"2 3 4 5 1"
]
} | {
"input": [
"5\n1 2 6 4 5\n1 2 3 4 5",
"5\n1 2 6 4 5\n1 2 5 4 5",
"5\n1 2 6 4 5\n1 2 1 4 5",
"5\n1 4 6 4 5\n1 2 1 4 5",
"5\n1 4 6 4 5\n1 1 1 4 5",
"5\n1 4 6 4 9\n1 1 1 3 5",
"5\n1 4 6 4 9\n1 1 1 3 10",
"5\n1 4 6 4 9\n1 1 1 3 7",
"5\n1 4 6 4 9\n1 1 2 3 7",
"5\n1 4 6 6 9\n1 1 2 ... |
p01110 Origami | Origami, or the art of folding paper
Master Grus is a famous origami (paper folding) artist, who is enthusiastic about exploring the possibility of origami art. For future creation, he is now planning fundamental experiments to establish the general theory of origami.
One rectangular piece of paper is used in each of... | {
"input": [],
"output": []
} | {
"input": [
"2 1 1 1\n1 1\n0 0\n1 3 2 1\n2 1\n2 1\n0 0\n10 8 3 2\n2 2\n1 3\n1 1\n0 1\n3 4\n3 3 3 2\n1 2\n2 1\n1 1\n0 1\n0 0\n0 0 0 0"
],
"output": [
"2\n3\n8\n1\n3\n6"
]
} | {
"input": [
"2 1 1 1\n1 1\n0 0\n1 3 2 1\n2 1\n2 1\n0 0\n10 8 3 2\n2 2\n1 2\n1 1\n0 1\n3 4\n3 3 3 2\n1 2\n2 1\n1 1\n0 1\n0 0\n0 0 0 0",
"2 1 1 1\n1 1\n0 0\n1 3 2 1\n2 1\n2 1\n0 0\n10 8 3 2\n2 2\n1 3\n1 1\n0 1\n3 4\n3 3 3 2\n1 2\n1 1\n1 1\n0 1\n0 0\n0 0 0 0",
"2 1 1 1\n1 0\n0 0\n1 3 2 1\n2 1\n2 1\n0 0\n10 ... |
p01248 Text Justification | You are hired by the ∀I¶אΞ℘, an extraterrestrial intelligence, as a programmer of their typesetting system. Your task today is to design an algorithm for text justification.
Text justification is to equalize the line widths as much as possible by inserting line breaks at appropriate posi- tions, given a word sequence ... | {
"input": [],
"output": []
} | {
"input": [
"4 10\n8\n6\n9\n1\n4 7\n1\n2\n3\n4\n0 0"
],
"output": [
"Case 1: 4\nCase 2: 1"
]
} | {
"input": [
"4 10\n8\n6\n9\n1\n4 7\n1\n2\n6\n4\n0 0",
"4 10\n8\n6\n9\n1\n4 7\n1\n0\n6\n0\n0 0",
"4 10\n2\n6\n9\n1\n4 7\n1\n0\n6\n0\n0 0",
"4 10\n0\n6\n9\n1\n4 7\n1\n2\n3\n4\n0 0",
"4 10\n2\n6\n9\n1\n4 7\n1\n2\n6\n4\n0 0",
"4 10\n7\n6\n9\n1\n4 7\n1\n0\n6\n0\n0 0",
"4 10\n3\n6\n9\n1\n4 7\n1... |
p01409 Common Palindromes | 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 practice is to improve the ability to read messages hidden from sentences by searching for palindromes in strings. There may be many palindromes, so I'd like to count the number w... | {
"input": [],
"output": []
} | {
"input": [
"ICPC\nCPCPC",
"MYON\nUSAGI",
"BABBAB\nABBA"
],
"output": [
"10",
"0",
"14"
]
} | {
"input": [
"ICPC\nCOCPC",
"MYON\nUSAHI",
"BBBBAB\nABBA",
"ICPC\nCOCPB",
"ICPD\nCOCPB",
"ICPD\nCOBPB",
"ICPD\nCOBOB",
"EIEN\nCEKEP",
"NYON\nUSAHI",
"NYNN\nUSAHI",
"NYNN\nIHASU",
"NYNN\nUTAHI",
"ICPD\nBPBOC",
"NNYN\nUTAHI",
"ICOD\nBPBOC",
"NNYN\nUIAHT",
... |
p01563 Connect | You are playing a solitaire puzzle called "Connect", which uses several letter tiles.
There are R × C empty cells. For each i (1 ≤ i ≤ R), you must put a string si (1 ≤ |si| ≤ C) in the i-th row of the table, without changing the letter order. In other words, you choose an integer sequence {aj} such that 1 ≤ a1 < a2 <... | {
"input": [],
"output": []
} | {
"input": [
"4 16\nINTERNATIONAL\nCOLLEGIATE\nPROGRAMMING\nCONTEST",
"2 4\nACM\nICPC",
"2 9\nPROBLEMF\nCONNECT"
],
"output": [
"18",
"2",
"6"
]
} | {
"input": [
"4 16\nINTERNATIONAL\nCOLLEGIATE\nPROGRAMMJNG\nCONTEST",
"4 16\nLANOITANRETNI\nCOLLEGIATE\nPROGRAMMJNG\nCONTEST",
"7 16\nLANOIUANRETNI\nCOLLAGIFTE\nPRNGRAMMJNG\nTSETNOC",
"7 16\nLANOIUANRETNI\nCOGLALIFTE\nPRNGRAMMJNG\nTSETNOC",
"8 16\nLANOIUANRETNI\nCOGLALIFTE\nPRNGRAMNJNG\nTSETNOC",
... |
p01725 Unordered Operators | One day, Ikta, an elementary school student, received a piece of paper with mathematical formulas from his grandfather. Apparently, the grandfather will give you as much money as the answer to the formula. Ikta has only learned addition, subtraction, and multiplication, so only addition, subtraction, and multiplication... | {
"input": [],
"output": []
} | {
"input": [
"1-2+3-4+5-6*0",
"(1989967-3*1-211+4487)",
"3-2*3",
"(5-3*4)*(0-2+1)"
],
"output": [
"3",
"8511076028",
"3",
"21"
]
} | {
"input": [
"(1989967-3*2-211+4487)",
"3-2)3",
"(5-3*4)+(0-2+1)",
"3)2-3",
"0-2+3-4+5-6*0",
"(1998967-3*1-211+4487)",
"(5-3*4)*(0-1+1)",
"(199896743*1-211+4-87)",
"(5-3*4)*(0-1+2)",
"0*6-5+5-3+2-0",
"(199876743*1-211+4-89)",
"(5-3*3)*(0-1+2)",
"(199877743*1-211+4-8... |
p01863 Miko Mi String | F: Miko Mi String-
story
Mikko Mikkomi ~! Everyone's idol, Miko Miko Tazawa! Today ~, with Mikoto ~, practice the string algorithm, let's do it ☆
Miko's special ~~ character making ~~ The slogan "MikoMikomi" becomes "MikoMikoMi" in Roman letters! In other words, if A = “Mi” and B = “Ko”, you can write in the form of... | {
"input": [],
"output": []
} | {
"input": [
"NicoNicoNi"
],
"output": [
"Love Nico!"
]
} | {
"input": [
"iNociNociN",
"iNobiNociN",
"iNoaiNociN",
"iNoaiNochN",
"NhcoNiaoNi",
"NhcoNiNoai",
"NhcoNjNoai",
"NhboNjNoai",
"NhbNNjooai",
"NhbNOjooai",
"jhbNONooai",
"jhbOONooai",
"jhbOOoNoai",
"jibOOoNoai",
"jibONoNoai",
"iibONoNoai",
"iNbOioNoai",... |
p01998 Prime Number | problem
One day, Sosusa, who loves prime numbers, was playing with the pair $ (p, q) $, where $ p + q $ is a prime number. Suddenly, Sosusa wondered how many of these pairs were prime numbers with $ p $ and $ q $ both less than or equal to $ N $. Find the number on your behalf.
output
Output the number of pairs. A... | {
"input": [],
"output": []
} | {
"input": [
"3"
],
"output": [
"2"
]
} | {
"input": [
"5",
"1",
"4",
"12",
"23",
"38",
"49",
"73",
"70",
"102",
"149",
"116",
"225",
"253",
"141",
"364",
"548",
"180",
"229",
"337",
"302",
"269",
"439",
"733",
"430",
"195",
"463",
"925",
"577"... |
p02144 Loss | Problem
You were asked by a company to create a program. The company has $ N $ jobs, and each job is numbered from $ 1 $ to $ N $. There are $ M_i $ prerequisite jobs $ X_ {i, j} $ in job $ i $, and work $ X_ {i, j} $ is performed before job $ X_ {i, j} $. And work $ i $ suffers a great loss.
So ask you to find the n... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 2\n1 3\n2 1 2\n3 1 3 5\n0",
"2\n1 1\n0",
"3\n3 2 1 2\n0\n1 2"
],
"output": [
"1",
"1",
"1"
]
} | {
"input": [
"5\n1 2\n1 3\n2 1 3\n3 1 3 5\n0",
"5\n1 2\n2 3\n2 1 3\n3 1 3 5\n0",
"5\n1 2\n0 3\n2 1 2\n3 1 3 5\n0",
"5\n1 2\n2 3\n2 1 3\n3 1 4 3\n0",
"5\n0 2\n1 3\n2 1 3\n3 1 3 5\n0",
"5\n0 2\n1 3\n2 1 2\n3 1 3 5\n0",
"3\n3 2 1 2\n0\n1 1",
"5\n0 2\n1 3\n2 1 2\n3 1 3 1\n0",
"5\n0 2\n... |
p02285 Binary Search Tree III | Write a program which performs the following operations to a binary search tree $T$ by adding delete operation to B: Binary Search Tree II.
* insert $k$: Insert a node containing $k$ as key into $T$.
* find $k$: Report whether $T$ has a node containing $k$.
* delete $k$: Delete a node containing $k$.
* print: Print t... | {
"input": [],
"output": []
} | {
"input": [
"18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint"
],
"output": [
"yes\nyes\nyes\nno\nno\nno\nyes\nyes\n 1 2 3 7 8 22\n 8 2 1 3 7 22\n 1 2 8 22\n 8 2 1 22"
]
} | {
"input": [
"18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 1\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint",
"18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 4\nfind 7\npr... |
p02432 Deque | For a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations:
* push($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$.
* randomAccess($p$): Print element $a_p$.
* pop($d$): Delete the first element of $A$, if $d = ... | {
"input": [],
"output": []
} | {
"input": [
"11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 2\n2 0\n2 1\n0 0 4\n1 0\n1 1"
],
"output": [
"2\n1\n3\n4\n1"
]
} | {
"input": [
"11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n1 1",
"11\n0 0 1\n0 0 2\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n2 1",
"11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n1 0\n2 1",
"11\n0 0 1\n0 0 3\n0 1 3\n1 0\n1 1\n1 0\n2 0\n2 1\n0 0 4\n2 0\n2 1",
"11\n0 0 ... |
acugray | Problem Description
Two mathematicians Mr.X and Mr.Y are discussing about a problem. Mr.X says that the ans is a and Mr.Y says the ans is b(where a and b being string containing 0's and 1's). After arguing for a long time they find that Mr.X was giving the answer in binary code where as Mr.Y was giving the answer in Gr... | {
"input": [],
"output": []
} | {
"input": [
"3\n100\n011\n10001"
],
"output": [
"110\n010\n11001"
]
} | {
"input": [
"3\n000\n011\n10001",
"3\n100\n111\n10001",
"3\n100\n111\n10000",
"3\n000\n111\n10000",
"3\n000\n110\n10000",
"3\n001\n110\n10000",
"3\n001\n010\n10000",
"3\n001\n010\n10100",
"3\n001\n011\n10100",
"3\n101\n011\n10100",
"3\n101\n010\n10100",
"3\n101\n010\n1... |
chefsock | Today, Chef woke up to find that he had no clean socks. Doing laundry is such a turn-off for Chef, that in such a situation, he always buys new socks instead of cleaning the old dirty ones. He arrived at the fashion store with money rupees in his pocket and started looking for socks. Everything looked good, but then Ch... | {
"input": [],
"output": []
} | {
"input": [
"1 2 3",
"1 2 6"
],
"output": [
"Unlucky Chef\n",
"Lucky Chef\n"
]
} | {
"input": [
"0 2 3",
"1 2 9",
"1 1 9",
"1 2 7",
"0 2 6",
"2 2 9",
"2 1 9",
"1 2 5",
"0 4 6",
"2 2 5",
"1 2 11",
"0 2 4",
"1 2 14",
"0 2 7",
"1 4 6",
"2 2 14",
"2 1 11",
"1 2 4",
"-1 4 6",
"2 2 11",
"0 1 4",
"0 2 14",
"1 3 6",... |
double | The palindrome is a string that can be read the same way from left to right and from right to left. For example, strings "aaaaa", "1221", "bbaabb" are palindromes, however the string "chef" is not a palindrome because if we read it from right to left, we will obtain "fehc" that is not the same as "chef".
We call a str... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n4"
],
"output": [
"2\n4\n"
]
} | {
"input": [
"2\n2\n0",
"2\n4\n0",
"2\n8\n0",
"2\n10\n0",
"2\n15\n0",
"2\n0\n0",
"2\n24\n0",
"2\n6\n1",
"2\n0\n2",
"2\n10\n2",
"2\n6\n2",
"2\n2\n2",
"2\n9\n2",
"2\n6\n4",
"2\n1\n4",
"2\n6\n7",
"2\n12\n1",
"2\n12\n2",
"2\n6\n10",
"2\n12\n4... |
jeryfibo | Today, as usual, Jerry comes up with a new puzzle for Tom. Jerry knows very well that Tom is well aware of the concepts of fibonacci series. So he intends to present the problem with a twist. By choosing any random integer Jerry asks Tom to tell whether the given number is a fibonacci number.
Input
The first line o... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n3\n7"
],
"output": [
"is fibo\nis fibo\nnot fibo\n"
]
} | {
"input": [
"3\n1\n5\n7",
"3\n1\n5\n1",
"3\n1\n6\n2",
"3\n1\n4\n7",
"3\n4\n24\n7",
"3\n4\n10\n1",
"3\n19\n5\n11",
"3\n4\n1\n2",
"3\n1\n5\n2",
"3\n1\n2\n2",
"3\n1\n2\n7",
"3\n2\n5\n7",
"3\n1\n3\n2",
"3\n2\n10\n7",
"3\n1\n12\n2",
"3\n3\n10\n7",
"3\n3\... |
noways | John wanted to buy gifts for some k children in his apartments on christmas.
He goes to the shop and the shopkeeper shows him n gifts.
How many ways John can choose k gifts from n total gifts ?.
Since answer could be large print the answer mod 1000000007
NOTE : ordering of the gifts do not matter
Different order of sa... | {
"input": [],
"output": []
} | {
"input": [
"1\n5 1"
],
"output": [
"5"
]
} | {
"input": [],
"output": []
} |
sgarden | All bandits are afraid of Sheriff. Sheriff constantly fights crime, but when bandits lay low, he gets bored and starts to entertain himself.
This time Sheriff gathered all the bandits in his garden and ordered them to line up. After the whistle all bandits should change the order in which they stand.
Sheriff gave all... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n1 2 3\n5\n2 3 1 5 4"
],
"output": [
"1\n6\n"
]
} | {
"input": [
"2\n2\n1 2 3\n5\n2 3 1 5 4",
"2\n3\n1 2 3\n5\n4 3 1 5 2",
"2\n3\n2 1 3\n5\n4 3 1 5 2",
"2\n2\n1 2 3\n5\n4 3 1 5 2",
"2\n1\n1 2 3\n5\n2 3 1 5 4",
"2\n1\n1 2 3\n5\n4 3 1 5 2",
"2\n2\n2 1 3\n5\n4 3 1 5 2",
"2\n2\n1 2 3\n5\n4 3 2 5 1"
],
"output": [
"1\n6\n",
"1\n5... |
1110_G. Tree-Tac-Toe | The tic-tac-toe game is starting on a tree of n vertices. Some vertices are already colored in white while the remaining are uncolored.
There are two players — white and black. The players make moves alternatively. The white player starts the game. In his turn, a player must select one uncolored vertex and paint it in... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n1 2\n1 3\n1 4\nNNNW\n5\n1 2\n2 3\n3 4\n4 5\nNNNNN\n"
],
"output": [
"White\nDraw\n"
]
} | {
"input": [
"2\n4\n1 2\n1 3\n1 4\nWNNN\n5\n1 2\n2 3\n3 4\n4 5\nNNNNN\n",
"2\n4\n1 2\n1 3\n2 4\nNNNW\n5\n1 2\n2 3\n3 4\n4 5\nNNNNN\n",
"2\n4\n1 2\n2 3\n1 4\nWNNN\n5\n1 3\n2 3\n3 4\n3 5\nNNNNN\n",
"2\n4\n1 2\n1 3\n1 4\nWNNN\n5\n1 2\n2 3\n2 4\n4 5\nNNNNN\n",
"2\n4\n1 2\n1 3\n2 4\nNNNW\n5\n1 2\n2 3\n... |
1408_C. Discrete Acceleration | There is a road with length l meters. The start of the road has coordinate 0, the end of the road has coordinate l.
There are two cars, the first standing at the start of the road and the second standing at the end of the road. They will start driving simultaneously. The first car will drive from the start to the end ... | {
"input": [],
"output": []
} | {
"input": [
"5\n2 10\n1 9\n1 10\n1\n5 7\n1 2 3 4 6\n2 1000000000\n413470354 982876160\n9 478\n1 10 25 33 239 445 453 468 477\n"
],
"output": [
"3\n3.666666666666667\n2.047619047619048\n329737645.75\n53.7\n"
]
} | {
"input": [
"5\n2 10\n1 9\n1 10\n1\n5 7\n1 2 3 4 6\n2 1000000000\n413470354 988915189\n9 478\n1 10 25 33 239 445 453 468 477\n",
"5\n2 10\n1 9\n1 10\n1\n5 7\n1 2 3 4 6\n2 1000000000\n413470354 988915189\n9 478\n2 10 25 33 239 445 453 468 477\n",
"5\n2 10\n1 6\n1 10\n1\n5 7\n1 2 3 4 6\n2 1000000000\n41347... |
1475_F. Unusual Matrix | You are given two binary square matrices a and b of size n × n. A matrix is called binary if each of its elements is equal to 0 or 1. You can do the following operations on the matrix a arbitrary number of times (0 or more):
* vertical xor. You choose the number j (1 ≤ j ≤ n) and for all i (1 ≤ i ≤ n) do the follow... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n110\n001\n110\n\n000\n000\n000\n3\n101\n010\n101\n\n010\n101\n010\n2\n01\n11\n\n10\n10\n"
],
"output": [
"\nYES\nYES\nNO\n"
]
} | {
"input": [
"3\n3\n110\n001\n110\n\n000\n000\n000\n3\n101\n010\n101\n\n110\n101\n010\n2\n01\n11\n\n10\n10\n",
"3\n3\n111\n001\n110\n\n000\n000\n000\n3\n101\n010\n101\n\n010\n101\n010\n2\n01\n11\n\n10\n10\n",
"3\n3\n110\n001\n110\n\n000\n010\n000\n3\n101\n010\n101\n\n110\n101\n010\n2\n01\n11\n\n10\n10\n",... |
530_E. Sum and product | You are given integers N and D. Find N positive integers x1...xN such that the difference of their product and their sum equals D.
Input
The only line of input contains integers N (2 ≤ N ≤ 1000) and D (0 ≤ D ≤ 1000).
Output
Output N integers that satisfy the given condition in non-decreasing order (in a single line... | {
"input": [],
"output": []
} | {
"input": [
"2 1\n",
"3 5\n"
],
"output": [
"2 3\n",
"1 2 8\n"
]
} | {
"input": [],
"output": []
} |
720_E. Cipher | Borya has recently found a big electronic display. The computer that manages the display stores some integer number. The number has n decimal digits, the display shows the encoded version of the number, where each digit is shown using some lowercase letter of the English alphabet.
There is a legend near the display, t... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n42\nabcdefghij\njihgfedcba\n2\n42\naaaaaaaaaa\naaaaaaaaaa\n1\n2\nabcdabcdff\n"
],
"output": [
"0\n58\n2\n"
]
} | {
"input": [
"3\n2\n42\nabcdffghij\njihgfedcba\n2\n42\naaaaaaaaaa\naaaaaaaaaa\n1\n2\nabcdabcdff\n",
"3\n2\n42\nabcdffghij\njihgfedcba\n2\n10\naaaaaaaaaa\naaaaaaaaaa\n1\n2\n`bcdabcdff\n",
"3\n2\n42\nabcdefghij\njihgfedcba\n2\n42\naaaaaaaaaa\naaaaaaaaaa\n1\n3\nabcdabcdff\n",
"3\n2\n42\nabcdffghij\njihgf... |
835_C. Star sky | The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c).
Over time the stars twinkle. At moment 0 the i-th star has brightness si. Let at moment t some star has brightness x. ... | {
"input": [],
"output": []
} | {
"input": [
"3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 50 50 51 51\n",
"2 3 3\n1 1 1\n3 2 0\n2 1 1 2 2\n0 2 1 4 5\n5 1 1 5 5\n"
],
"output": [
"3\n3\n5\n0\n",
"3\n0\n3\n"
]
} | {
"input": [
"2 3 3\n1 1 1\n3 2 0\n2 1 1 1 2\n0 2 1 4 5\n5 1 1 5 5\n",
"3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 60 50 51 51\n",
"2 3 3\n1 2 1\n3 2 0\n2 1 1 2 2\n0 2 1 7 5\n5 1 1 5 1\n",
"2 3 3\n1 2 1\n3 2 0\n0 1 1 2 2\n0 2 1 7 5\n5 1 1 5 5\n",
"2 3 3\n1 2 1\n3 2 0\n0 1 1... |
bholu-the-pandit-1 | Bholu the Pandit on this New Year wanted to divide his Cuboidal Packaging block into cubes.
But he loves uniformity so he asks you to divide it such a way that all the cubes are of same size and volume of individual cube is as large as possible.
Note: He will utilize whole volume i.e volume of cuboid before dividing i... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 4 6\n1 2 3\n\nSAMPLE"
],
"output": [
"2 6\n1 6\n"
]
} | {
"input": [
"2\n2 3 6\n1 2 3\n\nSAMPLE",
"2\n2 3 6\n1 2 6\n\nSAMPLE",
"2\n2 4 6\n1 4 3\n\nSAMPLE",
"2\n3 3 6\n1 2 3\n\nSAMPLD",
"2\n2 4 6\n1 7 3\n\nSAMPME",
"2\n3 3 6\n1 3 3\n\nSAMPLD",
"2\n3 3 6\n1 2 1\n\nSAMPLD",
"2\n3 3 11\n1 2 1\n\nSAMPLD",
"2\n3 4 11\n1 2 1\n\nSAMPLD",
"2... |
integration-1 | Bitoholic is an inhabitant of the planet Neo in a galaxy far far away. Their civilization is studies an advanced form of mathematics. However, rules of calculus are a bit different there. On his planet, integration and differentiation techniques are called alpha and beta operations respectively and are defined as:
alp... | {
"input": [],
"output": []
} | {
"input": [
"2 \n1 6 10 11 5 \n2 2 4 2 1\n\nSAMPLE"
],
"output": [
"Case #1: 1\nCase #2: 3\n"
]
} | {
"input": [
"2 \n1 6 14 11 5 \n2 2 4 2 1\n\nSAMPLE",
"2 \n1 6 14 11 5 \n3 2 4 2 1\n\nSAMPLE",
"2 \n1 6 11 11 1 \n3 2 4 2 1\n\nSAMPLE",
"2 \n1 6 14 11 10 \n3 2 4 0 1\n\nSAMPLE",
"2 \n1 4 8 19 5 \n3 2 4 2 1\n\nSAMPLE",
"2 \n1 6 14 11 2 \n2 2 4 2 1\n\nSAMPLE",
"2 \n1 6 11 11 1 \n2 2 4 2 1\n\... |
one-in-zillion-2 | The time is 1st January 20000014 Gazu is depressed with his life as he thinks there is nothing unique about him. One day he meets a travelling coder, Gazu tells him why he is depressed, to which coder replies “Everyone is one in a zillion my brother”. The coder explained it like this.
Considering every man and woman m... | {
"input": [],
"output": []
} | {
"input": [
"3\n140\n310\n30\n\nSAMPLE"
],
"output": [
"32\n2048\n4\n"
]
} | {
"input": [
"3\n245\n310\n30\n\nSAMPLE",
"3\n245\n260\n30\n\nSAMPLE",
"3\n241\n364\n30\n\nSAMPLE",
"3\n140\n310\n30\n\nS@MPLE",
"3\n111\n260\n30\n\nSAMPLE",
"3\n241\n205\n30\n\nSAMPLE",
"3\n382\n364\n30\n\nSAMPLE",
"3\n286\n205\n30\n\nSAMPKE",
"3\n517\n205\n30\n\nEJPMAS",
"3\n... |
random-generator | Aparna recently created a random number generator and now she wants Harsh to check if it works fine.
She gives Harsh an array containing N numbers generated from this random number generator of hers, and two integers K and P. If the given array contains more than or equal to K numbers in the range X-P to X+P (both inc... | {
"input": [],
"output": []
} | {
"input": [
"1\n5 2 2\n2 9 6 8 4\n\nSAMPLE"
],
"output": [
"NO"
]
} | {
"input": [
"1\n5 2 2\n4 9 6 8 4\n\nSAMPLE",
"1\n5 2 0\n2 9 6 3 4\n\nSAMPLF",
"1\n5 2 2\n4 0 6 8 4\n\nSAMPLE",
"1\n5 2 2\n2 9 6 5 4\n\nSAMPLE",
"1\n5 2 2\n4 9 6 8 4\n\nPAMSLE",
"1\n5 2 0\n4 0 6 8 4\n\nSAMPLE",
"1\n5 2 2\n2 9 6 5 4\n\nSAMPLF",
"1\n5 2 2\n4 9 6 12 4\n\nPAMSLE",
"1\n... |
the-tiled-footpath-on-marine-drive | X and Y are sitting beside a footpath on a bench on Marine Drive having a look at the beautiful sea.
(Anyone from Mumbai here ?). X is a top coder who studies at DA-IICT. His friend Y studies at some
local college from Mumbai. X always wants to show off his coding prowess so he asks puzzles to Y
and Y (being not so i... | {
"input": [],
"output": []
} | {
"input": [
"1\n5 2\n\nSAMPLE"
],
"output": [
"0"
]
} | {
"input": [],
"output": []
} |
p02550 AtCoder Beginner Contest 179 - Sequence Sum | Let us denote by f(x, m) the remainder of the Euclidean division of x by m.
Let A be the sequence that is defined by the initial value A_1=X and the recurrence relation A_{n+1} = f(A_n^2, M). Find \displaystyle{\sum_{i=1}^N A_i}.
Constraints
* 1 \leq N \leq 10^{10}
* 0 \leq X < M \leq 10^5
* All values in input are ... | {
"input": [],
"output": []
} | {
"input": [
"10000000000 10 99959",
"6 2 1001",
"1000 2 16"
],
"output": [
"492443256176507",
"1369",
"6"
]
} | {
"input": [
"10000000000 2 99959",
"1000 0 16",
"10010000000 2 99959",
"10010000100 2 99959",
"10000000000 15 99959",
"6 2 1101",
"1100 2 16",
"10010001000 2 99959",
"11010000100 2 99959",
"1000 1 20",
"10000000000 15 114525",
"6 4 1101",
"1100 1 16",
"11110000... |
p02681 AtCoder Beginner Contest 167 - Registration | Takahashi wants to be a member of some web service.
He tried to register himself with the ID S, which turned out to be already used by another user.
Thus, he decides to register using a string obtained by appending one character at the end of S as his ID.
He is now trying to register with the ID T. Determine whether... | {
"input": [],
"output": []
} | {
"input": [
"snuke\nsnekee",
"a\naa",
"chokudai\nchokudaiz"
],
"output": [
"No",
"Yes",
"Yes"
]
} | {
"input": [
"snuke\nsnelee",
"b\nba",
"a\nba",
"choktdai\nchokudaiz",
"nsuke\nsnelee",
"choktdai\nbhokudaiz",
"nuske\nsnelee",
"b\nab",
"iadtkohc\nbhokudaiz",
"nurke\nsnelee",
"a\nab",
"iadtkohc\nkhobudaiz",
"runke\nsnelee",
"a\nbb",
"iadtkohc\nkhobud`iz",
... |
p02809 Dwango Programming Contest 6th - Arrangement | Niwango has N cards, numbered 1,2,\ldots,N. He will now arrange these cards in a row.
Niwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the answer is yes, also find the lexicographically smallest such arrangeme... | {
"input": [],
"output": []
} | {
"input": [
"4\n2 3 4 1",
"2\n2 1",
"13\n2 3 4 5 6 7 8 9 10 11 12 13 12"
],
"output": [
"1 3 2 4",
"-1",
"1 3 2 4 6 5 7 9 8 10 12 11 13"
]
} | {
"input": [
"13\n2 3 4 5 6 7 8 5 10 11 12 13 12",
"13\n2 3 4 0 6 7 8 5 4 11 12 13 12",
"13\n2 3 4 0 6 2 8 5 4 11 13 13 12",
"4\n2 3 4 0",
"13\n2 3 4 5 6 7 4 9 10 11 12 13 12",
"13\n1 3 4 0 6 7 8 5 4 11 12 13 12",
"13\n2 3 4 0 9 2 8 5 4 11 12 13 12",
"13\n2 3 4 5 6 7 4 9 10 11 13 13 12... |
p02946 AtCoder Beginner Contest 137 - One Clue | There are 2000001 stones placed on a number line. The coordinates of these stones are -1000000, -999999, -999998, \ldots, 999999, 1000000.
Among them, some K consecutive stones are painted black, and the others are painted white.
Additionally, we know that the stone at coordinate X is painted black.
Print all coordi... | {
"input": [],
"output": []
} | {
"input": [
"4 0",
"1 100",
"3 7"
],
"output": [
"-3 -2 -1 0 1 2 3",
"100",
"5 6 7 8 9"
]
} | {
"input": [
"4 -1",
"2 100",
"3 14",
"2 -1",
"4 100",
"5 14",
"4 110",
"5 20",
"4 010",
"5 21",
"4 011",
"5 35",
"2 011",
"10 35",
"2 010",
"9 35",
"2 000",
"9 61",
"9 7",
"9 10",
"2 18",
"1 18",
"1 34",
"2 34",
"1 11... |
p03082 ExaWizards 2019 - Modulo Operations | Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i.
He wrote an integer X on the blackboard, then performed the following operation N times:
* Choose one element from S and remove it.
* Let x be the number written on the blackboard now, and y be the integer removed from S. Repla... | {
"input": [],
"output": []
} | {
"input": [
"5 82\n22 11 6 5 13",
"10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009",
"2 19\n3 7"
],
"output": [
"288",
"279669259",
"3"
]
} | {
"input": [
"5 82\n22 11 6 7 13",
"10 100000\n13715 50001 50002 50003 50004 50005 50006 50007 50008 50009",
"2 19\n3 11",
"5 134\n22 11 6 7 13",
"10 100000\n13715 50001 50002 50003 50004 50005 50006 50532 50008 50009",
"10 000000\n13715 50001 50002 50003 50004 50005 50006 50532 50008 50009",
... |
p03227 Tenka1 Programmer Beginner Contest - Measure | You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
Constraints
* The length of S is 2 or 3.
* S consists of lowercase English letters.
Input
Input is given from Standard Input i... | {
"input": [],
"output": []
} | {
"input": [
"abc",
"ac"
],
"output": [
"cba",
"ac"
]
} | {
"input": [
"acc",
"bc",
"acb",
"cb",
"adb",
"cc",
"`cb",
"dc",
"bc`",
"cd",
"cb`",
"ec",
"cba",
"fc",
"cab",
"cf",
"bac",
"df",
"b`c",
"bf",
"c`b",
"fb",
"d`b",
"fa",
"b`d",
"af",
"d`a",
"ae",
"a`d",
... |
p03375 AtCoder Regular Contest 096 - Everything on It | In "Takahashi-ya", a ramen restaurant, basically they have one menu: "ramen", but N kinds of toppings are also offered. When a customer orders a bowl of ramen, for each kind of topping, he/she can choose whether to put it on top of his/her ramen or not. There is no limit on the number of toppings, and it is allowed to ... | {
"input": [],
"output": []
} | {
"input": [
"3 1000000009",
"2 1000000007",
"3000 123456791",
"50 111111113"
],
"output": [
"118",
"2",
"16369789",
"1456748"
]
} | {
"input": [
"4 1000000007",
"5 111111113",
"6 111111113",
"7 111111113",
"8 111111113",
"3 937953985",
"2 1755323823",
"73 111111113",
"8 153159299",
"1 937953985",
"76 111111113",
"9 153159299",
"12 153159299",
"19 153159299",
"6 1000000009",
"11 11111... |
p03537 CODE FESTIVAL 2017 Final (Parallel) - Combination Lock | Ringo has a string S.
He can perform the following N kinds of operations any number of times in any order.
* Operation i: For each of the characters from the L_i-th through the R_i-th characters in S, replace it with its succeeding letter in the English alphabet. (That is, replace `a` with `b`, replace `b` with `c` a... | {
"input": [],
"output": []
} | {
"input": [
"bixzja\n2\n2 3\n3 6",
"abc\n1\n2 2",
"cassert\n4\n1 2\n3 4\n1 1\n2 2"
],
"output": [
"YES",
"NO",
"YES"
]
} | {
"input": [
"bixzja\n2\n2 0\n3 6",
"abc\n1\n2 3",
"cassert\n4\n1 2\n3 4\n1 1\n2 0",
"bixzja\n1\n2 0\n3 6",
"cassert\n3\n1 2\n3 4\n1 1\n2 0",
"bixzja\n1\n2 0\n3 5",
"cassert\n0\n1 2\n3 4\n1 1\n2 0",
"cassert\n0\n0 2\n3 4\n1 1\n2 0",
"ajzxib\n2\n2 3\n3 6",
"cba\n1\n2 2",
"ca... |
p03696 AtCoder Beginner Contest 064 - Insertion | You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a correct bracket sequence.
Here, a correct bracket sequence is defined as follows:
* `()` is a correct bracket sequence.
* If X is a correct bracket sequence, the concatenation of `(`, X ... | {
"input": [],
"output": []
} | {
"input": [
"8\n))))((((",
"3\n())",
"6\n)))())"
],
"output": [
"(((())))(((())))",
"(())",
"(((()))())"
]
} | {
"input": [
"8\n(((())))",
"3\n)()",
"6\n)())))",
"3\n)))",
"6\n())())",
"6\n))())(",
"6\n))(()(",
"8\n))))(()(",
"6\n)))()(",
"8\n)((())))",
"6\n()(())",
"6\n)(())(",
"8\n))))((()",
"8\n))((()))",
"6\n())(()",
"8\n)))((())",
"6\n)(()))",
"6\n))... |
p03851 AtCoder Regular Contest 066 - Contest with Drinks Hard | 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... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 1 4 1 1\n2\n3 2\n3 10",
"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"
],
"output": [
"9\n2",
"34\n35\n5\n11\n35\n17\n25\n26\n28\n21"
]
} | {
"input": [
"5\n1 1 4 1 1\n2\n3 2\n3 20",
"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",
"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",
"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\... |
p04018 AtCoder Regular Contest 060 - Best Representation | Let x be a string of length at least 1. We will call x a good string, if for any string y and any integer k (k \geq 2), the string obtained by concatenating k copies of y is different from x. For example, `a`, `bbc` and `cdcdc` are good strings, while `aa`, `bbbb` and `cdcdcd` are not.
Let w be a string of length at l... | {
"input": [],
"output": []
} | {
"input": [
"ddd",
"aab",
"bcbc"
],
"output": [
"3\n1",
"1\n1",
"2\n3"
]
} | {
"input": [
"ddc",
"aaa",
"adad",
"bbcc",
"dec",
"aa`",
"ccbb",
"eec",
"aa_",
"ccbc",
"cee",
"ba_",
"cbbc",
"ece",
"_ab",
"ccba",
"eed",
"`ab",
"ccab",
"dee",
"`ba",
"bcac",
"eee",
"`b`",
"bcca",
"dfe",
"ab`",... |
p00102 Matrix-like Computation | Your task is to develop a tiny little part of spreadsheet software.
Write a program which adds up columns and rows of given table as shown in the following figure:
<image>
Input
The input consists of several datasets. Each dataset consists of:
n (the size of row and column of the given table)
1st row of the tab... | {
"input": [],
"output": []
} | {
"input": [
"4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0"
],
"output": [
"52 96 15 20 183\n 86 22 35 45 188\n 45 78 54 36 213\n 16 86 74 55 231\n 199 282 178 156 815\n 52 96 15 20 183\n 8... | {
"input": [
"4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n10 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0",
"4\n52 26 15 20\n86 22 35 45\n45 78 54 36\n10 86 74 55\n4\n52 96 15 20\n86 22 35 45\n45 78 54 36\n16 86 74 55\n0",
"4\n52 26 15 20\n143 22 35 45\n45 78 54 36\n10 86 74 55\n4\n52 ... |
p00235 Sergeant Rian | Under the command "Save Sergeant Ryan," Aiz's rescue team fought fierce battles with enemy forces in the floating city of Lee, Germany. They successfully joined the sergeant, but there were many enemy tanks and they could not call a rescue herio. So, in order to confuse the enemy tanks, they decided to carry out an ope... | {
"input": [],
"output": []
} | {
"input": [
"7\n1 2 5\n2 3 2\n3 4 3\n2 5 3\n5 6 3\n5 7 8\n0"
],
"output": [
"12"
]
} | {
"input": [
"7\n1 2 5\n2 3 2\n3 4 3\n2 5 3\n5 6 5\n5 7 8\n0",
"7\n1 2 5\n2 3 2\n3 4 3\n2 5 0\n5 6 10\n5 7 7\n0",
"7\n1 2 5\n1 3 2\n6 4 3\n2 5 3\n5 6 5\n5 7 8\n0",
"7\n1 2 5\n2 3 3\n3 4 3\n2 5 3\n5 6 5\n5 7 8\n0",
"7\n1 2 5\n1 3 2\n3 4 3\n2 5 3\n5 6 5\n6 7 8\n0",
"7\n1 2 5\n2 3 3\n3 4 3\n2 5 5... |
p00397 Kth XOR | Exclusive OR (XOR) is an operation on two binary numbers $ x $ and $ y $ (0 or 1) that produces 0 if $ x = y $ and $ 1 $ if $ x \ ne y $. This operation is represented by the symbol $ \ oplus $. From the definition: $ 0 \ oplus 0 = 0 $, $ 0 \ oplus 1 = 1 $, $ 1 \ oplus 0 = 1 $, $ 1 \ oplus 1 = 0 $.
Exclusive OR on two... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2 3",
"7 1\n1 0 1 0 1 0 1",
"5 10\n1 2 4 8 16"
],
"output": [
"2",
"1",
"7"
]
} | {
"input": [
"5 10\n1 2 5 8 16",
"5 10\n1 2 5 8 14",
"5 10\n1 2 5 14 14",
"8 10\n1 2 5 24 14",
"8 10\n1 2 5 24 11",
"8 10\n1 2 5 6 11",
"8 10\n0 2 5 6 11",
"8 10\n0 1 2 5 11",
"8 10\n0 1 2 5 9",
"8 10\n0 1 2 5 18",
"7 4\n1 0 2 2 18",
"8 10\n0 2 5 2 11",
"7 4\n1 2 2 ... |
p00612 Hedro's Hexahedron | Dr. Hedro is astonished. According to his theory, we can make sludge that can dissolve almost everything on the earth. Now he's trying to produce the sludge to verify his theory.
The sludge is produced in a rectangular solid shaped tank whose size is N × N × 2. Let coordinate of two corner points of tank be (-N/2, -N/... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n0"
],
"output": [
"24\n64"
]
} | {
"input": [
"2\n8\n0",
"2\n6\n0",
"2\n2\n0",
"2\n0\n0",
"2\n14\n0",
"2\n12\n0",
"2\n10\n0",
"2\n18\n0",
"2\n24\n0",
"2\n0\n1",
"2\n0\n-1",
"2\n0\n-2",
"2\n0\n2",
"2\n0\n4",
"2\n0\n-4",
"2\n0\n0",
"2\n0\n-1",
"2\n0\n-2",
"2\n6\n0",
"2\n2\... |
p00750 The Most Powerful Spell | Long long ago, there lived a wizard who invented a lot of "magical patterns." In a room where one of his magical patterns is drawn on the floor, anyone can use magic by casting magic spells! The set of spells usable in the room depends on the drawn magical pattern. Your task is to compute, for each given magical patter... | {
"input": [],
"output": []
} | {
"input": [
"4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 st\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0"
],
"output": [
"abracadabra\nNO\nopqr\nNO"
]
} | {
"input": [
"4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 0\n3 1 op\n3 2 op\n3 4 opq\n1 0 tt\n2 0 qr\n4 0 r\n2 1 0 1\n1 1 loooop\n0 0 0 0",
"4 7 0 2\n0 1 abra\n0 1 oil\n2 0 ket\n1 3 cada\n3 3 da\n3 2 bra\n2 3 ket\n2 2 0 1\n0 0 a\n0 1 b\n5 6 3 1\n3 1 op... |
p00888 The Two Men of the Japanese Alps | Two experienced climbers are planning a first-ever attempt: they start at two points of the equal altitudes on a mountain range, move back and forth on a single route keeping their altitudes equal, and finally meet with each other at a point on the route. A wise man told them that if a route has no point lower than the... | {
"input": [],
"output": []
} | {
"input": [
"6\n0 0\n3 4\n9 12\n17 6\n21 9\n33 0\n5\n0 0\n10 0\n20 0\n30 0\n40 0\n10\n0 0\n1 2\n3 0\n6 3\n9 0\n11 2\n13 0\n15 2\n16 2\n18 0\n7\n0 0\n150 997\n300 1\n450 999\n600 2\n750 998\n900 0\n0"
],
"output": [
"52.5\n40.0\n30.3356209304689\n10078.072814085803"
]
} | {
"input": [
"6\n0 0\n3 4\n9 12\n17 6\n21 0\n33 0\n5\n0 0\n10 0\n20 0\n30 0\n40 0\n10\n0 0\n1 2\n3 0\n6 3\n9 0\n11 2\n13 0\n15 2\n16 2\n18 0\n7\n0 0\n150 997\n300 1\n450 999\n600 2\n750 998\n900 0\n0",
"6\n0 -1\n3 4\n9 12\n17 6\n21 9\n33 0\n5\n0 0\n10 0\n20 0\n30 0\n40 0\n10\n0 0\n1 2\n3 0\n6 3\n9 0\n11 2\n13... |
p01019 Cheat Case | Hint
* One grid may be filled more than once
* Even if it can be represented by one line segment such as '1', it may be represented by two or more line segments.
Sample Input 1
Formula for Sample Input 1.
Sample Input 2
Sample Input 2 formula. Another character may get inside the smallest rectangle that covers one... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 1 1 5\n3 3 5 3\n4 2 4 4\n7 1 7 5",
"23\n1 1 3 1\n3 1 3 3\n3 3 1 3\n1 3 1 5\n1 5 3 5\n5 2 7 2\n7 2 7 4\n7 4 5 4\n5 4 5 6\n5 6 7 6\n11 4 13 4\n13 0 15 0\n15 0 15 4\n18 2 18 2\n21 5 23 5\n21 5 21 7\n21 7 23 7\n23 7 23 9\n23 9 21 9\n24 0 26 0\n24 0 24 4\n24 4 26 4\n26 0 26 4"
],
"output": [... | {
"input": [
"23\n1 1 3 1\n3 1 3 3\n3 3 1 3\n1 3 1 5\n1 5 3 5\n5 2 7 2\n7 2 7 4\n7 4 5 4\n5 4 5 6\n5 6 7 6\n11 4 13 4\n13 0 15 0\n15 0 15 4\n18 2 18 2\n21 5 23 5\n21 5 21 7\n21 7 23 7\n23 7 23 8\n23 9 21 9\n24 0 26 0\n24 0 24 4\n24 4 26 4\n26 0 26 4",
"23\n1 1 3 1\n3 1 3 3\n3 3 1 3\n1 3 1 5\n1 5 3 5\n5 2 7 2\... |
p01152 Reading a Chord | In this problem, you are required to write a program that enumerates all chord names for given tones.
We suppose an ordinary scale that consists of the following 12 tones:
C, C# , D, D# , E, F, F# , G, G# , A, A# , B
Two adjacent tones are different by a half step; the right one is higher. Hence, for example, the to... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 C E G\n3 C E G#\n4 C A G E\n5 F A C E D\n3 C D E"
],
"output": [
"C Em(+5)\nC(+5) E(+5) G#(+5)\nC(13) Am7 Am(+13)\nDm7(9) FM7(13)\nUNKNOWN"
]
} | {
"input": [
"5\n3 C E G\n3 C D G#\n4 C A G E\n5 F A C E D\n3 C D E",
"5\n3 C E G\n3 C D G#\n4 D A G E\n5 F A C E D\n2 C D E",
"5\n3 D E G\n3 C D G#\n4 D A G E\n5 F A C E D\n2 C D E",
"5\n3 C E G\n3 C E G#\n4 C A G E\n5 F A C E D\n3 C C E",
"5\n3 C E F\n3 C D G#\n4 C A G E\n5 F A C E D\n6 C D E",
... |
p01291 Wind Passages | Wind Corridor is a covered passageway where strong wind is always blowing. It is a long corridor of width W, and there are several pillars in it. Each pillar is a right prism and its face is a polygon (not necessarily convex).
In this problem, we consider two-dimensional space where the positive x-axis points the east... | {
"input": [],
"output": []
} | {
"input": [
"5 2\n4\n1 1\n1 2\n2 2\n2 1\n4\n3 3\n3 4\n4 4\n4 3\n0 0"
],
"output": [
"3.41421356"
]
} | {
"input": [
"5 2\n4\n1 1\n1 2\n2 4\n2 1\n4\n3 3\n3 4\n4 4\n4 3\n0 0",
"5 2\n4\n1 1\n2 2\n2 4\n2 1\n4\n3 3\n3 4\n0 4\n4 3\n0 0",
"5 2\n4\n1 1\n1 2\n2 2\n2 1\n4\n3 3\n3 4\n3 4\n4 3\n0 0",
"5 2\n4\n1 1\n2 2\n2 4\n2 0\n4\n3 3\n3 4\n2 4\n4 3\n0 0",
"5 2\n4\n2 1\n1 2\n2 2\n1 4\n4\n3 3\n3 4\n3 4\n4 3\n0... |
p01460 Matrix Operation | 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... | {
"input": [],
"output": []
} | {
"input": [
"2 1 3 6 12 1 2 1 2\nRL",
"2 1 3 6 12 1 2 1 2\nRH",
"39989 6 999983 999979 999961 1 1000 1 1000\nSR 1 39989\nSC 1 39989\nRL\nRH\nRR\nRV",
"2 1 3 6 12 1 2 1 2\nWR 1 1 1"
],
"output": [
"676636559",
"676547189",
"458797120",
"676573821"
]
} | {
"input": [
"2 1 3 2 12 1 2 1 2\nRL",
"2 1 3 3 12 1 2 1 2\nWR 1 1 1",
"2 1 3 3 12 1 2 1 2\nWR 2 1 1",
"2 1 3 3 12 1 2 1 2\nWR 2 1 0",
"2 1 3 8 12 1 2 1 2\nRL",
"2 1 3 3 12 2 2 1 2\nWR 1 1 1",
"2 1 3 2 12 1 2 2 2\nRL",
"2 1 3 6 12 1 2 1 2\nWR 2 1 0",
"2 0 3 8 12 1 2 1 2\nRL",
"... |
p01612 Company Trip | Company trip
Problem Statement
Your company has n employees. For a group of m employees (a_i, b_i), a_i is the boss of b_i.
When employee x is the actual boss of employee y, it means that at least one of the following holds.
* x is y's boss.
* There is an employee z who is the actual boss of y, and x is the boss o... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n1 2\n2 3\n3 4\n3 5"
],
"output": [
"1\n2"
]
} | {
"input": [
"10 4\n1 2\n2 3\n3 4\n3 5",
"10 4\n1 2\n2 4\n3 4\n4 5",
"10 4\n1 2\n1 4\n3 4\n4 5",
"10 4\n1 2\n1 4\n2 4\n4 9",
"10 4\n1 3\n2 3\n3 4\n3 5",
"10 4\n1 3\n2 4\n3 4\n3 5",
"18 4\n1 2\n2 3\n3 4\n2 5",
"10 4\n1 2\n2 3\n3 4\n4 5",
"10 4\n1 2\n1 3\n3 4\n4 9",
"10 4\n1 2\n1... |
p01772 A-Z Cat | A: A-Z Cat / A-Z Cat
story
Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. It's so cute. Aizu Nyan was asked by her friend Joy to take care of her cat. It is a rare cat called A-Z cat. Aizunyan named the A-Z cat he had entrus... | {
"input": [],
"output": []
} | {
"input": [
"AIZUNYANPEROPERO"
],
"output": [
"AZ"
]
} | {
"input": [
"AOZUNYANPERIPERO",
"OREQIRMQEAYNUYOA",
"OREPIREPNAYNUZOA",
"OREPIRNPEAYNUZOA",
"OREQIRNPEAYNUZOA",
"OREQIRMPEAYNUZOA",
"AOZUNYAEPMRIQERO",
"OREQIRMQEAYNUZOA",
"ORFQIRMQEAYNUYOA",
"OREQIRNQEAYNUYOA",
"ORERIRNQEAYNUYOA",
"ORERIRNQEYANUYOA",
"ORERIANQEYRN... |
p01906 Weight Range | problem
There are many $ N $ colored balls of different weights in the queue. The queue is in ascending order from the beginning: $ 1,2,3, \ dots, N-1, N, 1,2,3, \ dots, N-1, N, 1,2,3, \ dots $ The balls are lined up, followed by the balls of color $ N $, followed by the balls of color $ 1 $. Balls of the same color w... | {
"input": [],
"output": []
} | {
"input": [
"8 2\n23 61 57 13 91 41 79 41"
],
"output": [
"170"
]
} | {
"input": [
"8 2\n23 85 57 13 91 41 79 41",
"8 2\n23 94 57 13 91 41 79 41",
"8 2\n23 70 57 13 91 41 79 41",
"8 2\n23 70 57 13 91 41 79 43",
"8 2\n46 70 57 13 91 41 79 43",
"8 4\n46 70 57 13 91 41 79 43",
"8 4\n46 70 57 10 91 41 79 43",
"8 4\n46 70 57 10 91 41 130 43",
"8 4\n46 70 ... |
p02044 Equal Split | 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... | {
"input": [],
"output": []
} | {
"input": [
"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"
],
"output": [
"280\n25\n800\n5"
]
} | {
"input": [
"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",
"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",
"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",
"3 300\n120 1... |
p02187 Substring Decomposition | F: Substring decomposition
problem
Given the two strings S and T and the integer k. Considering consecutive substrings of length k or more of T, determine if S can be constructed by concatenating them.
Where the string s = s_1 s_2 ... s_n is a contiguous substring s [l, r] = s_l s_ {l + 1} ... s_r (1 \ leq l \ leq r... | {
"input": [],
"output": []
} | {
"input": [
"abracadabra\ncadabra\n4"
],
"output": [
"Yes"
]
} | {
"input": [
"abracadabra\ncaeabra\n4",
"abracadabra\ncae`bra\n4",
"abracadabra\nbae`cra\n4",
"abracbdabra\nbae`cra\n4",
"abracbdabra\nbae`cr`\n4",
"abracbdabra\nb`e`cr`\n4",
"abracbdabra\nb`e`cr`\n6",
"abracbdabra\nbe``cr`\n6",
"arbadbcarba\nbe``cr`\n6",
"arbadbcarba\nbd``cr`\... |
p02329 Coin Combination Problem | You have 4 bags A, B, C and D each of which includes N coins (there are totally 4N coins). Values of the coins in each bag are ai, bi, ci and di respectively.
Find the number of combinations that result when you choose one coin from each bag (totally 4 coins) in such a way that the total value of the coins is V. You s... | {
"input": [],
"output": []
} | {
"input": [
"3 14\n3 1 2\n4 8 2\n1 2 3\n7 3 2",
"5 4\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1"
],
"output": [
"9",
"625"
]
} | {
"input": [
"3 14\n3 1 2\n4 8 2\n1 2 5\n7 3 2",
"5 4\n2 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1",
"5 4\n2 1 1 1 1\n1 1 1 1 1\n1 1 0 1 1\n1 1 1 1 1",
"5 4\n2 1 1 1 1\n1 1 1 1 1\n1 2 0 1 1\n1 1 1 1 1",
"5 4\n2 1 1 1 1\n1 1 1 1 1\n1 2 0 1 1\n1 2 1 1 1",
"3 14\n3 1 2\n4 8 2\n0 0 5\n7 0 4",
"... |
p02474 Multiplication of Big Integers | Multiplication of Big Integers
Given two integers $A$ and $B$, compute the product, $A \times B$.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the product in a line.
Constraints
* $-1 \times 10^{1000} \leq A, B \leq 10^{1000}$
Sample Input 1
5 8
Sample Ou... | {
"input": [],
"output": []
} | {
"input": [
"5 8"
],
"output": [
"40"
]
} | {
"input": [
"5 16",
"0 16",
"-1 9",
"-1 5",
"-2 5",
"-2 2",
"-1 2",
"-1 3",
"1 -8",
"1 -14",
"1 -18",
"1 -12",
"1 -21",
"1 -17",
"1 -25",
"1 -39",
"1 -67",
"2 -67",
"2 -134",
"3 -134",
"6 -134",
"6 -51",
"7 -51",
"3 -51",... |
aran01 | Oh my God!!! Someone is trying to break into Thapar University's Database and steal sensitive research information. It is now up to us to stop this attack. Fortunately our defense mechanisms have traced the attacks to their source. The fastest way to stop the attacks is to disable the source. So all we need to do is to... | {
"input": [],
"output": []
} | {
"input": [
"3\nabcd\nreverse\ngear"
],
"output": [
"b\nm\ng\n"
]
} | {
"input": [
"3\nabdc\nreverse\ngear",
"3\ncaad\nftsfwfr\ngrae",
"3\ncaad\nftsfwfr\nfarg",
"3\ncaad\nftsewfr\nfarg",
"3\ndbae\nfttewfr\nfarg",
"3\nfc`^\nhwqgsug\npehd",
"3\nf]^h\nvsegrgr\nijob",
"3\nh^f[\nqgvegsq\n`joi",
"3\nYf`h\nfrpdsgy\n^iof",
"3\nh`fY\nfrpdsgy\n^ioe",
"... |
cieltomy | Tomya is a girl. She loves Chef Ciel very much.
Today, too, Tomya is going to Ciel's restaurant.
Of course, Tomya would like to go to Ciel's restaurant as soon as possible.
Therefore Tomya uses one of the shortest paths from Tomya's house to Ciel's restaurant.
On the other hand, Tomya is boring now to use the same pa... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 3\n1 2 3\n2 3 6\n1 3 7\n3 3\n1 2 3\n2 3 6\n1 3 9"
],
"output": [
"1\n2"
]
} | {
"input": [
"2\n3 3\n1 2 3\n2 3 6\n1 1 7\n3 3\n1 2 3\n2 3 6\n1 3 9",
"2\n3 3\n1 2 3\n2 3 6\n1 1 7\n3 3\n1 2 3\n2 3 6\n2 3 9",
"2\n3 3\n1 2 3\n2 3 6\n1 1 7\n3 3\n2 2 3\n2 3 6\n2 3 9",
"2\n3 3\n1 2 3\n2 2 6\n1 1 7\n3 3\n2 2 3\n2 3 6\n2 3 9",
"2\n3 3\n1 1 3\n3 3 11\n1 2 7\n3 3\n2 2 3\n2 3 1\n2 1 9",... |
fact25 | Simple Factorial
You are asked to calculate factorials of some small positive integers.
Input
Input
Tips:
An integer T, denoting the number of testcases, followed by T lines, each containing a single integer N.
Output
For each integer N given at input, output a single line the value of N!
If you have multiple... | {
"input": [],
"output": []
} | {
"input": [
"4\n1\n2\n5\n3"
],
"output": [
"1\n2\n120\n6\n"
]
} | {
"input": [
"4\n0\n2\n5\n3",
"4\n0\n2\n5\n2",
"4\n0\n3\n5\n2",
"4\n1\n4\n5\n2",
"4\n1\n4\n5\n1",
"4\n1\n0\n5\n1",
"4\n1\n1\n9\n0",
"4\n1\n2\n9\n0",
"4\n2\n2\n9\n0",
"4\n2\n2\n2\n1",
"4\n2\n3\n2\n1",
"4\n2\n1\n2\n1",
"4\n2\n2\n1\n1",
"4\n1\n2\n1\n1",
"4\n1\n... |
lch15jab | This is a very easy warm-up problem.
You are given a string. Your task is to determine whether number of occurrences of some character in the string is equal to the sum of the numbers of occurrences of other characters in the string.
Input
The first line of the input contains an integer T denoting the number of test... | {
"input": [],
"output": []
} | {
"input": [
"4\nacab\nzzqzqq\nabc\nkklkwwww"
],
"output": [
"YES\nYES\nNO\nYES\n"
]
} | {
"input": [
"4\nacab\nzzqzqq\ncba\nkklkwwww",
"4\nacbb\nzzqzqq\ncba\nkkmkwvww",
"4\ncbba\nqrzqyz\nbab\nkllkxwvw",
"4\naccc\nqrzqyz\nbab\nkklkxwvw",
"4\nabbb\nzzqzqq\ncba\nkkmkwwww",
"4\ncbbb\nqqzqyz\nbab\nkllkxwvw",
"4\nadac\nzzqypr\nabc\nkklkwwww",
"4\nacab\nzzqzqq\ncba\nkkmkwwww",
... |
permsuff | You are given a permutation of natural integers from 1 to N, inclusive. Initially, the permutation is 1, 2, 3, ..., N.
You are also given M pairs of integers, where the i-th is (Li Ri). In a single turn you can choose any of these pairs (let's say with the index j) and arbitrarily shuffle the elements of our permutatio... | {
"input": [],
"output": []
} | {
"input": [
"2\n7 4\n3 1 2 4 5 7 6\n1 2\n4 4\n6 7\n2 3\n4 2\n2 1 3 4\n2 4\n2 3"
],
"output": [
"Possible\nImpossible"
]
} | {
"input": [
"2\n7 4\n6 1 2 4 5 7 6\n1 2\n4 4\n6 7\n2 3\n4 2\n2 1 3 4\n2 4\n2 3",
"2\n7 4\n3 1 2 4 5 7 6\n1 2\n4 4\n6 7\n2 3\n4 2\n2 1 3 6\n2 4\n2 3",
"2\n7 4\n6 1 2 4 5 7 6\n1 2\n4 0\n6 7\n2 3\n4 2\n2 1 3 4\n2 4\n2 3",
"2\n8 4\n6 1 2 4 5 7 6\n1 2\n4 4\n6 7\n2 3\n4 2\n2 1 3 4\n2 4\n2 3",
"2\n7 4\n... |
sticks | Chef and his little brother are playing with sticks. They have total N sticks. Length of i-th stick is Ai.
Chef asks his brother to choose any four sticks and to make a rectangle with those sticks its sides. Chef warns his brother to not to break any of the sticks, he has to use sticks as a whole. Also, he wants that ... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n1 2 3 1 2\n4\n1 2 2 3"
],
"output": [
"2\n-1\n"
]
} | {
"input": [
"2\n5\n1 2 3 1 1\n4\n1 2 2 3",
"2\n5\n1 2 3 1 2\n4\n1 3 2 3",
"2\n5\n1 2 3 1 1\n4\n2 2 4 4",
"2\n5\n1 3 3 1 1\n4\n0 2 0 3",
"2\n5\n1 2 3 1 2\n4\n1 3 1 3",
"2\n5\n2 2 3 1 2\n4\n1 3 1 3",
"2\n5\n1 4 1 1 1\n4\n0 2 1 12",
"2\n5\n2 2 3 2 2\n1\n2 5 4 3",
"2\n5\n1 2 3 1 0\n4\... |
1076_C. Meme Problem | Try guessing the statement from this picture:
<image>
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a + b = d and a ⋅ b = d.
Input
The first line contains t (1 ≤ t ≤ 10^3) — the number of test cases.
Each test case contains one integer d (0 ≤ d ≤ 10^3).
... | {
"input": [],
"output": []
} | {
"input": [
"7\n69\n0\n1\n4\n5\n999\n1000\n"
],
"output": [
"Y 67.9850713005 1.01492869949\nY 0.0 0.0\nN\nY 2.0 2.0\nY 3.61803398875 1.38196601125\nY 997.998996998 1.00100301004\nY 998.998998021 1.00100200501\n"
]
} | {
"input": [
"7\n69\n0\n1\n4\n3\n999\n1000\n",
"7\n69\n0\n1\n4\n2\n484\n1000\n",
"7\n69\n0\n1\n4\n2\n826\n1000\n",
"7\n69\n0\n1\n4\n2\n826\n1010\n",
"7\n69\n0\n1\n4\n2\n1335\n1010\n",
"7\n69\n0\n1\n4\n2\n1335\n1110\n",
"7\n87\n0\n1\n4\n2\n1335\n1110\n",
"7\n87\n0\n1\n4\n2\n1335\n1010\n... |
1329_E. Dreamoon Loves AA | There is a string of length n+1 of characters 'A' and 'B'. The first character and last character of the string are equal to 'A'.
You are given m indices p_1, p_2, …, p_m (0-indexation) denoting the other indices of characters 'A' in the string.
Let's denote the minimum distance between two neighboring 'A' as l, and ... | {
"input": [],
"output": []
} | {
"input": [
"5\n80 3 5\n11 24 50\n81 7 12\n4 10 17 26 37 48 61\n25 10 14\n3 4 7 12 13 15 17 19 21 23\n1 0 0\n\n10 2 0\n2 4\n"
],
"output": [
"5\n2\n0\n0\n4\n"
]
} | {
"input": [
"5\n80 3 5\n11 24 50\n81 7 12\n4 10 17 26 41 48 61\n25 10 14\n3 4 7 12 13 15 17 19 21 23\n1 0 0\n\n10 2 0\n2 4\n",
"5\n80 3 5\n11 24 50\n81 7 12\n4 10 17 26 37 48 61\n25 10 14\n3 4 7 12 13 15 17 19 21 23\n1 0 0\n\n10 2 0\n2 5\n",
"5\n80 3 5\n11 24 50\n81 7 12\n4 10 17 26 41 48 61\n46 10 14\n3... |
1416_E. Split | One day, BThero decided to play around with arrays and came up with the following problem:
You are given an array a, which consists of n positive integers. The array is numerated 1 through n. You execute the following procedure exactly once:
* You create a new array b which consists of 2n positive integers, where f... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n6 8 2\n1\n4\n3\n5 6 6\n"
],
"output": [
"3\n1\n2\n"
]
} | {
"input": [
"3\n3\n6 8 2\n1\n4\n3\n5 6 12\n",
"3\n3\n6 8 2\n1\n4\n3\n8 6 6\n",
"3\n3\n6 8 4\n1\n4\n1\n4 7 12\n",
"3\n3\n5 10 4\n1\n4\n3\n5 6 12\n",
"3\n3\n6 8 4\n1\n3\n2\n4 7 12\n",
"3\n3\n5 8 8\n1\n4\n2\n4 6 12\n",
"3\n3\n5 8 2\n1\n4\n3\n5 7 11\n",
"3\n3\n5 8 4\n1\n5\n3\n5 4 12\n",
... |
1458_C. Latin Square | You are given a square matrix of size n. Every row and every column of this matrix is a permutation of 1, 2, …, n. Let a_{i, j} be the element at the intersection of i-th row and j-th column for every 1 ≤ i, j ≤ n. Rows are numbered 1, …, n top to bottom, and columns are numbered 1, …, n left to right.
There are six t... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 2\n1 2 3\n2 3 1\n3 1 2\nDR\n3 2\n1 2 3\n2 3 1\n3 1 2\nLU\n3 1\n1 2 3\n2 3 1\n3 1 2\nI\n3 1\n1 2 3\n2 3 1\n3 1 2\nC\n3 16\n1 2 3\n2 3 1\n3 1 2\nLDICRUCILDICRUCI\n"
],
"output": [
"\n2 3 1 \n3 1 2 \n1 2 3 \n\n3 1 2 \n1 2 3 \n2 3 1 \n\n1 2 3 \n3 1 2 \n2 3 1 \n\n1 3 2 \n2 1 3 \n3 2 1 \n\n2 ... | {
"input": [
"5\n3 2\n1 2 3\n2 3 1\n3 2 2\nDR\n3 2\n1 2 3\n2 3 1\n3 1 2\nLU\n3 1\n1 2 3\n2 3 1\n3 1 2\nI\n3 1\n1 2 3\n2 3 1\n3 1 2\nC\n3 16\n1 2 3\n2 3 1\n3 1 2\nLDICRUCILDICRUCI\n",
"5\n3 2\n1 2 3\n2 3 1\n4 1 2\nDR\n3 2\n1 2 3\n2 3 1\n3 1 2\nLU\n3 1\n1 2 3\n2 3 1\n3 1 2\nI\n3 1\n1 2 3\n2 3 1\n3 1 2\nC\n3 16\... |
1481_C. Fence Painting | You finally woke up after this crazy dream and decided to walk around to clear your head. Outside you saw your house's fence — so plain and boring, that you'd like to repaint it.
<image>
You have a fence consisting of n planks, where the i-th plank has the color a_i. You want to repaint the fence in such a way that t... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 1\n1\n1\n1\n5 2\n1 2 2 1 1\n1 2 2 1 1\n1 2\n3 3\n2 2 2\n2 2 2\n2 3 2\n10 5\n7 3 2 1 7 9 4 2 7 9\n9 9 2 1 4 9 4 2 3 9\n9 9 7 4 3\n5 2\n1 2 2 1 1\n1 2 2 1 1\n3 3\n6 4\n3 4 2 4 1 2\n2 3 1 3 1 1\n2 2 3 4\n"
],
"output": [
"\nYES\n1\nYES\n2 2\nYES\n1 1 1\nYES\n2 1 9 5 9\nNO\nNO\n"
]
} | {
"input": [
"6\n1 1\n1\n1\n1\n5 2\n1 2 2 1 1\n1 2 2 1 1\n1 2\n3 3\n2 2 2\n2 2 2\n2 3 2\n10 5\n7 3 2 1 7 9 4 2 7 9\n9 9 2 1 4 9 4 2 3 9\n9 9 7 4 3\n5 2\n1 2 2 1 1\n1 2 2 1 1\n3 3\n6 4\n1 4 2 4 1 2\n2 3 1 3 1 1\n2 2 3 4\n",
"6\n1 1\n1\n1\n1\n5 2\n1 2 2 1 1\n1 2 2 1 1\n1 1\n3 3\n2 2 2\n2 2 2\n2 3 2\n10 5\n7 3 2... |
162_B. Binary notation | You are given a positive integer n. Output its binary notation.
Input
The only line of input data contains an integer n (1 ≤ n ≤ 106).
Output
Output the binary notation of n (without any leading zeros).
Examples
Input
5
Output
101
Input
126
Output
1111110
Note
In the first example 5 = 1 * 22 + 0 * 21 ... | {
"input": [],
"output": []
} | {
"input": [
"5\n",
"126\n"
],
"output": [
"101\n",
"1111110\n"
]
} | {
"input": [],
"output": []
} |
brattleship-3 | You're about to play a simplified "battleship" game with your little brother. The board for this game is a rectangular grid with R rows and C columns. At the start of the game, you will close your eyes, and you will keep them closed until the end of the game. Your little brother will take a single rectangular 1 x W shi... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 4 2\n1 7 7\n\nSAMPLE"
],
"output": [
"Case #1: 3\nCase #2: 7\n"
]
} | {
"input": [
"2\n1 8 2\n1 7 7\n\nSAMPLE",
"2\n1 2 2\n1 7 7\n\nSAMPLE",
"2\n1 4 4\n1 7 7\n\nSAMPLE",
"2\n1 8 2\n1 0 7\n\nSAMPLE",
"2\n1 2 2\n1 13 1\n\nFLOMAS",
"2\n1 4 2\n1 7 7\n\nSAMPLD",
"2\n1 8 1\n1 7 7\n\nSAMPLE",
"2\n1 0 2\n1 7 7\n\nSAMPLD",
"2\n1 12 2\n1 0 7\n\nSAMPLE",
"2... |
splendid-matrices-10 | Rani has challenged Nandu to generate Splendid Matrices. Splendid matrices are square matrices with dimensions 2^n X 2^n filled in a particular manner. To explain this manner, Rani gives Nandu the matrices for n=1, n=2 and n=3 :
n=1
1 2
3 4
n=2 (spacing for clarity)
1 2 5 6
3 4 7 8
9 10 13 14
11 12 15 16
n=3... | {
"input": [],
"output": []
} | {
"input": [
"3\n\nSAMPLE"
],
"output": [
"1 2 5 6 17 18 21 22 \n3 4 7 8 19 20 23 24 \n9 10 13 14 25 26 29 30 \n11 12 15 16 27 28 31 32 \n33 34 37 38 49 50 53 54 \n35 36 39 40 51 52 55 56 \n41 42 45 46 57 58 61 62 \n43 44 47 48 59 60 63 64 \n"
]
} | {
"input": [
"3\n\nSAMPKE",
"3\n\nSAMPKD",
"3\n\nSAMOKD",
"3\n\nSAMDKO",
"3\n\nSADMKO",
"3\n\nTADMKO",
"3\n\nTADMJO",
"3\n\nTADNJO",
"3\n\nT@DNJO",
"3\n\nT@DNJN",
"3\n\nJ@DNTN",
"3\n\nJ@DMTN",
"3\n\nI@DMTN",
"3\n\nI@DTMN",
"3\n\nI@ETMN",
"3\n\nI@MTEN",
... |
p02579 AtCoder Beginner Contest 176 - Wizard in Maze | A maze is composed of a grid of H \times W squares - H vertical, W horizontal.
The square at the i-th row from the top and the j-th column from the left - (i,j) - is a wall if S_{ij} is `#` and a road if S_{ij} is `.`.
There is a magician in (C_h,C_w). He can do the following two kinds of moves:
* Move A: Walk to a ... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..",
"4 4\n1 4\n4 1\n.##.\n\n\n.##.",
"4 5\n1 2\n2 5\n.###\n.\n..##\n..##",
"4 4\n2 2\n3 3\n....\n....\n....\n...."
],
"output": [
"1",
"-1",
"2",
"0"
]
} | {
"input": [
"4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n..#.",
"4 4\n1 1\n4 1\n.##.\n\n\n.##.",
"4 5\n1 2\n1 5\n.###\n.\n..##\n..##",
"4 4\n1 2\n3 3\n....\n....\n....\n....",
"4 4\n1 1\n4 4\n..#.\n..#.\n.$..\n..#.",
"4 4\n1 1\n2 1\n.##.\n\n\n.##.",
"4 4\n1 1\n1 4\n..#.\n..#.\n.$..\n..#.",
"4 4\... |
p02710 AtCoder Beginner Contest 163 - path pass i | We have a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and b_i. Additionally, each vertex is painted in a color, and the color of Vertex i is c_i. Here, the color of each vertex is represented by an integer between 1 and N (inclusive). The same integer corresponds to the same col... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 1\n1 2\n2 3",
"1\n1",
"2\n1 2\n1 2",
"8\n2 7 2 5 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8",
"5\n1 2 3 4 5\n1 2\n2 3\n3 4\n3 5"
],
"output": [
"5\n4\n0",
"1",
"2\n2",
"18\n15\n0\n14\n23\n0\n23\n0",
"5\n8\n10\n5\n5"
]
} | {
"input": [
"1\n0",
"2\n1 3\n1 2",
"8\n2 7 2 3 4 1 7 5\n3 1\n1 2\n2 7\n4 5\n5 6\n6 8\n7 8",
"5\n0 2 3 4 5\n1 2\n2 3\n3 4\n3 5",
"5\n0 2 3 4 4\n1 2\n2 3\n3 4\n3 5",
"5\n0 2 3 4 4\n1 4\n2 3\n3 4\n3 5",
"5\n0 2 4 4 4\n1 4\n2 3\n3 4\n3 5",
"5\n0 2 2 4 4\n1 5\n2 3\n3 4\n3 5",
"2\n1 1\n... |
p02839 AtCoder Beginner Contest 147 - Balanced Path | We have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.
The square (i, j) has two numbers A_{ij} and B_{ij} written on it.
First, for each square, Takahashi paints one of the written numbers red and the other blue.
Then... | {
"input": [],
"output": []
} | {
"input": [
"2 2\n1 2\n3 4\n3 4\n2 1",
"2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6"
],
"output": [
"0",
"2"
]
} | {
"input": [
"2 2\n1 2\n6 4\n3 4\n2 1",
"2 3\n1 10 80\n80 10 1\n1 2 3\n4 2 6",
"2 3\n2 10 98\n80 14 1\n1 2 3\n4 2 6",
"2 3\n4 10 98\n80 14 1\n1 2 3\n4 2 6",
"1 3\n4 10 90\n80 14 1\n1 2 3\n4 2 6",
"1 3\n0 10 90\n80 14 2\n1 2 3\n3 2 6",
"1 3\n0 10 90\n64 14 2\n1 2 3\n3 2 6",
"1 3\n0 10 9... |
p02976 AtCoder Grand Contest 035 - Even Degrees | You are given a simple connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge connects Vertex A_i and Vertex B_i. Takahashi will assign one of the two possible directions to each of the edges in the graph to make a directed graph. Determine if it is possible to make ... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n1 2\n2 3\n3 4\n2 5\n4 5",
"4 4\n1 2\n2 3\n3 4\n4 1"
],
"output": [
"-1",
"1 2\n1 4\n3 2\n3 4"
]
} | {
"input": [
"5 5\n1 2\n2 3\n3 4\n3 5\n4 5",
"10 2\n1 2\n1 3\n0 4\n3 5\n4 5",
"7 2\n1 2\n2 3\n0 2\n3 5\n4 5",
"5 5\n1 1\n2 3\n3 4\n3 5\n4 5",
"5 5\n1 1\n2 3\n4 4\n3 5\n4 5",
"5 5\n1 2\n2 3\n4 4\n3 5\n4 5",
"5 1\n1 2\n2 3\n4 4\n3 5\n4 5",
"5 1\n1 2\n1 3\n4 4\n3 5\n4 5",
"10 1\n1 2\n... |
p03112 AtCoder Beginner Contest 119 - Lazy Faith | Along a road running in an east-west direction, there are A shrines and B temples. The i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is located at a distance of t_i meters from the west end of the road.
Answer the following Q queries:
... | {
"input": [],
"output": []
} | {
"input": [
"2 3 4\n100\n600\n400\n900\n1000\n150\n2000\n899\n799",
"1 1 3\n1\n10000000000\n2\n9999999999\n5000000000"
],
"output": [
"350\n1400\n301\n399",
"10000000000\n10000000000\n14999999998"
]
} | {
"input": [
"2 3 4\n110\n600\n400\n900\n1000\n150\n2000\n899\n799",
"2 3 4\n110\n608\n400\n900\n1000\n150\n2000\n899\n799",
"2 3 4\n110\n608\n400\n900\n1000\n150\n2000\n899\n1571",
"2 3 4\n110\n608\n400\n900\n1000\n155\n2000\n899\n1571",
"2 3 4\n110\n608\n400\n900\n1000\n155\n2000\n1530\n1571",
... |
p03259 AtCoder Grand Contest 027 - Grafting | Snuke has found two trees A and B, each with N vertices numbered 1 to N. The i-th edge of A connects Vertex a_i and b_i, and the j-th edge of B connects Vertex c_j and d_j. Also, all vertices of A are initially painted white.
Snuke would like to perform the following operation on A zero or more times so that A coincid... | {
"input": [],
"output": []
} | {
"input": [
"3\n8\n2 7\n4 8\n8 6\n7 1\n7 3\n5 7\n7 8\n4 2\n5 2\n1 2\n8 1\n3 2\n2 6\n2 7\n4\n1 2\n2 3\n3 4\n3 4\n2 1\n3 2\n9\n5 3\n4 3\n9 3\n6 8\n2 3\n1 3\n3 8\n1 7\n4 1\n2 8\n9 6\n3 6\n3 5\n1 8\n9 7\n1 6",
"2\n3\n1 2\n2 3\n1 3\n3 2\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n1 2\n2 4\n4 3\n3 5\n5 6"
],
"output": [
... | {
"input": [
"3\n8\n2 7\n4 8\n8 6\n7 1\n7 3\n5 7\n7 8\n4 2\n5 2\n1 2\n8 1\n3 2\n2 6\n2 7\n4\n1 2\n2 3\n3 4\n3 4\n2 1\n3 2\n9\n5 3\n4 3\n9 3\n6 8\n2 3\n1 3\n5 8\n1 7\n4 1\n2 8\n9 6\n3 6\n3 5\n1 8\n9 7\n1 6",
"2\n3\n1 2\n2 3\n1 3\n3 2\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n1 2\n2 4\n4 5\n3 5\n5 6",
"2\n3\n1 3\n2 3\n1... |
p03415 AtCoder Beginner Contest 090 - Diagonal String | We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.
Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bot... | {
"input": [],
"output": []
} | {
"input": [
"ant\nobe\nrec",
"edu\ncat\nion"
],
"output": [
"abc",
"ean"
]
} | {
"input": [
"ant\nobe\nrfc",
"ddu\ncat\nion",
"ant\nobe\nrcf",
"ddu\ncat\nioo",
"ddu\ncat\nooi",
"una\nobe\nrcf",
"edu\nbau\nooi",
"una\npbe\nfdr",
"una\nbep\ndfr",
"ued\nbau\noni",
"ceu\nbau\noni",
"ceu\nbau\nonj",
"uo`\naep\nrfe",
"uec\nbau\nonj",
"uo`\na... |
p03575 AtCoder Beginner Contest 075 - Bridge | You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.
The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.
An edge whose removal disconnects the graph is called a bridge.
Find the number of the edges that are bridges among the M edges.... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 2\n1 3\n2 3",
"6 5\n1 2\n2 3\n3 4\n4 5\n5 6",
"7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7"
],
"output": [
"0",
"5",
"4"
]
} | {
"input": [
"3 2\n1 2\n1 3\n2 3",
"6 5\n1 2\n2 3\n3 4\n3 5\n5 6",
"3 0\n2 2\n1 3\n3 3",
"6 1\n2 1\n1 1\n1 3",
"3 2\n2 2\n1 3\n2 3",
"3 2\n2 1\n1 3\n2 3",
"6 5\n1 2\n2 3\n3 4\n4 5\n2 6",
"6 5\n1 4\n2 3\n3 4\n3 5\n5 6",
"3 2\n2 2\n1 3\n3 3",
"6 5\n1 4\n2 4\n3 4\n3 5\n5 6",
"... |
p03730 AtCoder Beginner Contest 060 - Choose Integers | We ask you to select some number of positive integers, and calculate the sum of them.
It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.
Your objecti... | {
"input": [],
"output": []
} | {
"input": [
"7 5 1",
"2 2 1",
"77 42 36",
"40 98 58",
"1 100 97"
],
"output": [
"YES",
"NO",
"NO",
"YES",
"YES"
]
} | {
"input": [
"7 5 0",
"77 42 5",
"2 2 0",
"80 98 58",
"1 110 97",
"11 5 0",
"2 4 0",
"77 42 2",
"103 98 58",
"0 110 97",
"14 5 0",
"2 4 -1",
"77 42 0",
"103 98 87",
"1 111 97",
"14 9 0",
"77 79 0",
"13 98 87",
"2 111 97",
"14 9 1",
"7... |
p03894 CODE FESTIVAL 2016 Relay (Parallel) - Magician | You have N cups and 1 ball.
The cups are arranged in a row, from left to right.
You turned down all the cups, then inserted the ball into the leftmost cup.
Then, you will perform the following Q operations:
* The i-th operation: swap the positions of the A_i-th and B_i-th cups from the left. If one of these cups co... | {
"input": [],
"output": []
} | {
"input": [
"10 3\n1 3\n2 4\n4 5",
"20 3\n1 7\n8 20\n1 19"
],
"output": [
"4",
"5"
]
} | {
"input": [
"10 3\n1 3\n2 8\n4 5",
"10 3\n1 3\n2 8\n4 2",
"14 1\n1 3\n2 8\n5 5",
"24 1\n1 1\n8 18\n1 35",
"14 3\n2 1\n2 8\n5 7",
"20 3\n1 7\n8 17\n1 19",
"20 3\n1 4\n8 17\n1 19",
"20 3\n1 4\n10 17\n1 19",
"10 3\n1 3\n2 8\n5 5",
"20 3\n1 7\n5 17\n1 19",
"10 3\n1 3\n2 8\n4 1... |
p00000 QQ | Write a program which prints multiplication tables in the following format:
1x1=1
1x2=2
.
.
9x8=72
9x9=81
Input
No input.
Output
1x1=1
1x2=2
.
.
9x8=72
9x9=81
Example
Input
Output | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p00132 Jigsaw Puzzle | Brain training puzzle games are popular from children to adults. We decided to make a puzzle game and play with everyone so that we could keep up.
We thought of a jigsaw puzzle game where you pick the pieces you need to fill in the unfinished parts. Figure 1 (a) is an example of a puzzle frame. The part where black is... | {
"input": [],
"output": []
} | {
"input": [
"14 20\n####################\n###.............####\n####..........######\n#######.....########\n########.....#######\n###..###......######\n###..####......#####\n#########......#####\n###########.....####\n############.....###\n###.########......##\n###.#######...###.##\n##...###....#####.##\n#######... | {
"input": [
"14 20\n####################\n###.............####\n####..........######\n#######.....########\n########.....#######\n###..###......######\n###..####......#####\n#########......#####\n###########.....####\n############.....###\n###.########......##\n###.#######...###.##\n##...###....#####.##\n#######... |
p00265 Modular Query | Give you N cards. Only one natural number is written on each card. However, the same number is never written.
From now on, as a question, I will say an appropriate natural number. Please answer the largest remainder you get when you divide the number on the card you have by the number I said.
For example, suppose you... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n9 3 8\n4\n6\n5"
],
"output": [
"3\n3\n4"
]
} | {
"input": [
"3 3\n9 3 8\n6\n6\n5",
"3 3\n9 3 10\n6\n6\n5",
"3 3\n9 3 8\n4\n6\n3",
"3 3\n9 3 8\n6\n6\n2",
"3 2\n1 3 8\n4\n6\n3",
"3 3\n9 2 8\n4\n6\n5",
"3 3\n12 3 8\n6\n6\n5",
"3 3\n9 3 8\n4\n6\n1",
"3 3\n9 3 8\n12\n6\n2",
"3 2\n1 3 11\n4\n6\n3",
"3 2\n0 3 8\n4\n3\n3",
... |
p00452 Darts | problem
You have to play a darts game with the following rules.
You can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in each part. The total score S of the place where the arrow is stuck ... | {
"input": [],
"output": []
} | {
"input": [
"4 50\n3\n14\n15\n9\n3 21\n16\n11\n2\n0 0"
],
"output": [
"48\n20"
]
} | {
"input": [
"4 58\n3\n14\n15\n9\n3 21\n16\n11\n2\n0 0",
"4 50\n3\n14\n27\n9\n3 21\n16\n11\n2\n0 0",
"4 58\n6\n14\n15\n6\n3 21\n5\n11\n2\n0 0",
"4 50\n3\n14\n20\n9\n3 21\n16\n11\n2\n0 0",
"4 58\n3\n14\n25\n9\n3 21\n16\n11\n2\n0 0",
"4 58\n6\n14\n28\n6\n3 21\n16\n11\n2\n0 0",
"4 10\n3\n14\n... |
p00643 Rolling Dice | The north country is conquered by the great shogun-sama (which means king). Recently many beautiful dice which were made by order of the great shogun-sama were given to all citizens of the country. All citizens received the beautiful dice with a tear of delight. Now they are enthusiastically playing a game with the dic... | {
"input": [],
"output": []
} | {
"input": [
"1 2\n8 8\n0 0\n0 1\n3 3\n1 2 5\n2 8 3\n0 1 2\n0 0\n2 2\n3 3\n1 2 5\n2 8 3\n0 1 2\n0 0\n1 2\n2 2\n1 2\n3 4\n0 0\n0 1\n2 3\n1 2 3\n4 5 6\n0 0\n1 2\n0 0"
],
"output": [
"24\n19\n17\n6\n21"
]
} | {
"input": [
"1 2\n8 8\n0 0\n0 1\n3 3\n1 2 5\n2 8 3\n0 1 2\n0 0\n2 2\n3 3\n1 2 5\n2 8 6\n0 1 2\n0 0\n1 2\n2 2\n1 2\n3 4\n0 0\n0 1\n2 3\n1 2 3\n4 5 6\n0 0\n1 2\n0 0",
"1 2\n8 8\n0 0\n0 1\n3 3\n1 3 5\n2 13 1\n0 1 2\n0 0\n2 2\n3 3\n1 2 4\n2 8 6\n0 1 2\n0 0\n1 2\n2 2\n1 2\n3 4\n0 0\n0 1\n2 3\n1 2 3\n4 5 6\n0 0\n1... |
p00787 Digital Racing Circuil | You have an ideally small racing car on an x-y plane (0 ≤ x, y ≤ 255, where bigger y denotes upper coordinate). The racing circuit course is figured by two solid walls. Each wall is a closed loop of connected line segments. End point coordinates of every line segment are both integers (See Figure 1). Thus, a wall is re... | {
"input": [],
"output": []
} | {
"input": [
"6 28 6 32 25 32 26 27 26 24 6 24 99999\n2 28 2 35 30 35 30 20 2 20 99999\n\n3 28\n22.667\n0 1 1 1 1 0 0 -1 0 -1 1 0 0 0 1 0 -1 0 0 -1 -1 -1 -1 0 -1 0 -1 -1 -1 1 -1 1\n-1 1 -1 0 1 0 1 1 1 1 1 0 1 1 99999\n\n5 28\n22.667\n0 1 -1 1 1 0 1 -1 1 -1 1 0 1 0 1 0 -1 -1 -1 0 -1 -1 -1 0 -1 1 -1 -1 -1 1\n-1 0 -... | {
"input": [
"6 28 6 32 25 32 26 27 26 24 6 24 99999\n2 28 2 35 30 35 30 20 2 20 99999\n\n3 28\n22.667\n0 1 1 1 1 0 0 -1 0 -1 1 0 0 0 1 0 -1 0 0 -1 -1 -1 -1 0 -1 0 -1 -1 -1 1 -1 1\n-1 1 -1 0 1 0 1 1 1 1 1 0 1 1 99999\n\n5 28\n22.667\n0 1 -1 1 1 0 1 -1 1 -1 1 0 1 0 1 0 -1 -1 -1 0 -1 -1 -1 0 -1 1 -1 -1 -1 1\n-1 0 -... |
p00919 Directional Resemblance | Vectors have their directions and two vectors make an angle between them. Given a set of three-dimensional vectors, your task is to find the pair among them that makes the smallest angle.
Input
The input is a sequence of datasets. A dataset specifies a set of three-dimensional vectors, some of which are directly gi... | {
"input": [],
"output": []
} | {
"input": [
"4 0 2013 1124\n1 1 1\n2 2 2\n2 1 1\n1 2 1\n2 100 131832453 129800231\n42 40 46\n42 40 46\n0 100000 7004674 484521438\n0 0 0 0"
],
"output": [
"1 1 1 1 2 1\n42 40 46 83 79 91\n92 92 79 99 99 85"
]
} | {
"input": [
"4 0 2013 1124\n1 1 1\n2 2 2\n2 1 1\n1 2 1\n2 100 131832453 129800231\n42 0 46\n42 40 46\n0 100000 7004674 484521438\n0 0 0 0",
"4 0 2013 1124\n1 1 1\n2 2 2\n3 1 1\n1 2 1\n2 100 131832453 129800231\n42 0 46\n42 40 48\n0 100000 7004674 484521438\n0 0 0 0",
"4 0 2013 1124\n1 1 1\n2 2 2\n2 1 1\n... |
p01052 Movie | Problem
Taro decided to watch one movie every day at a nearby movie theater during the summer vacation. (Taro has 31 days of summer vacation from August 1st to August 31st.)
The theater is set to show n movies during the summer vacation. Each movie is assigned a number from 1 to n, and the i-th movie will only be sho... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 31\n2 2\n2 3\n3 3",
"5\n1 10\n10 20\n20 21\n22 31\n4 20"
],
"output": [
"1700",
"1800"
]
} | {
"input": [
"4\n1 31\n2 4\n2 3\n3 3",
"5\n1 10\n10 20\n20 21\n22 31\n4 15",
"4\n1 31\n2 2\n2 1\n3 3",
"5\n1 10\n10 20\n20 21\n22 31\n4 28",
"5\n1 10\n15 20\n20 21\n22 31\n4 20",
"5\n1 10\n10 20\n20 21\n22 31\n7 15",
"5\n1 10\n10 20\n20 21\n12 31\n7 15",
"5\n1 10\n14 20\n20 21\n12 31\n... |
p01184 International Party | Isaac H. Ives is attending an international student party (maybe for girl-hunting). Students there enjoy talking in groups with excellent foods and drinks. However, since students come to the party from all over the world, groups may not have a language spoken by all students of the group. In such groups, some student(... | {
"input": [],
"output": []
} | {
"input": [
"3 4\nEnglish\nFrench\nJapanese\n1 English\n2 French English\n2 Japanese English\n1 Japanese\n2 2\nEnglish\nJapanese\n1 English\n1 Japanese\n6 7\nEnglish\nDutch\nGerman\nFrench\nItalian\nSpanish\n1 English\n2 English Dutch\n2 Dutch German\n2 German French\n2 French Italian\n2 Italian Spanish\n1 Spani... | {
"input": [
"3 4\nEnglish\nFrench\nJapanese\n1 English\n2 French English\n2 Japanese English\n1 Japanese\n2 2\nEnglish\nJapanese\n1 hsilgnE\n1 Japanese\n6 7\nEnglish\nDutch\nGerman\nFrench\nItalian\nSpanish\n1 English\n2 English Dutch\n2 Dutch German\n2 German French\n2 French Italian\n2 Italian Spanish\n1 Spani... |
p01321 Final Examination! | Yui Hirasawa, who attends private Sakuragaoka Girls' High School, has to make a career hope by the day after tomorrow, but the trouble is that she hasn't decided anything yet. When I consulted with my friend Wa, I knew that my first choice was K University, so I consulted with my career guidance teacher to see if I cou... | {
"input": [],
"output": []
} | {
"input": [
"3\n49 50 87 78 41\n27 61 100 45 84\n28 88 40 95 66\n2\n100 100 100 100 100\n0 0 0 0 0\n1\n89 90 85 93 82\n0",
"2\n100 100 100 100 100\n0 0 0 0 0",
"1\n89 90 85 93 82",
"3\n49 50 87 78 41\n27 61 100 45 84\n28 88 40 95 66"
],
"output": [
"317 305\n500 0\n439 439",
"500 0",
... | {
"input": [
"3\n49 50 87 78 41\n27 61 100 45 84\n28 36 40 95 66\n2\n100 100 100 100 100\n0 0 0 0 0\n1\n89 90 85 93 82\n0",
"2\n100 101 100 100 100\n0 0 0 0 0",
"3\n49 50 87 78 41\n27 61 100 45 84\n28 88 40 95 23",
"3\n49 50 87 78 41\n27 61 100 45 84\n28 36 40 95 66\n2\n100 100 100 100 100\n0 0 0 0 0\... |
p01489 IkaNumber | Example
Input
5
Output
5 | {
"input": [],
"output": []
} | {
"input": [
"5"
],
"output": [
"5"
]
} | {
"input": [
"3",
"6",
"7",
"10",
"9",
"13",
"19",
"22",
"27",
"20",
"40",
"16",
"56",
"31",
"88",
"32",
"161",
"11",
"69",
"21",
"54",
"8",
"18",
"15",
"1",
"2",
"4",
"12",
"33",
"24",
"28",
... |
p01651 Counting 1's | Problem Statement
Let b_i(x) be the i-th least significant bit of x, i.e. the i-th least significant digit of x in base 2 (i \geq 1). For example, since 6 = (110)_2, b_1(6) = 0, b_2(6) = 1, b_3(6) = 1, b_4(6) = 0, b_5(6) = 0, and so on.
Let A and B be integers that satisfy 1 \leq A \leq B \leq 10^{18}, and k_i be the... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n2\n1\n49\n95351238128934\n95351238128934\n95351238128932\n95351238128936\n95351238128936\n95351238128936\n95351238128960\n95351238128900\n95351238128896\n95351238129096\n95351238128772\n95351238129096\n95351238129096\n95351238126156\n95351238131712\n95351238131712\n95351238149576\n953512380933... | {
"input": [
"3\n2\n2\n1\n49\n95351238128934\n95351238128934\n95351238128932\n95351238128936\n95351238128936\n95351238128936\n95351238128960\n95351238128900\n95351238128896\n95351238129096\n95351238128772\n95351238129096\n95351238129096\n95351238126156\n95351238131712\n95351238131712\n95351238149576\n953512380933... |
p01802 Koto Municipal Subway | Koto Municipal Subway
Koto Municipal Subway
Koto City is a famous city whose roads are in a grid pattern, as shown in the figure below. The roads extending from north to south and the roads extending from east to west are lined up at intervals of 1 km each. Let Koto station at the southwestern intersection of Koto ci... | {
"input": [],
"output": []
} | {
"input": [
"2 1\n7 5\n7 6\n7 7\n76 5\n8 41\n0 0"
],
"output": [
"0.4142135624\n0\n0.0827625303\n0\n48.7401153702\n33"
]
} | {
"input": [
"2 1\n7 6\n7 6\n7 7\n76 5\n8 41\n0 0",
"1 1\n7 5\n7 6\n7 7\n76 5\n8 41\n0 0",
"2 1\n7 6\n7 6\n7 7\n76 3\n8 41\n0 0",
"2 1\n7 6\n7 6\n7 3\n76 3\n8 41\n0 0",
"2 1\n7 6\n7 6\n7 3\n76 3\n11 41\n0 0",
"2 1\n7 5\n14 6\n7 7\n76 5\n8 41\n0 0",
"1 1\n6 5\n7 6\n7 7\n76 5\n8 41\n0 0",
... |
p01936 Steps | problem
AOR Ika-chan visited AOR Co., Ltd. AOR Co., Ltd. is a $ N $ building with no basement floor. AOR Ika started the tour from the $ 1 $ floor and decided to move just $ M $. You can move from the $ i $ floor to the $ i + 1 $ floor, or the $ i --1 $ floor with $ 1 $ movements. However, it cannot be moved to the $ ... | {
"input": [],
"output": []
} | {
"input": [
"3 5"
],
"output": [
"3"
]
} | {
"input": [
"3 4",
"3 1",
"2 1",
"3 6",
"4 6",
"6 9",
"5 7",
"7 9",
"4 9",
"3 9",
"3 11",
"5 11",
"10 11",
"5 8",
"8 12",
"3 20",
"3 34",
"4 8",
"9 15",
"9 20",
"11 14",
"5 15",
"11 24",
"8 15",
"19 24",
"7 15",
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.