name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p00587 Binary Tree Intersection And Union | Given two binary trees, we consider the “intersection” and “union” of them. Here, we distinguish the left and right child of a node when it has only one child. The definitions of them are very simple. First of all, draw a complete binary tree (a tree whose nodes have either 0 or 2 children and leaves have the same dept... | {
"input": [],
"output": []
} | {
"input": [
"i ((,),(,)) ((,(,)),)\nu ((,),(,)) ((,(,)),)"
],
"output": [
"((,),)\n((,(,)),(,))"
]
} | {
"input": [],
"output": []
} |
p00724 Hexerpents of Hexwamp | Hexwamp is a strange swamp, paved with regular hexagonal dimples. Hexerpents crawling in this area are serpents adapted to the environment, consisting of a chain of regular hexagonal sections. Each section fits in one dimple.
Hexerpents crawl moving some of their sections from the dimples they are in to adjacent ones.... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 -2\n2 -1\n1 0\n1\n0 2\n0 0\n4\n2 -2\n2 -1\n2 0\n3 0\n2\n1 -1\n0 2\n0 0\n8\n-6 0\n-5 0\n-4 0\n-3 0\n-2 0\n-1 0\n0 0\n1 0\n1\n-1 1\n0 0\n6\n2 -3\n3 -3\n3 -2\n3 -1\n3 0\n2 1\n3\n1 -1\n1 0\n1 1\n0 0\n3\n-8000 4996\n-8000 4997\n-8000 4998\n2\n-7999 4999\n-8001 5000\n-8000 5000\n8\n10 -8\n9 -7\n9 -6\... | {
"input": [
"3\n2 -2\n2 -1\n1 0\n1\n0 2\n0 0\n4\n2 -2\n2 -1\n2 0\n3 0\n2\n1 -1\n0 2\n0 0\n0\n-6 0\n-5 0\n-4 0\n-3 0\n-2 0\n-1 0\n0 0\n1 0\n1\n-1 1\n0 0\n6\n2 -3\n3 -3\n3 -2\n3 -1\n3 0\n2 1\n3\n1 -1\n1 0\n1 1\n0 0\n3\n-8000 4996\n-8000 4997\n-8000 4998\n2\n-7999 4999\n-8001 5000\n-8000 5000\n8\n10 -8\n9 -7\n9 -6\... |
p00864 Grey Area | Dr. Grey is a data analyst, who visualizes various aspects of data received from all over the world everyday. He is extremely good at sophisticated visualization tools, but yet his favorite is a simple self-made histogram generator.
Figure 1 is an example of histogram automatically produced by his histogram.
<image>
... | {
"input": [],
"output": []
} | {
"input": [
"3 50\n100\n0\n100\n3 50\n100\n100\n50\n10 10\n1\n2\n3\n4\n5\n16\n17\n18\n29\n30\n0 0"
],
"output": [
"0.51\n0.26\n1.4766666666666667"
]
} | {
"input": [
"3 50\n100\n0\n100\n3 50\n100\n100\n50\n10 10\n1\n2\n3\n4\n5\n16\n17\n18\n29\n53\n0 0",
"3 50\n100\n0\n100\n3 50\n100\n100\n50\n10 10\n1\n2\n3\n8\n5\n16\n17\n18\n29\n65\n0 0",
"3 50\n100\n0\n100\n3 50\n100\n100\n50\n10 10\n1\n2\n3\n8\n5\n16\n17\n18\n56\n65\n0 0",
"3 50\n110\n1\n100\n3 50\... |
p00995 Dungeon | You are involved in the development of a certain game. The game is for players to explore randomly generated dungeons.
There are n rooms in the dungeon generated by this game, and they are numbered from 0 to n-1. The rooms are connected by a passage. There are m passages connecting rooms. The passage can go in either ... | {
"input": [],
"output": []
} | {
"input": [
"4 4\n0 1 3\n1 3 4\n0 2 2\n2 3 1\n4\n0 0\n2 2\n2 1\n3 4"
],
"output": [
"1\n1\n2\n1"
]
} | {
"input": [
"4 4\n0 1 3\n1 3 4\n0 2 2\n0 3 1\n4\n0 0\n2 2\n2 1\n3 4",
"4 4\n0 2 3\n1 3 5\n0 2 2\n0 3 1\n4\n0 0\n2 2\n2 1\n3 4",
"4 4\n0 1 3\n1 3 4\n0 2 2\n2 3 1\n4\n0 0\n2 2\n2 1\n3 0",
"4 4\n0 1 3\n1 3 4\n0 2 4\n2 3 1\n4\n0 0\n2 2\n2 1\n3 0",
"4 4\n0 1 3\n1 3 4\n0 2 2\n0 3 1\n4\n-1 0\n2 2\n2 1\n... |
p01127 X-Ray Screening System | This is the story of 20XX. The number of air passengers increased as a result of the stable energy supply by the renewable power network and the invention of liquefied synthetic fuel. However, the threat of terrorism by aircraft still exists, and the importance of fast and highly reliable automatic baggage inspection s... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 1\n.\n3 3\n...\n.W.\n...\n10 10\n..........\n.DDDDCCC..\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA..CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\n..........\n.DDDDDD...\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA..CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\nR..E..C.... | {
"input": [
"6\n1 1\n.\n3 3\n...\n.W.\n...\n10 10\n..........\n.DDDDCCC..\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA..CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\n..........\n.DDDDDD...\n.DDDDCCC..\n.DDDDCCC..\nADDDDCCC..\nAAA.-CCC..\nAAABBBBC..\nAAABBBB...\n..BBBBB...\n..........\n10 10\nR..E..C.... |
p01266 Robot Communication | In the year 21xx, human beings are proliferating across the galaxy. Since the end of the last century, thousands of pioneer spaceships have been launched in order to discover new habitation planets.
The Presitener is one of those spaceships, heading toward the Andromeda galaxy. After a long, long cruise in the hypersp... | {
"input": [],
"output": []
} | {
"input": [
"4 2\n2 0 0 1\n0 4 1 0\n4 6 0 -1\n6 2 -1 0\n4 6\n2 0 0 1\n0 4 1 0\n4 6 0 -1\n6 2 -1 0\n0 0"
],
"output": [
"6.00000000\n4.24264069"
]
} | {
"input": [],
"output": []
} |
p01426 Vector Compression | You are recording a result of a secret experiment, which consists of a large set of N-dimensional vectors. Since the result may become very large, you are thinking of compressing it. Fortunately you already have a good compression method for vectors with small absolute values, all you have to do is to preprocess the ve... | {
"input": [],
"output": []
} | {
"input": [
"2 3\n1.0 1.0\n-1.0 0.0\n0.5 0.5",
"4 3\n1.0 1.0 0.0 0.0\n-1.0 0.0 -1.0 0.0\n0.5 0.5 0.5 0.5",
"1 1\n1.0"
],
"output": [
"1.0",
"3.0",
"1.0"
]
} | {
"input": [
"2 3\n1.2834290847607077 1.0\n-1.0 0.0\n0.5 0.5",
"4 3\n1.0 1.0 0.0 0.40562788475787737\n-1.0 0.0 -1.0 0.0\n0.5 0.5 0.5 0.5",
"2 1\n1.0",
"2 3\n1.2834290847607077 1.0\n-1.0 0.27668724595465666\n0.5 0.5",
"8 3\n1.0 1.0 0.0 0.40562788475787737\n-1.0 0.0 -1.0 0.0\n0.5 0.5 0.5 0.5",
"... |
p01582 Cover Time | Let G be a connected undirected graph where N vertices of G are labeled by numbers from 1 to N. G is simple, i.e. G has no self loops or parallel edges.
Let P be a particle walking on vertices of G. At the beginning, P is on the vertex 1. In each step, P moves to one of the adjacent vertices. When there are multiple a... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p01742 Dictionary | Sunuke-kun's dictionary contains the words s1, ..., sn, which consist of n lowercase letters. This satisfies s1 <... <sn when compared in lexicographical order. Unfortunately, some characters are faint and unreadable. Unreadable characters are represented by?. Find out how many ways to restore the dictionary by replaci... | {
"input": [],
"output": []
} | {
"input": [
"2\n?sum??mer\nc??a??mp",
"3\nsnuje\n????e\nsnule"
],
"output": [
"703286064",
"1"
]
} | {
"input": [
"2\n?rum??mer\nc??a??mp",
"3\nsnuje\n????e\neluns",
"2\n?rum??mer\nc@?a??mp",
"3\nsunje\n????e\neluns",
"2\n?rum??mer\ncA?a??mp",
"3\nsunje\n@???e\neluns",
"2\nrem??mur?\ncA?a??mp",
"3\nsunje\n@???e\nsnule",
"2\nsem??mur?\ncA?a??mp",
"3\njunse\n@???e\nsnule",
"... |
p01882 We don't wanna work! | Example
Input
4
Durett 7
Gayles 3
Facenda 6
Daughtery 0
1
+ Mccourtney 2
Output
Mccourtney is not working now.
Durett is working hard now. | {
"input": [],
"output": []
} | {
"input": [
"4\nDurett 7\nGayles 3\nFacenda 6\nDaughtery 0\n1\n+ Mccourtney 2"
],
"output": [
"Mccourtney is not working now.\nDurett is working hard now."
]
} | {
"input": [
"4\nDurett 7\nGayles 3\nFacenda 6\nyrethguaD 0\n1\n+ Mccourtney 2",
"4\nDurett 7\nGayles 3\nFacenda 10\nyrethguaD 0\n1\n+ Mccourtney 2",
"4\nDurett 10\nGayles 4\nF`cenda 10\nyrethguaD 0\n1\n+ Mccourtney 1",
"4\nDurett 7\nGayles 3\nFacenda 6\nDaughtery 0\n1\n+ yentruoccM 3",
"4\nDurett... |
p02019 Training | E-training
Nene is writing a program to look up $ N $ integers $ V_1, V_2, V_3, \ cdots, V_N $ for programming training.
As told by his instructor, Umiko, Nene wrote a program to look up multiples of 2, 3, and 6.
Multiples of 2 were $ A $, multiples of 3 were $ B $, and multiples of 6 were $ C $.
Umiko told me to l... | {
"input": [],
"output": []
} | {
"input": [
"6 3 2 1"
],
"output": [
"2"
]
} | {
"input": [
"6 5 2 1",
"9 5 2 1",
"12 5 2 1",
"0 5 2 1",
"-1 5 2 1",
"-1 0 2 0",
"-1 0 1 0",
"-2 0 2 0",
"-2 0 8 0",
"0 -2 2 -1",
"0 -2 1 0",
"2 -1 0 -1",
"2 -1 -1 0",
"2 -2 -1 0",
"2 -2 -2 1",
"3 -2 -2 1",
"4 -2 -2 1",
"8 -1 -2 -1",
"10 -1 ... |
p02161 1333 | Problem
Given the string $ S $ of length $ N $. Process the following query $ Q $ times.
Query
Let $ S [L: R] $ be a character string consisting of $ S $ from the $ L $ character to the $ R $ character (including both ends).
Represent $ S [L: R] $ as $ AXBXCX (1 \ leq | A |, | B |, | C |, | X |) $ using the appropria... | {
"input": [],
"output": []
} | {
"input": [
"12 3\nitisansansan\n1 12\n5 12\n6 7",
"21 6\naaaabaaaabaaaaaaaaaab\n1 21\n10 21\n10 18\n4 16\n11 21\n1 6",
"20 2\nsensanbyakusanjuusan\n1 20\n1 14"
],
"output": [
"2\n1\n0",
"4\n0\n2\n2\n0\n1",
"3\n1"
]
} | {
"input": [
"12 3\nitisaosansan\n1 12\n5 12\n6 7",
"21 6\naaaabaaaabaaaaaaaaaab\n1 21\n10 21\n10 18\n4 16\n11 21\n1 5",
"20 2\nsensanbyakusanjuusan\n1 20\n1 1",
"20 2\nnasuujnasukaybnasnes\n1 20\n1 1",
"20 3\nnasuujnasukaybnasnes\n1 20\n0 1",
"12 3\nitisansansan\n1 1\n5 12\n6 7",
"21 6\na... |
p02302 Convex Cut | <image>
As shown in the figure above, cut a convex polygon g by a line p1p2 and print the area of the cut polygon which is on the left-hand side of the line.
g is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 ≤ i ≤ n−1) are sides of the convex polygon. The line segm... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 1\n4 1\n4 3\n1 3\n2\n2 0 2 4\n2 4 2 0"
],
"output": [
"2.00000000\n4.00000000"
]
} | {
"input": [
"4\n1 1\n4 1\n4 3\n1 3\n2\n2 0 2 5\n2 4 2 0",
"4\n1 1\n4 1\n4 3\n0 3\n2\n2 0 2 5\n2 4 2 0",
"4\n1 1\n4 2\n4 3\n0 3\n2\n2 0 2 5\n2 4 2 0",
"4\n1 1\n4 2\n4 3\n0 3\n2\n2 0 2 5\n0 4 2 0",
"4\n1 1\n4 2\n4 3\n0 3\n2\n2 0 2 0\n0 4 2 0",
"4\n1 1\n4 2\n4 3\n0 3\n2\n2 0 0 0\n0 4 2 0",
"... |
p02449 Permutation | For given a sequence $A = \\{a_0, a_1, ..., a_{n-1}\\}$, print the previous permutation and the next permutation in lexicographic order.
Constraints
* $1 \leq n \leq 9$
* $a_i$ consist of $1, 2, ..., n$
Input
A sequence is given in the following format.
$n$
$a_0 \; a_1 \; ... \; a_{n-1}$
Output
Print the previ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 2 1",
"3\n2 1 3"
],
"output": [
"3 1 2\n3 2 1",
"1 3 2\n2 1 3\n2 3 1"
]
} | {
"input": [
"3\n3 3 1",
"3\n3 1 3",
"3\n3 3 2",
"3\n6 1 3",
"3\n3 5 2",
"3\n11 1 3",
"3\n0 5 2",
"3\n11 1 4",
"3\n0 10 2",
"3\n6 1 4",
"3\n0 10 1",
"3\n6 1 6",
"3\n0 13 1",
"3\n6 0 6",
"3\n0 13 2",
"3\n6 0 4",
"3\n0 6 2",
"3\n6 0 7",
"3\n0 6... |
caos1 | Problem Statement
Past
In the year of 2048, the Virtual Reality Massively Multiplayer Online Role-Playing Game (VRMMORPG), Code Art Online (CAO), is released. With the Chef Gear, a virtual reality helmet that stimulates the user's five senses via their brain, players can experience and control their in-game characters ... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 5\n^^^^^\n^^^^^\n^^^^#\n^^^^^\n^^^^^\n5 7\n^^#^^^^\n^^#^#^#\n#^^^^^^\n^^#^^#^\n^^^^^^^"
],
"output": [
"0\n1\n"
]
} | {
"input": [
"2\n5 5\n^^^^^\n^^^^^\n^^^]#\n^^^^^\n^^^^^\n5 7\n^^#^^^^\n^^#^#^#\n#^^^^^^\n^^#^^#^\n^^^^^^^",
"2\n5 1\n^^^^^\n^^^^^\n^^^^#\n^^^^^\n^]^^^\n5 7\n^^#^^^_\n^^###^^\n#^^^^^^\n^^#^^#^\n^^^^^^^",
"2\n5 1\n^^^^^\n^^^^^\n^^^^#\n^^^^^\n^^^^^\n5 7\n^^#^^^^\n^^#^#^#\n#^^^^^^\n^^#^^#^\n^^^^^^^",
"2\n... |
crace | In CycleLand Jack and Jenny are two friends.They want to go CycleSchool By a cycle ( Assume that they live in same house) . Distance between CycleSchool and their house is n units. Jack and jenny both like Jelly . They decided to play a game who will win the game ,get a chance to sit with jelly in school. Rules of game... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2\n3"
],
"output": [
"JENNY\nJACK\nJENNY"
]
} | {
"input": [
"3\n1\n3\n3",
"3\n0\n3\n3",
"3\n0\n3\n6",
"3\n0\n2\n6",
"3\n0\n2\n7",
"3\n-1\n2\n7",
"3\n-1\n1\n4",
"3\n5\n0\n2",
"3\n-2\n2\n7",
"3\n-2\n2\n4",
"3\n0\n2\n4",
"3\n0\n1\n4",
"3\n-1\n1\n7",
"3\n-1\n1\n13",
"3\n0\n1\n13",
"3\n0\n1\n14",
"3\n... |
graysc | The Gray code (see wikipedia for more details) is a well-known concept.
One of its important properties is that every two adjacent numbers have exactly one different digit in their binary representation.
In this problem, we will give you n non-negative integers in a sequence A[1..n] (0<=A[i]<2^64), such that every tw... | {
"input": [],
"output": []
} | {
"input": [
"5\n1 0 2 3 7"
],
"output": [
"Yes"
]
} | {
"input": [],
"output": []
} |
maxgame | Tug of war is a sport that directly puts two teams against each other in a test of strength.
During school days, both Chef Shifu and Chef Po were champions of tug of war.
On behalf of restaurant's anniversary, Chef Shifu and Chef Po have decided to conduct
a tug of war game for their customers.
Master Chef Oogway h... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 2\n4 0\n2 1"
],
"output": [
"4\n0\n1"
]
} | {
"input": [
"3\n3 2\n0 0\n2 1",
"3\n3 2\n0 0\n3 1",
"3\n3 2\n0 0\n6 1",
"3\n3 4\n1 -1\n6 1",
"3\n1 4\n1 -1\n6 1",
"3\n1 4\n1 -1\n7 1",
"3\n1 4\n0 -1\n7 1",
"3\n1 2\n0 -1\n7 2",
"3\n1 6\n0 -1\n11 2",
"3\n1 6\n0 -1\n11 0",
"3\n0 6\n0 -1\n11 1",
"3\n0 8\n-1 -1\n1 1",
... |
rbtree | Chef likes trees a lot. Today he has an infinte full binary tree (each node has exactly two childs) with special properties.
Chef's tree has the following special properties :
Each node of the tree is either colored red or black.
Root of the tree is black intially.
Both childs of a red colored node are black and both ... | {
"input": [],
"output": []
} | {
"input": [
"5\nQb 4 5\nQr 4 5\nQi\nQb 4 5\nQr 4 5"
],
"output": [
"2\n1\n1\n2\n"
]
} | {
"input": [
"5\nQb 4 5\nQr 4 5\nQi\nQb 4 5\nQr 6 5",
"5\nQb 4 5\nQr 4 5\nQi\nQb 4 5\nQr 9 5",
"5\nQb 4 1\nQr 4 5\nQi\nQb 4 5\nQr 3 3",
"5\nQb 4 5\nQr 4 5\nQi\nQb 2 5\nQr 2 5",
"5\nQb 4 1\nQr 4 3\nQi\nQb 4 5\nQr 3 3",
"5\nQb 4 1\nQr 5 5\nQi\nQb 4 5\nQr 3 3",
"5\nQb 4 5\nQr 4 3\nQi\nQb 1 5\... |
totr | A tourist is visiting Byteland. The tourist knows English very well. The language of Byteland is rather different from English. To be exact it differs in following points:
Bytelandian alphabet has the same letters as English one, but possibly different in meaning. Like 'A' in Bytelandian may be 'M' in English. However... | {
"input": [],
"output": []
} | {
"input": [
"5 qwertyuiopasdfghjklzxcvbnm\nPh\nPcssi\nBpke_kdc_epclc_jcijsc_mihyo?\nEpcf_kdc_liswhyo_EIED_hy_Vimcvpcn_Zkdvp_siyo_viyecle.\nIpp!"
],
"output": [
"Hi\nHello\nWhat are these people doing?\nThey are solving TOTR in Codechef March long contest.\nOhh!\n"
]
} | {
"input": [
"5 qwertyuiopasdfghjklzxcvbnm\nPh\nisscP\nBpke_kdc_epclc_jcijsc_mihyo?\nEpcf_kdc_liswhyo_EIED_hy_Vimcvpcn_Zkdvp_siyo_viyecle.\nIpp!",
"5 qwertyuiopasdfghjklzxcvbnm\nPh\nisscP\nBpke_kdc_epclc_jcij?c_mihyos\nEpcf_kdc_liswhyo_EIED_hy_Vimcvpcn_Zkdvp_siyo_viyecle.\nIpp!",
"5 qwertyuiopasdfghjklzxc... |
1468_E. Four Segments | Monocarp wants to draw four line segments on a sheet of paper. He wants the i-th segment to have its length equal to a_i (1 ≤ i ≤ 4). These segments can intersect with each other, and each segment should be either horizontal or vertical.
Monocarp wants to draw the segments in such a way that they enclose a rectangular... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 3 4\n5 5 5 5\n3 1 4 1\n100 20 20 100\n"
],
"output": [
"\n3\n25\n3\n2000\n"
]
} | {
"input": [
"4\n1 0 3 4\n5 5 5 5\n3 1 4 1\n100 20 20 100\n",
"4\n1 1 3 4\n5 5 5 5\n3 1 4 1\n100 20 20 100\n",
"4\n1 1 3 4\n5 5 3 5\n3 1 4 1\n100 20 20 100\n",
"4\n1 1 3 4\n5 5 3 5\n1 1 4 1\n100 20 20 101\n",
"4\n1 1 3 4\n5 5 3 5\n1 1 4 1\n101 20 20 101\n",
"4\n1 1 3 4\n2 5 3 5\n1 1 4 1\n101 2... |
802_E. Marmots (medium) | Good job! Now that Heidi is able to distinguish between Poisson and uniform distributions, she is in a good position to actually estimate the populations.
Can you help Heidi estimate each village's population?
Input
Same as the easy version.
Output
Output one line per village, in the same order as provided in the ... | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} | {
"input": [],
"output": []
} |
asdasd-1 | Sherlock and Watson were good friends. They both were solving a mystery. But they got hungry and wanted to eat something.
Hence they asked for some candies from Mom. Mom was also clever. She told them to solve a function for her.
Function is defined as follows -
F(x) = 2^x - 1
She gave number "a" to Shelock and "b"... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 1\n2 2\n\nSAMPLE"
],
"output": [
"0\n1\n"
]
} | {
"input": [
"2\n1 1\n2 2\n\nTAMPLE",
"2\n2 1\n2 1\n\nEAMPLT",
"2\n2 2\n2 2\n\nEAMPLT",
"2\n2 2\n2 1\n\nEAMPLT",
"2\n4 4\n2 7\n\nEMQAMT",
"2\n7 1\n4 4\n\nDNQAMT",
"2\n4 2\n4 4\n\nLADPLT",
"2\n4 4\n2 8\n\nE@TPMN",
"2\n2 1\n2 2\n\nTAMPLE",
"2\n2 1\n2 2\n\nEAMPLT",
"2\n1 1\n2 ... |
little-monty-and-fibonacci-1 | Little Monty is very fond of Fibonacci numbers and challenges his friend Lopa
that he can solve any question regarding the same. Lopa however is jealous
and after thinking for a long time came up with a problem.
She says given
N(the number of fibonacci numbers) one has to count all the multiples of all
the fibon... | {
"input": [],
"output": []
} | {
"input": [
"3\n1\n2\n3\n\nSAMPLE"
],
"output": [
"1\n4\n7\n"
]
} | {
"input": [
"3\n1\n2\n4\n\nSAMPLE",
"3\n1\n4\n4\n\nSAMPLE",
"3\n1\n4\n7\n\nSALPME",
"3\n1\n2\n5\n\nSAMPLE",
"3\n1\n1\n4\n\nSAMPLE",
"3\n1\n4\n1\n\nSALPME",
"3\n1\n4\n6\n\nSALPME",
"3\n1\n2\n9\n\nSAMPLE",
"3\n2\n1\n4\n\nSAMPLE",
"3\n2\n4\n1\n\nSALPME",
"3\n1\n8\n6\n\nSALPME... |
sandy-permutes | Sandy is given an array of N integers which is a permutation of the first N natural numbers. He can swap any two elements of the array and can make at most K swaps. He needs to tell the largest permutation, in numerical order, could be made? You being sandy's friend help him in doing so.
Input Format:-
The first line ... | {
"input": [],
"output": []
} | {
"input": [
"5 1\n4 2 3 5 1\n\nSAMPLE"
],
"output": [
"5 2 3 4 1\n"
]
} | {
"input": [
"5 1\n4 2 3 5 1\n\nSAMOLE",
"5 1\n4 2 3 5 0\n\nSAMPLE",
"5 1\n2 2 3 5 0\n\nSAMPLE",
"5 1\n3 2 3 5 0\n\nSAMPLE",
"5 1\n4 0 3 5 1\n\nSAMPLE",
"5 1\n2 3 3 5 0\n\nSAMPLE",
"5 1\n3 2 1 5 0\n\nSAMPKE",
"5 1\n4 2 2 5 1\n\nOAMSLE",
"5 1\n3 2 3 5 1\n\nELPMAS",
"5 1\n4 0 3 5... |
supertables-3 | Little Timmy is exceptionally good at math tables, so his maths teacher decided to make things a bit more interesting. His teacher takes two numbers A and B and merges the tables of A and B in sorted order (ascending order), removing the duplicates and thus creates supertable of A and B and asks Little Timmy the Nth nu... | {
"input": [],
"output": []
} | {
"input": [
"4\n3 5 2\n3 5 3\n2 3 4\n2 3 6\n\nSAMPLE"
],
"output": [
"5\n6\n6\n9"
]
} | {
"input": [
"4\n3 5 2\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE",
"4\n3 5 4\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE",
"4\n3 5 4\n2 5 3\n2 3 4\n2 3 2\n\nSAMPLE",
"4\n3 5 6\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE",
"4\n6 5 6\n3 5 3\n2 3 4\n2 3 2\n\nSAMPLE",
"4\n6 5 6\n3 5 4\n2 3 4\n2 3 2\n\nSAMPLE",
"4\n3 5 2\n3 10 3\n... |
whens-the-separatist-next-attack | Separatist
Always finding new ways to destroy the Republic forces by surprise attacks.
Now they trapped the Republic fleet near the Abregado system. They have developed a way to communicate through the encrypted message to its fleet around the Abregado system.
They wrote a message in a cryptic language, and next to ... | {
"input": [],
"output": []
} | {
"input": [
"3\n11001001\ncats\nzig\n\nSAMPLE"
],
"output": [
"201\n75\n11\n"
]
} | {
"input": [
"3\n11001001\ncats\nzig\n\nSAMLPE",
"3\n11000001\ncbtr\ngj|\n\nEPLMAS",
"3\n11001000\ncbtr\nfj|\n\nEOLMAS",
"3\n11001101\nbcsr\n|if\n\nSAMMOE",
"3\n11011101\nbcsr\n|if\n\nSAMMOE",
"3\n11011100\nbcsr\n|if\n\nSAMMOE",
"3\n11011001\nrsbc\n|if\n\nSAMMOE",
"3\n10011001\nsbtc\ni... |
p02626 AtCoder Beginner Contest 172 - Unfair Nim | There are N piles of stones. The i-th pile has A_i stones.
Aoki and Takahashi are about to use them to play the following game:
* Starting with Aoki, the two players alternately do the following operation:
* Operation: Choose one pile of stones, and remove one or more stones from it.
* When a player is unable to do t... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 5",
"3\n4294967297 8589934593 12884901890",
"8\n10 9 8 7 6 5 4 3",
"2\n5 3",
"3\n1 1 2"
],
"output": [
"-1",
"1",
"3",
"1",
"-1"
]
} | {
"input": [
"2\n3 6",
"2\n5 5",
"2\n7 5",
"8\n10 9 8 8 6 9 7 3",
"2\n5 1",
"2\n11 1",
"2\n21 1",
"2\n19 1",
"2\n7 -1",
"3\n869 1 534",
"2\n12 0",
"3\n4294967297 8589934593 8519183127",
"8\n10 9 8 10 6 5 4 3",
"3\n1 1 1",
"2\n3 10",
"3\n4294967297 858993... |
p02757 AtCoder Beginner Contest 158 - Divisible Substring | Takahashi has a string S of length N consisting of digits from `0` through `9`.
He loves the prime number P. He wants to know how many non-empty (contiguous) substrings of S - there are N \times (N + 1) / 2 of them - are divisible by P when regarded as integers written in base ten.
Here substrings starting with a `0`... | {
"input": [],
"output": []
} | {
"input": [
"4 3\n3543",
"20 11\n33883322005544116655",
"4 2\n2020"
],
"output": [
"6",
"68",
"10"
]
} | {
"input": [
"20 8\n33883322005544116655",
"20 5\n33883322005544116655",
"20 5\n35091597582718018558",
"20 3\n35091597582718018558",
"20 5\n34713145004890865366",
"20 5\n63523169932268849551",
"20 2\n33883322005544116655",
"20 5\n39199232665812066366",
"20 1\n33883322005544116655",... |
p02892 AtCoder Grand Contest 039 - Graph Partition | Given is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is `1`, there is an edge connecting Vertex i and j; otherwise, there is no such edge.
Determine whether it is possible to divide the vertices into non-e... | {
"input": [],
"output": []
} | {
"input": [
"2\n01\n10",
"6\n010110\n101001\n010100\n101000\n100000\n010000",
"3\n011\n101\n110"
],
"output": [
"2",
"4",
"-1"
]
} | {
"input": [
"3\n011\n111\n110",
"3\n010\n101\n010",
"3\n011\n111\n111",
"3\n011\n110\n111",
"6\n010111\n101001\n010100\n101000\n100000\n010000",
"3\n010\n101\n110",
"3\n011\n011\n110",
"3\n011\n111\n011",
"3\n011\n011\n011",
"6\n010110\n101001\n010100\n101000\n100100\n010000",... |
p03027 M-SOLUTIONS Programming Contest - Product of Arithmetic Progression | Consider the following arithmetic progression with n terms:
* x, x + d, x + 2d, \ldots, x + (n-1)d
What is the product of all terms in this sequence? Compute the answer modulo 1\ 000\ 003.
You are given Q queries of this form. In the i-th query, compute the answer in case x = x_i, d = d_i, n = n_i.
Constraints
*... | {
"input": [],
"output": []
} | {
"input": [
"2\n7 2 4\n12345 67890 2019"
],
"output": [
"9009\n916936"
]
} | {
"input": [
"2\n7 2 4\n12345 17991 2019",
"2\n7 2 0\n12345 17991 2019",
"2\n7 2 0\n12345 17991 2755",
"2\n7 2 0\n9796 17991 2755",
"2\n7 2 4\n12345 86689 2019",
"2\n7 2 4\n12345 17991 226",
"2\n7 2 0\n12345 25838 2019",
"2\n7 2 1\n9796 17991 2755",
"2\n7 2 4\n23706 86689 2019",
... |
p03168 Educational DP Contest - Coins | Let N be a positive odd number.
There are N coins, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i.
Taro has tossed all the N coins. Find the probability of having more heads than tails.
Constraints
* N is an od... | {
"input": [],
"output": []
} | {
"input": [
"5\n0.42 0.01 0.42 0.99 0.42",
"1\n0.50",
"3\n0.30 0.60 0.80"
],
"output": [
"0.3821815872",
"0.5",
"0.612"
]
} | {
"input": [
"5\n1.024501914223776 0.01 0.42 0.99 0.42",
"1\n1.0727834824798",
"3\n0.5605093833878567 0.60 0.80",
"5\n1.024501914223776 0.01 0.5446982864891694 0.99 0.42",
"1\n1.4147366857390051",
"3\n0.63370309829039 0.60 0.80",
"5\n1.024501914223776 0.01 0.5446982864891694 1.826587176924... |
p03313 AtCoder Regular Contest 100 - Or Plus Max | There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.)
For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following problem:
* Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-1 and (i or j) \leq K. Here, or denot... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2 3 1",
"3\n10 71 84 33 6 47 23 25",
"4\n75 26 45 72 81 47 97 97 2 2 25 82 84 17 56 32"
],
"output": [
"3\n4\n5",
"81\n94\n155\n155\n155\n155\n155",
"101\n120\n147\n156\n156\n178\n194\n194\n194\n194\n194\n194\n194\n194\n194"
]
} | {
"input": [
"2\n1 2 3 2",
"3\n10 71 84 33 6 32 23 25",
"4\n75 26 45 72 81 47 97 97 2 2 25 95 84 17 56 32",
"2\n0 2 3 2",
"3\n10 71 155 33 6 32 23 25",
"4\n75 26 45 112 81 47 97 97 2 2 25 95 84 17 56 32",
"3\n8 71 155 33 6 32 23 25",
"3\n8 130 155 33 6 32 23 25",
"4\n75 10 45 112 8... |
p03470 AtCoder Beginner Contest 085 - Kagami Mochi | An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have... | {
"input": [],
"output": []
} | {
"input": [
"7\n50\n30\n50\n100\n50\n80\n30",
"3\n15\n15\n15",
"4\n10\n8\n8\n6"
],
"output": [
"4",
"1",
"3"
]
} | {
"input": [
"7\n50\n30\n50\n100\n50\n80\n35",
"3\n29\n15\n15",
"4\n10\n8\n14\n6",
"3\n29\n15\n14",
"7\n50\n40\n91\n110\n50\n34\n59",
"7\n50\n40\n91\n110\n3\n34\n59",
"3\n1\n1\n1",
"7\n50\n30\n50\n100\n50\n80\n59",
"4\n10\n8\n16\n6",
"7\n50\n40\n50\n100\n50\n80\n59",
"3\n29... |
p03632 AtCoder Beginner Contest 070 - Two Switches | Alice and Bob are controlling a robot. They each have one switch that controls the robot.
Alice started holding down her button A second after the start-up of the robot, and released her button B second after the start-up.
Bob started holding down his button C second after the start-up, and released his button D second... | {
"input": [],
"output": []
} | {
"input": [
"10 90 20 80",
"0 75 25 100",
"0 33 66 99"
],
"output": [
"60",
"50",
"0"
]
} | {
"input": [
"10 17 20 80",
"1 75 25 100",
"1 80 25 100",
"-1 2 1 10",
"10 90 20 58",
"0 75 22 100",
"1 72 25 100",
"1 34 25 100",
"-1 3 1 10",
"0 75 36 100",
"0 98 66 99",
"19 90 29 58",
"0 148 36 100",
"1 6 -1 4",
"-1 98 66 83",
"0 33 25 110",
"0 6... |
p03790 AtCoder Grand Contest 011 - Train Service Planning | There is a railroad in Takahashi Kingdom. The railroad consists of N sections, numbered 1, 2, ..., N, and N+1 stations, numbered 0, 1, ..., N. Section i directly connects the stations i-1 and i. A train takes exactly A_i minutes to run through section i, regardless of direction. Each of the N sections is either single-... | {
"input": [],
"output": []
} | {
"input": [
"3 10\n4 1\n3 1\n4 1",
"6 4\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1",
"20 987654321\n129662684 2\n162021979 1\n458437539 1\n319670097 2\n202863355 1\n112218745 1\n348732033 1\n323036578 1\n382398703 1\n55854389 1\n283445191 1\n151300613 1\n693338042 2\n191178308 2\n386707193 1\n204580036 1\n335134457 1... | {
"input": [
"3 15\n4 1\n3 1\n4 1",
"6 4\n1 1\n0 1\n1 1\n1 1\n1 1\n1 1",
"20 987654321\n129662684 2\n162021979 1\n458437539 1\n258406183 2\n202863355 1\n112218745 1\n348732033 1\n323036578 1\n382398703 1\n55854389 1\n283445191 1\n151300613 1\n693338042 2\n191178308 2\n386707193 1\n204580036 1\n335134457 1... |
p03958 CODE FESTIVAL 2016 qual C - K Cakes | There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all.
There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.
Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating ... | {
"input": [],
"output": []
} | {
"input": [
"7 3\n3 2 2",
"6 3\n1 4 1",
"100 1\n100"
],
"output": [
"0",
"1",
"99"
]
} | {
"input": [
"7 3\n4 2 2",
"6 2\n1 4 1",
"100 2\n100",
"110 2\n110",
"7 3\n2 2 2",
"7 3\n2 1 2",
"7 3\n0 1 2",
"7 3\n0 1 1",
"7 3\n0 1 0",
"7 3\n-1 1 1",
"7 5\n-1 1 1",
"7 3\n4 1 2",
"6 2\n1 0 1",
"7 3\n2 2 1",
"12 3\n2 1 2",
"7 3\n1 1 2",
"7 3\n1 1 ... |
p00050 Apple and Peach | Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the description about apples and the description about peaches in reverse.
Yo... | {
"input": [],
"output": []
} | {
"input": [
"the cost of one peach is higher than that of one apple."
],
"output": [
"the cost of one apple is higher than that of one peach."
]
} | {
"input": [
"the cost of one peach is higher than th`t of one apple.",
"the cost of ooe peach is higher than th`t of one apple.",
"the cost of ooe peach is higher than th`t of eno apple.",
"the cpst of ooe peach is higher than th`t of eno apple.",
"the cpst of ooe peach is higher than t`ht of eno... |
p00180 Demolition of Bridges | Water Country Water Deven has n cities. Each city is surrounded by water and looks like an island country. Water Deven has m bridges, and transportation between cities is carried out by these bridges, which allows you to travel to and from all cities.
Recently, it was decided to reduce the maintenance cost of the brid... | {
"input": [],
"output": []
} | {
"input": [
"5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 2\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0"
],
"output": [
"10\n6"
]
} | {
"input": [
"5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 1\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0",
"5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 3\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0",
"5 6\n0 2 1\n2 1 3\n2 3 8\n1 3 0\n3 4 5\n1 4 4\n3 3\n1 2 3\n2 0 3\n0 1 3\n0 0",
"5 6\n0 2 1\n2 1 3\n2 3 6\n0 3 1\n3 4 8\n1 3 4\n3... |
p00336 Repeated Spell | We, the researchers who discovered and investigated the ancient nation Iwashiro, finally discovered the temple in the center of Iwashiro. A lithograph dedicated to the god of Iwashiro was stored in the temple. On the lithograph, two strings were written, one for each sentence and one for the spell.
In Iwashiro, how ma... | {
"input": [],
"output": []
} | {
"input": [
"data\nstructure",
"aaaabaaaabaaaabaaaab\naaaaa",
"abab\nab"
],
"output": [
"0",
"4368",
"3"
]
} | {
"input": [
"data\nerutcurts",
"aaaabaaaabaaaabaaaab\nbaaaa",
"abaa\nab",
"aaaabaaaabaaaabaaaab\naabaa",
"aaaabaaaabaa`abaaaab\naabaa",
"aaaabaaaabaa`ababaaa\naabaa",
"aaaabaaaabaa`ababaaa\na`baa",
"aaaabaaaabaa`ababaaa\nb`baa",
"`caa\nca",
"aaaabbaaabaa`ababaaa\nb`baa",
"... |
p00527 Take the 'IOI' train | Take the'IOI'train
A new railway has been laid in IOI. Trains running on railways in IOI are a combination of several vehicles, and there are two types of vehicles, I and O. Vehicles can only be connected to different types of vehicles. Also, because the train has a driver's seat, the cars at both ends of the train mu... | {
"input": [],
"output": []
} | {
"input": [
"5 5\nOIOOI\nOOIOI"
],
"output": [
"7"
]
} | {
"input": [
"5 0\nOIOOI\nOOIOI",
"5 5\nOIOOI\nIOIOO",
"0 9\nOIOOI\nIOIOO",
"0 0\nOIOOI\nOOIOI",
"5 0\nOIOOI\nOOIPI",
"5 9\nOIOOI\nIOIOO",
"5 0\nOIOOI\nOOINI",
"5 5\nIOOIO\nIOIOO",
"5 1\nOIOOI\nOOIPI",
"5 1\nOIOOI\nOOIPH",
"5 0\nOIOOI\nOOIPH",
"7 0\nOIOOI\nOOIPH",
"... |
p00694 Strange Key | Professor Tsukuba invented a mysterious jewelry box that can be opened with a special gold key whose shape is very strange. It is composed of gold bars joined at their ends. Each gold bar has the same length and is placed parallel to one of the three orthogonal axes in a three dimensional space, i.e., x-axis, y-axis an... | {
"input": [],
"output": []
} | {
"input": [
"19\n 1 +x 1 +y +z 3 +z\n 3 +y -z +x +y -z -x +z 2 +z\n 2 +y\n19\n 1 +x 1 +y +z 3 +y -z +x +y -z -x +z 2 +y\n 3 +z\n 2 +z\n19\n 1 +x 1 +y +z 3 +z\n 3 +y -z +x +y -z -x +z 2 +y\n 2 +z\n18\n 1 -y\n 1 +y -z +x\n 1 +z +y +x +z +y -x -y 2 -y\n 2 +z\n3 +x +y +z\n3 +y +z -x\n0",
"19\n1 +x 1... | {
"input": [
"19\n 1 +x 1 +y +z 3 +z\n 3 +y -z +x +y -z -x +z 2 +z\n 2 +y\n19\n 1 +x 1 +x +z 3 +y -z +x +y -z -x +z 2 +y\n 3 +z\n 2 +z\n19\n 1 +x 1 +y +z 3 +z\n 3 +y -z +x +y -z -x +z 2 +y\n 2 +z\n18\n 1 -y\n 1 +y -z +x\n 1 +z +y +x +z +y -x -y 2 -y\n 2 +z\n3 +x +y +z\n3 +y +z -x\n0",
"19\n1 +x 1... |
p00835 Crossing Prisms | Prof. Bocchan is a mathematician and a sculptor. He likes to create sculptures with mathematics.
His style to make sculptures is very unique. He uses two identical prisms. Crossing them at right angles, he makes a polyhedron that is their intersection as a new work. Since he finishes it up with painting, he needs to k... | {
"input": [],
"output": []
} | {
"input": [
"4\n5 0\n0 10\n7 5\n10 5\n4\n7 5\n10 5\n5 0\n0 10\n4\n0 10\n10 10\n10 0\n0 0\n3\n0 0\n0 10\n10 0\n4\n0 10\n10 5\n0 0\n9 5\n4\n5 0\n0 10\n5 5\n10 10\n4\n0 5\n5 10\n10 5\n5 0\n4\n7 1\n4 1\n0 1\n9 5\n0"
],
"output": [
"194.8255\n194.8255\n600.0000\n341.4214\n42.9519\n182.5141\n282.8427\n149.2470... | {
"input": [
"4\n5 0\n0 10\n7 5\n10 5\n4\n7 5\n10 5\n5 0\n0 10\n4\n0 10\n10 10\n10 0\n0 0\n3\n0 0\n0 10\n10 0\n4\n0 10\n10 5\n0 0\n9 5\n4\n5 0\n0 10\n5 3\n10 10\n4\n0 5\n5 10\n10 5\n5 0\n4\n7 1\n4 1\n0 1\n9 5\n0",
"4\n5 0\n0 10\n7 5\n10 5\n4\n7 5\n10 5\n5 0\n0 10\n4\n0 10\n10 10\n10 0\n0 0\n3\n0 0\n0 10\n10 0... |
p00967 Counting Cycles | Problem K Counting Cycles
Given an undirected graph, count the number of simple cycles in the graph. Here, a simple cycle is a connected subgraph all of whose vertices have degree exactly two.
Input
The input consists of a single test case of the following format.
$n$ $m$
$u_1$ $v_1$
...
$u_m$ $v_m$
A test case ... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n1 2\n1 3\n1 4\n2 3\n3 4"
],
"output": [
"3"
]
} | {
"input": [
"4 3\n1 2\n1 3\n1 4\n2 3\n3 4",
"4 4\n1 2\n1 3\n3 4\n2 3\n5 5",
"4 5\n1 2\n1 3\n1 4\n2 3\n2 4",
"4 3\n1 2\n1 3\n1 4\n2 3\n1 4",
"4 3\n1 2\n1 3\n1 4\n2 3\n3 7",
"4 3\n1 2\n1 3\n1 4\n2 3\n5 7",
"4 3\n1 2\n1 3\n1 4\n2 3\n5 6",
"4 3\n1 2\n1 3\n2 4\n2 3\n3 7",
"4 3\n1 2\n1 ... |
p01099 Warp Drive | Warp Drive
<image>
The warp drive technology is reforming air travel, making the travel times drastically shorter. Aircraft reaching above the warp fields built on the ground surface can be transferred to any desired destination in a twinkling.
With the current immature technology, however, building warp fields is q... | {
"input": [],
"output": []
} | {
"input": [
"3 4\n100 4\n100 0\n0 0\n1 2 1.00\n2 1 1.00\n3 1 9.99\n3 2 9.99\n7 6\n0 0\n1 0\n2 0\n0 10\n1 10\n2 10\n20 5\n1 7 1.00\n2 7 1.00\n3 7 1.00\n4 7 1.00\n5 7 1.00\n6 7 1.00\n4 4\n-1 -1\n1 -1\n-1 1\n1 1\n1 4 1.10\n4 2 2.10\n2 3 3.10\n3 1 4.10\n8 12\n-91 0\n-62 0\n-18 0\n2 0\n23 0\n55 0\n63 0\n80 0\n2 7 3.9... | {
"input": [
"3 4\n100 4\n100 0\n0 0\n1 2 1.00\n2 1 1.00\n3 1 9.99\n3 2 9.99\n7 6\n0 0\n1 0\n2 0\n0 10\n1 10\n2 10\n20 5\n1 7 1.00\n2 7 1.00\n4 7 1.00\n4 7 1.00\n5 7 1.00\n6 7 1.00\n4 4\n-1 -1\n1 -1\n-1 1\n1 1\n1 4 1.10\n4 2 2.10\n2 3 3.10\n3 1 4.10\n8 12\n-91 0\n-62 0\n-18 0\n2 0\n23 0\n55 0\n63 0\n80 0\n2 7 3.9... |
p01236 Median Filter | The median filter is a nonlinear digital filter used to reduce noise in images, sounds, and other kinds of signals. It examines each sample of the input through a window and then emits the median of the samples in the win- dow. Roughly speaking, a window is an interval that contains a target sample and its preceding an... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n\n\n\n\n\n4 4\n\n\n\n\n4 4\n...\n....\n....\n...#\n4 4\n.#.#\n.#.\n.#.#\n.#.\n0 0",
"5 5\n#####\n#####\n#####\n#####\n#####\n4 4\n####\n####\n####\n####\n4 4\n#...\n....\n....\n...#\n4 4\n.#.#\n#.#.\n.#.#\n#.#.\n0 0"
],
"output": [
"Case 1: 10\nCase 2: 6\nCase 3: 2\nCase 4: Impossib... | {
"input": [
"5 5\n\n\n\n\n\n4 4\n\n\n\n\n4 4\n...\n....\n....\n...#\n4 4\n.#.#\n.\".\n.#.#\n.#.\n0 0",
"5 5\n#####\n#####\n#####\n#####\n#####\n3 4\n####\n####\n####\n####\n4 4\n#...\n....\n....\n...#\n4 4\n.#.#\n#.#.\n.#.#\n#.#.\n0 0",
"5 5\n#####\n#####\n#####\n##\"##\n#####\n3 4\n####\n####\n####\n###... |
p01398 Swap Cipher | Problem A: Swap crypto
A 2D enthusiast at R University, he often writes embarrassing sentences that blush when seen by people. Therefore, in order for a third party to not be able to see the text he is writing, he encrypts the text using a method called swap encryption that he devised independently. In swap encryption... | {
"input": [],
"output": []
} | {
"input": [
"1\ntojxo\n1 4\n5\nuhcqmlmkv\n4 5\n6 9\n3 6\n1 7\n3 6\n5\nshzxadexonr\n8 9\n3 9\n5 8\n4 9\n10 11\n0"
],
"output": [
"aojwo\nshinryaku\nshitadegeso"
]
} | {
"input": [
"1\ntojxo\n1 4\n5\nuhcqmlmkv\n4 5\n6 9\n3 6\n1 7\n3 6\n5\nshzxadexonr\n8 9\n3 9\n5 9\n4 9\n10 11\n0",
"1\ntojxo\n1 4\n5\nuhcqmlnkv\n4 5\n6 9\n3 6\n1 7\n3 6\n5\nshzxadexonr\n8 9\n3 9\n5 8\n4 9\n10 11\n0",
"1\ntojxo\n1 4\n5\nuhcqmlnkv\n4 5\n6 9\n3 6\n1 4\n3 6\n5\nshzxadexonr\n8 9\n3 9\n5 8\n4 9... |
p01551 DNA | A gene is a string consisting of `A`,` T`, `G`,` C`. The genes in this world are strangely known to obey certain syntactic rules.
Syntax rules are given in the following form:
Non-terminal symbol 1: Symbol 1_1 Symbol 1_2 ... Symbol 1_n1
Non-terminal symbol 2: Symbol 2_1 Symbol 2_2 ... Symbol 2_n2
...
Non-terminal sy... | {
"input": [],
"output": []
} | {
"input": [
"1 1 1 2\n1\nk: [ATG] [ATG] [ATG] [C] [C]",
"3 1 1 1\n3\ninv: at b b b\nat: [ATG] b\nb: [C]",
"1 0 1 0\n3\ndna: a b\na: [AT]\nb: [GC]"
],
"output": [
"6",
"0",
"1"
]
} | {
"input": [
"1 0 1 2\n1\nk: [ATG] [ATG] [ATG] [C] [C]",
"1 1 1 2\n1\nk: [ASG] [ATG] [ATG] [C] [C]",
"2 1 1 1\n3\ninv: at b b b\nat: [ATG] b\nb: [C]",
"0 1 1 1\n3\ninv: at b b b\nat: [ATG] b\nb: [C]",
"0 2 1 1\n3\ninv: at b b b\nat: [ATG] b\nb: [C]",
"1 1 1 1\n3\ninv: at b b b\nat: [ATG] b\nb:... |
p01707 Cookie Counter | Problem Statement
One day, my grandmas left $N$ cookies. My elder sister and I were going to eat them immediately, but there was the instruction. It said
* Cookies will go bad; you should eat all of them within $D$ days.
* Be careful about overeating; you should eat strictly less than $X$ cookies in a day.
My sist... | {
"input": [],
"output": []
} | {
"input": [
"5 2 5\n3 3 3\n5 4 5\n4 1 2\n1 5 1\n1250 50 50\n0 0 0"
],
"output": [
"4\n7\n52\n0\n0\n563144298"
]
} | {
"input": [
"5 2 5\n3 3 3\n5 4 5\n4 1 2\n1 5 1\n743 50 50\n0 0 0",
"5 2 5\n6 3 3\n5 4 5\n4 1 4\n1 5 1\n743 50 50\n0 0 0",
"5 2 5\n3 3 3\n5 4 5\n4 2 2\n1 5 1\n1250 50 50\n0 0 0",
"5 2 5\n3 3 3\n5 4 5\n4 1 4\n1 5 1\n1377 50 50\n0 0 0",
"5 2 5\n3 3 3\n5 4 5\n4 2 2\n1 5 1\n1250 87 50\n0 0 0",
"5 ... |
p01852 Finger Counting | Problem statement
Meatishi can increase or decrease the number of fingers.
There are n buns in front of Nikunishi-kun.
Meatishi is trying to count the number of steamed buns by breaking his finger.
There are only two shapes that Nishikun's fingers can take, whether they are broken or not.
Nikunishi understands binary ... | {
"input": [],
"output": []
} | {
"input": [
"0"
],
"output": [
"0"
]
} | {
"input": [
"1",
"2",
"4",
"9",
"19",
"38",
"83",
"159",
"296",
"000",
"545",
"1241",
"2473",
"6042",
"9030",
"17679",
"33209",
"96405",
"140502",
"299812",
"763679",
"1237235",
"3",
"7",
"5",
"6",
"8",
"1... |
p01987 Casino | casino
The company you work for is developing a new casino game. Today I decided to consider a recently proposed game.
In this game, N dice are rolled at the same time, and the total number of rolls is the score. The player plays with the goal of increasing the score. If you don't like the roll, you can roll the dice... | {
"input": [],
"output": []
} | {
"input": [
"1 2\n2 1\n2 2\n0 0"
],
"output": [
"4.25\n7\n7.9722222222"
]
} | {
"input": [
"1 2\n4 1\n2 2\n0 0",
"1 2\n4 1\n3 2\n0 0",
"1 4\n4 1\n3 2\n0 0",
"1 4\n4 1\n1 2\n0 0",
"1 4\n4 2\n1 2\n0 0",
"1 1\n4 1\n2 2\n0 0",
"1 4\n4 2\n1 1\n0 0",
"1 1\n4 1\n1 2\n0 0",
"1 6\n4 2\n1 1\n0 0",
"1 6\n4 1\n1 1\n0 0",
"1 2\n8 1\n2 2\n0 0",
"1 4\n4 2\n3 2\... |
p02133 Matrix | Problem
Given a sequence $ A $ of length $ H $ and a sequence $ B $ of length $ W $.
Define the matrix $ C $ consisting of $ H $ rows and $ W $ columns as follows.
$ C_ {i, j} = A_i \ times B_j (1 \ leq i \ leq H, 1 \ leq j \ leq W) $
Process the following four types of queries a total of $ Q $ times.
Query 1
$ 1 $... | {
"input": [],
"output": []
} | {
"input": [
"4 4 7\n1 2 3 4\n1 2 3 4\n3 2 3 2 3\n4 2 3 2 3\n3 1 1 1 1\n4 1 1 1 1\n1 1 1 1\n3 1 4 1 2\n4 2 3 2 4",
"4 4 7\n0 1 0 1\n1 0 1 0\n3 2 4 1 3\n4 1 4 1 4\n1 1 4 -1\n3 1 3 1 3\n1 3 3 2\n2 3 3 -2\n3 2 4 2 4",
"36 4 20\n-523 -460 -536 -885 652 782 513 -558 -521 -808 124 -708 -943 52 -856 -755 -958 91... | {
"input": [
"4 4 7\n1 2 3 4\n1 2 3 4\n3 2 3 2 3\n4 2 3 2 3\n3 1 1 1 2\n4 1 1 1 1\n1 1 1 1\n3 1 4 1 2\n4 2 3 2 4",
"4 4 7\n0 1 0 1\n1 0 1 0\n3 2 4 1 2\n4 1 4 1 4\n1 1 4 -1\n3 1 3 1 3\n1 3 3 2\n2 3 3 -2\n3 2 4 2 4",
"36 4 20\n-523 -460 -536 -885 652 782 513 -558 -521 -808 124 -708 -943 52 -856 -755 -958 91... |
p02274 The Number of Inversions | For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:
bubbleSort(A)
cnt = 0 // the number of inversions
for i = 0 ... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 1 2",
"5\n3 5 2 1 4"
],
"output": [
"2",
"6"
]
} | {
"input": [
"3\n6 1 2",
"5\n3 10 2 1 4",
"3\n6 1 0",
"5\n3 10 1 1 4",
"3\n0 -1 1",
"5\n1 6 1 0 0",
"3\n-2 -2 -2",
"5\n0 -13 17 1 0",
"5\n2 0 -1 -2 -1",
"5\n4 1 0 0 -1",
"5\n2 1 0 -1 -3",
"3\n6 2 0",
"5\n5 10 1 1 4",
"3\n6 2 1",
"5\n0 10 1 1 4",
"3\n6 2 ... |
p02421 Card Game | Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner ... | {
"input": [],
"output": []
} | {
"input": [
"3\ncat dog\nfish fish\nlion tiger"
],
"output": [
"1 7"
]
} | {
"input": [
"3\nact dog\nfish fish\nlion tiger",
"3\nact god\nfish fith\nlion tiger",
"3\nuea goe\ndirh giuh\nnojk tiger",
"3\nvea hpg\njrie giug\nnpjk rhget",
"3\nv`f ggn\njrhd jgug\njnok ehrug",
"3\nact god\nfish fish\nlion tiger",
"3\nact god\nfish gith\nlion tiger",
"3\nact goe\nf... |
abhstr | Abhi and his friends (Shanky,Anku and Pandey) love to play with strings. Abhi invented a simple game. He will give a string S to his friends. Shanky and Anku will play the game while Pandey is just a spectator. Shanky will traverse the string from beginning (left to right) while Anku will traverse from last (right to l... | {
"input": [],
"output": []
} | {
"input": [
"3\ngoogle\nbreakraekb\naman"
],
"output": [
"SHANKY\nPANDEY\nANKU"
]
} | {
"input": [
"3\ngoogle\nbreakraekb\nnama",
"3\ngoogle\nbreakraekb\naamn",
"3\nelgoog\nbrebkrkeab\nbbmn",
"3\nelgoog\nbrebkrleab\nbbmn",
"3\ngooglf\nberbkslebb\nbmbn",
"3\ngooglf\nbbelskbreb\nbmbn",
"3\ngooglg\nbbelskbreb\nbmbn",
"3\ngooglg\nbbblskeber\nnbmb",
"3\ngooglg\nbbbkbkete... |
chefluck | Every great chef knows that lucky numbers are positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Our chef has recently returned from the Lucky country. He observed that every restaurant in the Lucky country had a luc... | {
"input": [],
"output": []
} | {
"input": [
"5\n7\n4\n11\n1\n15"
],
"output": [
"7\n0\n7\n-1\n\n7\n"
]
} | {
"input": [
"5\n7\n4\n11\n1\n28",
"5\n7\n7\n11\n1\n15",
"5\n7\n6\n11\n1\n28",
"5\n9\n11\n11\n2\n15",
"5\n11\n4\n11\n1\n15",
"5\n7\n4\n17\n1\n28",
"5\n7\n6\n11\n1\n23",
"5\n7\n22\n11\n1\n15",
"5\n3\n3\n11\n1\n28",
"5\n7\n21\n11\n2\n15",
"5\n21\n4\n11\n1\n15",
"5\n7\n11\... |
dividing | Are you fond of collecting some kind of stuff? Mike is crazy about collecting stamps. He is an active member of Stamp Collecting Сommunity(SCC).
SCC consists of N members which are fond of philately. A few days ago Mike argued with the others from SCC. Mike told them that all stamps of the members could be divided in... | {
"input": [],
"output": []
} | {
"input": [
"5\n7 4 1 1 2",
"5\n1 1 1 1 1"
],
"output": [
"YES\n",
"NO\n"
]
} | {
"input": [
"5\n13 4 1 1 2",
"5\n13 1 1 1 -1",
"5\n1 1 1 1 0",
"5\n13 4 1 1 0",
"5\n1 2 1 1 0",
"5\n13 1 1 1 0",
"5\n0 2 1 1 0",
"5\n0 3 1 1 0",
"5\n13 0 1 1 -1",
"5\n0 3 1 0 0",
"5\n8 0 1 1 -1",
"5\n0 3 1 0 1",
"5\n8 1 1 1 -1",
"5\n0 3 0 0 1",
"5\n3 1 1 1 ... |
introsrm | Problem description.
This problem deals with the I/O methods used in codechef. You are supposed to print the integer in its reverse form , or in simple words, print the reverse of the given integer . For instance , reverse of 120 is 21 (not 021) .
Input
The first line of each test case contains an integer T .
fol... | {
"input": [],
"output": []
} | {
"input": [
"3\n1234\n4567\n1"
],
"output": [
"4321\n7654\n1"
]
} | {
"input": [
"3\n1234\n4567\n2",
"3\n196\n4567\n2",
"3\n196\n7458\n2",
"3\n196\n7458\n0",
"3\n196\n11215\n0",
"3\n347\n11215\n0",
"3\n9\n11215\n0",
"3\n3\n11215\n0",
"3\n3\n11215\n1",
"3\n4\n11215\n1",
"3\n5\n11215\n0",
"3\n929\n4567\n1",
"3\n1234\n2447\n2",
"3\... |
nmagic | Alice is a very brilliant student. He considers '4' and '7' as Magic numbers. The numbers containing only magic numbers are also magical. Given a magic number N ,he wants to know what could be the next magical number greater than the given number.
Input
First line of input contains number of test cases T. For each t... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n47"
],
"output": [
"7\n74"
]
} | {
"input": [
"2\n4\n20",
"2\n7\n20",
"2\n2\n20",
"2\n2\n12",
"2\n2\n8",
"2\n0\n8",
"2\n0\n9",
"2\n1\n9",
"2\n2\n9",
"2\n4\n9",
"2\n8\n9",
"2\n8\n18",
"2\n8\n22",
"2\n8\n2",
"2\n0\n2",
"2\n0\n3",
"2\n0\n0",
"2\n0\n1",
"2\n1\n1",
"2\n2\n1",... |
seatrsf | Problem Statement
Sereja has a sequence of n integers a[1], a[2], ..., a[n]. Sereja can do following transformation of the array:
create a new sequence of n integers b[1], b[2], ..., b[n]in this way: (1 ≤ i ≤ n)
Replace the sequence a by b, i.e., a[i] = b[i] for all i in [1, n]
Sereja decided to use his trans... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 1 1 1\n2 2 1 1\n2 3 1 1"
],
"output": [
"0\n2\n4"
]
} | {
"input": [
"3\n0 1 1 1\n2 2 1 1\n2 3 1 1",
"3\n0 1 1 1\n4 2 1 1\n2 3 1 1",
"3\n0 1 1 1\n4 1 1 1\n2 3 1 1",
"3\n-1 1 1 0\n4 1 1 1\n2 3 0 1",
"3\n-1 1 1 0\n4 1 1 1\n2 3 -1 1",
"3\n-1 1 1 0\n4 1 1 2\n2 0 -1 2",
"3\n-2 1 1 0\n8 1 0 0\n2 0 -3 2",
"3\n-2 1 1 0\n8 2 0 0\n2 0 -3 2",
"3\n... |
1257_D. Yet Another Monster Killing Problem | You play a computer game. In this game, you lead a party of m heroes, and you have to clear a dungeon with n monsters. Each monster is characterized by its power a_i. Each hero is characterized by his power p_i and endurance s_i.
The heroes clear the dungeon day by day. In the beginning of each day, you choose a hero ... | {
"input": [],
"output": []
} | {
"input": [
"2\n6\n2 3 11 14 1 8\n2\n3 2\n100 1\n5\n3 5 100 2 3\n2\n30 5\n90 1\n"
],
"output": [
"5\n-1\n"
]
} | {
"input": [
"2\n6\n2 3 11 14 1 8\n2\n3 2\n100 1\n5\n3 5 100 2 3\n2\n30 5\n95 1\n",
"2\n6\n3 3 11 14 1 8\n2\n3 1\n100 1\n5\n3 5 100 2 3\n2\n30 5\n90 1\n",
"2\n6\n2 3 11 14 1 8\n2\n3 2\n000 1\n5\n3 5 100 2 3\n2\n30 5\n90 1\n",
"2\n6\n2 3 11 14 1 8\n2\n3 2\n100 2\n5\n3 5 100 0 3\n2\n30 5\n95 1\n",
"... |
1385_E. Directing Edges | You are given a graph consisting of n vertices and m edges. It is not guaranteed that the given graph is connected. Some edges are already directed and you can't change their direction. Other edges are undirected and you have to choose some direction for all these edges.
You have to direct undirected edges in such a w... | {
"input": [],
"output": []
} | {
"input": [
"4\n3 1\n0 1 3\n5 5\n0 2 1\n1 1 5\n1 5 4\n0 5 2\n1 3 5\n4 5\n1 1 2\n0 4 3\n1 3 1\n0 2 3\n1 2 4\n4 5\n1 4 1\n1 1 3\n0 1 2\n1 2 4\n1 3 2\n"
],
"output": [
"YES\n3 1\nYES\n2 1\n1 5\n5 4\n2 5\n3 5\nYES\n1 2\n3 4\n3 1\n3 2\n2 4\nNO\n"
]
} | {
"input": [
"4\n3 1\n0 1 3\n5 5\n1 2 1\n1 1 5\n1 5 4\n0 5 2\n1 3 5\n4 5\n1 1 2\n0 4 3\n1 3 1\n0 2 3\n1 2 4\n4 5\n1 4 1\n1 1 3\n0 1 2\n1 2 4\n1 3 2\n",
"4\n3 1\n0 1 3\n5 5\n0 2 2\n1 1 5\n1 5 4\n0 5 2\n1 3 5\n4 5\n1 1 2\n0 4 3\n1 3 1\n0 2 3\n1 2 4\n4 5\n1 4 1\n1 1 3\n0 1 2\n1 2 4\n1 3 2\n",
"4\n3 1\n0 1 2\... |
1451_A. Subtract or Divide | Ridbit starts with an integer n.
In one move, he can perform one of the following operations:
* divide n by one of its proper divisors, or
* subtract 1 from n if n is greater than 1.
A proper divisor is a divisor of a number, excluding itself. For example, 1, 2, 4, 5, and 10 are proper divisors of 20, but 2... | {
"input": [],
"output": []
} | {
"input": [
"6\n1\n2\n3\n4\n6\n9\n"
],
"output": [
"\n0\n1\n2\n2\n2\n3\n"
]
} | {
"input": [
"6\n1\n2\n3\n4\n6\n16\n",
"6\n1\n2\n3\n7\n6\n16\n",
"6\n1\n2\n3\n7\n1\n30\n",
"6\n1\n2\n3\n4\n11\n9\n",
"6\n1\n3\n3\n4\n6\n16\n",
"6\n1\n2\n3\n7\n6\n45\n",
"6\n1\n2\n3\n7\n1\n17\n",
"6\n1\n2\n3\n4\n1\n9\n",
"6\n1\n2\n3\n7\n1\n1\n",
"6\n1\n2\n3\n14\n6\n45\n",
"6... |
64_H. Table Bowling | Table bowling tournament participant completed the competition according to the given final standings table. The table is given as a sequence of lines, each line has a format "name score". Your task is to prepare another table consisting of lines in the form "place name". Sort participant by score (desc.) and by the na... | {
"input": [],
"output": []
} | {
"input": [
"5\nvasya 10\nted 11\npetya 10\nkatya 33\nmike 44\n",
"3\na 1\nb 13\nc 1\n"
],
"output": [
"1 mike\n2 katya\n3 ted\n4-5 petya\n4-5 vasya\n",
"1 b\n2-3 a\n2-3 c\n"
]
} | {
"input": [],
"output": []
} |
find-mode | Write a program to find the mode of a given list of integers. Mode of a number is defined as the number which is most frequently occured.
For example:
L = {1,2,2,3} // Here mode is 2(most frequently occured)
It is possible that multiple answers are possible for a list. In that case print all possible answers in no... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n1 2 2 2 2 \n6\n1 2 2 3 3 4\n\nSAMPLE"
],
"output": [
"2\n3 2\n"
]
} | {
"input": [
"2\n5\n1 4 2 2 2 \n6\n1 2 2 3 3 4\n\nSAMPLE",
"2\n5\n1 2 2 2 2 \n6\n1 2 2 3 0 4\n\nSAMPLE",
"2\n5\n1 4 2 2 2 \n6\n1 2 0 3 3 4\n\nSAMPLE",
"2\n5\n1 4 0 2 2 \n6\n1 2 1 3 3 4\n\nS@EPLM",
"2\n5\n1 4 3 2 2 \n6\n1 2 2 3 6 6\n\nSAMPLE",
"2\n5\n1 4 0 2 2 \n6\n1 2 1 3 1 4\n\nS@EPLM",
"... |
raju-and-his-girlfriend | Raju has a very pretty girlfriend. He chats with her all day and night through his phone. His phone lacks a QWERTY keypad, instead it has a T9 keypad.
This takes a lot of time to type a message in his phone and he often fears that his girlfriend might get angry if he doesn't reply on time. So he sets a time limit to t... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 1 15\nilu\n1 1 10\nilu\n\nSAMPLE"
],
"output": [
"ilu\nil"
]
} | {
"input": [],
"output": []
} |
simple-divison-1 | Tom is very weak at maths, his teacher gave him a simple problem of dividing two numbers but as usual Tom is having difficulty solving the problem. Can you help tom solve the problem ?
Teacher has given him 3 numbers a, b and c. The task is to divide a by b and write the answer upto c decimal places.
Input:
The firs... | {
"input": [],
"output": []
} | {
"input": [
"3\n21 4 0\n5 4 3\n22 7 10\n\nSAMPLE"
],
"output": [
"5\n1.250\n3.1428571428\n"
]
} | {
"input": [
"3\n21 4 0\n5 4 3\n22 7 12\n\nSAMPLE",
"3\n21 4 0\n5 4 3\n22 7 3\n\nSAMPLE",
"3\n21 4 0\n5 4 3\n22 13 3\n\nSAMPLE",
"3\n21 5 0\n5 4 3\n22 13 3\n\nSAMPLE",
"3\n21 5 0\n5 4 3\n22 26 3\n\nSAMPLE",
"3\n21 5 0\n5 4 5\n22 26 3\n\nSAMPLE",
"3\n21 5 0\n5 4 1\n22 26 3\n\nSAMPLE",
"... |
the-sleeping-barber | Most of you know that how much the sleeping barber loves sleeping, and the way he works.
For those who don't know, it isn't important for now.
Because the problem , that the sleeping barber is facing is a new one for him and because he forgot to take his coding pills, he is not able to tackle with it.
Recently, the ba... | {
"input": [],
"output": []
} | {
"input": [
"2\n5 5\n3 2 1 4 7\n5 10\n5 5 2 7 4\n\nSAMPLE"
],
"output": [
"2\n2\n"
]
} | {
"input": [
"2\n5 5\n3 3 1 4 7\n5 10\n5 5 2 7 4\n\nSAMPLE",
"2\n5 1\n3 3 1 4 7\n5 10\n5 5 2 7 4\n\nSAMPLE",
"2\n3 1\n1 3 1 4 7\n5 10\n5 0 2 7 6\n\nSAMPLE",
"2\n3 1\n1 3 0 4 7\n5 10\n5 0 2 7 6\n\nSAMPLE",
"2\n3 1\n1 3 1 4 7\n5 0\n5 0 2 7 6\n\nSALPLE",
"2\n5 1\n3 3 2 4 7\n5 10\n3 5 2 7 4\n\nSAM... |
p02545 ACL Contest 1 - Center Rearranging | Given are integer sequences A and B of length 3N. Each of these two sequences contains three copies of each of 1, 2, \dots, N. In other words, A and B are both arrangements of (1, 1, 1, 2, 2, 2, \dots, N, N, N).
Tak can perform the following operation to the sequence A arbitrarily many times:
* Pick a value from 1, 2... | {
"input": [],
"output": []
} | {
"input": [
"8\n3 6 7 5 4 8 4 1 1 3 8 7 3 8 2 4 7 5 2 2 6 5 6 1\n7 5 8 1 3 6 7 5 4 8 1 3 3 8 2 4 2 6 5 6 1 4 7 2",
"3\n1 1 1 2 2 2 3 3 3\n1 1 1 2 2 2 3 3 3",
"3\n2 3 3 1 1 1 2 2 3\n3 2 2 1 1 1 3 3 2",
"3\n2 3 1 1 3 2 2 1 3\n1 2 2 3 1 2 3 1 3"
],
"output": [
"7",
"0",
"-1",
"4"
]... | {
"input": [
"3\n2 3 3 1 2 1 2 1 3\n3 2 2 1 1 1 3 3 2",
"3\n1 1 1 2 2 2 3 3 3\n2 1 1 1 2 2 3 3 3",
"3\n1 1 1 2 2 2 3 3 3\n1 1 1 2 3 2 3 3 2",
"3\n2 3 3 1 2 1 2 1 3\n3 2 1 2 1 1 3 3 2",
"3\n2 3 1 1 3 2 2 1 3\n1 2 1 3 1 2 3 2 3",
"3\n3 3 1 1 3 2 2 1 2\n1 1 2 3 2 2 3 1 3",
"3\n2 3 3 1 1 1 3 2... |
p02676 AtCoder Beginner Contest 168 - ... (Triple Dots) | We have a string S consisting of lowercase English letters.
If the length of S is at most K, print S without change.
If the length of S exceeds K, extract the first K characters in S, append `...` to the end of them, and print the result.
Constraints
* K is an integer between 1 and 100 (inclusive).
* S is a string ... | {
"input": [],
"output": []
} | {
"input": [
"7\nnikoandsolstice",
"40\nferelibenterhominesidquodvoluntcredunt"
],
"output": [
"nikoand...",
"ferelibenterhominesidquodvoluntcredunt"
]
} | {
"input": [
"7\necitslosdnaokin",
"40\nferelibenterhominesidquodvomuntcredunt",
"7\nnikoandrolstice",
"40\nferelibenterhominesidquodvonuntcredunt",
"7\noikoandrolstice",
"40\nferelibenterhominesidquodvonuntcreudnt",
"40\nferelhbenterhominesidquodvonuntcreudnt",
"7\noikoancrolstice",
... |
p02804 AtCoder Beginner Contest 151 - Max-Min Sums | For a finite set of integers X, let f(X)=\max X - \min X.
Given are N integers A_1,...,A_N.
We will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. Find the sum of f(S) ove... | {
"input": [],
"output": []
} | {
"input": [
"3 1\n1 1 1",
"4 2\n1 1 3 4",
"10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0",
"6 3\n10 10 10 -10 -10 -10"
],
"output": [
"0",
"11",
"999998537",
"360"
]
} | {
"input": [
"3 1\n1 1 2",
"4 2\n1 1 2 4",
"10 5\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0",
"6 4\n10 10 10 -10 -10 -10",
"4 2\n1 1 1 4",
"6 4\n10 10 10 -10 -10 -13",
"6 4\n10 10 10 -10 -10 0",
"6 4\n10 10 10 -10 -10 -1",
"6 4\n10 4 10 -10 -10 -1",
"6 4\... |
p02940 AtCoder Grand Contest 037 - RGB Balls | We have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if S_i is `R`, green if S_i is `G`, and blue if S_i is `B`. There are N red balls, N green balls, and N blue balls.
Takahashi will distribute these 3N balls to N people so that each pe... | {
"input": [],
"output": []
} | {
"input": [
"3\nRRRGGGBBB",
"5\nBBRGRRGRGGRBBGB"
],
"output": [
"216",
"960"
]
} | {
"input": [
"3\nBBBGGGRRR",
"3\nRRRBGGBGB",
"3\nBRRGGGRBB",
"5\nBGRGRRBRGGRBBGB",
"3\nBGRGGRRBB",
"5\nBGBBRGGRGRRGRBB",
"3\nRGRBGRBGB",
"5\nBGRGRRBBGGRBRGB",
"5\nBRRBRGGBBGRGRGB",
"5\nBRRBRBGBGGRGRGB",
"3\nBBBGGRRGR",
"5\nBRRRRGBBGGGBGRB",
"5\nBRRGRBBBBGRGGRG",
... |
p03077 AtCoder Beginner Contest 123 - Five Transportations | In 2028 and after a continuous growth, AtCoder Inc. finally built an empire with six cities (City 1, 2, 3, 4, 5, 6)!
There are five means of transport in this empire:
* Train: travels from City 1 to 2 in one minute. A train can occupy at most A people.
* Bus: travels from City 2 to 3 in one minute. A bus can occupy a... | {
"input": [],
"output": []
} | {
"input": [
"5\n3\n2\n4\n3\n5",
"10\n123\n123\n123\n123\n123",
"10000000007\n2\n3\n5\n7\n11"
],
"output": [
"7",
"5",
"5000000008"
]
} | {
"input": [
"5\n3\n2\n4\n3\n6",
"10\n123\n219\n123\n123\n123",
"10000000007\n2\n3\n5\n3\n11",
"10000000007\n2\n3\n1\n3\n11",
"10\n123\n633\n27\n9\n123",
"5\n3\n2\n4\n1\n6",
"10\n31\n457\n1\n123\n48",
"10\n110\n1017\n3\n9\n29",
"10000000007\n4\n3\n9\n14\n3",
"10\n123\n219\n27\n... |
p03219 AtCoder Beginner Contest 113 - Discount Fare | There is a train going from Station A to Station B that costs X yen (the currency of Japan).
Also, there is a bus going from Station B to Station C that costs Y yen.
Joisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B by train and then trav... | {
"input": [],
"output": []
} | {
"input": [
"81 58",
"4 54"
],
"output": [
"110",
"31"
]
} | {
"input": [
"35 58",
"3 54",
"68 58",
"3 34",
"88 58",
"5 34",
"88 51",
"5 0",
"88 27",
"5 -1",
"51 11",
"51 1",
"2 -2",
"95 1",
"2 -4",
"54 1",
"4 -1",
"47 0",
"7 -1",
"47 -1",
"10 -1",
"77 1",
"15 -1",
"134 1",
"28 ... |
p03368 AtCoder Grand Contest 023 - 01 on Tree | Snuke has a rooted tree with N vertices, numbered 1 through N. Vertex 1 is the root of the tree, and the parent of Vertex i ( 2\leq i \leq N ) is Vertex P_i ( P_i < i ). There is a number, 0 or 1, written on each vertex. The number written on Vertex i is V_i.
Snuke would like to arrange the vertices of this tree in a ... | {
"input": [],
"output": []
} | {
"input": [
"15\n1 2 3 2 5 6 2 2 9 10 1 12 13 12\n1 1 1 0 1 1 0 0 1 0 0 1 1 0 0",
"6\n1 1 2 3 3\n0 1 1 0 0 0",
"1\n\n0"
],
"output": [
"31",
"4",
"0"
]
} | {
"input": [
"15\n1 2 3 2 5 6 2 2 9 10 1 11 13 12\n1 1 1 0 1 1 0 0 1 0 0 1 1 0 0",
"1\n\n-1",
"15\n1 2 3 2 5 6 2 2 9 10 1 12 13 12\n1 1 1 0 1 0 0 0 1 0 0 1 1 0 0",
"15\n1 2 3 2 5 6 2 2 9 10 1 11 13 12\n1 1 1 0 1 1 0 1 1 0 0 1 1 0 0",
"1\n\n-2",
"1\n\n-3",
"1\n\n-4",
"1\n\n1",
"1\n\... |
p03530 CODE FESTIVAL 2017 Final - Poor Penguin | In some place in the Arctic Ocean, there are H rows and W columns of ice pieces floating on the sea. We regard this area as a grid, and denote the square at the i-th row and j-th column as Square (i,j). The ice piece floating in each square is either thin ice or an iceberg, and a penguin lives in one of the squares tha... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n+#+\n#P#\n+#+",
"40 40\n++#+++++#+#+#+##+++++++##+#+++#++##++##\n+##++++++++++#+###+##++++#+++++++++#++##\n+++#+++++#++#++####+++#+#+###+++##+++#++\n+++#+######++##+#+##+#+++#+++++++++#++#+\n+++##+#+#++#+++#++++##+++++++++#++#+#+#+\n++#+++#+#++++##+#+#+++##+#+##+#++++##++\n++#+##+++#++####+... | {
"input": [
"3 3\n+#+\nP##\n+#+",
"40 40\n++#+++++#+#+#+##+++++++##+#+++#++##++##\n+##++++++++++#+###+##++++#+++++++++#++##\n+++#+++++#++#++####+++#+#+###+++##+++#++\n+++#+######++##+#+##+#+++#+++++++++#++#+\n+++##+#+#++#+++#++++##+++++++++#++#+#+#+\n++#+++#+#++++##+#+#+++##+#+##+#++++##++\n++#+##+++#++####+... |
p03691 AtCoder Grand Contest 016 - Poor Turkeys | There are N turkeys. We number them from 1 through N.
M men will visit here one by one. The i-th man to visit will take the following action:
* If both turkeys x_i and y_i are alive: selects one of them with equal probability, then eats it.
* If either turkey x_i or y_i is alive (but not both): eats the alive one.
* ... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n1 2\n1 2",
"4 3\n1 2\n3 4\n2 3",
"10 10\n8 9\n2 8\n4 6\n4 9\n7 8\n2 8\n1 8\n3 4\n3 4\n2 7",
"3 1\n1 2"
],
"output": [
"0",
"1",
"5",
"2"
]
} | {
"input": [
"4 1\n1 2\n3 4\n2 3",
"10 10\n8 9\n2 8\n4 6\n4 9\n7 8\n2 9\n1 8\n3 4\n3 4\n2 7",
"3 2\n1 2\n2 2",
"4 3\n1 2\n3 4\n2 2",
"6 1\n1 2",
"1 1\n1 2\n3 4\n2 3",
"10 10\n8 9\n2 8\n7 6\n4 9\n7 8\n2 9\n1 8\n3 4\n3 4\n2 7",
"3 0\n1 2\n2 2",
"10 1\n8 9\n2 8\n4 6\n4 9\n7 8\n2 8\n1 ... |
p03844 AtCoder Beginner Contest 050 - Addition and Subtraction Easy | Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
Constraints
* 1≦A,B≦10^9
* op is either `+` or `-`.
Input
The input is given from Standard Input in the following format:
A op B
Outpu... | {
"input": [],
"output": []
} | {
"input": [
"1 + 2",
"5 - 7"
],
"output": [
"3",
"-2"
]
} | {
"input": [
"0 + 2",
"5 - 13",
"-1 + 2",
"5 - 14",
"1 - 14",
"1 - 1",
"1 - 7",
"-1 + 0",
"5 - 20",
"2 - 7",
"1 - 4",
"3 - 7",
"9 - 4",
"0 - 7",
"7 - 4",
"7 - 3",
"0 + -2",
"5 - 23",
"3 - 14",
"1 - 27",
"5 - 22",
"0 - 23",
"1 ... |
p04011 AtCoder Beginner Contest 044 - Tak and Hotels (ABC Edit) | There is a hotel with the following accommodation fee:
* X yen (the currency of Japan) per night, for the first K nights
* Y yen per night, for the (K+1)-th and subsequent nights
Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
Constraints
* 1 \leq N, K \leq 10000
* 1 \leq ... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n10000\n9000",
"5\n3\n10000\n9000"
],
"output": [
"20000",
"48000"
]
} | {
"input": [
"2\n3\n10000\n2613",
"5\n3\n10010\n9000",
"2\n3\n10010\n2613",
"5\n3\n10010\n10766",
"5\n3\n10010\n18306",
"2\n3\n10110\n4944",
"5\n6\n10010\n18306",
"5\n6\n00010\n18306",
"2\n0\n10110\n4944",
"2\n-1\n10110\n4944",
"5\n6\n00000\n23314",
"2\n-1\n00110\n4944"... |
p00097 Sum of Integers II | Write a program that extracts n different numbers from the numbers 0 to 100 and outputs the number of combinations that add up to s. Each n number is from 0 to 100, and the same number cannot be used in one combination. For example, if n is 3 and s is 6, the combination of the three numbers totaling 6 is
1 + 2 + 3 = ... | {
"input": [],
"output": []
} | {
"input": [
"3 6\n3 1\n0 0"
],
"output": [
"3\n0"
]
} | {
"input": [
"3 12\n3 1\n0 0",
"5 12\n3 0\n0 0",
"5 23\n3 0\n0 0",
"5 28\n3 0\n0 0",
"6 6\n3 1\n0 0",
"3 12\n3 3\n0 0",
"6 23\n3 0\n0 0",
"3 11\n3 3\n0 0",
"3 19\n3 -1\n0 0",
"6 19\n3 0\n0 0",
"3 11\n3 2\n0 0",
"6 26\n3 0\n0 0",
"3 22\n3 1\n0 0",
"5 12\n0 0\n0 0... |
p00229 Big Hit ! | Ataru Oafoot of Aizu Gakuen University High School decided to play with a slot machine.
When you insert a medal on this machine, three reels will start spinning and each reel will stop automatically. In a normal game (normal game), 3 medals are inserted, and when the symbols are aligned, the following medals are obtai... | {
"input": [],
"output": []
} | {
"input": [
"3 2 30 3 26 226\n9 0 18 3 20 118\n5 5 12 2 15 203\n7 4 19 2 22 197\n7 4 24 4 17 209\n0 0 0 0 0 0"
],
"output": [
"127\n793\n414\n629\n617"
]
} | {
"input": [
"3 2 30 3 26 226\n9 0 18 3 20 118\n5 5 12 0 15 203\n7 4 19 2 22 197\n7 4 24 4 17 209\n0 0 0 0 0 0",
"3 2 30 3 41 226\n9 0 18 3 20 118\n5 5 12 0 15 203\n7 4 19 2 22 197\n7 4 24 4 17 209\n0 0 0 0 0 0",
"3 2 30 3 41 226\n9 0 18 4 20 118\n5 5 12 0 15 203\n7 4 19 2 22 197\n7 4 24 4 17 209\n0 0 0 0... |
p00391 Treasure Map | Mr. Kobou found a bundle of old paper when he was cleaning his family home. On each paper, two series of numbers are written. Strange as it appeared to him, Mr. Kobou further went through the storehouse and found out a note his ancestor left. According to it, the bundle of paper is a treasure map, in which the two sequ... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n3 2 3 0 0\n4 2 0 0 2",
"5 4\n0 2 2 1 1\n1 1 1 3"
],
"output": [
"0",
"1"
]
} | {
"input": [
"5 3\n3 2 3 0 0\n4 2 0 0 2",
"4 4\n0 1 1 1 1\n1 0 1 4",
"5 3\n3 2 5 0 0\n4 2 0 0 2",
"4 3\n3 2 5 0 0\n4 2 0 0 2",
"4 3\n3 2 5 0 0\n4 2 0 0 4",
"4 3\n3 2 6 0 0\n4 2 0 0 4",
"4 3\n3 1 6 0 0\n4 2 0 0 4",
"5 5\n3 2 3 0 0\n4 2 0 -1 2",
"5 4\n0 2 2 0 1\n1 1 1 3",
"5 3\n3... |
p00607 Emacs-like Editor | Emacs is a text editor which is widely used by many programmers.
The advantage of Emacs is that we can move a cursor without arrow keys and the mice. For example, the cursor can be moved right, left, down, and up by pushing f, b, n, p with the Control Key respectively. In addition, cut-and-paste can be performed witho... | {
"input": [],
"output": []
} | {
"input": [
"hyo\nni\nEND_OF_TEXT\nf\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-"
],
"output": [
"honihoni\nhoni"
]
} | {
"input": [
"oyh\nni\nEND_OF_TEXT\nf\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-",
"hyo\nnh\nEND_OF_TEXT\nf\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-",
"hyo\nni\nEND_OF_TEXT\nf\nd\ng\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-",
"hyo\nnh\nEND_OF_TEXT\ne\nd\nf\nf\nk\np\np\ne\ny\na\nk\ny\ny\nn\ny\n-",
... |
p00744 Cards | There are many blue cards and red cards on the table. For each card, an integer number greater than 1 is printed on its face. The same number may be printed on several cards.
A blue card and a red card can be paired when both of the numbers printed on them have a common divisor greater than 1. There may be more than o... | {
"input": [],
"output": []
} | {
"input": [
"4 3\n2 6 6 15\n2 3 5\n2 3\n4 9\n8 16 32\n4 2\n4 9 11 13\n5 7\n5 5\n2 3 5 1001 1001\n7 11 13 30 30\n10 10\n2 3 5 7 9 11 13 15 17 29\n4 6 10 14 18 22 26 30 34 38\n20 20\n195 144 903 63 137 513 44 626 75 473\n876 421 568 519 755 840 374 368 570 872\n363 650 155 265 64 26 426 391 15 421\n373 984 564 54 ... | {
"input": [
"4 3\n2 6 6 15\n2 3 5\n2 3\n4 9\n8 16 32\n4 2\n4 9 11 13\n5 7\n5 5\n2 3 5 1001 1001\n7 11 13 30 30\n10 10\n2 3 5 7 9 11 13 15 17 29\n4 6 10 14 18 22 26 30 34 38\n20 20\n195 144 903 63 137 513 44 626 75 473\n876 421 568 519 755 840 374 368 570 872\n363 650 155 265 64 26 426 391 15 421\n373 984 564 54 ... |
p00883 Infected Land | The earth is under an attack of a deadly virus. Luckily, prompt actions of the Ministry of Health against this emergency successfully confined the spread of the infection within a square grid of areas. Recently, public health specialists found an interesting pattern with regard to the transition of infected areas. At e... | {
"input": [],
"output": []
} | {
"input": [
"3\n...\n.@.\n...\n3\n.##\n.#.\n@##\n3\n##.\n#..\n@..\n5\n....@\n##...\n#....\n...#.\n##.##\n5\n#...#\n...#.\n#....\n...##\n..@..\n5\n#....\n.....\n.....\n.....\n..@..\n5\n#..#.\n#.#.#\n.#.#.\n....#\n.#@##\n5\n..##.\n..#..\n#....\n#....\n.#@..\n0",
"3\n...\n.@.\n...\n3\n.##\n.#.\n@##\n3\n.\n..\n@... | {
"input": [
"3\n...\n.@.\n...\n3\n.##\n.#.\n@##\n3\n##.\n#..\n@..\n5\n....@\n##...\n#....\n...#.\n##.##\n5\n#...#\n...#.\n#....\n...##\n..@..\n5\n#..-.\n.....\n.....\n.....\n..@..\n5\n#..#.\n#.#.#\n.#.#.\n....#\n.#@##\n5\n..##.\n..#..\n#....\n#....\n.#@..\n0",
"3\n...\n.@.\n...\n3\n.##\n.#.\n@##\n3\n.\n..\n@... |
p01014 Rolling Block | Problem
Rolling Block is a game in which a rectangular parallelepiped metal body is rotated and moved, and dropped into a hole in the goal.
The condition to clear this game is to drop the metal body to the goal.
image0
About blocks
From (1) in the figure below, the block is a 1 × 1 × L rectangular parallelepiped. Th... | {
"input": [],
"output": []
} | {
"input": [
"5 5 2\n#####\n#S.G#\n#...#\n#...#\n#####",
"3 12 2\n\nS...A.a..G#",
"3 12 2\n\nS^^.^^.^^G#",
"3 12 2\n\nS..A..a..G#",
"5 5 2\n\nS.G#\n...#\n...#",
"7 13 3\n\nS....#.....#\n.....#.....#\n.....#.....#\n...........#\n..........G#"
],
"output": [
"4",
"-1",
"6",
"... | {
"input": [
"6 5 2\n#####\n#S.G#\n#...#\n#...#\n#####",
"3 12 2\n\nS^..^^^^^G#",
"3 12 2\n\nS..A..a.-G#",
"3 12 2\n\n\"G-....Aa.S",
"3 12 4\n\n\"G-....Aa.S",
"3 12 1\n\nS^^.^^.^^G#",
"5 5 2\n\nS.G#\n#...\n...#",
"7 13 3\n\nS....#.....#\n.....#.....#\n.....#.....#\n#...........\n...-..... |
p01147 Princess | Princess, a Cryptanalyst
Decryption of the princess
English text is not available in this practice contest.
A brave princess in a poor country's tomboy got an old document written in Japanese, a town she went out in stealth. The princess can speak Japanese, so I immediately read this old document. Then I found somet... | {
"input": [],
"output": []
} | {
"input": [
"4\napple\nlength\nthings\nthin\n2\nicp\ncpc\n3\nzeta\neta\nalphabet\n2\nuntil\ntill\n0"
],
"output": [
"applengthings\nicpc\nzetalphabet\nuntill"
]
} | {
"input": [
"4\napple\nlength\ntiings\nthin\n2\nicp\ncpc\n3\nzeta\neta\nalphabet\n2\nuntil\ntill\n0",
"4\napple\nlength\ntiings\nthin\n2\nicp\ncpc\n3\nzeta\neta\nalphacet\n2\nuntil\ntill\n0",
"4\napple\nhtgnel\ntiings\nthin\n2\nicp\ncpc\n3\nzeta\neta\nalphacet\n2\nuntil\ntill\n0",
"4\napple\nhtgnel\n... |
p01285 Find the Point | We understand that reading English is a great pain to many of you. So we’ll keep this problem statememt simple. Write a program that reports the point equally distant from a set of lines given as the input. In case of no solutions or multiple solutions, your program should report as such.
Input
The input consists o... | {
"input": [],
"output": []
} | {
"input": [
"2\n-35 -35 100 100\n-49 49 2000 -2000\n4\n0 0 0 3\n0 0 3 0\n0 3 3 3\n3 0 3 3\n4\n0 3 -4 6\n3 0 6 -4\n2 3 6 6\n-1 2 -4 6\n0"
],
"output": [
"Many\n1.5000 1.5000\n1.000 1.000"
]
} | {
"input": [
"2\n-35 -35 100 100\n-49 49 2000 -2000\n4\n0 0 0 3\n0 0 3 0\n0 3 3 3\n6 0 3 3\n4\n0 3 -4 6\n3 0 6 -4\n2 3 6 6\n-1 2 -4 6\n0",
"2\n-35 -35 100 100\n-49 49 1588 -2000\n4\n0 0 0 3\n0 0 3 0\n0 3 3 3\n3 0 3 3\n4\n0 3 -4 6\n3 0 6 -4\n2 3 6 6\n-1 2 -4 6\n0",
"2\n-35 -35 100 100\n-49 49 2000 -2000\n4... |
p01455 Intelligible Double Magic | The 15th month of 2119. A spellbook was written by the court magician Sengemon Lugene. This magic book "In Magiray" was an innovative book in that it systematized "double magic", which is deeply related to the basis of the magic law of this world, as a technique that anyone can learn. First, let's take a look at a summ... | {
"input": [],
"output": []
} | {
"input": [
"9 10\nriris\nsoa\nelah\nclar\narma\nmemori\nneoles\nqhaon\nclue\nclar riris\nriris memori\nriris neoles\nsoa clar\nsoa memori\nneoles elah\nelah qhaon\nneoles qhaon\nclue riris\narma elah",
"3 3\ntorn\nsiole\ndimi\ntorn siole\ntorn dimi\nsiole dimi",
"4 3\nhuda\nleide\nloar\nsheza\nhuda leid... | {
"input": [
"4 3\nhuda\nleide\nloar\nsheza\nhuda leide\nlehde loar\nloar sheza",
"9 10\nriris\nsoa\nelah\nclar\narma\nmemori\nneoles\nqhaon\nclue\nclar riris\nriris oemmri\nriris neoles\nsoa clar\nsoa memori\nneoles elah\nelah qhaon\nneoles qhaon\nclue riris\narma elah",
"3 2\ntorn\nsiole\ndimi\ntorn sio... |
p01606 Sliding GCD | Sliding GCD
Problem Statement
For the set S of natural numbers, let f (S) be the number of elements in the set \\ {GCD (T) | T ⊆ S, T is not empty \\}.
Here, GCD (T) is the greatest integer that divides all the numbers contained in T.
In particular, note that GCD (\\ {a \\}) = a when T consists of only one integer a... | {
"input": [],
"output": []
} | {
"input": [
"10 2",
"30 7"
],
"output": [
"2 3 3 3 3 3 3 3 3",
"7 8 9 10 10 11 11 11 11 12 11 12 10 12 12 11 10 12 12 12 10 11 11 13"
]
} | {
"input": [
"10 0",
"14 7",
"15 7",
"7 7",
"10 3",
"30 0",
"16 0",
"20 7",
"7 5",
"20 3",
"11 0",
"23 7",
"22 3",
"23 12",
"27 3",
"42 12",
"7 3",
"42 10",
"6 5",
"48 10",
"5 5",
"34 10",
"17 2",
"11 7",
"18 7",
"... |
p01767 RUPC | Problem statement
A programming contest will be held in the Russian Federation. The contest has N questions and has M participants. Question i has a score a_i, and it is known that participant j's ability is b_j. For problem i and participant j, participant j can always solve problem i if a_i ≤ b_j and only then. The ... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2 1 3 4 5\n7\n1 3 4 5 3 1 0\n2 4 5 3 4 5 3"
],
"output": [
"Yes\nYes\nYes\nYes\nYes\nNo\nNo"
]
} | {
"input": [
"6\n1 2 1 3 4 5\n7\n1 3 4 5 3 1 0\n2 8 5 3 4 5 3",
"6\n1 2 1 3 4 5\n7\n1 3 4 10 3 1 0\n2 4 5 3 4 5 3",
"6\n1 2 1 5 4 5\n7\n1 3 4 7 3 1 0\n2 8 5 3 7 5 3",
"6\n1 2 2 5 4 5\n7\n1 3 4 7 3 1 0\n2 8 5 3 7 5 3",
"6\n2 0 1 3 3 5\n7\n1 1 4 10 3 1 0\n2 4 5 3 4 5 3",
"6\n1 2 1 6 3 1\n7\n1 3 ... |
p01901 Suntan | D: Sunburn-Suntan-
story
Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festival, so I made a schedule for the band to go to listen to. I'm worried abou... | {
"input": [],
"output": []
} | {
"input": [
"20\n1\n0 10"
],
"output": [
"10"
]
} | {
"input": [
"20\n1\n1 10",
"20\n1\n0 7",
"20\n1\n2 10",
"20\n1\n3 7",
"20\n1\n0 19",
"20\n1\n0 12",
"20\n1\n2 7",
"20\n1\n4 10",
"20\n1\n0 28",
"20\n0\n0 12",
"20\n1\n0 3",
"20\n1\n4 6",
"20\n1\n1 15",
"20\n1\n-1 12",
"20\n1\n6 7",
"20\n1\n1 19",
"2... |
p02038 Tanuki and Fox | problem
There is a mysterious device $ M $, and if you put Tanuki and Fox in this device, one animal will come out from the device (hereinafter, Tanuki will be $ T $ and Fox will be $ F $).
$ M (x, y) $ represents an animal that came out by putting animals in the device $ M $ in the order of $ x, y $.
As a result of... | {
"input": [],
"output": []
} | {
"input": [
"3\nF T T"
],
"output": [
"T"
]
} | {
"input": [
"3\nF S T",
"3\nF R T",
"3\nG S T",
"3\nG R T",
"3\nH R T",
"3\nF U T",
"3\nE S T",
"3\nE T T",
"3\nD T T",
"3\nI R T",
"3\nG Q T",
"3\nE U T",
"3\nE R T",
"3\nD S T",
"3\nE V T",
"3\nF Q T",
"3\nE W T",
"3\nD V T",
"3\nG P T",
... |
p02182 Spot The Difference | A: Find the difference
problem
Given rectangular boards A and B with N squares vertically and M squares horizontally. For each board, each square is painted white or black.
The color of the square in the i-th row and j-th column of the board X is written as C (i, j, X).
Count how many pairs of integers (i, j) meet ... | {
"input": [],
"output": []
} | {
"input": [
"2 3\n..#\n##.\n.##\n#.."
],
"output": [
"2"
]
} | {
"input": [
"2 3\n..\"\n##.\n.##\n#..",
"2 3\n..\"\n.##\n.##\n#..",
"2 3\n..#\n#\".\n.##\n$./",
"2 1\n..\"\n.##\n.##\n#./",
"2 3\n..#\n#\".\n##.\n$./",
"0 3\n..#\n.\"#\n##.\n$./",
"3 3\n#..\n.#\"\n##.\n$./",
"2 3\n.#.\n##.\n##.\n#..",
"4 3\n..\"\n##.\n.##\n..#",
"3 3\n..#\n\"\... |
p02324 Chinese Postman Problem | For a given weighted undirected graph G(V, E), find the distance of the shortest route that meets the following criteria:
* It is a closed cycle where it ends at the same point it starts.
* The route must go through every edge at least once.
Constraints
* 2 ≤ |V| ≤ 15
* 0 ≤ |E| ≤ 1,000
* 0 ≤ di ≤ 1,000
* si ≠ ti
* T... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n0 1 1\n0 2 2\n1 3 3\n2 3 4\n1 2 5",
"4 4\n0 1 1\n0 2 2\n1 3 3\n2 3 4",
"2 3\n0 1 1\n0 1 2\n0 1 3"
],
"output": [
"18",
"10",
"7"
]
} | {
"input": [
"4 5\n0 1 1\n0 2 2\n1 3 3\n2 3 4\n1 3 5",
"4 4\n0 1 1\n1 2 2\n1 3 3\n2 3 4",
"6 5\n0 1 1\n0 2 2\n1 3 3\n2 3 7\n1 3 5",
"6 4\n0 1 0\n1 2 2\n1 3 3\n2 3 4",
"6 4\n0 1 0\n1 2 2\n1 3 6\n2 3 4",
"6 4\n0 2 0\n1 2 3\n1 3 6\n2 3 4",
"6 4\n0 2 0\n1 0 3\n1 4 6\n2 3 4",
"6 4\n0 2 0\n1... |
p02469 Least Common Multiple | Find the least common multiple (LCM) of given n integers.
Constraints
* 2 ≤ n ≤ 10
* 1 ≤ ai ≤ 1000
* Product of given integers ai(i = 1, 2, ... n) does not exceed 231-1
Input
n
a1 a2 ... an
n is given in the first line. Then, n integers are given in the second line.
Output
Print the least common multiple of th... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 3 5",
"3\n3 4 6"
],
"output": [
"30",
"12"
]
} | {
"input": [
"4\n1 2 5 5",
"3\n3 4 3",
"4\n1 2 5 7",
"3\n3 7 3",
"4\n1 2 1 7",
"3\n3 10 3",
"3\n3 13 3",
"4\n1 2 2 11",
"3\n6 13 3",
"3\n4 13 3",
"3\n4 13 4",
"3\n4 13 5",
"3\n4 6 5",
"3\n4 6 7",
"3\n4 4 7",
"3\n5 4 7",
"3\n9 4 3",
"3\n19 4 4",
... |
astring | Akhil comes across a string S of length N. He started wondering about the smallest lexicographical subsequence of string S of length K.
A subsequence of a string is formed by deleting some characters (possibly none) from it's original string.
A string A is said to be lexicographically smaller than the string B of the s... | {
"input": [],
"output": []
} | {
"input": [
"2\nabdc\n3\nbacb\n2"
],
"output": [
"abc\nab"
]
} | {
"input": [
"2\nabdc\n3\nbcab\n2",
"2\ncdba\n3\nbcab\n2",
"2\ncdba\n3\nbcba\n2",
"2\ncdba\n3\nbcba\n1",
"2\ncdba\n3\nbcbb\n1",
"2\nbdca\n3\nbcbb\n1",
"2\nacdb\n3\nbcbb\n1",
"2\naddb\n3\nbcbb\n1",
"2\nbdda\n3\nbcbb\n1",
"2\nbcda\n3\nbbdb\n0",
"2\ncbda\n3\nbbdb\n0",
"2\n... |
clost | Churu is taking the course called “Introduction to Data Structures”. Yesterday, he learned how to use a stack to check is a given parentheses expression is balanced or not. He finds it intriguing, and more importantly, he was given an assignment. The professor gave him a string S containing characters “(” and “)”, and ... | {
"input": [],
"output": []
} | {
"input": [
"2\n4 1\n0 3\n4 2\n0 3\n1 2"
],
"output": [
"()()\n(())"
]
} | {
"input": [
"2\n4 1\n0 3\n4 1\n0 3\n1 2",
"2\n4 1\n1 2\n4 2\n0 3\n2 1",
"2\n4 2\n0 3\n4 2\n0 0\n1 -1",
"2\n4 1\n0 3\n4 2\n0 3\n2 2",
"2\n4 1\n0 3\n4 2\n0 3\n2 0",
"2\n4 1\n0 3\n4 1\n0 3\n1 0",
"2\n4 1\n0 3\n4 1\n0 3\n1 -1",
"2\n4 1\n0 3\n4 1\n0 3\n1 1",
"2\n4 1\n0 3\n4 1\n0 3\n2 0... |
flow006 | You're given an integer N. Write a program to calculate the sum of all the digits of N.
Input
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.
Output
Calculate the sum of digits of N.
Constraints
1 ≤ T ≤ 1000
1 ≤ N ≤ 100000
Example
Inpu... | {
"input": [],
"output": []
} | {
"input": [
"3 \n12345\n31203\n2123"
],
"output": [
"15\n9\n8\n"
]
} | {
"input": [
"3 \n12345\n50368\n2123",
"3 \n17364\n50368\n2123",
"3 \n17364\n87192\n2123",
"3 \n17364\n87192\n3009",
"3 \n17364\n87192\n4291",
"3 \n17364\n87192\n8146",
"3 \n27324\n87192\n8146",
"3 \n27324\n87192\n7989",
"3 \n36926\n87192\n7989",
"3 \n36926\n87192\n1688",
"... |
leexams | Little Elephant from the Zoo of Lviv hates exams. Since Little Elephant lives in Ukraine, he is going to take exams called 'ZNO'. Help him.
There will be n tickets on the table. Each ticket has a number written on it. The i-th ticket can be numbered Ai with probability Pi percent and with probability 100-Pi percent it ... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n50 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n74 3 2"
],
"output": [
"0.5\n0.3478\n"
]
} | {
"input": [
"2\n2\n54 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n74 3 2",
"2\n2\n54 1 2\n50 2 1\n3\n100 1 3\n47 2 1\n5 3 2",
"2\n2\n54 1 2\n50 2 1\n3\n100 1 3\n47 2 0\n5 4 2",
"2\n2\n54 1 2\n52 2 1\n3\n100 1 3\n47 2 0\n5 4 2",
"2\n2\n84 1 2\n52 2 1\n3\n100 1 3\n47 2 0\n5 4 2",
"2\n2\n84 1 3\n52 2 1\n3\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.