name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p01579 Substring Expression | Trees are sometimes represented in the form of strings. Here is one of the most popular ways to represent unlabeled trees:
* Leaves are represented by "()".
* Other nodes (i.e. internal nodes) are represented by "( S1 S2 ... Sn )", where Si is the string representing the i-th subnode.
For example, the tree depicted... | {
"input": [],
"output": []
} | {
"input": [
"((()())())"
],
"output": [
"10"
]
} | {
"input": [
"((())()())",
"(((()())))",
"((())(()))",
"(((()))())",
"((((()))))",
"(()()()())",
"(((*)()())",
"(()(())())",
"(()((())))",
"(()()(()))",
"(((+)()())",
"((()()()))",
"(((())()))",
"(((+)(*())",
"((((*)()))",
"((((')()))",
"((((&)()))",... |
p01740 Rotation Game | You have a board with height two and width W. The board is divided into 1x1 cells. Each row of the board is numbered 1 and 2 from top to bottom and each column is numbered 1 to W from left to right. We denote a cell at the i-th row in the j-th column by (i, j). Initially, some checkers are placed on some cells of the b... | {
"input": [],
"output": []
} | {
"input": [
"3\n.oo\no..\n\no.o\no.."
],
"output": [
"1"
]
} | {
"input": [],
"output": []
} |
p01880 Best Matched Pair | Example
Input
2
1 2
Output
2 | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2"
],
"output": [
"2"
]
} | {
"input": [
"2\n2 2",
"2\n2 3",
"2\n2 4",
"2\n2 7",
"2\n2 17",
"2\n1 12",
"2\n0 12",
"2\n1 1",
"2\n-1 -5",
"2\n1 3",
"2\n9 5",
"2\n7 8",
"2\n1 7",
"2\n3 3",
"2\n-1 -2",
"2\n23 1",
"2\n2 10",
"2\n2 19",
"2\n2 9",
"2\n1 17",
"2\n1 19",... |
p02017 Pray | C: Prayer (Pray)
Some twins are famous for praying before the contest.
There are four integers $ H, W, X, Y $, and it seems unlucky if $ H \ times W $ and $ x + y $ are both odd numbers.
input
Four integers $ H, W, X, Y $ are given, separated by spaces.
output
Output "No" if you are unlucky, or "Yes" if not. But ... | {
"input": [],
"output": []
} | {
"input": [
"3 5 1 4"
],
"output": [
"No"
]
} | {
"input": [
"3 5 2 4",
"3 9 1 4",
"3 13 1 4",
"3 13 1 3",
"3 13 1 1",
"3 13 2 1",
"3 13 3 1",
"0 13 3 1",
"0 13 4 1",
"0 13 2 1",
"0 21 2 1",
"0 21 1 1",
"1 21 1 1",
"1 6 1 1",
"1 6 0 1",
"1 6 0 0",
"1 10 0 0",
"1 10 0 1",
"1 3 0 1",
"1 ... |
p02159 Encampment Game | Problem
There is a tree with $ N $ vertices. Each vertex is assigned a number from 1 to $ N $.
Gacho and Kawabayashi decided to play a camp game using this tree.
The game starts with Gacho and Kawabayashi at different vertices.
Gacho repeatedly moves the vertices alternately, and the one who can not move first is the ... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2\n2 3\n3 4\n4 5\n5 6",
"2\n1 2",
"20\n14 1\n2 1\n18 14\n10 1\n12 10\n5 1\n17 5\n7 1\n11 17\n4 1\n19 2\n15 1\n3 19\n8 15\n9 8\n20 8\n6 1\n16 15\n13 7",
"5\n1 2\n1 3\n3 4\n3 5"
],
"output": [
"12",
"0",
"243",
"12"
]
} | {
"input": [
"20\n14 1\n2 1\n18 4\n10 1\n12 10\n5 1\n17 5\n7 1\n11 17\n4 1\n19 2\n15 1\n3 19\n8 15\n9 8\n20 8\n6 1\n16 15\n13 7",
"6\n1 3\n2 3\n3 4\n4 5\n5 6",
"20\n14 1\n2 1\n18 14\n10 1\n12 10\n5 1\n17 5\n7 1\n11 17\n4 1\n19 2\n15 1\n3 19\n8 15\n9 16\n20 8\n6 1\n16 15\n13 7",
"20\n14 1\n2 1\n18 14\n... |
p02300 Convex Hull | Find the convex hull of a given set of points P. In other words, find the smallest convex polygon containing all the points of P. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.
Please note that you should find all the points of P on both corner and boundary of the convex polygon.... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 0\n2 2\n0 2\n0 1",
"7\n2 1\n0 0\n1 2\n2 2\n4 2\n1 3\n3 3"
],
"output": [
"4\n0 0\n2 2\n0 2\n0 1",
"5\n0 0\n2 1\n4 2\n3 3\n1 3"
]
} | {
"input": [
"4\n1 0\n2 2\n0 2\n0 1",
"7\n2 1\n0 0\n1 2\n2 0\n4 2\n1 3\n3 3",
"4\n1 0\n3 2\n0 2\n0 1",
"7\n4 1\n0 0\n1 2\n2 0\n4 2\n1 3\n3 3",
"7\n4 1\n0 0\n1 2\n3 0\n4 2\n1 3\n3 3",
"7\n2 1\n0 0\n1 2\n2 2\n4 2\n1 3\n0 3",
"4\n1 0\n2 2\n1 2\n0 1",
"7\n2 1\n0 0\n1 2\n2 0\n4 2\n1 3\n5 3"... |
p02447 Sorting Pairs | Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria.
1. first by $x$-coordinate
2. in case of a tie, by $y$-coordinate
Constraints
* $1 \leq n \leq 100,000$
* $-1,000,000,000 \leq x_i, y_i \leq 1,000,000,000$
Input
The input is given in the following form... | {
"input": [],
"output": []
} | {
"input": [
"5\n4 7\n5 5\n2 3\n6 8\n2 1"
],
"output": [
"2 1\n2 3\n4 7\n5 5\n6 8"
]
} | {
"input": [
"5\n4 7\n5 5\n2 3\n5 8\n2 1",
"5\n4 7\n5 5\n2 6\n5 8\n2 1",
"5\n4 7\n5 5\n2 12\n5 8\n2 1",
"5\n0 7\n5 5\n2 12\n5 8\n2 1",
"5\n0 7\n5 5\n2 12\n5 16\n2 1",
"5\n0 7\n5 5\n3 12\n5 16\n2 1",
"5\n1 7\n5 5\n3 12\n5 16\n2 1",
"5\n1 7\n8 5\n3 12\n5 16\n2 1",
"5\n1 7\n8 5\n3 12\... |
attic | Digory Kirke and Polly Plummer are two kids living next door to each other. The attics of the two houses are connected to each other through a passage. Digory's Uncle Andrew has been secretly doing strange things in the attic of his house, and he always ensures that the room is locked. Being curious, Digory suspects th... | {
"input": [],
"output": []
} | {
"input": [
"4\n####\n##.#..#\n##..#.#\n##.#....#"
],
"output": [
"0\n2\n1\n2\n"
]
} | {
"input": [
"4\n####\n#..#.##\n##..#.#\n##.#....#",
"4\n####\n#..#.##\n#.#..##\n##.#....#",
"4\n####\n##.#..#\n#.#..##\n##.#....#",
"4\n####\n##.#..#\n#.#..##\n#....#.##",
"4\n####\n#..#.##\n#.#..##\n#....#.##",
"4\n####\n##.#..#\n##..#.#\n#....#.##",
"4\n####\n##.#..#\n##..#.#\n#..#...##... |
cm1404 | Problem description.
Liza wants to share her pizza among n friends, What are the minimum number of straight knife strokes required to cut the pizza into n pieces?
Input
The first line contains number of test cases T.
The next T lines contain the input numbers N, the numbers of pieces required.
Output
For each tes... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n5\n6"
],
"output": [
"2\n3\n3"
]
} | {
"input": [],
"output": []
} |
flow010 | Write a program that takes in a letterclass ID of a ship and display the equivalent string class description of the given ID. Use the table below.
Class ID
Ship Class
B or b
BattleShip
C or c
Cruiser
D or d
Destroyer
F or f
Frigate
Input
The first line contains an integer T, total number of testcases. Then... | {
"input": [],
"output": []
} | {
"input": [
"3 \nB\nc\nD"
],
"output": [
"BattleShip\nCruiser\nDestroyer\n"
]
} | {
"input": [
"3 \nC\nc\nD",
"3 \nB\nc\nC",
"3 \nB\nc\nB",
"3 \nC\nc\nB",
"3 \nC\nb\nB",
"3 \nB\nd\nD",
"3 \nC\nd\nD",
"3 \nB\nd\nC",
"3 \nC\nd\nB",
"3 \nD\nc\nB",
"3 \nD\nc\nD",
"3 \nC\nd\nC",
"3 \nD\nb\nB",
"3 \nD\nb\nD",
"3 \nB\nc\nF",
"3 \nB\nb\nB",
... |
lemouse | It is well-known that the elephants are afraid of mouses. The Little Elephant from the Zoo of Lviv is not an exception.
The Little Elephant is on a board A of n rows and m columns (0-based numeration). At the beginning he is in cell with coordinates (0; 0) and he wants to go to cell with coordinates (n-1; m-1). From c... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 9\n001000001\n111111010\n100100100\n7 9\n010101110\n110110111\n010011111\n100100000\n000010100\n011011000\n000100101"
],
"output": [
"9\n10"
]
} | {
"input": [],
"output": []
} |
pptest | Polo, the Penguin, has a lot of tests tomorrow at the university.
He knows that there are N different questions that will be on the tests. For each question i (i = 1..N), he knows C[i] - the number of tests that will contain this question, P[i] - the number of points that he will get for correctly answering this questi... | {
"input": [],
"output": []
} | {
"input": [
"1\n3 7\n1 2 3\n2 3 5\n3 3 3"
],
"output": [
"11\n"
]
} | {
"input": [
"1\n3 7\n1 2 0\n2 3 5\n3 3 3",
"1\n3 7\n1 2 3\n2 3 5\n3 4 3",
"1\n3 7\n1 2 3\n2 3 5\n3 0 3",
"1\n3 7\n1 2 0\n2 3 10\n7 3 3",
"1\n3 7\n1 2 0\n2 3 8\n3 1 4",
"1\n3 7\n1 2 0\n2 2 10\n0 3 3",
"1\n3 12\n1 2 2\n4 3 5\n3 1 3",
"1\n3 7\n1 1 0\n2 3 5\n3 3 3",
"1\n3 7\n1 2 0\n2 ... |
sumpair | Given an array of N numbers, a pair of numbers is called good if difference between the two numbers is strictly less than D.
Find out maximum possible sum of all good disjoint pairs that can be made from these numbers.
Sum of X pairs is the sum of all 2*X numbers in the pairs.
Input
First line contains T, the number o... | {
"input": [],
"output": []
} | {
"input": [
"3\n3 3\n3 5 8\n4 3\n5 8 10 12\n5 3\n3 2 8 17 15"
],
"output": [
"8\n22\n37\n"
]
} | {
"input": [
"3\n3 3\n3 5 8\n4 3\n5 8 11 12\n5 3\n3 2 8 17 15",
"3\n3 3\n3 5 8\n4 3\n5 8 11 12\n5 6\n3 2 8 17 15",
"3\n3 3\n3 4 8\n4 3\n5 8 11 12\n5 6\n3 2 8 17 15",
"3\n3 3\n3 5 8\n4 3\n3 8 10 12\n5 3\n3 2 8 17 15",
"3\n3 3\n3 5 8\n4 3\n5 8 20 12\n5 3\n3 2 8 17 15",
"3\n3 3\n0 5 8\n4 3\n5 8 2... |
100_I. Rotation | Ehsan loves geometry! Especially he likes to rotate points!
Given a point in the plane, Ehsan likes to rotate it by k degrees (counter-clockwise), around the origin. What is the result of this rotation?
Input
A single integer k (0 ≤ k < 360) is given in the first line. Two integer numbers x and y are given in the se... | {
"input": [],
"output": []
} | {
"input": [
"90\n1 1\n",
"180\n1 1390\n"
],
"output": [
"-1.00000000 1.00000000\n",
"-1.00000000 -1390.00000000\n"
]
} | {
"input": [],
"output": []
} |
1078_E. Negative Time Summation | Everyone knows that computers become faster and faster. Recently Berland scientists have built a machine that can move itself back in time!
More specifically, it works as follows. It has an infinite grid and a robot which stands on one of the cells. Each cell of the grid can either be empty or contain 0 or 1. The mach... | {
"input": [],
"output": []
} | {
"input": [
"2\n123456789 987654321\n555555555 555555555\n"
],
"output": [
"ds10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10... | {
"input": [
"2\n236675740 987654321\n555555555 555555555\n",
"2\n236675740 1140949963\n555555555 555555555\n",
"2\n236675740 1140949963\n555555555 369548570\n",
"2\n236675740 590626629\n555555555 369548570\n",
"2\n236675740 590626629\n555555555 475806795\n",
"2\n236675740 590626629\n555555555... |
130_D. Exponentiation | You are given integers a, b and c. Calculate ab modulo c.
Input
Input data contains numbers a, b and c, one number per line. Each number is an integer between 1 and 100, inclusive.
Output
Output ab mod c.
Examples
Input
2
5
40
Output
32
Input
2
5
26
Output
6 | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n40\n",
"2\n5\n26\n"
],
"output": [
"32\n",
"6\n"
]
} | {
"input": [],
"output": []
} |
1331_G. Lingua Romana | per nextum in unam tum XI conscribementis fac sic
vestibulo perlegementum da varo.
morde varo.
seqis cumula varum.
cis
per nextum in unam tum XI conscribementis fac sic
seqis decumulamenta da varo.
varum privamentum fodementum da aresulto.
... | {
"input": [],
"output": []
} | {
"input": [
"0\n1\n-2\n-3\n-4\n-5\n-6\n-7\n-8\n-9\n10\n"
],
"output": [
"f(10) = MAGNA NIMIS!\nf(-9) = -3642.00\nf(-8) = -2557.17\nf(-7) = -1712.35\nf(-6) = -1077.55\nf(-5) = -622.76\nf(-4) = -318.00\nf(-3) = -133.27\nf(-2) = -38.59\nf(1) = 6.00\nf(0) = 0.00\n"
]
} | {
"input": [
"0\n1\n-2\n-3\n-4\n-5\n-6\n-2\n-8\n-9\n10\n",
"0\n2\n-2\n-3\n-4\n-5\n-6\n-2\n-8\n-9\n10\n",
"0\n2\n-2\n-3\n-4\n-5\n-2\n-2\n-8\n-9\n10\n",
"0\n2\n-2\n-3\n-4\n-5\n-2\n-2\n-8\n-9\n11\n",
"0\n2\n-2\n-3\n-4\n0\n-2\n-2\n-8\n-9\n11\n",
"0\n2\n-2\n-3\n-4\n0\n-2\n-2\n-14\n-9\n11\n",
"0... |
1419_B. Stairs | Jett is tired after destroying the town and she wants to have a rest. She likes high places, that's why for having a rest she wants to get high and she decided to craft staircases.
A staircase is a squared figure that consists of square cells. Each staircase consists of an arbitrary number of stairs. If a staircase ha... | {
"input": [],
"output": []
} | {
"input": [
"4\n1\n8\n6\n1000000000000000000\n"
],
"output": [
"1\n2\n1\n30\n"
]
} | {
"input": [
"4\n1\n8\n1\n1000000000000000000\n",
"4\n1\n3\n1\n1000000100000000000\n",
"4\n1\n8\n10\n1100000000000000100\n",
"4\n1\n4\n10\n1110000000000000100\n",
"4\n1\n4\n10\n0111000000000000100\n",
"4\n1\n8\n10\n0111100000000000100\n",
"4\n1\n39\n3\n1000000100000000000\n",
"4\n1\n4\... |
1437_B. Reverse Binary Strings | You are given a string s of even length n. String s is binary, in other words, consists only of 0's and 1's.
String s has exactly n/2 zeroes and n/2 ones (n is even).
In one operation you can reverse any substring of s. A substring of a string is a contiguous subsequence of that string.
What is the minimum number of... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n10\n4\n0110\n8\n11101000\n"
],
"output": [
"0\n1\n2\n"
]
} | {
"input": [
"3\n2\n10\n4\n0110\n8\n11100001\n",
"3\n2\n10\n4\n1010\n8\n11101000\n",
"3\n2\n10\n4\n0011\n8\n11101000\n",
"3\n2\n10\n4\n0101\n8\n11100001\n",
"3\n2\n10\n4\n0101\n8\n11101000\n",
"3\n2\n10\n4\n0011\n8\n11100001\n",
"3\n2\n10\n4\n1001\n8\n11101000\n",
"3\n2\n10\n4\n0011\n8... |
1510_I. Is It Rated? | The popular improv website Interpretation Impetus hosts regular improv contests and maintains a rating of the best performers. However, since improv can often go horribly wrong, the website is notorious for declaring improv contests unrated. It now holds a wager before each improv contest where the participants try to ... | {
"input": [],
"output": []
} | {
"input": [
"3 4\n000\n\n1\n100\n\n1\n001\n\n0\n111\n\n1\n"
],
"output": [
"\n\n\n0\n\n\n0\n\n\n1\n\n\n1\n\n"
]
} | {
"input": [
"3 1\n000\n\n1\n100\n\n1\n001\n\n0\n111\n\n1\n",
"3 2\n000\n\n1\n000\n\n1\n101\n\n0\n011\n\n1\n",
"3 1\n000\n\n1\n100\n\n1\n001\n\n1\n111\n\n1\n",
"3 1\n000\n\n1\n100\n\n0\n001\n\n0\n111\n\n1\n",
"3 1\n000\n\n1\n100\n\n1\n001\n\n1\n011\n\n1\n",
"3 1\n000\n\n1\n100\n\n0\n001\n\n1\n... |
185_D. Visit of the Great | The Great Mushroom King descended to the dwarves, but not everyone managed to see him. Only the few chosen ones could see the King.
We know that only LCM(k2l + 1, k2l + 1 + 1, ..., k2r + 1) dwarves can see the Great Mushroom King. Numbers k, l, r are chosen by the Great Mushroom King himself in some complicated manner... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 1 10 2\n5 0 4 3\n"
],
"output": [
"0\n0\n"
]
} | {
"input": [
"2\n3 1 9 2\n5 0 4 3\n",
"2\n3 1 2 2\n5 0 4 3\n",
"2\n1 1 9 2\n5 0 4 3\n",
"2\n3 1 9 2\n5 0 5 3\n",
"2\n3 1 10 2\n5 0 5 3\n",
"2\n1 1 9 2\n5 0 5 3\n",
"2\n5 1 10 2\n5 0 5 3\n",
"2\n5 1 10 2\n5 0 10 3\n",
"2\n5 0 10 2\n5 0 10 3\n",
"2\n3 1 2 2\n5 0 2 3\n",
"2\n1... |
683_F. Reformat the String | In this problem you are given a string s consisting of uppercase and lowercase Latin letters, spaces, dots and commas. Your task is to correct the formatting of this string by removing and inserting spaces, as well as changing the case of the letters.
After formatting, the resulting string must meet the following requ... | {
"input": [],
"output": []
} | {
"input": [
"hello ,i AM veRy GooD.Boris\n",
"a. b, C . \n"
],
"output": [
"Hello, i am very good. Boris\n",
"A. B, c.\n"
]
} | {
"input": [],
"output": []
} |
72_A. Goshtasp, Vishtasp and Eidi | Goshtasp was known to be a good programmer in his school. One day Vishtasp, Goshtasp's friend, asked him to solve this task:
Given a positive integer n, you should determine whether n is rich.
The positive integer x is rich, if there exists some set of distinct numbers a1, a2, ..., am such that <image>. In addition: ... | {
"input": [],
"output": []
} | {
"input": [
"11\n",
"545\n"
],
"output": [
"11=11\n",
"541+3+1=545\n"
]
} | {
"input": [],
"output": []
} |
843_D. Dynamic Shortest Path | You are given a weighted directed graph, consisting of n vertices and m edges. You should answer q queries of two types:
* 1 v — find the length of shortest path from vertex 1 to vertex v.
* 2 c l1 l2 ... lc — add 1 to weights of edges with indices l1, l2, ..., lc.
Input
The first line of input data contains i... | {
"input": [],
"output": []
} | {
"input": [
"3 2 9\n1 2 0\n2 3 0\n2 1 2\n1 3\n1 2\n2 1 1\n1 3\n1 2\n2 2 1 2\n1 3\n1 2\n",
"5 4 9\n2 3 1\n2 4 1\n3 4 1\n1 2 0\n1 5\n1 4\n2 1 2\n2 1 2\n1 4\n2 2 1 3\n1 4\n2 1 4\n1 4\n"
],
"output": [
" 1\n ... | {
"input": [
"5 4 9\n2 3 1\n2 4 1\n3 4 1\n1 2 0\n1 5\n1 1\n2 1 2\n2 1 2\n1 4\n2 2 1 3\n1 4\n2 1 4\n1 4\n",
"3 2 9\n1 2 0\n2 3 0\n2 1 2\n1 3\n1 2\n2 1 1\n1 3\n1 2\n2 2 1 2\n1 1\n1 2\n",
"5 4 9\n2 3 1\n2 4 1\n3 4 0\n1 2 0\n1 5\n1 4\n2 1 2\n2 1 2\n1 4\n2 2 1 3\n1 4\n2 1 4\n1 4\n",
"5 4 9\n2 3 1\n2 4 1\n3... |
altf4-ctrlf4-and-the-game | AltF4 and CtrlF4 again started playing games. This time they drew a N x N matrix and filled number in each of the cells randomly. The game is played in turns (AltF4 always starts first, as his name comes first alphabetically). In each turn, a player calls out a number in the range [1, N] which has not already been cal... | {
"input": [],
"output": []
} | {
"input": [
"1\n2\n4 1\n1 8\n\nSAMPLE"
],
"output": [
"8 4"
]
} | {
"input": [
"1\n2\n4 1\n1 10\n\nSAMPLE",
"1\n2\n6 1\n0 10\n\nSAMLPE",
"1\n2\n12 1\n0 10\n\nSAMLPE",
"1\n2\n0 1\n0 10\n\nSAMLPE",
"1\n2\n4 1\n1 6\n\nSAMPLE",
"1\n0\n4 1\n0 10\n\nSAMPLE",
"1\n2\n4 1\n0 1\n\nSAMLPE",
"1\n2\n4 2\n1 12\n\nSAMPLE",
"1\n2\n0 0\n0 14\n\nSAMLPE",
"1\n2... |
candle-problem | Rajiv is given a problem in class.
" Suppose N burnt candles together make a new candle. then how many new candles are created if we start with M candles"
Please refer to similar MCQ Question for clarification.
SAMPLE INPUT
121
SAMPLE OUTPUT
30 | {
"input": [],
"output": []
} | {
"input": [
"121\n\nSAMPLE"
],
"output": [
"30\n"
]
} | {
"input": [
"121\n\nELPMAS",
"121\n\nSAMPLF",
"121\n\nSLMPAF",
"121\n\nSLFPAM",
"121\n\nSLFPAL",
"121\n\nSLEPAL",
"121\n\nLAPELS",
"121\n\nPALELS",
"121\n\nPAMELS",
"121\n\nPBMELS",
"121\n\nPBMEMS",
"121\n\nSMEMBP",
"121\n\nSMEMBO",
"121\n\nSOEMBM",
"121\n\... |
kth-sequence | Today RK has a special task for you. RK gives you a positive integer N. First you have to find all the sequences of length N consisting of characters 'O' and 'Z' only such that no two 'Z' are adjacent in any sequence. After finding all such sequences you have to find Kth sequence when all found sequences are sorted lex... | {
"input": [],
"output": []
} | {
"input": [
"1\n3 2\n\nSAMPLE"
],
"output": [
"OOZ"
]
} | {
"input": [],
"output": []
} |
paroothi-and-his-date | Recently our Paroothi got a crush on a girl , as we all know he is not good with the girls so he asked Vikrant ( The stud ) for expert advise and he told him to take her to her favourite restaurant .
It is known that there are K restaurants in the city numbered from 1 to K.Now Paroothi has a list which contains N integ... | {
"input": [],
"output": []
} | {
"input": [
"8 6\n2 1 2 3 4 2 3 3\n\nSAMPLE"
],
"output": [
"2"
]
} | {
"input": [],
"output": []
} |
p02595 AtCoder Beginner Contest 174 - Distance | We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).
Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?
We remind you that the distance between the origin and the point (p, q) can be represented as \... | {
"input": [],
"output": []
} | {
"input": [
"12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3",
"4 5\n0 5\n-2 4\n3 4\n4 -4",
"20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-1535... | {
"input": [
"12 3\n1 1\n1 1\n1 1\n1 1\n0 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3",
"4 5\n0 5\n-2 4\n3 4\n4 -2",
"20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n191679 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-1535... |
p02726 AtCoder Beginner Contest 160 - Line++ | We have an undirected graph G with N vertices numbered 1 to N and N edges as follows:
* For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.
* There is an edge between Vertex X and Vertex Y.
For each k=1,2,...,N-1, solve the problem below:
* Find the number of pairs of integers (i,j) (1 \leq i... | {
"input": [],
"output": []
} | {
"input": [
"7 3 7",
"10 4 8",
"3 1 3",
"5 2 4"
],
"output": [
"7\n8\n4\n2\n0\n0",
"10\n12\n10\n8\n4\n1\n0\n0\n0",
"3\n0",
"5\n4\n1\n0"
]
} | {
"input": [
"4 1 3",
"7 3 4",
"10 4 6",
"9 2 4",
"14 3 4",
"10 4 9",
"10 4 5",
"3 2 3",
"5 1 4",
"4 1 2",
"8 4 5",
"12 8 9",
"10 5 8",
"6 1 3",
"10 1 6",
"17 4 5",
"19 5 8",
"8 1 3",
"10 1 3",
"9 1 2",
"17 3 5",
"8 1 6",
"16 ... |
p02857 DISCO Presents Discovery Channel Code Contest 2020 Qual - Majority of Balls | This is an interactive task.
We have 2N balls arranged in a row, numbered 1, 2, 3, ..., 2N from left to right, where N is an odd number. Among them, there are N red balls and N blue balls.
While blindfolded, you are challenged to guess the color of every ball correctly, by asking at most 210 questions of the followin... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p02993 AtCoder Beginner Contest 131 - Security | The door of Snuke's laboratory is locked with a security code.
The security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.
You are given the current security code S. If S is hard to enter, print `Bad`; otherwise, print `Good`.
Constraint... | {
"input": [],
"output": []
} | {
"input": [
"1333",
"8080",
"3776",
"0024"
],
"output": [
"Bad",
"Good",
"Bad",
"Bad"
]
} | {
"input": [
"333",
"5823",
"7702",
"446",
"12101",
"4736",
"6783",
"12904",
"24106",
"8244",
"9217",
"5243",
"199",
"4960",
"2178",
"6416",
"9215",
"7196",
"16798",
"29052",
"11746",
"1923",
"8183",
"5267",
"1159",
... |
p03134 Yahoo Programming Contest 2019 - Pass | There are N Snukes lining up in a row. You are given a string S of length N. The i-th Snuke from the front has two red balls if the i-th character in S is `0`; one red ball and one blue ball if the i-th character in S is `1`; two blue balls if the i-th character in S is `2`.
Takahashi has a sequence that is initially ... | {
"input": [],
"output": []
} | {
"input": [
"1210",
"02",
"12001021211100201020"
],
"output": [
"55",
"3",
"543589959"
]
} | {
"input": [
"1",
"0",
"10",
"11",
"21",
"101",
"111",
"011",
"010",
"110",
"102",
"2100",
"2",
"12",
"22",
"20",
"001",
"000",
"100",
"202",
"201",
"121",
"220",
"120",
"112",
"200",
"221",
"212",
"122... |
p03279 AtCoder Regular Contest 101 - Robots and Exits | There are N robots and M exits on a number line. The N + M coordinates of these are all integers and all distinct. For each i (1 \leq i \leq N), the coordinate of the i-th robot from the left is x_i. Also, for each j (1 \leq j \leq M), the coordinate of the j-th exit from the left is y_j.
Snuke can repeatedly perform ... | {
"input": [],
"output": []
} | {
"input": [
"4 1\n1 2 4 5\n3",
"4 5\n2 5 7 11\n1 3 6 9 13",
"10 10\n4 13 15 18 19 20 21 22 25 27\n1 5 11 12 14 16 23 26 29 30",
"3 4\n2 5 10\n1 3 7 13",
"2 2\n2 3\n1 4"
],
"output": [
"1",
"6",
"22",
"8",
"3"
]
} | {
"input": [
"4 5\n0 5 7 11\n1 3 6 9 13",
"0 2\n2 3\n1 4",
"4 5\n0 5 7 19\n1 3 6 9 13",
"1 2\n1 0\n7 4",
"0 2\n2 3\n2 4",
"0 2\n1 3\n2 4",
"0 2\n1 3\n2 3",
"0 1\n1 3\n2 3",
"1 1\n1 3\n2 3",
"0 1\n1 3\n2 2",
"0 2\n1 3\n2 2",
"4 1\n1 2 4 8\n3",
"0 10\n4 13 15 18 19 20... |
p03434 AtCoder Beginner Contest 088 - Card Game for Two | We have N cards. A number a_i is written on the i-th card.
Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.
The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards... | {
"input": [],
"output": []
} | {
"input": [
"4\n20 18 2 18",
"2\n3 1",
"3\n2 7 4"
],
"output": [
"18",
"2",
"5"
]
} | {
"input": [
"4\n20 18 2 12",
"2\n2 1",
"3\n3 7 4",
"4\n20 1 2 12",
"2\n2 0",
"3\n3 9 4",
"4\n20 1 4 12",
"2\n2 -1",
"2\n4 -1",
"4\n20 2 0 12",
"2\n5 -2",
"4\n23 4 0 12",
"4\n23 4 1 12",
"2\n4 0",
"4\n18 4 1 3",
"4\n33 4 1 3",
"4\n47 4 1 5",
"2\n... |
p03593 CODE FESTIVAL 2017 qual A - Palindromic Matrix | We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter.
Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition:
* Every ro... | {
"input": [],
"output": []
} | {
"input": [
"2 5\nabxba\nabyba",
"5 1\nt\nw\ne\ne\nt",
"2 2\naa\nbb",
"1 1\nz",
"3 4\naabb\naabb\naacc"
],
"output": [
"No",
"Yes",
"No",
"Yes",
"Yes"
]
} | {
"input": [
"2 5\nabxab\nabyba",
"1 1\ny",
"5 1\nu\nw\ne\ne\nt",
"2 2\nba\nbb",
"2 5\nbaxba\nabyba",
"5 1\nu\nw\ne\ne\ns",
"2 5\nbaxba\nacyba",
"2 2\nab\nbb",
"0 5\nbaxba\nabyba",
"2 5\nabxab\nacyba",
"1 5\nbaxba\nabyba",
"2 5\nabxba\nacyba",
"0 5\naaxbb\nabyba",
... |
p03750 AtCoder Grand Contest 013 - Two Faced Cards | There are N cards. The two sides of each of these cards are distinguishable. The i-th of these cards has an integer A_i printed on the front side, and another integer B_i printed on the back side. We will call the deck of these cards X. There are also N+1 cards of another kind. The i-th of these cards has an integer C_... | {
"input": [],
"output": []
} | {
"input": [
"5\n7 1\n9 7\n13 13\n11 8\n12 9\n16 7 8 6 9 11\n7\n6 11\n7 10\n9 3\n12 9\n18 16\n8 9\n10 15",
"9\n89 67\n37 14\n6 1\n42 25\n61 22\n23 1\n63 60\n93 62\n14 2\n67 96 26 17 1 62 56 92 13 38\n11\n93 97\n17 93\n61 57\n88 62\n98 29\n49 1\n5 1\n1 77\n34 1\n63 27\n22 66",
"3\n4 1\n5 3\n3 1\n1 2 3 4\n3... | {
"input": [
"5\n7 1\n9 7\n13 13\n11 8\n12 9\n16 7 8 6 9 11\n7\n9 11\n7 10\n9 3\n12 9\n18 16\n8 9\n10 15",
"9\n89 67\n37 14\n6 1\n42 25\n61 34\n23 1\n63 60\n93 62\n14 2\n67 96 26 17 1 62 56 92 13 38\n11\n93 97\n17 93\n61 57\n88 62\n98 29\n49 1\n5 1\n1 77\n34 1\n63 27\n22 66",
"3\n4 1\n5 3\n3 1\n1 2 3 4\n3... |
p03914 CODE FESTIVAL 2016 Final - Road of the King | There are N towns in Takahashi Kingdom. They are conveniently numbered 1 through N.
Takahashi the king is planning to go on a tour of inspection for M days. He will determine a sequence of towns c, and visit town c_i on the i-th day. That is, on the i-th day, he will travel from his current location to town c_i. If he... | {
"input": [],
"output": []
} | {
"input": [
"3 3",
"150 300",
"300 150"
],
"output": [
"2",
"734286322",
"0"
]
} | {
"input": [
"3 5",
"21 300",
"300 280",
"5 5",
"13 300",
"5 6",
"13 146",
"2 146",
"1 8",
"62 300",
"13 178",
"3 6",
"4 146",
"3 146",
"4 6",
"2 8",
"2 13",
"2 5",
"62 108",
"13 214",
"2 3",
"3 289",
"2 14",
"2 18",
"... |
p00016 Treasure Hunt | When a boy was cleaning up after his grand father passing, he found an old paper:
<image>
In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer".
His grand mother says that Sanbonmatsu was standing ... | {
"input": [],
"output": []
} | {
"input": [
"56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0"
],
"output": [
"171\n-302"
]
} | {
"input": [
"56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n5,59\n0,0",
"56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0",
"56,65\n97,54\n64,-4\n65,76\n42,-27\n43,80\n77,-86\n55,-6\n89,34\n95,5\n0,0",
"56,65\n97,54\n64,-4\n65,76\n42,-27\n43,80\n77,-86\n55,... |
p00148 Candy and Class Flag | In Group C of the 3rd year, we decided to use the "class flag" used at the sports festival on November 10, 2007 at future class reunions. So, in order to decide which students to keep the "class flag", I decided to play the following game using a large amount of candy that the teacher gave me the other day.
* Each stu... | {
"input": [],
"output": []
} | {
"input": [
"50\n5576\n5577\n5578"
],
"output": [
"3C11\n3C38\n3C39\n3C01"
]
} | {
"input": [
"50\n5576\n6063\n5578",
"50\n5576\n6063\n515",
"50\n5576\n6063\n39",
"50\n9200\n6063\n39",
"50\n2171\n6063\n39",
"50\n1864\n6063\n39",
"50\n1864\n7383\n39",
"50\n1864\n7046\n39",
"50\n1864\n13193\n39",
"50\n1864\n896\n39",
"50\n1864\n1759\n39",
"50\n1864\n3... |
p00299 School Cafeteria | Today is the open campus of Z University. Every year during the lunch break on this day, many high school students line up for the school cafeteria. Therefore, the secretariat of Z University decided to predict the maximum distance of the procession. As a result of the preliminary survey, we know the following.
* The ... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n1"
],
"output": [
"3"
]
} | {
"input": [
"4 2\n1",
"1 1\n0",
"4 3\n1",
"6 2\n1",
"4 4\n1",
"5 2\n1",
"4 4\n2",
"5 2\n2",
"4 3\n2",
"5 0\n2",
"4 0\n2",
"8 0\n2",
"8 0\n4",
"8 1\n4",
"8 1\n1",
"8 2\n1",
"14 2\n1",
"14 2\n2",
"14 2\n0",
"7 2\n0",
"6 2\n0",
"7 2... |
p00469 Lining up the cards | problem
Hanako is playing with n (4 ≤ n ≤ 10) cards side by side. Each card has one integer between 1 and 99. Hanako chose k cards (2 ≤ k ≤ 4) from these cards and arranged them in a horizontal row to make an integer. How many kinds of integers can Hanako make in total?
For example, consider that you are given five c... | {
"input": [],
"output": []
} | {
"input": [
"4\n2\n1\n2\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0"
],
"output": [
"7\n68"
]
} | {
"input": [
"4\n2\n1\n3\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0",
"4\n2\n1\n3\n12\n1\n6\n3\n11\n2\n12\n7\n2\n1\n0\n0",
"4\n2\n0\n5\n12\n1\n6\n3\n72\n2\n12\n7\n2\n1\n0\n0",
"4\n2\n1\n3\n12\n1\n6\n3\n9\n2\n12\n7\n2\n1\n0\n0",
"4\n1\n1\n3\n12\n1\n6\n3\n9\n2\n12\n7\n2\n1\n0\n0",
"4\n2\n1\n1\n12\n1... |
p00661 Time Manipulation | She is an apprentice wizard. She first learned the magic of manipulating time. And she decided to open a liquor store to earn a living. It has to do with the fact that all the inhabitants of the country where she lives love alcohol. Residents especially like sake that has been aged for many years, and its value increas... | {
"input": [],
"output": []
} | {
"input": [
"12 3\n2 3 6\n12 4\n1 2 3 6\n0 0"
],
"output": [
"6.0000000000\n0.0000000000"
]
} | {
"input": [
"12 3\n2 3 6\n13 4\n1 2 3 6\n0 0",
"12 3\n2 3 6\n12 4\n2 2 3 6\n0 0",
"12 3\n1 4 11\n13 4\n1 2 3 6\n0 0",
"7 3\n4 1 29\n13 4\n2 2 6 6\n0 0",
"17 3\n2 4 11\n13 4\n1 2 3 6\n0 0",
"15 3\n2 6 11\n13 4\n1 2 3 6\n0 0",
"21 3\n2 3 19\n13 4\n1 2 4 6\n0 0",
"7 3\n4 1 21\n17 4\n2 3 ... |
p00804 e-market | The city of Hakodate recently established a commodity exchange market. To participate in the market, each dealer transmits through the Internet an order consisting of his or her name, the type of the order (buy or sell), the name of the commodity, and the quoted price.
In this market a deal can be made only if the pri... | {
"input": [],
"output": []
} | {
"input": [
"3\nPERLIS SELL A 300\nWILKES BUY A 200\nHAMMING SELL A 100\n4\nBACKUS SELL A 10\nFLOYD BUY A 20\nIVERSON SELL B 30\nBACKUS BUY B 40\n7\nWILKINSON SELL A 500\nMCCARTHY BUY C 300\nWILKINSON SELL C 200\nDIJKSTRA SELL B 100\nBACHMAN BUY A 400\nDIJKSTRA BUY A 600\nWILKINSON SELL A 300\n2\nABCD SELL X 10\... | {
"input": [
"3\nPERLIS SELL A 300\nWILKES BUY A 200\nHAMMING SELL A 100\n4\nBACKUS SELL A 10\nFLOYD BUY A 20\nIVERSON SELL B 17\nBACKUS BUY B 40\n7\nWILKINSON SELL A 500\nMCCARTHY BUY C 300\nWILKINSON SELL C 200\nDIJKSTRA SELL B 100\nBACHMAN BUY A 400\nDIJKSTRA BUY A 600\nWILKINSON SELL A 300\n2\nABCD SELL X 10\... |
p00935 Decimal Sequences | Example
Input
3
3 0 1
Output
2 | {
"input": [],
"output": []
} | {
"input": [
"3\n3 0 1"
],
"output": [
"2"
]
} | {
"input": [
"3\n0 0 1",
"3\n0 0 2",
"3\n-1 -1 1",
"3\n0 1 2",
"3\n0 0 0",
"3\n3 0 2",
"3\n1 0 1",
"3\n0 1 0",
"3\n6 0 2",
"3\n1 0 0",
"3\n1 1 0",
"3\n8 0 2",
"3\n-1 0 1",
"3\n8 0 3",
"3\n8 1 3",
"3\n0 -1 1",
"3\n8 0 1",
"3\n8 -1 1",
"3\n8 -1... |
p01068 Equivalent Vertices | Background
The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu-kun, one of the kindergarten children, loves drawing as much as programming. So far, Yu has drawn many pictures with circles, hexagons and arrows. One day Yu finds out that these pictures are... | {
"input": [],
"output": []
} | {
"input": [
"6 6\n0 1 5\n1 1 1\n0 1 5\n0 2 1\n0 5 1\n1 5 5\n0\n1\n2\n3\n4\n5",
"2 1\n0 0 1\n0 1 0\n0"
],
"output": [
"3\n2\n3\n1\n3\n2",
"2"
]
} | {
"input": [
"2 1\n0 0 1\n0 1 0\n1",
"6 6\n0 1 5\n1 1 1\n0 1 5\n0 2 0\n0 5 1\n1 5 5\n0\n1\n2\n3\n4\n5",
"2 1\n0 0 1\n1 1 0\n1",
"6 6\n0 1 5\n1 1 1\n0 1 5\n0 2 1\n0 5 0\n1 5 5\n0\n1\n2\n3\n4\n5",
"6 6\n0 1 5\n1 1 1\n0 2 5\n0 2 1\n0 5 1\n1 5 5\n0\n1\n2\n3\n4\n5",
"2 2\n1 1 1\n0 1 0\n0",
"2 2... |
p01202 Dance Dance Revolution | Dance Dance Revolution is one of the most popular arcade games in Japan. The rule of this game is very simple. A series of four arrow symbols, up, down, left and right, flows downwards on the screen in time to music. The machine has four panels under your foot, each of which corresponds to one of the four arrows, and y... | {
"input": [],
"output": []
} | {
"input": [
"3\nUU\nRDUL\nULDURDULDURDULDURDULDURD"
],
"output": [
"No\nYes\nYes"
]
} | {
"input": [
"3\nUU\nRDLU\nULDURDULDURDULDURDULDURD",
"3\nTU\nRDLU\nULDURDULDURDULDURDULDURD",
"3\nTV\nRVKD\nULDUREULDUDDULDURRUKDURD",
"3\nTU\nRDLU\nULDURDULDUREULDURDULDURD",
"3\nUU\nRDUL\nULDTRDULDURDULDURDULDURD",
"3\nUU\nRULD\nULDURDULDURDULDURDULDURD",
"3\nTV\nRDLU\nULDURDULDURDULDUR... |
p01338 KULASIS | Description
KULASIS is the name of a system developed and operated by the Higher Education Research and Development Promotion Organization for the purpose of providing information on common subjects throughout the university on the Web, supporting students and faculty members, and improving services. KULASIS started w... | {
"input": [],
"output": []
} | {
"input": [
"5\n\n1 1 0 3 3\n1 1 0 3 3\n0 0 0 0 0\n2 2 0 4 4\n2 2 0 4 4\n\n1 1 1 0 0\n1 1 1 1 0\n1 0 1 1 0\n0 0 1 1 1\n1 1 1 1 1\n\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n\n4 3 4 3 4\n3 4 3 4 3\n4 3 4 3 4\n3 4 3 4 3\n4 3 4 3 4\n\n2 2 2 2 2\n0 0 0 2 0\n2 2 0 2 0\n2 2 0 2 0\n0 0 0 2 0"
],
"outp... | {
"input": [
"5\n\n1 1 0 3 3\n1 1 0 3 3\n0 0 0 0 0\n2 2 0 4 4\n2 2 0 4 4\n\n1 1 1 0 0\n1 1 1 1 0\n1 0 0 1 0\n0 0 1 1 1\n1 1 1 1 1\n\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n\n4 3 4 3 4\n3 4 3 4 3\n4 3 4 3 4\n3 4 3 4 3\n4 3 4 3 4\n\n2 2 2 2 2\n0 0 0 2 0\n2 2 0 2 0\n2 2 0 2 0\n0 0 0 2 0",
"5\n\n1... |
p01505 Billiards Sorting | Rotation is one of several popular pocket billiards games. It uses 15 balls numbered from 1 to 15, and set them up as illustrated in the following figure at the beginning of a game. (Note: the ball order is modified from real-world Rotation rules for simplicity of the problem.)
[ 1]
[ 2][ 3]
[ 4][ 5][ 6]
[ 7][ 8][ 9]... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n2 1\n4\n9\n2 4\n8 5 3\n7 1 6 10\n0"
],
"output": [
"Case 1: 1\nCase 2: 13"
]
} | {
"input": [
"2\n3\n2 1\n4\n9\n2 4\n8 5 3\n7 1 6 10\n-1",
"2\n3\n2 1\n0\n9\n2 4\n8 5 3\n7 1 6 10\n0",
"2\n3\n2 1\n0\n9\n2 4\n8 5 5\n7 1 6 10\n0",
"2\n3\n2 1\n0\n9\n2 4\n8 5 3\n7 1 6 10\n1",
"2\n3\n2 1\n0\n9\n2 4\n5 5 5\n7 1 6 10\n0",
"2\n3\n2 1\n0\n9\n2 4\n5 5 5\n1 1 6 10\n0",
"2\n3\n2 1\n... |
p01676 Tree Reconstruction | J - Tree Reconstruction
Problem Statement
You have a directed graph. Some non-negative value is assigned on each edge of the graph. You know that the value of the graph satisfies the flow conservation law That is, for every node v, the sum of values on edges incoming to v equals to the sum of values of edges outgoing... | {
"input": [],
"output": []
} | {
"input": [
"9 13\n1 2\n1 3\n2 9\n3 4\n3 5\n3 6\n4 9\n5 7\n6 7\n6 8\n7 9\n8 9\n9 1"
],
"output": [
"5"
]
} | {
"input": [
"9 13\n1 2\n1 3\n2 9\n3 4\n3 5\n3 6\n4 9\n5 8\n6 7\n6 8\n7 9\n8 9\n9 1",
"9 13\n1 2\n1 3\n1 9\n1 4\n3 5\n5 6\n4 9\n5 7\n6 7\n8 8\n7 9\n5 9\n9 1",
"9 1\n1 1\n1 3\n1 9\n1 4\n3 5\n5 6\n4 9\n5 7\n6 7\n6 8\n7 9\n5 9\n9 1",
"9 10\n1 2\n1 3\n2 9\n1 4\n3 5\n4 6\n3 9\n5 7\n6 7\n6 8\n7 9\n5 9\n9 1"... |
p01820 Vector Field | Example
Input
9
0 0 v
1 0 >
2 0
Output
9 | {
"input": [],
"output": []
} | {
"input": [
"9\n0 0 v\n1 0 >\n2 0"
],
"output": [
"9"
]
} | {
"input": [
"9\n0 1 v\n1 0 >\n2 0",
"9\n1 1 v\n1 -1 >\n2 0",
"9\n1 1 v\n1 -1 >\n2 1",
"9\n1 1 v\n1 0 >\n2 0",
"9\n1 1 w\n1 -1 >\n2 0",
"9\n1 1 w\n1 -2 >\n2 0",
"9\n0 0 v\n1 1 >\n2 0",
"9\n1 1 v\n0 0 >\n2 0",
"9\n1 2 w\n1 -2 >\n2 0",
"9\n0 0 v\n1 1 >\n1 0",
"9\n1 1 v\n0 0 >... |
p01953 Librarian's Work | Japanese Animal Girl Library (JAG Library) is famous for a long bookshelf. It contains $N$ books numbered from $1$ to $N$ from left to right. The weight of the $i$-th book is $w_i$.
One day, naughty Fox Jiro shuffled the order of the books on the shelf! The order has become a permutation $b_1, ..., b_N$ from left to r... | {
"input": [],
"output": []
} | {
"input": [
"3 2\n2 3\n3 4\n1 2",
"3 2\n1 2\n2 3\n3 3",
"10 5\n8 3\n10 6\n5 8\n2 7\n7 6\n1 9\n9 3\n6 2\n4 5\n3 5"
],
"output": [
"15",
"0",
"824"
]
} | {
"input": [
"3 2\n0 3\n3 4\n1 2",
"3 1\n1 2\n2 3\n3 3",
"10 5\n8 3\n10 6\n5 8\n2 7\n7 6\n0 9\n9 3\n6 2\n4 5\n3 5",
"10 5\n8 3\n10 6\n5 8\n2 7\n7 6\n0 9\n9 3\n6 3\n4 5\n3 5",
"3 2\n2 3\n3 7\n1 2",
"3 2\n0 3\n5 2\n1 2",
"3 1\n2 3\n3 4\n1 2",
"4 5\n8 3\n10 6\n5 8\n2 7\n7 6\n1 9\n9 3\n6 2... |
p02102 Tangled Cables | Problem
On a company's network, there are $ n $ computers and $ m $ communication cables that connect them. Computers are distinguished by identifiers from $ 0 $ to $ n -1 $, and communication cables also have identifiers from $ 0 $ to $ m -1 $.
Any two different computers currently in the company can communicate wit... | {
"input": [],
"output": []
} | {
"input": [
"4 5\n0 2 22 13\n0 3 15 25\n1 2 3 3\n1 3 28 5\n2 3 5 22",
"2 1\n0 1 1 1",
"5 6\n0 1 22 33\n0 2 43 11\n0 3 92 10\n1 3 50 12\n2 3 88 2\n3 4 58 89"
],
"output": [
"0.36000",
"0",
"0.06667"
]
} | {
"input": [
"4 5\n0 2 22 13\n0 3 15 25\n1 2 0 3\n1 3 28 5\n2 3 5 22",
"2 1\n0 1 0 1",
"5 6\n0 1 22 33\n0 2 43 11\n0 3 86 10\n1 3 50 12\n2 3 88 2\n3 4 58 89",
"4 5\n0 3 22 13\n0 3 15 25\n1 2 0 3\n1 3 18 5\n2 3 5 22",
"4 5\n0 3 22 13\n0 3 15 25\n1 2 0 3\n1 3 1 5\n2 3 5 22",
"5 6\n0 1 22 33\n0 2... |
p02240 Connected Components | Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.
Constraints
* $2 \leq n \leq 100,000$
* $0 \leq m \leq 100,000$
* $1 \leq q \leq 10,000$
Input
In the first line, two integer $n$ and $m$ are given. $n$ is the ... | {
"input": [],
"output": []
} | {
"input": [
"10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n6 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3"
],
"output": [
"yes\nyes\nno"
]
} | {
"input": [
"10 9\n0 1\n0 2\n3 4\n5 7\n5 6\n3 7\n6 8\n7 8\n8 9\n3\n0 1\n5 9\n1 3",
"16 9\n0 2\n0 2\n3 4\n5 7\n5 6\n3 7\n6 13\n7 8\n8 9\n3\n0 1\n5 9\n1 3",
"16 9\n0 2\n0 2\n3 4\n2 7\n5 6\n3 7\n6 13\n7 8\n8 9\n3\n0 1\n5 9\n1 3",
"16 9\n0 2\n0 2\n3 4\n2 7\n5 6\n3 7\n6 13\n7 8\n8 9\n3\n0 0\n5 9\n1 3",
... |
p02386 Dice IV | Write a program which reads $n$ dices constructed in the same way as Dice I, and determines whether they are all different. For the determination, use the same way as Dice III.
Constraints
* $2 \leq n \leq 100$
* $0 \leq $ the integer assigned to a face $ \leq 100$
Input
In the first line, the number of dices $n$ i... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 3 4 5 6\n6 5 4 3 2 1\n5 4 3 2 1 6",
"3\n1 2 3 4 5 6\n6 2 4 3 5 1\n6 5 4 3 2 1"
],
"output": [
"Yes",
"No"
]
} | {
"input": [
"3\n1 2 3 4 5 6\n6 5 4 3 2 1\n5 4 0 2 1 6",
"3\n1 2 3 4 5 6\n6 2 5 3 5 1\n6 5 4 3 2 1",
"3\n1 2 3 4 5 6\n5 5 4 3 2 1\n5 4 0 2 1 6",
"3\n1 2 3 4 5 6\n6 2 5 3 0 1\n6 5 4 3 2 1",
"3\n1 2 3 3 5 6\n5 5 4 3 2 1\n5 4 0 2 1 6",
"3\n1 4 3 4 5 6\n6 2 5 3 0 1\n6 5 4 3 2 1",
"3\n1 2 3 3 5... |
arraytrm | Given n numbers, you can perform the following operation any number of times : Choose any subset of the numbers (possibly empty), none of which are 0. Decrement the numbers in the subset by 1, and increment the numbers not in the subset by K.
Is it possible to perform operations such that exactly n - 1 numbers becom... | {
"input": [],
"output": []
} | {
"input": [
"3\n2 1\n10 10\n3 2\n1 2 2\n3 2\n1 2 3"
],
"output": [
"YES\nYES\nNO\n"
]
} | {
"input": [
"3\n2 1\n10 10\n3 2\n1 2 2\n3 2\n1 2 2",
"3\n2 1\n10 10\n3 2\n1 1 2\n3 2\n1 3 2",
"3\n2 1\n20 10\n3 2\n1 2 3\n3 2\n1 2 2",
"3\n2 1\n20 0\n3 2\n1 2 3\n3 2\n1 3 2",
"3\n2 1\n10 10\n3 2\n1 1 2\n3 2\n1 2 2",
"3\n2 1\n10 10\n3 2\n1 2 2\n3 2\n0 2 2",
"3\n2 1\n10 10\n3 2\n1 2 2\n3 2\... |
clco05 | After coming to college, Harry decided to have a get together with friends. So he contacted Chahak who is a renowned event organiser. She is given the task of managing this lavish party.
Harry is fond of eating and his friend Joseph is fond of cracking jokes. As per Harry’s demand, Chahak kept N food items in the party... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 30\n2 2 1\n3 20\n2 1 1"
],
"output": [
"5\n-1"
]
} | {
"input": [],
"output": []
} |
fest | Indian Institute of Technology, Banaras Hindu University is organizing an annual cultural festival. An organizing committee has been formed to get all the preprations done for the fest. The convener of the fest has decided to invite the American Band, Linkin Park to the institute. which in turn gets disadvantageous as ... | {
"input": [],
"output": []
} | {
"input": [
"5\n3 2\n4 5\n7 4\n34534985349875439875439875349875 93475349759384754395743975349573495\n34543987529435983745230948023948 3498573497543987543985743989120393097595572309482304"
],
"output": [
"9\n1024\n2401\n735851262\n985546465"
]
} | {
"input": [],
"output": []
} |
lebombs | The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent buildings with indices i-1 and i+1. The first and the last buildings have j... | {
"input": [],
"output": []
} | {
"input": [
"3\n3\n010\n5\n10001\n7\n0000000"
],
"output": [
"0\n1\n7\n"
]
} | {
"input": [
"3\n3\n011\n5\n10001\n7\n0000000",
"3\n3\n010\n5\n10001\n7\n0010000",
"3\n3\n010\n5\n10001\n7\n1010000",
"3\n3\n010\n5\n10000\n7\n1010000",
"3\n3\n010\n5\n10011\n7\n0000000",
"3\n3\n001\n5\n10101\n7\n0000000",
"3\n3\n010\n5\n00011\n7\n1010000",
"3\n3\n010\n5\n10011\n7\n101... |
pntng | You are given a transparent three-dimensional table, the height equals to H and the base is a two-dimensional table N∙M.
The layers of the 3D table are numbered from 1 to H. Each layer is a two-dimensional table, the rows are numbered from 1 to N and the columns are numbered from 1 to M. A pair (i, j) (1 ≤ i ≤ N, 1 ≤ j... | {
"input": [],
"output": []
} | {
"input": [
"2 2 3\n1 1\n1 2\n1 3"
],
"output": [
"Impossible\n"
]
} | {
"input": [
"1 2 3\n1 1\n1 2\n1 3",
"1 2 3\n1 1\n1 1\n1 3",
"1 2 3\n0 1\n1 1\n0 5",
"1 2 3\n1 1\n1 3\n1 3",
"1 2 3\n1 0\n1 1\n2 5",
"0 2 3\n1 2\n1 2\n0 10",
"1 2 3\n0 1\n2 10\n1 3",
"1 2 3\n0 1\n2 3\n1 3",
"1 3 3\n2 4\n1 1\n0 11",
"1 3 1\n4 4\n2 1\n0 3",
"2 2 3\n1 0\n1 2\n... |
subarray | You are given a character parenthesis array and an integer array.
You need to find the maximum sum sub-array in the integer array such that the corresponding sub-array in the character array has balanced parenthesis.
Formally, a balanced parentheses is subset of { [,],{,},<,>,(,) }∗ defined recursively as follows: ... | {
"input": [],
"output": []
} | {
"input": [
"3\n4\n()()\n-1 -2 3 4\n4\n(()]\n-1 -2 3 4\n4\n[{]{\n1 2 3 4"
],
"output": [
"7\n1\n0"
]
} | {
"input": [
"3\n3\n()()\n-1 -2 3 4\n4\n(()]\n-1 -2 3 4\n4\n[{]{\n1 2 3 4",
"3\n4\n()()\n-1 -2 3 4\n4\n(()]\n-1 -2 3 4\n4\n[]{{\n1 2 3 4",
"3\n3\n)()(\n-1 -2 3 4\n8\n(()]\n-1 -2 3 4\n4\n{]{[\n1 4 3 5",
"3\n3\n()()\n-2 -2 3 8\n4\n(()]\n-1 -2 3 4\n4\n[{]{\n1 2 3 4",
"3\n3\n()()\n0 -2 3 4\n4\n(()]\n-... |
100_B. Friendly Numbers | Kiana thinks two integers are friends if and only if one of them divides the other one. For example, 12 and 4 are friends, also 6 and 6 are friends too, but 120 and 36 are not.
A group of non-zero integers is called friendly, if each pair of its integers form a friend pair.
You are given a group of non-zero integers.... | {
"input": [],
"output": []
} | {
"input": [
"4\n1,3,6,12\n",
"3\n1,2,9\n"
],
"output": [
"FRIENDS\n",
"NOT FRIENDS\n"
]
} | {
"input": [],
"output": []
} |
1221_A. 2048 Game | You are playing a variation of game 2048. Initially you have a multiset s of n integers. Every integer in this multiset is a power of two.
You may perform any number (possibly, zero) operations with this multiset.
During each operation you choose two equal integers from s, remove them from s and insert the number eq... | {
"input": [],
"output": []
} | {
"input": [
"6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n7\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4096\n"
],
"output": [
"YES\nYES\nNO\nNO\nYES\nYES\n"
]
} | {
"input": [
"6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n1\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4096\n",
"6\n4\n1024 512 64 512\n1\n4096\n3\n64 512 2\n2\n4096 4\n7\n2048 2 2048 2048 2048 2048 2048\n2\n2048 4096\n",
"6\n4\n1024 512 64 512\n1\n2048\n3\n64 512 2\n2\n4096 4\n7\n2048 4 2048 2... |
1266_B. Dice Tower | Bob is playing with 6-sided dice. A net of such standard cube is shown below.
<image>
He has an unlimited supply of these dice and wants to build a tower by stacking multiple dice on top of each other, while choosing the orientation of each dice. Then he counts the number of visible pips on the faces of the dice.
Fo... | {
"input": [],
"output": []
} | {
"input": [
"4\n29 34 19 38\n"
],
"output": [
"YES\nYES\nYES\nNO\n"
]
} | {
"input": [
"4\n29 34 18 38\n",
"4\n29 13 19 38\n",
"4\n29 13 19 57\n",
"4\n49 13 19 57\n",
"4\n29 34 19 30\n",
"4\n26 34 19 30\n",
"4\n29 34 0 38\n",
"4\n49 13 19 66\n",
"4\n29 68 25 38\n",
"4\n29 68 25 32\n",
"4\n0 34 18 38\n",
"4\n29 65 19 38\n",
"4\n29 13 19 9\... |
1330_D. Dreamoon Likes Sequences | Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS:
You are given two integers d, m, find the number of arrays a, satisfying the following constraints:
* The length of a is n, n ≥ 1
* 1 ≤ a_1 < a_2 < ... < a_n ≤ d
* Define an array b of length n as foll... | {
"input": [],
"output": []
} | {
"input": [
"10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n6 99995\n7 9994\n8 993\n9 92\n10 1\n"
],
"output": [
"1\n3\n5\n11\n17\n23\n29\n59\n89\n0\n"
]
} | {
"input": [
"10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n10 99995\n7 9994\n8 993\n9 92\n10 1\n",
"10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n10 99995\n7 9994\n8 993\n12 92\n19 1\n",
"10\n1 1000000000\n2 999999999\n3 99999998\n4 9999997\n5 999996\n6 99995\n5 9994\n... |
1485_F. Copy or Prefix Sum | You are given an array of integers b_1, b_2, …, b_n.
An array a_1, a_2, …, a_n of integers is hybrid if for each i (1 ≤ i ≤ n) at least one of these conditions is true:
* b_i = a_i, or
* b_i = ∑_{j=1}^{i} a_j.
Find the number of hybrid arrays a_1, a_2, …, a_n. As the result can be very large, you should pri... | {
"input": [],
"output": []
} | {
"input": [
"4\n3\n1 -1 1\n4\n1 2 3 4\n10\n2 -1 1 -2 2 3 -5 0 2 -1\n4\n0 0 0 1\n"
],
"output": [
"\n3\n8\n223\n1\n"
]
} | {
"input": [
"4\n3\n1 -1 1\n4\n1 2 3 4\n10\n2 -1 1 -2 2 6 -5 0 2 -1\n4\n0 0 0 1\n",
"4\n3\n1 -1 1\n4\n1 2 3 4\n10\n2 -1 1 -2 1 6 -5 0 2 -1\n4\n0 0 0 1\n",
"4\n3\n1 -1 1\n4\n1 2 2 4\n10\n2 -1 1 -2 1 1 -5 0 2 -1\n4\n0 -1 0 1\n",
"4\n3\n2 -1 1\n4\n1 2 2 4\n10\n2 -1 1 -2 1 1 -6 0 2 -1\n4\n0 -1 0 1\n",
... |
alexanders-journey-4 | There are N (labelled 1 to N) kingdoms in a country. Our king Alexander is living in the kingdom S. We are given R distances, these distances are between two kingdoms and the distance between any two kingdom may or may not be unique.
Now Alexander wants to visit each kingdom in minimum distance possible starting from ... | {
"input": [],
"output": []
} | {
"input": [
"1\n4 4\n1 2 24\n1 4 20\n3 1 3\n4 3 12\n1\n\nSAMPLE"
],
"output": [
"24 3 15"
]
} | {
"input": [],
"output": []
} |
day-6-advanced-mathematics | Problem :
Bajirao is on a date with his girlfriend Avni. It is a romantic night and they are
playing a game of words.
The rule of this game is that if Bajirao says a word such that no adjacent letters occurring in the word are same then he gets a kiss from her otherwise he gets a slap.
Input :
The first line consi... | {
"input": [],
"output": []
} | {
"input": [
"2\nremember\noccurring\n\nSAMPLE"
],
"output": [
"KISS\nSLAP\n"
]
} | {
"input": [
"2\nremember\noccurring\n\nELPMAS",
"2\nrmeenber\noccurrhng\n\nSAMPMD",
"2\nrfrnfemc\nvohtrcgcn\n\nLDPMAS",
"2\nqfrefmmc\nnohsrcgdv\n\nSCLPEN",
"2\nremenber\noccurring\n\nELPMAS",
"2\nremenber\noccurring\n\nSAMPLE",
"2\nremenber\noccurrhng\n\nSAMPLE",
"2\nremenber\noccurrh... |
game-of-numbers-7 | Game of numbers is a game where you are given two integers (X and Y), and you have to print the number of special numbers between X and Y both inclusive.
The property of a special numbers is as follows:
A special number is not divisible by any number of the form ZZ* where (Z\; >\; 1).
Input:
T, the number of ... | {
"input": [],
"output": []
} | {
"input": [
"1\n1 10\n\nSAMPLE"
],
"output": [
"7\n"
]
} | {
"input": [
"1\n1 10\n\nELPMAS",
"1\n1 9\n\nELPMAS",
"1\n2 9\n\nELPMAS",
"1\n2 4\n\nSAMPLE",
"1\n2 2\n\nSANPLE",
"1\n1 15\n\nELPMAS",
"1\n3 9\n\nSAMPLE",
"1\n1 14\n\nELPM@S",
"1\n1 29\n\nELOMAS",
"1\n1 25\n\nELOMAS",
"1\n0 50\n\nELOMAS",
"1\n0 27\n\nTAMPLE",
"1\n1 ... |
kejal-color-problem | Kejal have N points, with coordinates (1, 0), (2, 0), ..., (N, 0). Every point has a color, point with coordinate (i, 0) has color C[i].
Kejal have painted arcs between every pair of points with same color. Formally Kejal painted arc between points (i, 0) and (j, 0) if C[i] = C[j] and i != j, such arc has color C[i]. ... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2 1 2 1 2\n\nSAMPLE"
],
"output": [
"6"
]
} | {
"input": [],
"output": []
} |
panda-and-maximum-product | Panda has started learning about subsets. His professor gave him a simple task. Given a list of numbers, Panda has to choose the subset which gives the maximum product. However, the professor asked Panda only to submit the maximum product obtained by taking exactly two numbers from the list. Please help Panda in findi... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 3\n\nSAMPLE"
],
"output": [
"6\n"
]
} | {
"input": [
"2\n2 3\n\nTAMPLE",
"2\n2 6\n\nTAMPEL",
"2\n2 2\n\nTAMPEL",
"2\n0 2\n\nTAMPDL",
"2\n1 2\n\nTAMPDL",
"2\n1 3\n\nTAMPDL",
"2\n3 3\n\nLEQMAT",
"2\n2 4\n\nDLPMAT",
"2\n6 3\n\nMAPSEL",
"2\n1 24\n\nTBNPDL",
"2\n2 24\n\nTBNPDL",
"2\n7 1\n\nNAPSEL",
"2\n2 11\n\... |
roots | Bosky needs your help in completing his maths homework today. He has to solve some questions as homework from a book named Jungly Mathematics. He knows that Jungly Mathematics contains certain quadratic equations which have imaginary roots. He is not yet introduced to the concept of imaginary roots and is only concerne... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 0 -1\n1 1 1\n\nSAMPLE"
],
"output": [
"1\n"
]
} | {
"input": [
"2\n2 0 -1\n1 1 1\n\nSAMPLE",
"2\n2 0 -1\n1 2 1\n\nSAMPLE",
"2\n17 0 1\n3 -2 1\n\nE@QNMS",
"2\n4 0 -1\n1 1 1\n\nSAMPLE",
"2\n4 0 -1\n1 1 2\n\nSAMPLE",
"2\n4 0 -2\n1 1 2\n\nSAMPLE",
"2\n4 0 -2\n1 0 2\n\nSAMPLE",
"2\n4 0 -2\n1 0 2\n\nSANPLE",
"2\n4 0 -4\n1 0 2\n\nSANPLE"... |
p02588 AtCoder Grand Contest 047 - Integer Product | You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer.
Constraints
* 2 \leq N \leq 200\,000
* 0 < A_i < 10^4
* A_i is given with at most 9 digits after the decimal.
Input
Input is given from Standard Input in the fol... | {
"input": [],
"output": []
} | {
"input": [
"5\n7.5\n2.4\n17.000000001\n17\n16.000000000",
"11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.000000001"
],
"output": [
"3",
"8"
]
} | {
"input": [
"5\n7.5\n2.4\n17.000000001\n17\n16.487690532545415",
"5\n7.950925288494011\n2.4\n17.000000001\n17\n16.487690532545415",
"5\n7.5\n2.4\n17.000000001\n22\n16.000000000",
"11\n0.9\n1\n1\n1.25\n2.30000\n5\n70\n0.000000001\n9999.999999999\n0.999999999\n1.7676771981771382",
"5\n7.5\n2.4\n17.... |
p02719 AtCoder Beginner Contest 161 - Replacing Integer | Given any integer x, Aoki can do the operation below.
Operation: Replace x with the absolute difference of x and K.
You are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.
Constraints
* 0 ≤ N ≤ 10^{18}
* 1 ≤ K ≤ 10^{18}
* All valu... | {
"input": [],
"output": []
} | {
"input": [
"1000000000000000000 1",
"7 4",
"2 6"
],
"output": [
"0",
"1",
"2"
]
} | {
"input": [
"1000000000000010000 1",
"7 6",
"7 9",
"17 12",
"7 13",
"8 16",
"5 9",
"30 23",
"10 22",
"37 10",
"12 23",
"14 23",
"13 30",
"19 31",
"-1 -2",
"44 30",
"70 44",
"33 84",
"1 -3",
"1 -4",
"22 50",
"103 44",
"42 84",... |
p02848 AtCoder Beginner Contest 146 - ROT N | We have a string S consisting of uppercase English letters. Additionally, an integer N will be given.
Shift each character of S by N in alphabetical order (see below), and print the resulting string.
We assume that `A` follows `Z`. For example, shifting `A` by 2 results in `C` (`A` \to `B` \to `C`), and shifting `Y` ... | {
"input": [],
"output": []
} | {
"input": [
"13\nABCDEFGHIJKLMNOPQRSTUVWXYZ",
"0\nABCXYZ",
"2\nABCXYZ"
],
"output": [
"NOPQRSTUVWXYZABCDEFGHIJKLM",
"ABCXYZ",
"CDEZAB"
]
} | {
"input": [
"13\nABCDEFGGIJKLMNOPQRSTUVWXYZ",
"0\nYBCXAZ",
"2\nABDXYZ",
"13\nABCDEFGGIJKLMNOOQRSTUVWXYZ",
"0\nYBBXAZ",
"2\nZYXDBA",
"13\nABCDEFGOIJKLMNGOQRSTUVWXYZ",
"0\nYABXAZ",
"2\nZXXDBA",
"13\nZYXWVUTSRQOGNMLKJIOGFEDCBA",
"0\nZAXBAY",
"2\nZXXBDA",
"13\nAICDEFGO... |
p02986 AtCoder Beginner Contest 133 - Colorful Tree | There is a tree with N vertices numbered 1 to N. The i-th edge in this tree connects Vertex a_i and Vertex b_i, and the color and length of that edge are c_i and d_i, respectively. Here the color of each edge is represented by an integer between 1 and N-1 (inclusive). The same integer corresponds to the same color, and... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n1 2 1 10\n1 3 2 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4"
],
"output": [
"130\n200\n60"
]
} | {
"input": [
"5 3\n1 2 1 10\n1 3 1 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 3 4",
"5 3\n1 2 1 10\n1 3 1 20\n2 4 4 30\n5 2 1 40\n1 100 1 4\n1 100 1 5\n3 1000 1 4",
"5 3\n1 2 1 10\n1 3 1 20\n2 4 4 30\n5 2 1 40\n1 100 1 7\n1 100 1 5\n3 1000 1 4",
"5 3\n1 2 1 6\n1 3 1 20\n2 4 4 30\n5 2 1 40\n1... |
p03127 AtCoder Beginner Contest 118 - Monsters Battle Royale | There are N monsters, numbered 1, 2, ..., N.
Initially, the health of Monster i is A_i.
Below, a monster with at least 1 health is called alive.
Until there is only one alive monster, the following is repeated:
* A random alive monster attacks another random alive monster.
* As a result, the health of the monster a... | {
"input": [],
"output": []
} | {
"input": [
"3\n1000000000 1000000000 1000000000",
"4\n5 13 8 1000000000",
"4\n2 10 8 40"
],
"output": [
"1000000000",
"1",
"2"
]
} | {
"input": [
"3\n1000000100 1000000000 1000000000",
"4\n5 13 8 1000010000",
"4\n0 10 8 40",
"3\n1100000100 0100100010 1000000000",
"3\n0111100010 0101001110 1010110101",
"4\n0 0 0 0111111011",
"3\n1110110010 0100001100 1011100110",
"4\n0 0 0 0101011001",
"4\n0 0 0 0101011000",
... |
p03270 AtCoder Regular Contest 102 - Stop. Otherwise... | Takahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable. For each i=2,3,...,2K, find the following value modulo 998244353:
* The number of combinations of N sides shown by the dice such that the sum of no two different sides is i.
Note that the dice are ... | {
"input": [],
"output": []
} | {
"input": [
"6 1000",
"3 3",
"4 5"
],
"output": [
"149393349\n149393349\n668669001\n668669001\n4000002\n4000002\n4000002\n668669001\n668669001\n149393349\n149393349",
"7\n7\n4\n7\n7",
"36\n36\n20\n20\n20\n36\n36"
]
} | {
"input": [
"8 1000",
"3 6",
"1 5",
"13 1000",
"18 1000",
"18 1100",
"2 3",
"18 0100",
"5 3",
"21 1100",
"5 5",
"35 1100",
"47 1100",
"47 1000",
"93 1000",
"110 1000",
"110 1010",
"110 0010",
"110 0110",
"100 0110",
"6 1010",
"3 ... |
p03427 AtCoder Grand Contest 021 - Digit Sum 2 | Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.
Constraints
* 1\leq N \leq 10^{16}
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
Print the maximum possible sum of the digits (in base 10) of a positive integer not... | {
"input": [],
"output": []
} | {
"input": [
"3141592653589793",
"100",
"9995"
],
"output": [
"137",
"18",
"35"
]
} | {
"input": [
"1265641936938969",
"101",
"613",
"1180",
"2005985506723837",
"78",
"813322357948504",
"127248513971408",
"46390584841058",
"51",
"67784328360011",
"89",
"34",
"307201070613497",
"2",
"1909031865550",
"1",
"3052173209686",
"24053... |
p03585 Tenka1 Programmer Contest - CARtesian Coodinate | There are N lines in the xy-plane. The i-th line is represented by A_ix+B_iy=C_i. Any two lines among the N+2 lines, the above N lines plus the x-axis and y-axis, cross each other at exactly one point.
For each pair 1 \leq i < j \leq N, there is a car at the cross point of the i-th and j-th lines. Even where three or ... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 1 2\n1 -1 0\n3 -1 -2\n1 -3 4",
"3\n1 1 1\n2 -1 2\n-1 2 2",
"7\n1 7 8\n-2 4 9\n3 -8 -5\n9 2 -14\n6 7 5\n-8 -9 3\n3 8 10"
],
"output": [
"-1.000000000000000 -1.000000000000000",
"1.000000000000000 1.000000000000000",
"-1.722222222222222 1.325000000000000"
]
} | {
"input": [
"4\n1 1 2\n1 -1 0\n3 -1 -2\n1 -3 5",
"3\n1 1 1\n2 -1 2\n-1 2 4",
"3\n1 1 1\n2 -1 2\n-1 2 1",
"7\n1 7 8\n-2 4 9\n3 -8 -5\n9 2 -14\n4 7 5\n-8 -9 3\n3 8 10",
"3\n1 1 1\n2 -1 2\n-1 2 0",
"7\n1 7 8\n-2 4 9\n3 -8 -5\n9 2 -14\n4 7 5\n-8 -9 3\n3 5 10",
"4\n2 1 2\n1 -1 0\n2 -1 -2\n2 -3... |
p03743 AtCoder Regular Contest 072 - Alice in linear land | Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is D. When she input a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would shorten the distance between the vehicle... | {
"input": [],
"output": []
} | {
"input": [
"5 9\n4 4 2 3 2\n5\n1 4 2 3 5",
"6 15\n4 3 5 4 2 1\n6\n1 2 3 4 5 6",
"4 10\n3 4 3 3\n2\n4 3"
],
"output": [
"YES\nYES\nYES\nYES\nYES",
"NO\nNO\nYES\nNO\nNO\nYES",
"NO\nYES"
]
} | {
"input": [
"5 9\n4 4 2 3 4\n5\n1 4 2 3 5",
"6 15\n4 3 5 4 2 1\n6\n1 2 3 0 5 6",
"6 15\n4 3 5 4 2 1\n6\n1 2 4 0 5 6",
"6 15\n4 3 5 4 0 1\n6\n1 2 3 4 5 6",
"4 10\n3 2 3 3\n2\n4 3",
"6 15\n4 3 5 4 2 1\n6\n1 3 3 0 5 6",
"6 15\n4 3 5 4 0 1\n6\n2 2 4 0 5 6",
"6 15\n4 3 5 3 0 1\n6\n0 2 4 0 ... |
p03903 CODE FESTIVAL 2016 Elimination Tournament Round 1 (Parallel) - Graph | Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i.
He will play Q rounds of a game using this graph. In the i-th round, two vertices S_i and T_i are specified, and he will choose a subse... | {
"input": [],
"output": []
} | {
"input": [
"4 6\n1 3 5\n4 1 10\n2 4 6\n3 2 2\n3 4 5\n2 1 3\n1\n2 3",
"4 3\n1 2 3\n2 3 4\n3 4 5\n2\n2 3\n1 4"
],
"output": [
"8",
"8\n7"
]
} | {
"input": [
"4 6\n1 3 5\n4 1 10\n2 4 6\n3 2 2\n3 4 5\n2 1 4\n1\n2 3",
"4 6\n1 3 5\n4 1 11\n2 4 6\n3 2 2\n3 4 5\n2 1 4\n1\n2 1",
"4 6\n1 3 5\n4 2 10\n2 4 6\n3 2 2\n3 4 5\n2 1 3\n1\n2 3",
"4 6\n1 3 5\n4 1 10\n2 4 6\n3 2 2\n2 4 8\n2 1 4\n1\n2 3",
"4 6\n1 3 5\n4 2 10\n2 4 3\n3 2 2\n2 4 5\n1 2 3\n1\n2... |
p00009 Prime Number | Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
Input
Input consists of several da... | {
"input": [],
"output": []
} | {
"input": [
"10\n3\n11"
],
"output": [
"4\n2\n5"
]
} | {
"input": [
"10\n3\n5",
"10\n3\n9",
"10\n3\n2",
"10\n6\n2",
"10\n6\n11",
"10\n1\n5",
"10\n1\n2",
"10\n2\n2",
"10\n3\n4",
"10\n6\n3",
"10\n2\n5",
"10\n1\n4",
"10\n2\n4",
"10\n5\n1",
"10\n4\n1",
"10\n1\n1",
"10\n2\n1",
"10\n8\n1",
"10\n16\n1",... |
p00141 Spiral Pattern | I decided to create a program that displays a "round and round pattern". The "round and round pattern" is as follows.
* If the length of one side is n, it is displayed as a character string with n rows and n columns.
* A spiral pattern that rotates clockwise with the lower left corner as the base point.
* The part wit... | {
"input": [],
"output": []
} | {
"input": [
"2\n5\n6"
],
"output": [
"#####\n# #\n# # #\n# # #\n# ###\n\n######\n# #\n# ## #\n# # #\n# # #\n# ####"
]
} | {
"input": [
"2\n5\n5",
"2\n8\n5",
"2\n12\n5",
"2\n12\n3",
"2\n5\n9",
"2\n5\n7",
"2\n8\n9",
"2\n16\n3",
"2\n9\n9",
"2\n10\n7",
"2\n8\n4",
"2\n20\n3",
"2\n9\n8",
"2\n9\n7",
"2\n2\n4",
"2\n20\n4",
"2\n9\n13",
"2\n1\n13",
"2\n2\n2",
"2\n32\n... |
p00274 A Pair of Prizes | Jou and Yae are a good couple. Jou is collecting prizes for capsule toy vending machines (Gachapon), and even when they go out together, when they find Gachapon, they seem to get so hot that they try it several times. Yae was just looking at Jou, who looked happy, but decided to give him a Gachapon prize for his upcomi... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 2\n3\n0 1 1\n1\n1000\n0"
],
"output": [
"3\nNA\n2"
]
} | {
"input": [
"2\n3 0\n3\n0 1 1\n1\n1000\n0",
"2\n3 2\n3\n0 1 1\n1\n0000\n0",
"2\n1 0\n3\n0 1 1\n1\n1000\n0",
"2\n2 0\n3\n0 1 1\n0\n1100\n0",
"2\n1 0\n3\n0 1 1\n0\n1100\n0",
"2\n3 2\n3\n0 0 1\n1\n1000\n0",
"2\n6 4\n3\n0 1 2\n1\n0000\n0",
"2\n0 4\n3\n0 1 2\n1\n0000\n0",
"2\n2 0\n0\n0... |
p00462 Pizza | problem
JOI Pizza sells pizza home delivery along the d-meter-long ring road that runs through the city center.
JOI Pizza has n stores S1, ..., Sn on the loop line. The head office is S1. The distance from S1 to Si when moving the loop line clockwise is set to di meters. D2 , ..., dn is an integer greater than or equ... | {
"input": [],
"output": []
} | {
"input": [
"8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n12\n8\n16\n7\n7\n11\n8\n0"
],
"output": [
"3\n3"
]
} | {
"input": [
"8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n10\n8\n16\n7\n7\n11\n8\n0",
"8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n12\n8\n16\n7\n7\n4\n8\n0",
"8\n3\n2\n3\n1\n4\n6\n20\n4\n4\n14\n8\n16\n7\n7\n11\n8\n0",
"8\n3\n2\n3\n1\n7\n7\n12\n4\n4\n12\n8\n16\n7\n7\n4\n8\n0",
"8\n3\n2\n3\n1\n7\n6\n20\n4\n4\n12\n0\n16\n7\n7... |
p00652 Cutting a Chocolate | Turtle Shi-ta and turtle Be-ko decided to divide a chocolate. The shape of the chocolate is rectangle. The corners of the chocolate are put on (0,0), (w,0), (w,h) and (0,h). The chocolate has lines for cutting. They cut the chocolate only along some of these lines.
The lines are expressed as follows. There are m poi... | {
"input": [],
"output": []
} | {
"input": [
"2 3 10 10 50\n3 3\n6 6\n10 10\n4.0000000000 4.0000000000\n7.0000000000 7.0000000000\n2 3 10 10 70\n3 3\n6 6\n10 10\n4.0000000000 4.0000000000\n7.0000000000 7.0000000000\n2 3 10 10 30\n3 3\n6 6\n10 10\n4.0000000000 4.0000000000\n7.0000000000 7.0000000000\n2 3 10 10 40\n3 3\n6 6\n10 10\n4.0000000000 4... | {
"input": [
"2 3 10 10 50\n3 3\n6 6\n10 10\n4.0000000000 4.0000000000\n7.0000000000 7.0000000000\n2 3 10 10 70\n3 3\n6 6\n10 10\n4.0000000000 4.0000000000\n7.0000000000 7.0000000000\n2 3 10 10 30\n3 3\n6 6\n10 10\n4.0000000000 4.0000000000\n7.0000000000 7.0000000000\n2 3 10 10 40\n3 3\n6 6\n10 10\n4.0000000000 4... |
p00797 Family Tree | A professor of anthropology was interested in people living in isolated islands and their history. He collected their family trees to conduct some anthropological experiment. For the experiment, he needed to process the family trees with a computer. For that purpose he translated them into text files. The following is ... | {
"input": [],
"output": []
} | {
"input": [
"6 5\nJohn\nRobert\nFrank\nAndrew\nNancy\nDavid\nRobert is a child of John.\nRobert is an ancestor of Andrew.\nRobert is a sibling of Nancy.\nNancy is the parent of Frank.\nJohn is a descendant of Andrew.\n2 1\nabc\nxyz\nxyz is a child of abc.\n0 0",
"6 5\nJohn\n Robert\n Frank\n Andrew\n Nancy... | {
"input": [
"6 5\nJohn\nRobert\nFrank\nAndrew\nNancy\nDivad\nRobert is a child of John.\nRobert is an ancestor of Andrew.\nRobert is a sibling of Nancy.\nNancy is the parent of Frank.\nJohn is a descendant of Andrew.\n2 1\nabc\nxyz\nxyz is a child of abc.\n0 0",
"6 5\nJohn\n Robert\n Frank\n Andrew\n Nancy... |
p00928 Automotive Navigation | Example
Input
4 2 1 1
1 1 1 2
2 2 2 1
2 2 1 2
1 1 2 1
9 N
Output
1 1
2 2 | {
"input": [],
"output": []
} | {
"input": [
"4 2 1 1\n1 1 1 2\n2 2 2 1\n2 2 1 2\n1 1 2 1\n9 N"
],
"output": [
"1 1\n2 2"
]
} | {
"input": [
"4 2 1 1\n1 1 1 2\n2 2 2 1\n2 2 1 2\n1 1 2 1\n17 N",
"4 2 1 1\n1 1 1 2\n2 2 2 1\n2 2 1 2\n1 1 2 1\n4 N",
"4 2 1 1\n1 0 1 2\n2 2 2 1\n2 2 1 2\n1 1 2 1\n2 N",
"4 1 1 1\n1 1 1 2\n2 2 2 1\n2 2 1 2\n1 1 2 1\n4 N",
"4 2 1 1\n1 0 1 2\n2 4 2 1\n2 2 1 2\n1 1 2 1\n4 N",
"4 2 1 1\n1 0 1 2\n2... |
p01061 Community Integration | Problem
There are N villages. Each village is numbered from 1 to N. Due to the recent merger boom, several villages have been merged. Two or more merged villages will become one new city, and villages that are not merged with any village will remain villages.
You will be given multiple pieces of information that two ... | {
"input": [],
"output": []
} | {
"input": [
"4 2\n1 4\n2 3",
"5 0",
"10 5\n3 4\n1 2\n9 6\n2 6\n2 9",
"3 1\n1 2",
"3 3\n1 2\n2 3\n3 1",
"3 2\n1 2\n2 3",
"5 4\n1 2\n2 3\n3 4\n4 5"
],
"output": [
"2",
"5",
"2",
"0",
"1",
"1",
"1"
]
} | {
"input": [
"4 0",
"10 5\n3 4\n1 2\n9 6\n3 6\n2 9",
"3 1\n1 3",
"5 3\n1 2\n2 3\n3 1",
"8 4\n1 2\n2 3\n3 4\n4 5",
"7 0",
"13 0",
"26 0",
"8 0",
"16 0",
"9 1\n1 3",
"9 0\n1 3",
"20 5\n3 4\n1 2\n9 6\n2 6\n2 9",
"14 0",
"24 0",
"10 0",
"23 0",
"15 0... |
p01193 First Experience | After spending long long time, you had gotten tired of computer programming. Instead you were inter- ested in electronic construction. As your first work, you built a simple calculator. It can handle positive integers of up to four decimal digits, and perform addition, subtraction and multiplication of numbers. You did... | {
"input": [],
"output": []
} | {
"input": [
"1+2+3+4+5+6+7+8+9+10=\n1000-500-250-125=\n1*2*3*4*5*6=\n5000*5000=\n10-100=\n100*100=\n10000="
],
"output": [
"55\n125\n720\nE\nE\nE\nE"
]
} | {
"input": [
"1+2+3+4+5+6+7+8+9+10=\n1000-500-250-125=\n1*2*3*4*5*6=\n0500*5000=\n10-100=\n100*100=\n10000=",
"++213+4+5+6+7+8+9+10=\n1000-500-250-125=\n1*2*3*4*5*6=\n0500*5000=\n10-100=\n100*100=\n10000=",
"1+2+3+4+5+6+7+8+9+10=\n2000-500-250-125=\n1*2*3*4*5*6=\n5000*5000=\n10-100=\n100*100=\n10000=",
... |
p01331 Warp Hall | In 20XX, an efficient material transfer method was established for distant places, and human beings' advance into space was accelerated more and more. This transfer method was innovative in that, in principle, larger substances could be transferred when trying to transfer the substance farther. The details of the trans... | {
"input": [],
"output": []
} | {
"input": [
"1 1 0",
"5 5 3\n4 4 5 5\n2 2 3 3\n3 3 4 4",
"1 4 1\n1 2 1 3",
"4 4 1\n2 2 3 3",
"4 4 1\n2 2 3 3\n1 4 1\n1 2 1 3\n5 5 2\n2 2 3 4\n3 3 5 3\n5 5 3\n4 4 5 5\n2 2 3 3\n3 3 4 4\n100000 100000 1\n2 2 99999 99999\n1 1 0\n0 0 0",
"100000 100000 1\n2 2 99999 99999",
"5 5 2\n2 2 3 4\n3 ... | {
"input": [
"5 5 3\n4 4 5 5\n3 2 3 3\n3 3 4 4",
"1 4 1\n1 2 1 2",
"4 4 1\n2 2 3 0",
"4 4 1\n2 2 3 3\n2 4 1\n1 2 1 3\n5 5 2\n2 2 3 4\n3 3 5 3\n5 5 3\n4 4 5 5\n2 2 3 3\n3 3 4 4\n100000 100000 1\n2 2 99999 99999\n1 1 0\n0 0 0",
"5 6 2\n2 2 3 4\n3 3 5 3",
"4 5 3\n4 4 5 5\n3 2 3 3\n3 3 4 4",
"... |
p01498 King Slime | There is a grid of size W × H surrounded by walls. Some cells in the grid are occupied by slimes. The slimes want to unite with each other and become a "King Slime".
In each move, a slime can move to east, west, south and north direction until it enters a cell occupied by another slime or hit the surrounding wall. If ... | {
"input": [],
"output": []
} | {
"input": [
"2 3 3\n2 2\n3 3",
"4 3 3\n1 1\n1 3\n3 1\n3 3",
"2 4 4\n2 2\n3 3",
"2 4 4\n2 2\n2 3"
],
"output": [
"2",
"3",
"3",
"1"
]
} | {
"input": [
"2 3 3\n2 4\n3 3",
"4 3 3\n1 1\n0 3\n3 1\n3 3",
"2 4 6\n2 2\n2 3",
"1 4 4\n2 2\n3 3",
"4 3 3\n1 1\n1 3\n6 1\n3 2",
"2 4 6\n2 2\n0 3",
"4 3 3\n1 1\n1 3\n3 1\n3 6",
"4 6 3\n1 1\n0 3\n3 1\n3 3",
"2 4 3\n2 2\n2 3",
"4 3 3\n1 1\n1 3\n3 1\n3 2",
"1 4 4\n2 2\n4 3",
... |
p01669 Iyasugigappa | C - Iyasugigappa
Problem Statement
Three animals Frog, Kappa (Water Imp) and Weasel are playing a card game.
In this game, players make use of three kinds of items: a guillotine, twelve noble cards and six action cards. Some integer value is written on the face of each noble card and each action card. Before stating... | {
"input": [],
"output": []
} | {
"input": [
"3 2 1 3 2 1 3 2 1 3 2 1\n1 1\n1 1\n1 1"
],
"output": [
"4 8 12"
]
} | {
"input": [
"3 2 1 3 2 1 3 2 1 1 2 1\n1 1\n1 1\n1 1",
"3 2 1 3 2 1 3 2 1 2 2 1\n1 1\n1 1\n1 1",
"3 2 1 5 2 1 3 2 1 3 2 1\n1 1\n1 1\n1 1",
"3 2 1 5 2 0 3 2 1 3 2 1\n1 1\n1 1\n1 1",
"3 2 1 5 2 0 3 2 1 2 2 1\n1 1\n1 1\n1 1",
"3 2 1 5 2 0 3 2 1 2 2 2\n1 1\n1 1\n1 1",
"3 2 1 3 2 1 3 2 1 3 2 0\... |
p01811 ABC Gene | ABC Gene
There is a gene sequence represented by the string `ABC`. You can rewrite this gene sequence by performing the following operations several times.
* Choose one of the letters `A`,` B`, `C`. Let this be x. Replace all x in the gene sequence with `ABC` at the same time.
Given a string S consisting only of `... | {
"input": [],
"output": []
} | {
"input": [
"ABC"
],
"output": [
"Yes"
]
} | {
"input": [
"BAC",
"ACB",
"CAB",
"CBA",
"ACA",
"BCA",
"BAB",
"ABA",
"BAA",
"AAB",
"BBA",
"AAA",
"ABB",
"BBB",
"CBB",
"CCB",
"BCC",
"CBC",
"ACC",
"CAC",
"BBC",
"CCA",
"CCC",
"CAA",
"BCB",
"AAC",
"ACB",
"BBC... |
p01946 Slimming Plan | Chokudai loves eating so much. However, his doctor Akensho told him that he was overweight, so he finally decided to lose his weight.
Chokudai made a slimming plan of a $D$-day cycle. It is represented by $D$ integers $w_0, ..., w_{D-1}$. His weight is $S$ on the 0-th day of the plan and he aims to reduce it to $T$ ($... | {
"input": [],
"output": []
} | {
"input": [
"100000 1 1\n-1",
"65 60 3\n-2 3 -4",
"60 59 1\n-123",
"65 60 3\n-2 10 -3"
],
"output": [
"99999",
"4",
"1",
"-1"
]
} | {
"input": [
"65 1 3\n-2 3 -4",
"60 59 1\n-68",
"120 60 3\n-2 10 -3",
"48 1 3\n-2 3 -4",
"48 1 5\n-2 3 -4",
"48 1 5\n-2 3 -3",
"48 1 10\n-2 0 -3",
"48 1 14\n-2 0 -3",
"48 1 14\n-2 0 -5",
"48 1 14\n-2 0 -8",
"48 1 14\n-2 -1 -8",
"48 0 14\n-4 0 -8",
"87 0 14\n-4 0 -8"... |
p02095 Colorful Tree | H: Colorful Tree
Story
Yamiuchi (assassination) is a traditional event that is held annually in JAG summer camp. Every team displays a decorated tree in the dark and all teams' trees are compared from the point of view of their colorfulness. In this competition, it is allowed to cut the other teams’ tree to reduce it... | {
"input": [],
"output": []
} | {
"input": [
"2 10\n1 2\n1 9\n8 7"
],
"output": [
"2\n1"
]
} | {
"input": [
"2 10\n1 2\n1 9\n6 7",
"2 10\n2 2\n1 9\n10 7",
"1 10\n1 2\n1 9\n8 7",
"2 10\n1 2\n1 9\n10 7",
"2 20\n2 2\n1 9\n10 7",
"2 10\n3 2\n1 9\n10 7",
"1 10\n1 2\n0 9\n8 7",
"2 11\n2 2\n1 9\n10 7",
"2 13\n3 2\n1 9\n10 7",
"1 10\n1 0\n0 9\n8 7",
"2 14\n2 2\n1 9\n10 7",
... |
p02233 Fibonacci Number | Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:
\begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + fib(n - 2) & \\\ \end{array} \right. \end{equation*}
Constraints
... | {
"input": [],
"output": []
} | {
"input": [
"3"
],
"output": [
"3"
]
} | {
"input": [
"1",
"2",
"4",
"8",
"6",
"15",
"7",
"24",
"14",
"5",
"13",
"11",
"22",
"9",
"29",
"12",
"10",
"41",
"16",
"30",
"21",
"28",
"17",
"34",
"18",
"38",
"31",
"44",
"36",
"32",
"33",
... |
p02379 Distance | Write a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2).
Input
Four real numbers x1, y1, x2 and y2 are given in a line.
Output
Print the distance in real number. The output should not contain an absolute error greater than 10-4.
Example
Input
0 0 1 1
Output
1.41421356 | {
"input": [],
"output": []
} | {
"input": [
"0 0 1 1"
],
"output": [
"1.41421356"
]
} | {
"input": [
"0 0 1 2",
"0 0 2 2",
"-1 0 2 2",
"0 0 4 2",
"0 1 4 2",
"0 1 1 0",
"-1 1 1 1",
"0 1 1 1",
"0 1 0 1",
"0 2 -1 -1",
"0 3 -2 -2",
"0 5 0 0",
"0 8 0 0",
"0 8 1 0",
"1 8 1 -1",
"2 8 1 -1",
"2 8 0 -1",
"2 6 0 -1",
"0 6 0 -1",
"0 6 ... |
cd202 | Brachiosaurus is trying to become a detective by writing words in codes. It manipulates each word in a sentence by putting the letter 'z' after each vowel, followed by that very vowel.
Eg- "belina" translates into "bezelizinaza" and "zazhiba" translates into "zazazhizibaza". A team of secret agents want to decode the ... | {
"input": [],
"output": []
} | {
"input": [
"razat geze hozotazamnaza ozoraza bezehizisaza"
],
"output": [
"rat ge hotamna ora behisa\n"
]
} | {
"input": [
"razat geye hozotazamnaza ozoraza bezehizisaza",
"razat geye hozotazamnaza ozoraza azasizihezeb",
"rayat eyeg hozotazamnaza ozoraza azasizihezeb",
"rayat eyeg hozotazamnaza ozoraza bezehizisaza",
"razat zege hozotazamnaza ozoraza bezehizisaza",
"razat geye hozotazamnaza ozoqaza be... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.