name stringlengths 2 112 | description stringlengths 29 13k | private_tests dict | public_tests dict | generated_tests dict |
|---|---|---|---|---|
p00788 Rational Irrationals | Rational numbers are numbers represented by ratios of two integers. For a prime number p, one of the elementary theorems in the number theory is that there is no rational number equal to √p. Such numbers are called irrational numbers. It is also known that there are rational numbers arbitrarily close to √p
Now, given ... | {
"input": [],
"output": []
} | {
"input": [
"2 5\n3 10\n5 100\n0 0"
],
"output": [
"3/2 4/3\n7/4 5/3\n85/38 38/17"
]
} | {
"input": [
"2 5\n3 10\n5 110\n0 0",
"3 5\n3 10\n5 100\n0 0",
"3 5\n3 17\n5 101\n0 0",
"3 4\n3 8\n5 100\n0 0",
"3 5\n6 10\n5 100\n0 0",
"3 4\n3 8\n10 100\n0 0",
"2 3\n3 10\n5 101\n0 0",
"2 5\n3 10\n10 111\n0 0",
"6 5\n6 10\n5 100\n0 0",
"3 4\n3 3\n10 100\n0 0",
"3 5\n3 20\... |
p00920 Longest Chain | Let us compare two triples a = (xa, ya, za) and b = (xb, yb, zb) by a partial order ∠ defined as follows.
a ∠ b ⇔ xa < xb and ya < yb and za < zb
Your mission is to find, in the given set of triples, the longest ascending series a1 ∠ a2 ∠ ... ∠ ak.
Input
The input is a sequence of datasets, each specifying a set... | {
"input": [],
"output": []
} | {
"input": [
"6 0 1 1\n0 0 0\n0 2 2\n1 1 1\n2 0 2\n2 2 0\n2 2 2\n5 0 1 1\n0 0 0\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n10 0 1 1\n3 0 0\n2 1 0\n2 0 1\n1 2 0\n1 1 1\n1 0 2\n0 3 0\n0 2 1\n0 1 2\n0 0 3\n0 10 1 1\n0 0 0 0"
],
"output": [
"3\n5\n1\n3"
]
} | {
"input": [
"6 0 1 1\n0 0 0\n0 2 2\n1 1 1\n2 0 2\n2 2 0\n1 2 2\n5 0 1 1\n0 0 0\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n10 0 1 1\n3 0 0\n2 1 0\n2 0 1\n1 2 0\n1 1 1\n1 0 2\n0 3 0\n0 2 1\n0 1 2\n0 0 3\n0 10 1 1\n0 0 0 0",
"6 0 1 1\n0 0 0\n0 2 2\n1 1 1\n2 0 2\n2 2 0\n1 2 2\n5 0 1 1\n0 0 0\n1 1 1\n2 0 2\n3 3 3\n4 4 4\n10 0 ... |
p01053 Lucky Number | Problem
There are numbers from 0 to N-1. I would like to select the lucky number for M + 1 days by the following methods. Randomly decide the lucky number on the first day. If the lucky number after i days is A and the lucky number after (i + 1) days is B,
B = (A + j)% N
(However, j is all integers where 0 ≤ j <N an... | {
"input": [],
"output": []
} | {
"input": [
"6 3 1 10\n0 1 0\n0 2 0\n0 3 0\n1 3 3\n0 2 1\n2 2 2\n2 3 2\n2 2 0\n1 1 1\n2 2 1"
],
"output": [
"1\n3\n9\n9\n0\n3\n9\n3\n1\n0"
]
} | {
"input": [
"6 3 1 10\n0 1 0\n-1 2 0\n0 3 0\n1 3 3\n0 2 1\n2 2 2\n2 3 2\n2 2 0\n1 1 1\n2 2 1",
"6 3 1 10\n0 1 0\n-1 2 0\n0 3 0\n1 3 3\n0 2 1\n2 1 2\n2 3 2\n2 2 0\n1 1 1\n2 2 1",
"6 3 1 10\n0 1 0\n-1 2 0\n0 3 0\n1 2 3\n0 2 1\n2 1 2\n2 3 2\n2 2 0\n1 1 1\n2 2 1",
"6 3 1 10\n0 1 0\n-1 2 0\n0 3 0\n1 2 3\n... |
p01185 Hide-and-seek | Hide-and-seek is a children’s game. Players hide here and there, and one player called it tries to find all the other players.
Now you played it and found all the players, so it’s turn to hide from it. Since you have got tired of running around for finding players, you don’t want to play it again. So you are going to ... | {
"input": [],
"output": []
} | {
"input": [
"2\n0 0 3 3\n0 4 3 1\n1 1\n0"
],
"output": [
"4.243"
]
} | {
"input": [
"2\n0 0 3 3\n0 5 3 1\n1 1\n0",
"2\n0 0 3 3\n1 4 3 1\n1 1\n0",
"2\n0 0 3 3\n1 4 3 0\n1 1\n0",
"2\n0 0 3 3\n1 4 5 0\n1 1\n0",
"2\n0 0 3 3\n1 4 6 0\n1 1\n0",
"2\n0 0 3 3\n1 8 3 0\n1 1\n0",
"2\n0 0 3 3\n0 4 6 0\n1 1\n0",
"2\n0 0 3 3\n1 5 3 0\n1 1\n0",
"2\n0 0 3 3\n1 1 5 0\... |
p01322 Lottery Checker | You have successfully completed your studies and are preparing to move from near Komaba to near Hongo. As I was organizing my house, I found a lot of lottery tickets I bought last year. After confirming the exchange deadline, I have to cash in by tomorrow, but it is troublesome to go to the lottery counter for a small ... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n*******1 100\n******22 1000\n11111112 1000000\n01203291\n02382022\n11111111\n10 10\n****3228 149416\n****3992 198635\n****4286 77783\n****4843 225244\n***49835 231046\n***59393 379996\n*5763748 437345\n*6726222 58054\n*8117882 16375\n*9244339 537727\n77885716\n96726222\n26971031\n66652868\n8959... | {
"input": [
"3 3\n*******1 100\n******22 1000\n11111112 1000100\n01203291\n02382022\n11111111",
"10 10\n****3228 149416\n****3992 198635\n****4286 77783\n****4843 225244\n***49835 231046\n***59393 379996\n*5763748 437345\n*6726222 58054\n*8117882 16375\n*9244339 537727\n30548855\n96726222\n26971031\n66652868... |
p01490 HullMarathon | Example
Input
4
5
8
58
85
Output
2970.000000000 | {
"input": [],
"output": []
} | {
"input": [
"4\n5\n8\n58\n85"
],
"output": [
"2970.000000000"
]
} | {
"input": [
"4\n5\n8\n58\n152",
"4\n5\n8\n55\n152",
"4\n5\n20\n55\n152",
"4\n5\n15\n58\n85",
"4\n5\n8\n58\n171",
"4\n5\n9\n55\n152",
"4\n2\n11\n55\n152",
"4\n5\n17\n55\n152",
"4\n5\n15\n58\n7",
"4\n5\n10\n58\n171",
"4\n5\n9\n27\n152",
"4\n5\n1\n55\n152",
"4\n5\n7\n... |
p01652 Ancient Commemorative Monolith | Problem Statement
One day in a forest, Alice found an old monolith.
<image>
She investigated the monolith, and found this was a sentence written in an old language. A sentence consists of glyphs and rectangles which surrounds them. For the above example, there are following glyphs.
<image>
<image>
Notice that... | {
"input": [],
"output": []
} | {
"input": [
"2 1\na 11 9\n****.....\n.*.*.....\n.*.*.....\n.*..*....\n.**..*...\n..**..*..\n..*.*....\n..**.*.*.\n..*..*.*.\n..*****.*\n******.**\nb 10 6\n....*.\n....*.\n....*.\n....*.\n....*.\n....*.\n....*.\n....*.\n.**..*\n*****.\n19 55\n*******************************************************\n*................ | {
"input": [
"2 1\na 11 9\n****.....\n.*.*.....\n.*.*.....\n.*..*....\n.**..*...\n..**..*..\n..*.*....\n..**.*.*.\n..*..*.*.\n..*****.*\n******.**\nb 10 6\n....*.\n....*.\n....*.\n....*.\n....*.\n....*.\n....*.\n....*.\n.**..*\n*****.\n19 55\n*******************************************************\n*................ |
p01803 Airport Codes | Airport Codes
Airport code
In the Kingdom of JAG, airport codes are assigned to each domestic airport for identification.
Airport codes are assigned according to the following rules based on the name of the airport in lowercase English alphabet:
1. Extract the first letter of the name and the letter immediately aft... | {
"input": [],
"output": []
} | {
"input": [
"3\nhaneda\noookayama\ntsu\n2\nazusa\nazishirabe\n2\nsnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\nhawaii\n0"
],
"output": [
"1\n4\n-1\n3"
]
} | {
"input": [
"3\nhaneda\noookayama\nssu\n2\nazusa\nazishirabe\n2\nsnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\nhawaii\n0",
"3\nhaneda\noookayama\ntsv\n2\nazusa\nazishirabe\n2\nrnuke\nsnake\n4\nhaneda\nhonda\nhanamaki\nhawbii\n0",
"3\nhaneda\noookayama\ntsv\n2\nazvsa\nazishirabe\n2\nrnuke\nsnake\n4\nhaneda\nh... |
p01938 A-Z- | A: A-Z-
problem
There is a circular board of 26 squares, each square with one capital letter of the alphabet written clockwise in alphabetical order. That is, the clockwise side of the'A'square is the'B' square, the next side of the'B'square is the'C'square, and ..., the clockwise side of the'Z'square is the'A'. It's... | {
"input": [],
"output": []
} | {
"input": [
"AIZU"
],
"output": [
"2"
]
} | {
"input": [
"AIZV",
"W\\AG",
"[VIA",
"BEW]",
"VZIA",
"V[IA",
"W[IA",
"AI[W",
"AH[W",
"HA[W",
"HA[V",
"GA[V",
"GA\\V",
"GA\\W",
"W\\BG",
"W\\BF",
"FB\\W",
"GB\\W",
"WFB\\",
"WF\\B",
"B\\FW",
"A\\FW",
"A[FW",
"AIZT",
"A... |
p02077 Bombing | Problem Statement
JAG land is a country, which is represented as an $M \times M$ grid. Its top-left cell is $(1, 1)$ and its bottom-right cell is $(M, M)$.
Suddenly, a bomber invaded JAG land and dropped bombs to the country. Its bombing pattern is always fixed and represented by an $N \times N$ grid. Each symbol in ... | {
"input": [],
"output": []
} | {
"input": [
""
],
"output": [
""
]
} | {
"input": [],
"output": []
} |
p02219 Wizard Tower | Problem statement
The spellbook you have contains $ N $ of spells.
Magic is numbered from $ 1 $ to $ N $, and the cost of magic $ i (1 \ le i \ le N) $ is initially an integer $ A_i $.
Your goal is to cast all the spells in the spellbook $ 1 $ each.
You can eat $ K $ of cookies before you start casting magic. It do... | {
"input": [],
"output": []
} | {
"input": [
"2 4 0\n2 4"
],
"output": [
"3"
]
} | {
"input": [
"2 4 1\n2 4",
"2 4 1\n2 1",
"7 4 0\n3 2",
"2 4 1\n1 1",
"2 3 1\n1 1",
"2 3 1\n2 1",
"0 3 1\n2 1",
"0 5 1\n2 1",
"0 4 1\n2 1",
"0 8 1\n2 1",
"0 1 1\n2 1",
"0 1 1\n0 1",
"0 1 1\n0 2",
"0 1 1\n0 3",
"0 1 1\n1 3",
"2 8 0\n2 4",
"1 4 1\n2 1",... |
p02371 Diameter of a Tree | Diameter of a Tree
Given a tree T with non-negative weight, find the diameter of the tree.
The diameter of a tree is the maximum distance between two nodes in a tree.
Constraints
* 1 ≤ n ≤ 100,000
* 0 ≤ wi ≤ 1,000
Input
n
s1 t1 w1
s2 t2 w2
:
sn-1 tn-1 wn-1
The first line consists of an integer n which repre... | {
"input": [],
"output": []
} | {
"input": [
"4\n0 1 1\n1 2 2\n2 3 4",
"4\n0 1 2\n1 2 1\n1 3 3"
],
"output": [
"7",
"5"
]
} | {
"input": [
"4\n0 1 1\n1 3 2\n2 3 4",
"4\n0 1 1\n1 2 1\n1 3 3",
"4\n0 1 2\n1 3 2\n2 3 4",
"4\n0 1 1\n1 3 1\n2 3 4",
"4\n0 1 1\n1 3 0\n2 3 4",
"4\n0 1 1\n1 3 1\n2 3 0",
"4\n0 1 0\n2 2 2\n2 3 4",
"4\n0 1 2\n1 3 1\n2 3 0",
"4\n0 1 1\n2 3 1\n2 3 6",
"4\n0 1 1\n0 2 8\n1 3 2",
"... |
bintreeq | Let's consider a rooted binary tree with the following properties:
The number of nodes and edges in the tree is infinite
The tree root is labeled by 1
A node labeled by v has two children: 2 × v (the left son of v) and 2 × v + 1 (the right son of v)
Here is an image of the first several tree layers of such a tree:
L... | {
"input": [],
"output": []
} | {
"input": [
"3\n11 9 11\n10 2 2\n8 1 8"
],
"output": [
"2\n10\n1"
]
} | {
"input": [
"3\n11 9 11\n10 4 2\n8 1 8",
"3\n11 9 11\n10 4 2\n8 1 10",
"3\n9 9 11\n10 4 2\n6 1 10",
"3\n9 15 11\n10 4 2\n6 1 10",
"3\n9 15 11\n10 4 2\n10 1 10",
"3\n9 15 9\n10 4 2\n10 1 3",
"3\n9 15 9\n10 2 2\n10 1 3",
"3\n9 15 9\n10 2 0\n10 1 3",
"3\n9 15 9\n10 2 0\n10 2 0",
... |
codecrck | Wet Shark once had 2 sequences:
{a_n}= {a_1, a_2, a_3, ... , a_(10^9)}
{b_n} = {b_1, b_2, b_3, ... , b_(10^9)}
However, he only kept one element from each sequence. Luckily, both the elements that Wet Shark kept have the same index in Wet Shark's sequences: that is, he took a_i and b_i for some 1 ≤ i ≤ 10^9.
Righ... | {
"input": [],
"output": []
} | {
"input": [
"1 1 5\n4 5"
],
"output": [
"0.28125\n"
]
} | {
"input": [
"1 1 5\n4 3",
"1 0 5\n4 3",
"1 0 5\n4 5",
"1 2 5\n4 5",
"1 2 5\n2 5",
"1 2 6\n2 5",
"0 2 6\n2 5",
"0 2 6\n4 5",
"0 2 6\n4 7",
"0 2 6\n4 10",
"0 2 0\n4 10",
"0 2 1\n4 10",
"0 4 1\n4 10",
"0 4 2\n4 10",
"0 4 2\n4 4",
"0 4 2\n8 4",
"-1 4 2\... |
fsqrt | In olden days finding square roots seemed to be difficult but nowadays it can be easily done using in-built functions available across many languages
.
Assume that you happen to hear the above words and you want to give a try in finding the square root of any given integer using in-built functions. So here's your cha... | {
"input": [],
"output": []
} | {
"input": [
"3\n10\n5\n10000"
],
"output": [
"3\n2\n100\n"
]
} | {
"input": [
"3\n10\n5\n10010",
"3\n1\n5\n10000",
"3\n1\n11\n10000",
"3\n1\n2\n10000",
"3\n10\n2\n10100",
"3\n1\n12\n11100",
"3\n1\n17\n10000",
"3\n2\n6\n11100",
"3\n16\n2\n10000",
"3\n19\n5\n10001",
"3\n19\n5\n00001",
"3\n4\n4\n10001",
"3\n2\n1\n11101",
"3\n11\... |
luckpal | Chef Palin, as his name suggests, is always very interested in palindromic strings. Recently, he made a pretty interesting discovery on palindromes and that made him feel really Lucky. He came across something known as Lucky Palindromes. He defines a string as being a lucky palindrome if it is a palindrome containing t... | {
"input": [],
"output": []
} | {
"input": [
"3\nlaubcdkey\nluckycodechef\naaaaaaaa"
],
"output": [
"luckykcul 8\nluckycocykcul 6\nunlucky"
]
} | {
"input": [
"3\nlaubcdkey\nlubkycodechef\naaaaaaaa",
"3\nlaubcdkey\nyubklcodechef\naaaaaaaa",
"3\nlatbcdkfy\nfeicedocljbux\naaaaaaba",
"3\nytkdadfbl\ntobjlcedechwf\naabaaaba",
"3\nytkdadfbl\ntobjlcfdechwf\naabaaaba",
"3\nytkdadlbf\ntobjlcfdechwf\naabaaaca",
"3\nytjdadlbf\nfwmceefchjtnb\nb... |
prob | Chef, Artem and Eugene are the best of friends and teammates. Recently, they won a lot of money at the Are You Feeling Lucky Cup. Having put their fortune to test and emerging victorious, they are now busy enjoying their wealth. Eugene wanted to drink it all away. Chef and Artem had better plans.
Chef and Artem decide... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 2 1 2\n2 3 4 1"
],
"output": [
"0.5\n0.4\n"
]
} | {
"input": [
"2\n2 2 1 4\n2 3 4 1",
"2\n2 2 1 7\n2 2 2 1",
"2\n2 3 0 7\n2 2 1 0",
"2\n2 3 -1 7\n1 2 1 1",
"2\n2 3 -1 7\n3 2 1 1",
"2\n2 1 -1 7\n3 2 0 0",
"2\n2 0 -1 11\n3 2 -1 0",
"2\n2 -1 -1 11\n3 2 -1 0",
"2\n2 0 1 2\n2 3 4 1",
"2\n2 1 1 4\n2 3 2 1",
"2\n2 2 1 7\n3 2 2 1"... |
tcfst07 | Consider a sequence of non- negative integers b(1), b(2) … , b(n) of length n. The given sequence is called a winning sequence if and only if there exists integers p and q between 1 and n (both inclusive) such that a(p) xor a(p+1) xor a(p+2) …. xor a(q) = 0. The xor operation is the bitwise xor operation between two in... | {
"input": [],
"output": []
} | {
"input": [
"3 2"
],
"output": [
"6"
]
} | {
"input": [],
"output": []
} |
1490_A. Dense Array | Polycarp calls an array dense if the greater of any two adjacent elements is not more than twice bigger than the smaller. More formally, for any i (1 ≤ i ≤ n-1), this condition must be satisfied: $$$(max(a[i], a[i+1]))/(min(a[i], a[i+1])) ≤ 2$$$
For example, the arrays [1, 2, 3, 4, 3], [1, 1, 1] and [5, 10] are dense.... | {
"input": [],
"output": []
} | {
"input": [
"6\n4\n4 2 10 1\n2\n1 3\n2\n6 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 31 25 50 30 20 34 46 42 16 15 16\n"
],
"output": [
"\n5\n1\n2\n1\n0\n3\n"
]
} | {
"input": [
"6\n4\n4 2 10 1\n2\n1 3\n2\n6 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 27 25 50 30 20 34 46 42 16 15 16\n",
"6\n4\n4 2 10 1\n2\n1 3\n2\n6 1\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 27 25 50 30 20 34 46 42 16 3 16\n",
"6\n4\n4 2 10 1\n2\n1 3\n2\n6 2\n3\n1 4 2\n5\n1 2 3 4 3\n12\n4 31 25 50 30 20 34 46 42 16 15 1... |
188_A. Hexagonal Numbers | Hexagonal numbers are figurate numbers which can be calculated using the formula hn = 2n2 - n. You are given n; calculate n-th hexagonal number.
Input
The only line of input contains an integer n (1 ≤ n ≤ 100).
Output
Output the n-th hexagonal number.
Examples
Input
3
Output
15
Input
6
Output
66 | {
"input": [],
"output": []
} | {
"input": [
"3\n",
"6\n"
],
"output": [
"15\n",
"66\n"
]
} | {
"input": [],
"output": []
} |
661_H. Rotate Matrix | You are given a square matrix of integer numbers. Rotate it 90 degrees clockwise (see examples for clarification of rotation).
Input
The input consists of n lines (1 ≤ n ≤ 10, n is not given explicitly). Each of the lines contains n space-separated integers; j-th integer in i-th line corresponds to matrix element mij... | {
"input": [],
"output": []
} | {
"input": [
"1 2 3\n4 5 6\n7 8 9\n",
"1 2 3 4\n5 6 7 8\n9 10 11 12\n13 14 15 16\n"
],
"output": [
"7 4 1\n8 5 2\n9 6 3\n",
"13 9 5 1\n14 10 6 2\n15 11 7 3\n16 12 8 4\n"
]
} | {
"input": [],
"output": []
} |
aniruddha-and-hackerearth | Aniruddha loves to code on HackerEarth. There are some type of problems which he likes the most.
Problems are tagged with non empty strings containing only 'H' or 'E' or both. But he likes the problems tagged with strings containing no consecutive E's. Given an integer N, find maximum number of problems Aniruddha may l... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n3\n\nSAMPLE"
],
"output": [
"5\n10\n"
]
} | {
"input": [
"2\n2\n4\n\nSAMPLE",
"2\n2\n8\n\nSAMPLE",
"2\n2\n3\n\nSMAPLE",
"2\n4\n8\n\nSAMPLE",
"2\n3\n8\n\nASMOLE",
"2\n2\n2\n\nSMAPLE",
"2\n2\n7\n\nSAMELP",
"2\n5\n8\n\nSAMPLE",
"2\n3\n7\n\nSAMELP",
"2\n5\n12\n\nSAMPLE",
"2\n5\n15\n\nASMOLE",
"2\n3\n6\n\nSAMELP",
... |
difficult-characters | Yesterday while Omar was trying to learn English, he saw that there are letters repeated many times in words while some other letters repeated only few times or not repeated at all!
Of course anyone can memorize the letters (repeated many times) better than the letters repeated few times, so Omar will concatenate al... | {
"input": [],
"output": []
} | {
"input": [
"1\noomar\n\nSAMPLE"
],
"output": [
"z y x w v u t s q p n l k j i h g f e d c b r m a o \n"
]
} | {
"input": [
"1\nonmar\n\nSAMPLE",
"1\nonlar\n\nSAMPLE",
"1\narlmo\n\nTAMPLE",
"1\narmmo\n\nULAPMF",
"1\naqmmo\n\nULAPMF",
"1\naqmmn\n\nUFAPML",
"1\naqmmm\n\nLMFAPU",
"1\nlamrn\n\nMKNE@R",
"1\nnsmal\n\nLKNE@R",
"1\nqlmma\n\nLMF@OU",
"1\nqkmma\n\nLMF@OU",
"1\nnmmas\n\nLK... |
get-the-1 | Katoch, a notorious boy, is always keen about getting number 1. Given a number, he squares every digit of the number and adds to the result. He repeats the process until he gets a 1 digit number. Suppose he is given a number 82, he squares 8 & 2 individually and then add the result to make it 68. Then he continues with... | {
"input": [],
"output": []
} | {
"input": [
"3\n82 \n1\n67\n\nSAMPLE"
],
"output": [
"Case #1:YES\nCase #2:YES\nCase #3:NO\n"
]
} | {
"input": [
"3\n153 \n1\n67\n\nSAMPLE",
"3\n153 \n2\n67\n\nELPMAS",
"3\n44 \n1\n67\n\nSAMPLE",
"3\n36 \n1\n32\n\nFLOMAS",
"3\n244 \n2\n44\n\nELPMAS",
"3\n13 \n2\n3\n\nSANPLF",
"3\n23 \n12\n1\n\nSOLMAE",
"3\n23 \n10\n1\n\nSOMMAE",
"3\n153 \n1\n67\n\nELPMAS",
"3\n153 \n2\n67\n\n... |
lets-count-3 | While Omar was studying for Math lectures, he found the following problem.
Given 3 Integers N_1, N_2, N_3, count the number of common divisors which divide all of them.
Can you please help Omar in solving this problem, because he usually sleeps in lectures.
Input:
Given an integer T, which indicates the number o... | {
"input": [],
"output": []
} | {
"input": [
"1\n2 4 6\n\nSAMPLE"
],
"output": [
"2"
]
} | {
"input": [
"1\n2 6 6\n\nSAMPLE",
"1\n2 8 5\n\nDAMPLS",
"1\n4 8 8\n\nDAMPLS",
"1\n6 18 6\n\nSLLQBE",
"1\n2 10 6\n\nSAMPLE",
"1\n2 10 6\n\nSAMPLD",
"1\n2 8 6\n\nSAMPLD",
"1\n2 8 6\n\nDAMPLS",
"1\n2 8 10\n\nDAMPLS",
"1\n2 4 9\n\nSAMPLE",
"1\n2 3 6\n\nSAMPLE",
"1\n2 10 6\... |
monk-in-the-magical-land | Monk visits a magical place, Makizam. He is greeted by his old friend, Wiz. Wiz happy to see his old friend, gives him a puzzle.
He takes him to a room with N keys placed on the floor, the i'th key is of type Xi. The keys are followed by M chests of treasures, the i'th chest is of type Ci.
These chests give out gems ... | {
"input": [],
"output": []
} | {
"input": [
"2\n2 4 1 \n2 3\n5 3 10 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n1 2 5 7\n\nSAMPLE"
],
"output": [
"12\n14"
]
} | {
"input": [
"2\n2 4 1 \n2 3\n5 3 10 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n0 2 5 7\n\nSAMPLE",
"2\n2 4 1 \n2 3\n5 3 7 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n0 2 5 7\n\nSAMPLE",
"2\n2 4 1 \n2 3\n5 3 7 2\n1 2 5 7\n3 4 2\n2 3 5\n5 3 10 2\n0 2 2 7\n\nSAMPLE",
"2\n2 4 1 \n2 3\n5 3 12 2\n1 2 5 2\n3 4 2\n2 3 5\n5... |
roy-and-sweets | Its Diwali time and Little Roy's family is having a lot of guests. Guests come in families. Each guest family has M members. Roy's task is to serve sweets to them. Roy has N different sweets and each sweet has some specific sweetness level S and quantity Q.
Each guest family will give R rupees (as a token of gratitude... | {
"input": [],
"output": []
} | {
"input": [
"5\n5 8\n3 6\n10 7\n4 6\n2 5\n2\n5\n8\n\nSAMPLE"
],
"output": [
"100"
]
} | {
"input": [],
"output": []
} |
p02607 AIsing Programming Contest 2020 - An Odd Problem | We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.
How many squares i satisfy both of the following conditions?
* The assigned number, i, is odd.
* The written integer is odd.
Constraints
* All values in input are integers.
* ... | {
"input": [],
"output": []
} | {
"input": [
"15\n13 76 46 15 50 98 93 77 31 43 84 90 6 24 14",
"5\n1 3 4 5 7"
],
"output": [
"3",
"2"
]
} | {
"input": [
"15\n13 76 46 15 50 98 93 77 31 43 44 90 6 24 14",
"5\n1 5 4 5 7",
"5\n0 4 4 5 7",
"15\n15 5 71 15 50 98 93 87 31 43 44 11 6 24 14",
"15\n15 5 71 15 87 98 135 87 0 60 44 11 6 14 19",
"15\n1 10 109 15 87 98 29 161 0 60 44 11 9 14 19",
"15\n1 3 109 15 87 98 29 161 1 60 9 11 9 14... |
p02738 AtCoder Grand Contest 043 - Merge Triplets | Given is a positive integer N. Find the number of permutations (P_1,P_2,\cdots,P_{3N}) of (1,2,\cdots,3N) that can be generated through the procedure below. This number can be enormous, so print it modulo a prime number M.
* Make N sequences A_1,A_2,\cdots,A_N of length 3 each, using each of the integers 1 through 3N ... | {
"input": [],
"output": []
} | {
"input": [
"314 1000000007",
"1 998244353",
"2 998244353"
],
"output": [
"182908545",
"6",
"261"
]
} | {
"input": [
"356 1000000007",
"1 1368499722",
"0 998244353",
"502 1000000007",
"2 1368499722",
"184 1000000007",
"4 1368499722",
"184 601990858",
"319 601990858",
"5 814283492",
"216 601990858",
"5 1392460857",
"142 601990858",
"5 972753396",
"142 851033055... |
p02873 AtCoder Grand Contest 040 - >< | Given is a string S of length N-1. Each character in S is `<` or `>`.
A sequence of N non-negative integers, a_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \leq i \leq N-1):
* If S_i= `<`: a_i<a_{i+1}
* If S_i= `>`: a_i>a_{i+1}
Find the minimum possible sum of the ele... | {
"input": [],
"output": []
} | {
"input": [
"<>>><<><<<<<>>><",
"<>>"
],
"output": [
"28",
"3"
]
} | {
"input": [
">><",
"<>>><<<<<><<>>><",
"><>",
"<>>>><<<<><<<>><",
"<>><<<><<<<>>>><",
"<<>><<><<<<>>>><",
"<>>>><<<<><<>><<",
"<>>>>><<<><<<><<",
"<>>><>><<><<<><<",
"<<><<<><<>><>>><",
"<<>>>><<<><><><<",
"<>>>>><<<><<<<<>",
"<<>><><<<><><>><",
"<><>><<<<><>>>... |
p03007 diverta 2019 Programming Contest 2 - Successive Subtraction | There are N integers, A_1, A_2, ..., A_N, written on a blackboard.
We will repeat the following operation N-1 times so that we have only one integer on the blackboard.
* Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.
Find the maximum possible value of the... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 1 1",
"3\n1 -1 2"
],
"output": [
"1\n1 1\n1 0",
"4\n-1 1\n2 -2"
]
} | {
"input": [
"3\n0 1 1",
"3\n2 -1 2",
"3\n2 0 2",
"3\n2 0 1",
"3\n2 1 1",
"3\n2 1 2",
"3\n1 1 -1",
"3\n2 2 2",
"3\n3 2 2",
"3\n3 1 0",
"3\n1 -2 2",
"3\n2 -1 3",
"3\n3 0 2",
"3\n4 1 1",
"3\n4 2 1",
"3\n1 -2 1",
"3\n2 4 2",
"3\n3 3 2",
"3\n1 -2... |
p03147 AtCoder Beginner Contest 116 - Grand Garden | In a flower bed, there are N flowers, numbered 1,2,......,N. Initially, the heights of all flowers are 0. You are given a sequence h=\\{h_1,h_2,h_3,......\\} as input. You would like to change the height of Flower k to h_k for all k (1 \leq k \leq N), by repeating the following "watering" operation:
* Specify integers... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 2 1",
"8\n4 23 75 0 23 96 50 100",
"5\n3 1 2 3 1"
],
"output": [
"2",
"221",
"5"
]
} | {
"input": [
"4\n1 4 2 1",
"8\n4 23 75 1 23 96 50 100",
"5\n1 1 2 3 1",
"4\n1 8 2 1",
"8\n4 23 75 0 23 97 50 100",
"4\n1 12 2 1",
"8\n4 23 136 0 23 97 50 100",
"4\n1 12 0 2",
"8\n4 39 136 0 23 97 50 101",
"8\n4 39 136 0 23 108 50 101",
"5\n2 1 4 3 0",
"5\n2 1 8 3 0",
... |
p03291 AtCoder Beginner Contest 104 - We Love ABC | The ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following conditions:
* 1 ≤ i < j < k ≤ |T| (|T| is the length of T.)
* T_i = `A` (T_i is the i-th character of T from the beginning.)
* T_j = `B`
* T_k = `C`
For example, when T = `ABCBC`, there are three triples of... | {
"input": [],
"output": []
} | {
"input": [
"ABCBC",
"????C?????B??????A???????",
"A??C"
],
"output": [
"3",
"979596887",
"8"
]
} | {
"input": [
"ABCCC",
"??????????B??????AC??????",
"??AC",
"CCCBA",
"??????????B??????AB??????",
"??????BA??????B??????????",
"B?????BA?????????????????",
"ABDBC",
"?????????????????AB?????B",
"????>????????????AB?????B",
"????>????????????AB??>??B",
">???>????????????A... |
p03447 AtCoder Beginner Contest 087 - Buying Sweets | You went shopping to buy cakes and donuts with X yen (the currency of Japan).
First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop.
How much do you have left after shopping?
Constraints
* 1 \leq A, B \leq 1 000
* A + B \leq X \leq 10 000
* ... | {
"input": [],
"output": []
} | {
"input": [
"1000\n108\n108",
"1234\n150\n100",
"579\n123\n456",
"7477\n549\n593"
],
"output": [
"28",
"84",
"0",
"405"
]
} | {
"input": [
"1000\n18\n108",
"579\n17\n456",
"7477\n549\n1145",
"1000\n18\n210",
"579\n17\n446",
"7477\n549\n494",
"1000\n18\n302",
"579\n17\n393",
"7477\n678\n494",
"1000\n18\n500",
"579\n17\n733",
"7477\n678\n233",
"1000\n9\n500",
"579\n27\n733",
"7477\n3... |
p03607 AtCoder Beginner Contest 073 - Write and Erase | You are playing the following game with Joisino.
* Initially, you have a blank sheet of paper.
* Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.
* Then, you are asked a question: How many numbe... | {
"input": [],
"output": []
} | {
"input": [
"3\n6\n2\n6",
"4\n2\n5\n5\n2",
"6\n12\n22\n16\n22\n18\n12"
],
"output": [
"1",
"0",
"2"
]
} | {
"input": [
"3\n6\n2\n7",
"4\n3\n5\n5\n2",
"6\n12\n22\n18\n22\n18\n12",
"4\n3\n5\n9\n1",
"6\n4\n47\n28\n35\n18\n12",
"3\n0\n0\n10",
"3\n6\n2\n8",
"4\n3\n5\n5\n1",
"6\n12\n22\n18\n35\n18\n12",
"3\n3\n2\n8",
"6\n12\n22\n28\n35\n18\n12",
"3\n0\n2\n8",
"4\n3\n5\n9\n2",... |
p03768 AtCoder Grand Contest 012 - Splatter Painting | Squid loves painting vertices in graphs.
There is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b_i. The length of every edge is 1.
Squid performed Q operations on th... | {
"input": [],
"output": []
} | {
"input": [
"14 10\n1 4\n5 7\n7 11\n4 10\n14 7\n14 3\n6 14\n8 11\n5 13\n8 3\n8\n8 6 2\n9 7 85\n6 9 3\n6 7 5\n10 3 1\n12 9 4\n9 6 6\n8 2 3",
"7 7\n1 2\n1 3\n1 4\n4 5\n5 6\n5 7\n2 3\n2\n6 1 1\n1 2 2"
],
"output": [
"1\n0\n3\n1\n5\n5\n3\n3\n6\n1\n3\n4\n5\n3",
"2\n2\n2\n2\n2\n1\n0"
]
} | {
"input": [
"14 10\n1 4\n5 7\n7 11\n4 10\n14 7\n14 3\n6 14\n8 11\n5 13\n8 3\n8\n8 6 2\n14 7 85\n6 9 3\n6 7 5\n10 3 1\n12 9 4\n9 6 6\n8 2 3",
"14 10\n1 4\n5 7\n7 11\n2 10\n14 7\n14 3\n6 14\n8 11\n5 13\n8 3\n8\n8 6 2\n14 7 85\n6 9 6\n6 7 5\n10 3 1\n12 9 4\n9 6 6\n8 2 3",
"14 10\n1 4\n5 7\n7 11\n2 10\n14 7\... |
p03937 AtCoder Grand Contest 007 - Shik and Stone | We have a grid of H rows and W columns. Initially, there is a stone in the top left cell. Shik is trying to move the stone to the bottom right cell. In each step, he can move the stone one cell to its left, up, right, or down (if such cell exists). It is possible that the stone visits a cell multiple times (including t... | {
"input": [],
"output": []
} | {
"input": [
"5 3\n\n..#\n\n..",
"4 5\n##...\n.##..\n..##.\n...##",
"4 5\n...\n.###.\n.###.\n...##",
"4 5\n...\n.##..\n..##.\n...##"
],
"output": [
"Impossible",
"Possible",
"Impossible",
"Possible"
]
} | {
"input": [
"5 1\n\n..#\n\n..",
"4 5\n...##\n.##..\n..##.\n...##",
"4 10\n...\n.###.\n.###.\n...##",
"4 8\n...\n.##..\n..##.\n...##",
"5 0\n\n..#\n\n..",
"4 5\n...##\n.##/.\n..##.\n...##",
"4 10\n./.\n.###.\n.###.\n...##",
"4 8\n...\n.##/.\n..##.\n...##",
"8 0\n\n..#\n\n..",
"... |
p00029 English Sentence | Your task is to write a program which reads a text and prints two words. The first one is the word which is arise most frequently in the text. The second one is the word which has the maximum number of letters.
The text includes only alphabetical characters and spaces. A word is a sequence of letters which is separate... | {
"input": [],
"output": []
} | {
"input": [
"Thank you for your mail and your lectures"
],
"output": [
"your lectures"
]
} | {
"input": [
"Thank you for your mail amd your lectures",
"ahTnk you for your mail and your serutcel",
"Uhank you for your mail mad your lrctuees",
"ahTnk you for your mail and your leeturcs",
"khTna you for your mail and your sequtcel",
"khTna you for your mail dna your sequucel",
"Uhank ... |
p00160 Delivery Fee | The courier charges for a courier company are set according to size and weight as shown in the table below.
A size | B size | C size | D size | E size | F size
--- | --- | --- | --- | --- | --- | ---
Size | 60 cm or less | 80 cm or less | 100 cm or less | 120 cm or less | 140 cm or less | 160 cm or less
Weight | 2kg o... | {
"input": [],
"output": []
} | {
"input": [
"2\n50 25 5 5\n80 60 10 30\n3\n10 15 25 24\n5 8 12 5\n30 30 30 18\n0"
],
"output": [
"800\n3800"
]
} | {
"input": [
"2\n50 25 5 5\n80 60 10 30\n3\n10 7 25 24\n5 8 12 5\n30 30 30 18\n0",
"2\n50 25 5 5\n80 60 10 30\n3\n10 7 25 24\n5 8 12 5\n30 30 30 3\n0",
"2\n50 25 5 5\n135 60 10 30\n3\n10 7 25 24\n5 8 13 5\n30 30 30 14\n0",
"2\n50 36 5 5\n135 60 8 30\n3\n10 8 25 24\n5 1 13 5\n30 30 30 14\n0",
"2\n7... |
p00317 Slates | Countless lithographs have been found in the ruins of the ancient nation Iwashiro. Researchers have found that each lithograph has one word engraved on it. However, due to many years of weathering, some lithographs are difficult to decipher for the following reasons.
* Only one letter of a word written on a lithograph... | {
"input": [],
"output": []
} | {
"input": [
"5 4\naloe\napple\napricot\ncactus\ncat\napple\nap*\n*e\nca?*"
],
"output": [
"1\n2\n2\n2"
]
} | {
"input": [
"5 4\naloe\napple\napricot\ncactus\ncat\nappld\nap*\n*e\nca?*",
"5 4\neola\napple\napricot\ncactus\ncat\ndlppa\nap*\n*e\nca?*",
"5 4\neola\napple\naprhcou\ncactus\ncat\ndlppb\nap*\n*d\nca?*",
"5 4\naloe\napple\napricot\ncactus\ncat\napple\n*pa\n*e\nca?*",
"5 4\neola\napple\naprhcou\nc... |
p00487 Bug Party | Do you know Just Odd Inventions? The business of this company is to "just odd inventions". Here, it is abbreviated as JOI.
JOI is conducting research to confine many microorganisms in one petri dish alive. There are N microorganisms to be investigated, and they are numbered 1, 2, ..., N. When each microorganism is tra... | {
"input": [],
"output": []
} | {
"input": [
"6\n12 8\n5 9\n2 4\n10 12\n6 7\n13 9"
],
"output": [
"3"
]
} | {
"input": [
"6\n12 8\n5 9\n2 4\n10 12\n6 7\n6 9",
"6\n12 9\n5 9\n2 4\n10 12\n6 12\n6 9",
"6\n12 8\n5 5\n2 4\n10 12\n6 7\n13 9",
"6\n12 8\n5 9\n2 4\n10 6\n6 7\n6 9",
"6\n12 26\n5 9\n0 14\n10 9\n6 12\n6 9",
"6\n12 9\n5 9\n2 4\n10 12\n6 7\n6 9",
"6\n12 13\n5 9\n2 4\n10 12\n6 12\n6 9",
"6... |
p00673 School Excursion | Spring is the time for school trips. The University of Aizu Elementary School (Aizu University and Small) also had a plan for a school trip next year. It is a tradition to travel by train on school trips. This is because there are few opportunities to use the train in Aizuwakamatsu city.
However, the teachers were tro... | {
"input": [],
"output": []
} | {
"input": [
"2\n4\n1 2 10\n2 2 5\n1 3 20\n2 3 10\n10\n3\n2\n1 2 5\n0 3 4\n3\n10 11 100\n2 12 2\n12 12 3\n10\n0"
],
"output": [
"2 15\n2 111"
]
} | {
"input": [
"2\n4\n1 2 10\n2 2 5\n1 3 20\n2 3 10\n10\n3\n2\n1 2 5\n0 3 4\n3\n10 11 100\n4 12 2\n12 12 3\n10\n0",
"2\n4\n1 2 10\n2 2 5\n0 3 20\n2 3 10\n3\n3\n2\n1 2 5\n0 3 4\n3\n10 11 100\n4 12 2\n12 12 0\n2\n0",
"2\n4\n1 2 10\n2 2 5\n0 0 20\n2 3 10\n3\n3\n2\n1 2 5\n0 3 4\n3\n10 11 100\n4 12 2\n12 12 0\n2... |
p00816 Shredding Company | You have just been put in charge of developing a new shredder for the Shredding Company. Although a ``normal'' shredder would just shred sheets of paper into little pieces so that the contents would become unreadable, this new shredder needs to have the following unusual basic characteristics.
* The shredder takes as ... | {
"input": [],
"output": []
} | {
"input": [
"50 12346\n376 144139\n927438 927438\n18 3312\n9 3142\n25 1299\n111 33333\n103 862150\n6 1104\n0 0"
],
"output": [
"43 1 2 34 6\n283 144 139\n927438 927438\n18 3 3 12\nerror\n21 1 2 9 9\nrejected\n103 86 2 15 0\nrejected"
]
} | {
"input": [
"50 12346\n376 144139\n927438 667387\n18 3312\n9 3142\n25 1299\n111 33333\n103 862150\n6 1104\n0 0",
"50 12346\n712 144139\n927438 667387\n23 3312\n9 3142\n25 1299\n111 33333\n103 862150\n6 1104\n0 0",
"81 12346\n376 144139\n927438 927438\n18 3312\n9 3142\n25 1299\n111 33333\n103 862150\n6 11... |
p00947 Quality of Check Digits | Example
Input
0 3 1 7 5 9 8 6 4 2
7 0 9 2 1 5 4 8 6 3
4 2 0 6 8 7 1 3 5 9
1 7 5 0 9 8 3 4 2 6
6 1 2 3 0 4 5 9 7 8
3 6 7 4 2 0 9 5 8 1
5 8 6 9 7 2 0 1 3 4
8 9 4 5 3 6 2 0 1 7
9 4 3 8 6 1 7 2 0 5
2 5 8 1 4 3 6 7 9 0
Output
0 | {
"input": [],
"output": []
} | {
"input": [
"0 3 1 7 5 9 8 6 4 2\n7 0 9 2 1 5 4 8 6 3\n4 2 0 6 8 7 1 3 5 9\n1 7 5 0 9 8 3 4 2 6\n6 1 2 3 0 4 5 9 7 8\n3 6 7 4 2 0 9 5 8 1\n5 8 6 9 7 2 0 1 3 4\n8 9 4 5 3 6 2 0 1 7\n9 4 3 8 6 1 7 2 0 5\n2 5 8 1 4 3 6 7 9 0"
],
"output": [
"0"
]
} | {
"input": [
"0 3 1 7 5 9 8 6 4 2\n7 0 9 2 1 5 4 8 6 3\n4 2 0 6 8 7 1 3 5 9\n1 7 5 0 9 8 3 4 2 6\n6 1 2 3 0 4 5 9 7 8\n3 6 7 4 2 0 17 5 8 1\n5 8 6 9 7 2 0 1 3 4\n8 9 4 5 3 6 2 0 1 7\n9 4 3 8 6 1 7 2 0 5\n2 5 8 1 4 3 6 7 9 0",
"0 3 1 7 5 9 8 6 4 2\n7 0 9 2 1 5 4 8 6 3\n4 2 0 6 8 7 1 3 5 9\n1 7 5 0 9 8 3 4 2 6\... |
p01080 Traffic Tree | Problem
A graph is given in which N vertices, each numbered from 1 to N, are connected by N-1 undirected edges. For each vertex, output the shortest number of steps to start from that vertex and visit all vertices.
However, one step is to follow one side from one vertex and move to another vertex.
Constraints
* 2 ≤... | {
"input": [],
"output": []
} | {
"input": [
"6\n1 2\n1 3\n3 4\n3 5\n5 6",
"2\n1 2"
],
"output": [
"7\n6\n8\n7\n7\n6",
"1\n1"
]
} | {
"input": [
"6\n1 2\n2 3\n3 4\n3 5\n5 6",
"6\n1 2\n2 3\n6 4\n3 5\n5 6",
"6\n1 2\n2 3\n6 4\n3 4\n5 6",
"6\n1 2\n2 3\n3 4\n3 5\n1 6",
"6\n1 2\n1 3\n3 4\n3 5\n3 6",
"6\n1 2\n2 3\n3 4\n3 5\n2 6",
"6\n1 2\n2 5\n6 4\n3 4\n5 6",
"6\n1 2\n2 5\n6 4\n3 4\n2 6",
"6\n1 2\n2 5\n6 4\n3 4\n1 6",... |
p01214 Petoris | You are playing a puzzle game named petoris. It is played with a board divided into square grids and square tiles each of which fits to a single grid.
In each step of the game, you have a board partially filled with tiles. You also have a block consisting of several tiles. You are to place this block somewhere on the ... | {
"input": [],
"output": []
} | {
"input": [
"5\n4 4\n....\n....\n####\n....\n12 8\n........\n........\n........\n........\n........\n.......#\n##.##..#\n.#######\n.#######\n.#######\n.#######\n.####.#.\n4 4\n....\n....\n.###\n...#\n12 8\n........\n........\n........\n........\n........\n........\n........\n##...###\n##.#####\n#######.\n#######... | {
"input": [
"5\n4 4\n....\n....\n####\n....\n12 8\n........\n........\n........\n........\n........\n.......#\n##.##..#\n.#######\n.#######\n.#######\n.#######\n.####.#.\n7 4\n....\n....\n.###\n...#\n12 8\n........\n........\n........\n........\n........\n........\n........\n##...###\n##.#####\n#######.\n#######... |
p01350 Carrot Tour | I'm traveling to a country with a rabbit. There are n cities in this country numbered from 1 to n, and the rabbit is now in city 1. City i is a point on the coordinate plane (xi, yi) ).
Rabbits travel to meet the following conditions.
* The travel path is a polygonal line, each part of which must be a line segment co... | {
"input": [],
"output": []
} | {
"input": [
"5\n100.1 90.1\n0 0\n0 10\n5 5\n10 0\n10 10"
],
"output": [
"10"
]
} | {
"input": [
"5\n100.1 90.1\n0 0\n0 10\n7 5\n10 0\n10 10",
"5\n100.1 90.65666260699702\n0 0\n1 10\n7 5\n10 0\n10 10",
"5\n100.1 90.1\n0 0\n0 10\n5 5\n10 0\n10 4",
"5\n100.1 90.65666260699702\n0 0\n0 10\n7 5\n13 0\n10 10",
"5\n100.1 90.65666260699702\n1 0\n1 10\n8 10\n10 0\n10 10",
"5\n100.1 90... |
p01532 Problem B War II | Second Problem B War
2D enthusiasts (2D Respecters) from R University will participate in a programming training camp held at Atsu University. In this training camp, participants bring their own programming problems and use them for practice. This year, the 2D Respecters ran for the questioner of question B, who can e... | {
"input": [],
"output": []
} | {
"input": [
"3 0 0 100\n4 0\n3 0\n3 0"
],
"output": [
"2"
]
} | {
"input": [
"3 -1 0 100\n4 0\n3 0\n3 0",
"3 -1 0 100\n4 0\n5 0\n3 0",
"2 -1 0 100\n4 0\n5 -1\n3 0",
"5 -2 -1 011\n8 0\n-1 -1\n6 0",
"3 -1 0 100\n4 0\n5 -1\n3 0",
"3 -2 0 100\n4 0\n5 -1\n3 0",
"3 0 0 100\n7 0\n3 0\n3 0",
"3 -1 0 101\n4 0\n3 0\n3 0",
"3 -1 0 100\n4 1\n5 0\n3 0",
... |
p01688 Doctor Course Is Recommended | B --Doctor Course Is Recommended / D How about going forward?
Story
Since the person D decided to advance to D, he decided to take the entrance examination for the doctoral program. The written test was in mark sheet format. Since all the questions were in his area of expertise, D was able to quickly come up with a... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\nD 30\nD 50\nD 20\n0"
],
"output": [
"80"
]
} | {
"input": [
"2\n3\nD 30\nC 50\nD 20\n0",
"2\n3\nD 35\nC 88\nD 20\n0",
"2\n3\nD 43\nD 50\nD 20\n0",
"2\n3\nD 30\nC 50\nD 24\n0",
"2\n3\nD 35\nC 88\nD 40\n0",
"2\n3\nD 30\nC 50\nD 26\n0",
"2\n3\nD 27\nC 24\nD 20\n0",
"2\n3\nD 12\nC 88\nD 40\n0",
"2\n3\nD 27\nC 24\nD 17\n0",
"2\n... |
p01832 Shifting a Matrix | Example
Input
3 2
R1
Output
3 1 2
4 5 6
7 8 9 | {
"input": [],
"output": []
} | {
"input": [
"3 2\nR1"
],
"output": [
"3 1 2\n4 5 6\n7 8 9"
]
} | {
"input": [
"2 2\nR1",
"1 2\nR1",
"5 2\nR1",
"4 2\nR1",
"8 2\nR1",
"7 2\nR1",
"3 2\nR2",
"11 2\nR1",
"3 2\nR3",
"11 2\nR2",
"20 2\nR1",
"5 2\nR3",
"7 2\nR2",
"22 2\nR1",
"9 2\nR2",
"30 2\nR1",
"9 2\nR1",
"36 2\nR1",
"5 2\nR2",
"6 2\nR2",... |
p01967 Many Kinds of Apples | A: Many Kinds of Apples
Problem Statement
Apple Farmer Mon has two kinds of tasks: "harvest apples" and "ship apples".
There are N different species of apples, and N distinguishable boxes. Apples are labeled by the species, and boxes are also labeled, from 1 to N. The i-th species of apples are stored in the i-th bo... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 3\n4\n1 1 2\n1 2 3\n2 1 3\n2 2 3"
],
"output": [
"1"
]
} | {
"input": [
"2\n3 3\n4\n1 1 0\n1 2 3\n2 1 3\n2 2 3",
"2\n3 3\n0\n1 1 0\n1 2 3\n2 1 3\n2 2 3",
"2\n3 3\n4\n1 1 2\n1 2 4\n2 1 3\n2 2 3",
"2\n3 2\n0\n1 1 0\n1 2 3\n2 1 3\n2 2 3",
"2\n3 2\n0\n1 1 0\n1 2 3\n2 1 3\n2 2 1",
"2\n3 2\n0\n1 1 0\n1 2 3\n2 1 3\n0 2 1",
"2\n3 2\n0\n1 1 1\n1 2 3\n2 1 3... |
p02114 Fissure Puzzle Easy | Problem
There is a grid of $ N \ times N $ cells. Initially all cells are white. Follow the steps below to increase the number of black squares.
Select one white cell from the cells that are even-numbered from the top and even-numbered from the left. The selected square turns black. Further, the adjacent white square... | {
"input": [],
"output": []
} | {
"input": [
"5\noxooo\noxooo\noxooo\nxxxxx\noxooo",
"9\noxoooooxo\noxxxxxxxx\noxoooooxo\nxxxxxxxxx\noxoxooooo\noxxxxxxxx\noxoxoxooo\noxoxxxxxx\noxoxoxooo"
],
"output": [
"1",
"4"
]
} | {
"input": [
"9\noxoooooxo\noxxxxxxxx\noxoooooxo\nxxxxxxxxx\noxoxooooo\noxxxxxxxx\noxoxoxooo\nxxxxxxoxo\noxoxoxooo",
"5\noxoop\noxooo\noxooo\nxxxxx\noxooo",
"9\noxoooooxo\noxxxxxxxx\noxoooooxo\nxxxxxxxxx\noxoxooooo\noxxxxxxxx\noxoxoxooo\nxxxxxxoxo\noooxoxoxo",
"9\noxoooooxo\noxxxxxxxx\noxoooooxo\nxxxx... |
p02254 Huffman Coding | We want to encode a given string $S$ to a binary string. Each alphabet character in $S$ should be mapped to a different variable-length code and the code must not be a prefix of others.
Huffman coding is known as one of ways to obtain a code table for such encoding.
For example, we consider that appearance frequencyc... | {
"input": [],
"output": []
} | {
"input": [
"z",
"aaabbcccdeeeffg",
"abca"
],
"output": [
"1",
"41",
"6"
]
} | {
"input": [
"y",
"aaabbcccdeeegfg",
"baca",
"aaadbcccbeedgfg",
"bbcb",
"gegdeebcccbeaaa",
"aeaaacccbeedgeg",
"gegdeebccdaaaea",
"gegdfebccdaaaea",
"bedc",
"abadbcccbeedhfg",
"cggdeebcgcbeaaa",
"x",
"gfgeeedcccbbaaa",
"acab",
"w",
"gfgeeebcccbdaaa",
... |
p02402 Min | Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
Constraints
* $0 < n \leq 10000$
* $-1000000 \leq a_i \leq 1000000$
Input
In the first line, an integer $n$ is given. In the next line, $n$ integers $a_i$ are given in... | {
"input": [],
"output": []
} | {
"input": [
"5\n10 1 5 4 17"
],
"output": [
"1 17 37"
]
} | {
"input": [
"5\n13 1 5 4 17",
"5\n13 1 5 7 17",
"5\n13 0 5 7 17",
"5\n13 0 7 7 17",
"5\n23 0 7 7 17",
"5\n23 0 0 7 17",
"5\n23 0 0 4 17",
"5\n43 0 0 4 17",
"5\n43 0 0 4 18",
"5\n43 0 -1 4 18",
"5\n43 0 -1 4 17",
"5\n43 0 -1 4 0",
"5\n43 1 -1 4 0",
"5\n42 1 -1 4... |
adigit | Yesterday Chef had a great party and doesn't remember the way he celebreated it. But he found a strange paper in his kitchen containing n digits (lets give them indices from 1 to n and name them a1, a2 ... aN).
Chef remembers that he played such game:
On each step he choose an index x from 1 to n.
For all indices ... | {
"input": [],
"output": []
} | {
"input": [
"10 3\n0324152397\n1\n4\n7"
],
"output": [
"0\n7\n9\n"
]
} | {
"input": [
"10 3\n0324152397\n1\n6\n7",
"10 1\n0324152397\n1\n6\n7",
"10 2\n0324152397\n1\n6\n7",
"10 3\n0324152397\n2\n4\n7",
"10 2\n0324152397\n1\n7\n7",
"10 3\n0324152397\n1\n3\n7",
"10 3\n0324152397\n3\n1\n7",
"10 3\n0324152397\n2\n3\n7",
"10 3\n0324152397\n2\n3\n10",
"10... |
chefspl | One day, Chef prepared D brand new dishes. He named the i-th dish by a string Si. After the cooking, he decided to categorize each of these D dishes as special or not.
A dish Si is called special if it's name (i.e. the string Si) can be represented in the form of a double string by removing at most one (possibly zero... | {
"input": [],
"output": []
} | {
"input": [
"3\naba\nabac\nabcd"
],
"output": [
"YES\nNO\nNO\n"
]
} | {
"input": [
"3\naba\nabac\naacd",
"3\nbca\nb`dc\naabd",
"3\ncdd\n_a_a\n_ed[",
"3\nfda\n`a`a\nb`Ze",
"3\naba\nabac\ndaca",
"3\naba\nabac\ndaac",
"3\naba\nabac\nadac",
"3\naba\nabac\nadbc",
"3\naba\nabac\ndabc",
"3\naba\ncaba\ndabc",
"3\naba\nc`ba\ndabc",
"3\naba\nab`c\n... |
dpc207 | When
displaying a collection of rectangular windows, a critical step is determining
whether two windows overlap, and, if so, where on the screen the overlapping
region lies. Write a program to perform this function. Your program will accept
as input the coordinates of two rectangular... | {
"input": [],
"output": []
} | {
"input": [
"2\n\n0 20 \n 100 120\n\n80 0 \n 500 60\n\n10 10 \n 20 20\n\n30 30 \n 40 40"
],
"output": [
"80 20 \n 100 60\n\nNo \n Overlap"
]
} | {
"input": [
"2\n\n0 20 \n 100 120\n\n80 0 \n 500 60\n\n10 5 \n 20 20\n\n30 30 \n 40 40",
"2\n\n0 20 \n 100 120\n\n130 0 \n 500 60\n\n10 5 \n 20 20\n\n30 30 \n 40 40",
"2\n\n0 20 \n 100 120\n\n130 0 \n 157 60\n\n10 5 \n 20 20\n\n... |
jmi04 | XOXO likes to play with numbers.So,given a number N help XOXO to find whether it is a fibonacci number or not.It won't be hard!
Input
First line contains T denoting the number of test case.
The next T line contains an integer N
Output
For every test case print(without quotes) "Yes" if N is a fibonacci number else o... | {
"input": [],
"output": []
} | {
"input": [
"2\n3\n10"
],
"output": [
"Yes\nNo\n"
]
} | {
"input": [
"2\n1\n10",
"2\n0\n13",
"2\n4\n7",
"2\n9\n13",
"2\n0\n10",
"2\n5\n10",
"2\n1\n17",
"2\n8\n10",
"2\n0\n17",
"2\n13\n10",
"2\n13\n7",
"2\n1\n7",
"2\n2\n7",
"2\n0\n7",
"2\n3\n3",
"2\n2\n10",
"2\n0\n16",
"2\n5\n6",
"2\n1\n0",
"2\... |
nsit15 | Majin wants to label his N (1 ≤ N ≤ 1,000,000) towers. He has lost the labels with the digit L (0 ≤ L ≤ 9) written on them. Assume he has sufficient labels to complete the task.
If the towers are labeled with the smallest set of N positive integers that don't have the digit L, what is the largest number that Majin wil... | {
"input": [],
"output": []
} | {
"input": [
"1\n10 0"
],
"output": [
"11"
]
} | {
"input": [
"1\n11 0",
"1\n4 0",
"1\n4 1",
"1\n1 0",
"1\n11 1",
"1\n3 0",
"1\n5 1",
"1\n11 2",
"1\n6 2",
"1\n7 3",
"1\n8 2",
"1\n14 3",
"1\n28 3",
"1\n9 3",
"1\n28 0",
"1\n29 0",
"1\n13 0",
"1\n16 0",
"1\n10 2",
"1\n22 0",
"1\n1 1",
... |
shuttle | Chef has decided to arrange the free shuttle service for his employees. City of Bhiwani has a strange layout - all of its N shuttle boarding points are arranged in a circle, numbered from 1 to N in clockwise direction. Chef's restaurant is at boarding point number 1. There is a single ring road that runs over the circu... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n3\n4"
],
"output": [
"1\n2\n2"
]
} | {
"input": [
"3\n2\n3\n1",
"3\n2\n5\n1",
"3\n2\n2\n1",
"3\n3\n2\n1",
"3\n2\n3\n6",
"3\n4\n3\n1",
"3\n4\n3\n6",
"3\n1\n15\n1",
"3\n4\n3\n7",
"3\n1\n25\n1",
"3\n4\n2\n14",
"3\n1\n42\n1",
"3\n4\n2\n21",
"3\n1\n73\n1",
"3\n2\n2\n4",
"3\n5\n2\n1",
"3\n4\n... |
1366_D. Two Divisors | You are given n integers a_1, a_2, ..., a_n.
For each a_i find its two divisors d_1 > 1 and d_2 > 1 such that \gcd(d_1 + d_2, a_i) = 1 (where \gcd(a, b) is the greatest common divisor of a and b) or say that there is no such pair.
Input
The first line contains single integer n (1 ≤ n ≤ 5 ⋅ 10^5) — the size of the ar... | {
"input": [],
"output": []
} | {
"input": [
"10\n2 3 4 5 6 7 8 9 10 24\n"
],
"output": [
"-1 -1 -1 -1 2 -1 -1 -1 2 2\n-1 -1 -1 -1 3 -1 -1 -1 5 3\n"
]
} | {
"input": [
"10\n2 3 4 5 6 8 8 9 10 24\n",
"10\n7 3 6 5 6 8 8 9 10 24\n",
"10\n7 3 6 10 6 8 8 9 10 24\n",
"10\n7 3 2 10 6 8 8 9 10 24\n",
"10\n7 3 2 10 8 8 8 9 10 24\n",
"10\n7 3 2 10 8 8 8 9 3 24\n",
"10\n2 3 3 5 6 8 8 9 2 24\n",
"10\n4 3 3 5 6 14 8 9 10 24\n",
"10\n7 3 6 10 6 8 ... |
530_F. Jumping frogs | A rectangular swamp is inhabited by 10 species of frogs. Frogs of species i can jump from hillocks to hillock exactly i units along X-axis or Y-axis. Initially frogs of all types sit at the hillock at coordinates (0, 0). You are given coordinates of all other hillocks in the swamp. Find the largest Manhattan distance f... | {
"input": [],
"output": []
} | {
"input": [
"3\n0 1\n0 -2\n0 3\n",
"5\n0 1\n0 2\n0 3\n2 2\n2 4\n",
"1\n18 0\n"
],
"output": [
"3\n",
"6\n",
"0\n"
]
} | {
"input": [],
"output": []
} |
954_I. Yet Another String Matching Problem | Suppose you have two strings s and t, and their length is equal. You may perform the following operation any number of times: choose two different characters c1 and c2, and replace every occurence of c1 in both strings with c2. Let's denote the distance between strings s and t as the minimum number of operations requir... | {
"input": [],
"output": []
} | {
"input": [
"abcdefa\nddcb\n"
],
"output": [
"2 3 3 3 "
]
} | {
"input": [
"abcdffa\nddcb\n",
"abdcefa\nbcdd\n",
"abcdfaf\ndecb\n",
"abcdfaf\ndfcb\n",
"abcedfa\nddcb\n",
"abcdfaf\nfdcb\n",
"bbdcefa\nbddc\n",
"abcdffa\nddcc\n",
"bbdcefa\ndddb\n",
"afecdbb\ndbdc\n",
"afedcaa\nddcb\n",
"afecdbb\ncdbd\n",
"bfedcaa\nddcb\n",
"b... |
2-fast-2-furious | Problem Statement:
Dom and Brian were trying to evade the truck drivers of Verone's gang. They were too fast, too furious for them, and could get away from the truck drivers easily. They decided to race with each other, and divided the city into N checkpoints for the same. Mia was monitoring Dom and Brian throughout t... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 3\n1 2 4\n\nSAMPLE"
],
"output": [
"Brian\n2\n"
]
} | {
"input": [
"3\n1 2 3\n1 2 4\n\nSAMPKE",
"3\n1 2 3\n1 4 4\n\nSAMPKE",
"3\n1 2 3\n0 4 4\n\nSAMPKE",
"3\n1 0 3\n1 3 4\n\nSAMPKE",
"3\n1 -1 3\n1 3 4\n\nSAMPKE",
"3\n1 -1 4\n1 3 4\n\nSAMPKE",
"3\n1 2 9\n1 2 4\n\nSLLPAE",
"3\n1 2 11\n1 2 4\n\nSAMPKE",
"3\n1 2 5\n1 2 8\n\nSLLPAE",
"... |
bhulla-and-captain-cold-1 | Mr. Bhulla, now a member of the Mafia, is ordered by his capo Captain Cold to buy guns, ammunition and masks for the organization. Captain Cold is used to playing games with his men and so gives Bhulla some rules regarding the purchase. He says:
There are N different factories in the market of illegal guns and ammo. ... | {
"input": [],
"output": []
} | {
"input": [
"1\n3\n25 10 30\n20 10 15\n15 20 30\n\nSAMPLE"
],
"output": [
"40\n"
]
} | {
"input": [
"1\n3\n25 10 30\n20 10 15\n15 20 29\n\nSAMPLE",
"1\n3\n25 10 30\n20 10 15\n19 20 29\n\nSAMPLE",
"1\n3\n28 10 30\n20 0 15\n19 2 29\n\nSAMPLE",
"1\n3\n28 10 30\n20 1 15\n19 4 29\n\nSAMPLE",
"1\n3\n25 0 30\n20 10 15\n15 20 29\n\nSAMPLE",
"1\n3\n6 10 30\n20 2 15\n15 4 29\n\nSAMPLE",
... |
count-divisors | You have been given 3 integers l, r and k. Find how many numbers between l and r (both inclusive) are divisible by k. You do not need to print these numbers, you just have to find their count.
Input Format
The first and only line of input contains 3 space separated integers l, r and k.
Output Format
Print the requ... | {
"input": [],
"output": []
} | {
"input": [
"1 10 1\n\nSAMPLE"
],
"output": [
"10\n"
]
} | {
"input": [
"1 10 2\n\nSAMPLE",
"2 10 1\n\nSAMPLE",
"2 16 2\n\nSMAPLE",
"2 26 2\n\nSMAPLE",
"2 38 2\n\nSMAPKE",
"1 10 1\n\nSBMPLE",
"2 19 1\n\nSAMPLE",
"2 10 3\n\nSAMPLE",
"4 16 2\n\nSMAPLE",
"3 26 2\n\nSMAPLE",
"4 19 1\n\nSAMPLE",
"3 19 1\n\nRAMPLE",
"2 5 2\n\nSML... |
find-the-substrings | Given a string S made of letters a, b and c, find the number of sub strings that do not contain all the letters a, b and c. That is the number of sub strings that do not contain at least one of the letters a or b or c.
Note that the sub string should contain atleast one letter, that is it should not be empty string.
... | {
"input": [],
"output": []
} | {
"input": [
"3\nababa\nabc\nbabac\n\nSAMPLE"
],
"output": [
"15\n5\n12\n"
]
} | {
"input": [
"3\nababa\ncba\nbabac\n\nSAMPLE",
"3\n`baba\ncba\nbabad\n\nSAMPLE",
"3\n`aaba\ncbb\nbbbad\n\nSAMPLE",
"3\na_c]b\ndda\nbaea`\n\nADQNKQ",
"3\n]ac_b\nbdi\n`afaa\n\nBODQPF",
"3\n`baba\ncba\nbabac\n\nSAMPLE",
"3\n`aaba\ncba\nbabad\n\nSAMPLE",
"3\n`aaba\ncba\nbbbad\n\nSAMPLE",
... |
one-way-or-another-juneclash-3 | The link to the Russian translation.
Stefan is stuck in Marty's body and in order to fix him, Valerie has encountered a problem with dead witches spirits.
In order to allow her to do such magic, the witches gave her a huge grid (10^18 by 10^18, rows numbered from 1 to 10^18, from top to bottom and columns from left ... | {
"input": [],
"output": []
} | {
"input": [
"3\n2\n5 4 2\n1 5 2\n5\n1 4 4\n3 1 2\n1 2 5\n3 3 3\n1 1 1\n5\n1 4 1\n4 1 1\n5 2 5\n2 5 3\n5 3 4\n\nSAMPLE"
],
"output": [
"No\nNo\nYes\n"
]
} | {
"input": [
"3\n2\n5 4 2\n1 5 2\n5\n1 4 4\n3 1 2\n1 2 7\n3 3 3\n1 1 1\n5\n1 4 1\n4 1 1\n5 2 5\n2 5 3\n5 3 4\n\nSAMPLE",
"3\n2\n5 4 2\n1 5 2\n5\n1 4 4\n3 1 2\n1 2 7\n3 3 3\n1 1 0\n5\n1 5 1\n4 1 1\n5 2 5\n2 5 3\n5 3 4\n\nSAMPME",
"3\n2\n5 4 2\n1 5 2\n5\n1 4 4\n3 2 2\n1 5 7\n3 3 3\n1 1 1\n5\n1 4 1\n1 1 1\n5... |
random-shuffle | In computer Science there is common need to generate random permutation. It can be seen as the shuffle of the numbers. Start with sorted permutation of n, at each step select the random no between 1 to n and put it at front. after doing n steps you can write shuffle sequence like {p1,p2,p3 ,...,pn} where at i th step ... | {
"input": [],
"output": []
} | {
"input": [
"1\n2\n\nSAMPLE"
],
"output": [
"2"
]
} | {
"input": [],
"output": []
} |
skipping-sum-1 | You are given an array of N integers A[1] , A[2] , ... , A[N] . You have to answer Q queries. Each query consists of 3 integers L, R and K. For each query, you have to find the value of the Skipping Sum in the following manner :
def skipping_sum(L,R,K) :
sum = 0
while L ≤ R :
... | {
"input": [],
"output": []
} | {
"input": [
"8 6\n5 4 2 1 7 9 10 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n3 7 3\n3 7 4\n\nSAMPLE"
],
"output": [
"47\n24\n1\n19\n11\n12\n"
]
} | {
"input": [
"8 6\n5 4 2 1 7 9 12 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n3 7 3\n3 7 4\n\nSAMPLE",
"8 6\n5 4 2 1 7 9 12 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n5 7 3\n3 7 4\n\nSAMPLE",
"8 3\n5 4 2 1 7 9 12 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n5 7 3\n3 7 4\n\nSAMPLE",
"8 6\n5 4 2 1 7 9 10 9\n1 8 1\n1 8 2\n4 8 9\n3 7 2\n3 5 3\... |
the-treasure-lock | In vardhaman college of engineering, there is competition with name treasure lock.
To make this competition the key for the lock should satisfy following rules.
1 .3, 5, or both as its digits. No other digit is allowed.
2. Number of times 3 appears is divisible by 5.
3. Number of times 5 appears is divisible by 3.
Rak... | {
"input": [],
"output": []
} | {
"input": [
"4\n1\n3\n5\n17\n\nSAMPLE"
],
"output": [
"-1\n555\n33333\n55555555555533333\n"
]
} | {
"input": [
"4\n1\n3\n5\n17\n\nLAMPSE",
"4\n1\n3\n5\n12\n\nLAMPSE",
"4\n1\n3\n5\n8\n\nLAMPTE",
"4\n1\n3\n5\n3\n\nETPMBL",
"4\n1\n3\n5\n5\n\nETPBML",
"4\n1\n3\n8\n5\n\nEUPBML",
"4\n1\n3\n8\n1\n\nLMBPUE",
"4\n1\n6\n8\n1\n\nLMBPUE",
"4\n1\n8\n8\n1\n\nLMBPUE",
"4\n1\n6\n5\n3\n\nET... |
p02551 AtCoder Beginner Contest 179 - Simplified Reversi | There is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left.
Each of the central (N-2) \times (N-2) squares in the grid has a black stone on it. Each of the 2N - 1 squares on the bottom side and the right side has a white stone on it.
Q... | {
"input": [],
"output": []
} | {
"input": [
"5 5\n1 3\n2 3\n1 4\n2 2\n1 2",
"200000 0",
"176527 15\n1 81279\n2 22308\n2 133061\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 77429\n1 97459\n2 71282"
],
"output": [
"1",
"39999200004",
"31159505795"
]
} | {
"input": [
"2463 0",
"176527 15\n1 81279\n2 22308\n2 168987\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 77429\n1 97459\n2 71282",
"1874 0",
"176527 15\n1 81279\n2 22308\n2 168987\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 78642\n2 156968\... |
p02682 AtCoder Beginner Contest 167 - Easy Linear Programming | We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.
We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?
Constraints
* All values in input are integers.
* 0 \leq A, B, C
* 1 \leq K \l... | {
"input": [],
"output": []
} | {
"input": [
"2000000000 0 0 2000000000",
"1 2 3 4",
"2 1 1 3"
],
"output": [
"2000000000",
"0",
"2"
]
} | {
"input": [
"1 2 5 4",
"2 0 1 3",
"0 3 8 6",
"0 3 8 5",
"-1 3 5 5",
"-1 3 5 6",
"-1 6 3 2",
"2 2 3 4",
"-2 3 5 5",
"4 2 0 4",
"4 3 4 3",
"5 21 5 20",
"6 1 1 7",
"0 3 10 12",
"1 0 8 9",
"-3 3 8 5",
"-4 3 8 5",
"10 2 4 8",
"3 0 17 18",
"1 ... |
p02810 Dwango Programming Contest 6th - Span Covering | Niwango bought a piece of land that can be represented as a half-open interval [0, X).
Niwango will lay out N vinyl sheets on this land. The sheets are numbered 1,2, \ldots, N, and they are distinguishable. For Sheet i, he can choose an integer j such that 0 \leq j \leq X - L_i and cover [j, j + L_i) with this sheet.
... | {
"input": [],
"output": []
} | {
"input": [
"3 3\n1 1 2",
"18 477\n324 31 27 227 9 21 41 29 50 34 2 362 92 11 13 17 183 119"
],
"output": [
"10",
"134796357"
]
} | {
"input": [
"3 4\n1 1 2",
"18 477\n324 31 27 227 9 21 41 55 50 34 2 362 92 11 13 17 183 119",
"3 4\n2 1 2",
"18 477\n324 31 27 227 9 7 41 55 50 34 2 362 92 11 13 17 183 119",
"18 477\n324 47 27 227 9 7 41 55 50 34 2 362 92 11 13 17 183 119",
"18 409\n324 47 27 227 9 7 41 55 50 34 2 362 92 11 ... |
p02947 AtCoder Beginner Contest 137 - Green Bin | We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.
For example, `greenbin` is an anagram of `beginner`. As seen here, when the same character occurs multiple times, that character must be used that number of times.
Given are N strings s_1, s_2, \ldots, s... | {
"input": [],
"output": []
} | {
"input": [
"5\nabaaaaaaaa\noneplustwo\naaaaaaaaba\ntwoplusone\naaaabaaaaa",
"2\noneplustwo\nninemodsix",
"3\nacornistnt\npeanutbomb\nconstraint"
],
"output": [
"4",
"0",
"1"
]
} | {
"input": [
"5\nabaaaaaaaa\noweplustno\naaaaaaaaba\ntwoplusone\naaaabaaaaa",
"2\noneplustwo\nnioemodsix",
"3\nacornistnt\npeaoutbnmb\nconstraint",
"5\nabaaaaaaaa\noweplustmo\naaaaaaaaba\nunoselpowt\naaaaaaaaba",
"5\nabaaaaaaaa\noweplustno\naaaaaaaaba\ntwoplusone\naaaaaaaaba",
"2\nonepltsuwo\n... |
p03083 ExaWizards 2019 - Black or White | Today, Snuke will eat B pieces of black chocolate and W pieces of white chocolate for an afternoon snack.
He will repeat the following procedure until there is no piece left:
* Choose black or white with equal probability, and eat a piece of that color if it exists.
For each integer i from 1 to B+W (inclusive), fi... | {
"input": [],
"output": []
} | {
"input": [
"2 1",
"3 2",
"6 9"
],
"output": [
"500000004\n750000006\n750000006",
"500000004\n500000004\n625000005\n187500002\n187500002",
"500000004\n500000004\n500000004\n500000004\n500000004\n500000004\n929687507\n218750002\n224609377\n303710940\n633300786\n694091802\n172485353\n411682... | {
"input": [
"1 2",
"6 3",
"1 3",
"6 6",
"2 3",
"10 6",
"2 6",
"10 8",
"4 6",
"12 8",
"8 6",
"8 8",
"8 3",
"10 14",
"5 3",
"13 6",
"5 4",
"13 1",
"7 4",
"3 1",
"2 4",
"6 1",
"2 2",
"9 1",
"4 2",
"1 1",
"4 1",
... |
p03228 Tenka1 Programmer Beginner Contest - Exchange | In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:
* If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pers... | {
"input": [],
"output": []
} | {
"input": [
"3 3 3",
"5 4 2",
"314159265 358979323 84"
],
"output": [
"1 3",
"5 3",
"448759046 224379523"
]
} | {
"input": [
"3 2 3",
"5 4 1",
"231274241 358979323 84",
"0 2 3",
"8 4 1",
"377378637 358979323 84",
"0 0 3",
"8 4 2",
"7425724 358979323 84",
"10 4 2",
"7425724 358979323 157",
"7425724 65000432 157",
"10 6 3",
"7425724 2844927 157",
"13 6 3",
"7425724 ... |
p03376 AtCoder Regular Contest 096 - Sweet Alchemy | Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o... | {
"input": [],
"output": []
} | {
"input": [
"3 100 10\n15\n10 1\n20 1",
"5 1000000000 1000000\n123\n159 1\n111 1\n135 3\n147 3",
"3 100 1\n15\n10 1\n20 1"
],
"output": [
"10",
"7496296",
"7"
]
} | {
"input": [
"3 100 10\n30\n10 1\n20 1",
"5 1000010000 1000000\n123\n159 1\n111 1\n135 3\n147 3",
"3 101 1\n15\n10 1\n20 1",
"3 000 10\n30\n10 1\n20 1",
"5 1000010000 1000000\n30\n159 1\n111 1\n135 3\n147 3",
"5 1000010000 1000000\n30\n84 1\n111 1\n135 3\n147 3",
"5 1000010000 1000000\n30\... |
p03543 AtCoder Beginner Contest 079 - Good Integer | We call a 4-digit integer with three or more consecutive same digits, such as 1118, good.
You are given a 4-digit integer N. Answer the question: Is N good?
Constraints
* 1000 ≤ N ≤ 9999
* N is an integer.
Input
Input is given from Standard Input in the following format:
N
Output
If N is good, print `Yes`; ot... | {
"input": [],
"output": []
} | {
"input": [
"7777",
"1118",
"1234"
],
"output": [
"Yes",
"Yes",
"No"
]
} | {
"input": [
"8920",
"4000",
"2051",
"1247",
"15093",
"3362",
"1887",
"2106",
"2603",
"3550",
"3088",
"860",
"2216",
"374",
"2401",
"425",
"4049",
"647",
"6567",
"317",
"8004",
"2070",
"1674",
"3716",
"1045",
"943"... |
p03697 AtCoder Beginner Contest 063 - Restricted | You are given two integers A and B as the input. Output the value of A + B.
However, if A + B is 10 or greater, output `error` instead.
Constraints
* A and B are integers.
* 1 ≤ A, B ≤ 9
Input
Input is given from Standard Input in the following format:
A B
Output
If A + B is 10 or greater, print the string `e... | {
"input": [],
"output": []
} | {
"input": [
"6 4",
"6 3"
],
"output": [
"error",
"9"
]
} | {
"input": [
"6 7",
"6 0",
"7 0",
"5 0",
"1 1",
"1 0",
"2 1",
"3 1",
"1 -1",
"0 -1",
"0 -2",
"-1 -2",
"-2 -2",
"-1 -4",
"-4 -2",
"-1 -6",
"-2 -6",
"-2 -8",
"-2 -10",
"-1 -10",
"1 -10",
"1 -16",
"1 -27",
"1 -31",
"1 -40... |
p03852 AtCoder Beginner Contest 049 - UOIAUAI | Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
Constraints
* c is a lowercase English letter.
Input
The input is given from Standard Input in the following format:
c
Output
If c is a vowel, print `vowel`. Oth... | {
"input": [],
"output": []
} | {
"input": [
"s",
"z",
"a"
],
"output": [
"consonant",
"consonant",
"vowel"
]
} | {
"input": [
"t",
"o",
"y",
"`",
"r",
"x",
"b",
"q",
"w",
"_",
"p",
"{",
"^",
"|",
"]",
"n",
"}",
"\\",
"m",
"~",
"[",
"l",
"",
"Z",
"k",
"",
"Y",
"j",
"",
"X",
"i",
"",
"W",
"h"... |
p04019 AtCoder Grand Contest 003 - Wanna go back home | Snuke lives on an infinite two-dimensional plane. He is going on an N-day trip. At the beginning of Day 1, he is at home. His plan is described in a string S of length N. On Day i(1 ≦ i ≦ N), he will travel a positive distance in the following direction:
* North if the i-th letter of S is `N`
* West if the i-th letter... | {
"input": [],
"output": []
} | {
"input": [
"NSNNSNSN",
"NNEW",
"SENW",
"W"
],
"output": [
"Yes",
"No",
"Yes",
"No"
]
} | {
"input": [
"SEWN",
"NNDW",
"ESWN",
"NSNSNNSN",
"WNES",
"NEWS",
"ENWS",
"NWES",
"WNEN",
"SNEW",
"NWSE",
"SWNE",
"XNEN",
"SWEN",
"XNNE",
"NNXE",
"NENW",
"S",
"SNWE",
"NESW",
"WENS",
"NSWE",
"NENX",
"ENNX",
"EXNN",
... |
p00103 Baseball Simulation | Ichiro likes baseball and has decided to write a program which simulates baseball.
The program reads events in an inning and prints score in that inning. There are only three events as follows:
Single hit
* put a runner on the first base.
* the runner in the first base advances to the second base and the runner in t... | {
"input": [],
"output": []
} | {
"input": [
"2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT"
],
"output": [
"7\n0"
]
} | {
"input": [],
"output": []
} |
p00236 Alien Messages | Alien Mr.X left a message for Earthlings to commemorate the arrival of the planet on Earth. Mr.X chose "Tronco Ruins", which is famous as an ancient ruin, as the place to leave a message. This was a mysterious place where strange stone statues were randomly placed in the squares of the grid of various sizes.
As a mess... | {
"input": [],
"output": []
} | {
"input": [
"5 4\n0 0 0 0 0\n0 1 1 0 0\n0 0 1 0 1\n1 0 0 0 1\n5 4\n0 0 0 0 0\n0 1 1 0 0\n0 0 0 0 1\n1 0 0 0 1\n0 0"
],
"output": [
"Yes\nNo"
]
} | {
"input": [
"5 4\n0 0 0 0 0\n0 1 1 0 0\n0 0 1 0 1\n1 0 0 0 1\n5 4\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 1\n1 0 0 0 1\n0 0",
"5 4\n0 0 0 0 0\n0 1 1 0 0\n0 0 1 0 0\n1 0 0 0 1\n5 4\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 1\n1 0 0 0 1\n0 0",
"5 4\n0 0 0 0 0\n0 1 1 0 0\n0 0 1 0 1\n1 0 0 0 1\n5 4\n0 0 0 1 0\n0 1 0 0 0\n0 0 0 ... |
p00398 Road Construction | The Zuia Kingdom has finally emerged through annexation of $N$ cities, which are identified by index from $1$ to $N$. You are appointed the Minister of Transport of the newly born kingdom to construct the inter-city road network.
To simplify the conceptual design planning, you opted to consider each city as a point on... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2\n3 4\n3 2",
"5\n7 41\n10 0\n99 27\n71 87\n14 25",
"3\n1 2\n3 4\n10 1"
],
"output": [
"4",
"163",
"9"
]
} | {
"input": [
"3\n1 2\n3 4\n3 3",
"5\n7 60\n10 0\n99 27\n71 87\n14 25",
"3\n0 2\n3 4\n10 1",
"3\n1 2\n5 4\n3 3",
"5\n7 60\n10 0\n99 27\n71 87\n3 25",
"3\n-1 2\n3 4\n10 1",
"3\n1 0\n5 4\n3 3",
"5\n7 114\n10 0\n99 27\n71 87\n3 25",
"3\n-1 2\n3 4\n11 1",
"5\n8 114\n10 0\n99 27\n71 ... |
p00613 A Piece of Cake | In the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although cause of his shop's unpopularity is incredibly awful taste of its cakes, he never improved it. He was just growing hate... | {
"input": [],
"output": []
} | {
"input": [
"2\n2\n3\n5 4 3\n0"
],
"output": [
"2\n6"
]
} | {
"input": [
"2\n2\n3\n7 4 3\n0",
"2\n2\n0\n7 4 3\n0",
"2\n2\n3\n3 4 3\n0",
"2\n0\n0\n7 8 3\n0",
"2\n1\n3\n3 4 3\n0",
"2\n1\n0\n7 14 4\n0",
"2\n2\n3\n2 1 4\n0",
"2\n2\n3\n4 1 4\n0",
"2\n1\n3\n4 5 3\n0",
"2\n-1\n0\n7 14 4\n0",
"2\n1\n3\n2 5 1\n0",
"2\n4\n3\n4 1 4\n0",
... |
p00751 Old Memories | In 4272 A.D., Master of Programming Literature, Dr. Isaac Cornell Panther-Carol, who has miraculously survived through the three World Computer Virus Wars and reached 90 years old this year, won a Nobel Prize for Literature. Media reported every detail of his life. However, there was one thing they could not report -- ... | {
"input": [],
"output": []
} | {
"input": [
"1 4\nAABBCCDDEEFFGGHHIJJKKLLMMNNOOPP\nAABBCCDDEEFFGG\nCCDDEEFFGGHHII\nFFGGHHIIJJKKLL\nJJKKLLMMNNOOPP\n2 3\nABRACADABRA.ABBRACADABRA.\nABRACADABRA.A\n.ABRACADABRA.\nBRA.ABRACADAB\n2 2\nAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAA\nAAAAAAAAAAAAA\n2 3\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXAXXXXXX\nXXXXXXBXXXXXX\... | {
"input": [
"1 4\nAABBCCDDEEFFGGHHIJJKKLLMMNNOOPP\nAABBCCDDEEFFGG\nCCDDEEFFGGHHII\nFFGGHHIIJJKKLL\nJJKKLLMMNNOOPP\n2 3\nABRACADABRA.ABBRACADABRA.\nABRACADABRA.A\n.ABRADADABRA.\nBRA.ABRACADAB\n2 2\nAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAA\nAAAAAAAAAAAAA\n2 3\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXXXXXAXXXXXX\nXXXXXXBXXXXXX\... |
p00889 Find the Multiples | You are given a sequence a0a1...aN-1 digits and a prime number Q. For each i ≤ j with ai ≠ 0, the subsequence aiai+1...aj can be read as a decimal representation of a positive integer. Subsequences with leading zeros are not considered. Your task is to count the number of pairs (i, j) such that the corresponding subseq... | {
"input": [],
"output": []
} | {
"input": [
"3 32 64 7\n4 35 89 5\n5 555 442 3\n5 777 465 11\n100000 666 701622763 65537\n0 0 0 0"
],
"output": [
"2\n4\n6\n3\n68530"
]
} | {
"input": [
"3 32 64 13\n4 35 89 5\n5 555 442 3\n5 777 465 11\n100000 666 701622763 65537\n0 0 0 0",
"3 32 64 13\n4 35 89 5\n5 555 442 3\n5 777 465 9\n100000 666 701622763 65537\n0 0 0 0",
"3 32 64 13\n4 35 82 5\n5 555 442 3\n5 777 465 9\n100000 666 701622763 65537\n0 0 0 0",
"3 32 64 13\n4 35 82 5\n... |
p01020 Lonely Adventurer | Boy G was on a voyage with his father to celebrate his 13th birthday. However, during the voyage, unfortunately the ship was hit by a storm and the ship capsized. When he woke up, it was an uninhabited island. Partly due to the influence of the adventurer's father, he decided to live a survival life on an uninhabited i... | {
"input": [],
"output": []
} | {
"input": [
"4\n1 2 3 4",
"5\n3 3 3 3 3"
],
"output": [
"11",
"21"
]
} | {
"input": [
"4\n1 2 0 4",
"5\n5 3 3 3 3",
"4\n1 2 1 4",
"5\n4 3 3 3 3",
"4\n2 2 1 4",
"5\n4 3 6 3 3",
"5\n4 0 6 3 3",
"5\n4 0 4 3 3",
"4\n2 1 0 8",
"4\n2 1 -1 8",
"5\n4 0 7 3 1",
"5\n4 -2 10 3 1",
"4\n5 0 -2 8",
"4\n5 0 -2 7",
"4\n5 0 -2 6",
"5\n1 -2 18... |
p01153 Gather on the Clock | There is a self-playing game called Gather on the Clock.
At the beginning of a game, a number of cards are placed on a ring. Each card is labeled by a value.
In each step of a game, you pick up any one of the cards on the ring and put it on the next one in clockwise order. You will gain the score by the difference of... | {
"input": [],
"output": []
} | {
"input": [
"2\n4 0 1 2 3\n6 1 8 0 3 5 9"
],
"output": [
"6\n34"
]
} | {
"input": [
"2\n4 1 1 2 3\n6 1 8 0 3 5 9",
"2\n4 1 1 2 3\n6 1 8 0 3 1 9",
"2\n4 1 1 2 3\n6 1 8 0 3 0 9",
"2\n4 1 1 2 3\n4 1 8 0 3 0 9",
"2\n0 0 1 2 3\n6 1 8 0 3 5 9",
"2\n4 1 1 2 3\n6 1 8 0 3 1 5",
"2\n4 1 1 2 3\n6 1 8 -1 3 0 9",
"2\n4 1 1 2 3\n4 1 8 0 6 -1 9",
"2\n4 1 1 2 3\n3 1 ... |
p01292 Secret Operation | Mary Ice is a member of a spy group. She is about to carry out a secret operation with her colleague.
She has got into a target place just now, but unfortunately the colleague has not reached there yet. She needs to hide from her enemy George Water until the colleague comes. Mary may want to make herself appear in Geo... | {
"input": [],
"output": []
} | {
"input": [
"50 100\n2\n50 50 0\n51 51 50\n2\n0 0 0\n1 1 50\n0\n0 0"
],
"output": [
"50"
]
} | {
"input": [
"50 100\n2\n50 50 0\n51 51 50\n2\n0 -1 0\n1 1 50\n0\n0 0",
"50 000\n2\n50 50 0\n51 51 50\n2\n0 -1 0\n1 1 50\n0\n0 0",
"50 000\n2\n28 42 0\n90 26 50\n0\n1 -1 0\n1 1 7\n0\n1 0",
"50 100\n1\n50 50 0\n51 51 50\n2\n0 -1 0\n1 1 50\n0\n0 0",
"50 100\n1\n33 50 0\n51 51 50\n2\n0 -1 0\n2 2 50\n... |
p01461 Multi Ending Story | You are a programmer who loves bishojo games (a sub-genre of dating simulation games). A game, which is titled "I * C * P * C!" and was released yesterday, has arrived to you just now. This game has multiple endings. When you complete all of those endings, you can get a special figure of the main heroine, Sakuya. So, y... | {
"input": [],
"output": []
} | {
"input": [
"5\n5 2\n3 5\n5 4\n5 5",
"4\n2 3\n4 4\n4 4"
],
"output": [
"8",
"6"
]
} | {
"input": [
"4\n3 3\n4 4\n4 4",
"5\n5 4\n3 5\n5 4\n5 5",
"4\n2 3\n4 3\n4 4",
"5\n5 5\n1 0\n5 4\n5 5",
"5\n3 3\n0 0\n5 4\n5 5",
"5\n5 4\n1 5\n5 4\n5 5",
"5\n5 4\n1 3\n5 4\n5 5",
"5\n5 4\n1 0\n5 4\n5 5",
"5\n5 4\n2 0\n5 4\n5 5",
"5\n5 4\n3 5\n6 4\n5 5",
"5\n5 4\n1 5\n5 8\n5 ... |
p01620 King's Inspection | A great king of a certain country suddenly decided to visit the land of a friendly country. The country is famous for trains, and the king visits various stations.
There are 52 train stations, each with a single uppercase or lowercase alphabetic name (no overlapping names). The line of this train is circular, with sta... | {
"input": [],
"output": []
} | {
"input": [
"2\n1 2\nbdd\n3\n3 2 1\nDDDA\n5\n3 1 4 5 3\ndcdkIlkP\n0"
],
"output": [
"abc\nABCx\nabZfFijL"
]
} | {
"input": [
"2\n1 2\nbdd\n3\n3 2 1\nDDDA\n5\n3 1 4 5 2\ndcdkIlkP\n0",
"2\n1 2\nbdd\n3\n3 2 2\nDDDA\n5\n3 1 4 5 2\ndcdkIlkP\n0",
"2\n1 2\nbdd\n3\n5 2 2\nDDDA\n5\n3 1 4 5 2\ndcdkIlkP\n0",
"2\n1 2\nddb\n3\n3 2 1\nDDDA\n5\n3 1 4 5 3\ndcdkIlkP\n0",
"2\n1 2\nbcd\n3\n3 2 1\nDDDA\n5\n3 1 4 5 2\ndcdkIlkP\... |
p01773 Cram School Schedule | B: Cram School Schedule / Cram School Timetable
story
You are the owner of a cram school. Your cram school is a private lesson system with one student and one teacher. The teachers at this cram school are very good and can teach all classes regardless of the subject. Also, because teachers and students are very tough... | {
"input": [],
"output": []
} | {
"input": [
"2 10:00-11:30 12:00-13:00\n2\n1 10:00-15:00\n2 09:00-12:00 18:10-18:55\n2\n2 10:00-13:00 15:30-16:40\n3 06:00-08:00 12:00-13:10 15:00-17:00"
],
"output": [
"2"
]
} | {
"input": [
"2 10:00-11:30 12:00-13:00\n2\n1 10:00-15:00\n2 09:00-12:00 18:10-18:55\n2\n2 10:00-13:00 15:30-16:40\n3 06:80-00:00 12:00-13:10 15:00-17:00",
"2 10:00-11:30 00:31-00:21\n2\n1 10:00-15:00\n2 09:00-12:00 18:10-18:55\n2\n2 10:00-13:00 15:30-16:40\n3 06:00-08:00 12:00-13:10 15:00-17:00",
"2 10:0... |
p01907 Fractal Tree | problem
AOR Ika likes rooted trees with a fractal (self-similar) structure. Consider using the weighted rooted tree $ T $ consisting of $ N $ vertices to represent the rooted tree $ T'$ with the following fractal structure.
* $ T'$ is the addition of a tree rooted at $ x $ and having a tree structure similar to $ T $... | {
"input": [],
"output": []
} | {
"input": [
"0.75\n4\n1 2 1\n2 3 3\n3 4 10"
],
"output": [
"24.8569335938"
]
} | {
"input": [
"0.75\n4\n1 2 1\n2 3 3\n3 4 20",
"0.75\n4\n1 2 1\n2 3 3\n3 4 26",
"0.75\n4\n1 2 1\n2 3 3\n3 4 15",
"1.2394215424675763\n4\n1 2 1\n2 3 3\n3 4 20",
"1.2394215424675763\n4\n1 3 1\n2 3 3\n3 4 20",
"0.75\n4\n1 2 0\n2 3 3\n3 4 26",
"1.2394215424675763\n4\n1 2 1\n2 3 3\n1 4 20",
... |
p02045 Poison Swamp | Poisonous swamp
You are playing a retro role-playing game. The field of this game is a grid of 100 squares vertically and 100 squares horizontally. The cells in the xth column from the left and the yth row from the top of this field are represented as (x, y). The character you control is on one of the squares in the f... | {
"input": [],
"output": []
} | {
"input": [
"2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 10\n1 1\n100 1\n50 20\n50 80\n51 21\n51 1\n0"
],
"output": [
"5\n174"
]
} | {
"input": [
"2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 10\n1 1\n100 1\n53 20\n50 80\n51 21\n51 1\n0",
"2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 18\n1 1\n100 1\n53 20\n50 80\n51 21\n51 1\n0",
"2\n3 3 5 7\n3 3\n7 3\n7 7\n5\n1 10 100 18\n1 1\n100 1\n53 3\n50 80\n51 21\n51 1\n0",
"2\n3 3 7 7\n3 3\n7 3\n7 7\n5... |
p02188 Restricted DFS | G: Restricted DFS
problem
There is an undirected tree G that consists of N vertices N-1 edges and has no self-loops or multiple edges. The vertices are each numbered from 1 to N, the edges are also numbered from 1 to N-1, and the i-th edge connects u_i and v_i. A non-negative integer A_i is assigned to the i-th verte... | {
"input": [],
"output": []
} | {
"input": [
"3\n1 2 3\n1 2\n1 3"
],
"output": [
"2\n3\n3"
]
} | {
"input": [
"3\n1 1 3\n1 2\n1 3",
"3\n1 1 3\n1 2\n2 3",
"3\n1 2 3\n1 2\n2 3",
"3\n1 0 3\n1 2\n2 3",
"3\n1 2 0\n1 2\n1 3",
"3\n1 3 3\n1 2\n2 3",
"3\n2 2 0\n1 2\n1 3",
"3\n2 2 1\n1 2\n1 3",
"3\n1 0 0\n1 2\n1 3",
"3\n1 0 5\n1 3\n2 3",
"3\n2 2 0\n1 2\n2 3",
"3\n0 2 1\n1 2\... |
p02330 Coin Combination Problem II | You have N coins each of which has a value ai. Find the number of combinations that result when you choose K different coins in such a way that the total value of the coins is greater than or equal to L and less than or equal to R.
Constraints
* 1 ≤ K ≤ N ≤ 40
* 1 ≤ ai ≤ 1016
* 1 ≤ L ≤ R ≤ 1016
* All input values are... | {
"input": [],
"output": []
} | {
"input": [
"5 2 7 19\n3 5 4 2 2",
"2 2 1 9\n5 1"
],
"output": [
"5",
"1"
]
} | {
"input": [
"5 2 7 19\n6 5 4 2 2",
"2 2 2 9\n5 1",
"5 2 7 19\n2 5 4 2 2",
"2 2 2 9\n9 1",
"5 4 7 19\n2 5 4 2 2",
"5 2 7 19\n3 5 4 2 3",
"5 3 7 19\n6 5 1 2 2",
"5 4 7 19\n1 5 1 2 -1",
"5 3 7 17\n0 5 4 2 3",
"2 1 1 9\n6 1",
"2 2 2 9\n9 2",
"5 4 7 19\n1 5 4 2 2",
"2 2... |
p02475 Division of Big Integers | Division of Big Integers
Given two integers $A$ and $B$, compute the quotient, $\frac{A}{B}$. Round down to the nearest decimal.
Input
Two integers $A$ and $B$ separated by a space character are given in a line.
Output
Print the quotient in a line.
Constraints
* $-1 \times 10^{1000} \leq A, B \leq 10^{1000}$
* $... | {
"input": [],
"output": []
} | {
"input": [
"5 8"
],
"output": [
"0"
]
} | {
"input": [
"5 16",
"9 6",
"18 6",
"18 3",
"21 3",
"21 4",
"16 4",
"2 1",
"52 6",
"36 4",
"-1 1",
"18 1",
"36 1",
"21 1",
"45 1",
"11 1",
"29 1",
"-2 1",
"4 -1",
"3 -1",
"14 1",
"22 1",
"17 1",
"28 1",
"21 2",
"-6... |
cbars | A few days ago Chef decided to cook a new dish – chocolate. This must be something amazing. The idea is that chocolate bar will be divided into cells. It must be long, but narrow. To interest customers every bar must be unique. Bar will consist of cells of black or white chocolate. In addition every bar must be good l... | {
"input": [],
"output": []
} | {
"input": [
"2 2",
"3 3"
],
"output": [
"14",
"322"
]
} | {
"input": [],
"output": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.