name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
pour1
Given two vessels, one of which can accommodate a liters of water and the other which can accommodate b liters of water, determine the number of steps required to obtain exactly c liters of water in one of the vessels. At the beginning both vessels are empty. The following operations are counted as 'steps': emptying...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n2\n3\n2\n3\n4" ], "output": [ "2\n-1\n" ] }
{ "input": [ "2\n5\n2\n3\n2\n2\n4", "2\n5\n2\n6\n2\n3\n4", "2\n5\n1\n3\n2\n2\n4", "2\n5\n3\n3\n1\n2\n4", "2\n4\n1\n6\n2\n2\n2", "2\n5\n3\n4\n1\n2\n4", "2\n4\n1\n2\n2\n2\n2", "2\n5\n2\n3\n4\n3\n4", "2\n1\n3\n3\n3\n4\n4", "2\n5\n4\n6\n3\n4\n1", "2\n4\n3\n2\n1\n4\n3", "2\n...
submat
Problem description. A matrix of dimension mxn containing only 0's and 1's as it elements is given.Determine the maximum possible sub-square matrix containing only 1's as its elements Input Input description. The first line of input contains an integer T,denoting the number of test cases First line of each test cas...
{ "input": [], "output": [] }
{ "input": [ "3\n3 3 \n1 0 0\n0 1 0\n0 0 1\n3 3\n0 0 0\n0 0 0\n0 0 0\n4 5\n1 0 0 0 0\n1 0 1 1 0\n0 1 1 1 1\n0 1 0 0 0" ], "output": [ "1\n0\n2" ] }
{ "input": [], "output": [] }
100_F. Polynom
You are given a polynom in form p(x) = (x + a1)·(x + a2)·... (x + an). Write Pike program to print it in a standard form p(x) = xn + b1xn - 1 + ... + bn - 1x + bn. You should write each addend in form «C*X^K» (for example, 5*X^8). Please, write the polynom in the shortest way, so you should skip unnecessary terms: som...
{ "input": [], "output": [] }
{ "input": [ "2\n-1\n1\n", "2\n1\n1\n" ], "output": [ "X^2-1\n", "X^2+2*X+1\n" ] }
{ "input": [], "output": [] }
130_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 2 Output 6 Input 5 Output 45
{ "input": [], "output": [] }
{ "input": [ "2\n", "5\n" ], "output": [ "6\n", "45\n" ] }
{ "input": [], "output": [] }
1331_D. Again?
Input The only line of the input contains a 7-digit hexadecimal number. The first "digit" of the number is letter A, the rest of the "digits" are decimal digits 0-9. Output Output a single integer. Examples Input A278832 Output 0 Input A089956 Output 0 Input A089957 Output 1 Input A1440...
{ "input": [], "output": [] }
{ "input": [ "A089956\n", "A089957\n", "A144045\n", "A278832\n" ], "output": [ "0\n", "1\n", "1\n", "0\n" ] }
{ "input": [ "A089946\n", "A144035\n", "A378822\n", "A089947\n", "A378282\n", "A079948\n", "A388282\n", "A079848\n", "A388822\n", "A079849\n", "B388822\n", "A079749\n", "B398822\n", "A079759\n", "A989056\n", "A089857\n", "A154044\n", "A089936\n",...
163_E. e-Government
The best programmers of Embezzland compete to develop a part of the project called "e-Government" — the system of automated statistic collecting and press analysis. We know that any of the k citizens can become a member of the Embezzland government. The citizens' surnames are a1, a2, ..., ak. All surnames are differen...
{ "input": [], "output": [] }
{ "input": [ "7 3\na\naa\nab\n?aaab\n-2\n?aaab\n-3\n?aaab\n+2\n?aabbaa\n" ], "output": [ "6\n4\n3\n6\n" ] }
{ "input": [ "7 3\na\naa\nab\n?aaab\n-2\n?aaab\n-1\n?aaab\n+2\n?aabbaa\n", "7 3\nb\naa\nab\n?aaab\n-2\n?aaab\n-1\n?aaab\n+2\n?aabbaa\n", "7 3\nb\naa\nab\n?aaab\n-2\n?aaab\n-2\n?aaab\n+2\n?aabbaa\n", "7 3\na\naa\nbb\n?aaab\n-2\n?aaab\n-3\n?aaab\n+2\n?aabbaa\n", "7 3\nb\naa\nab\n?caab\n-2\n?aaab\n-2...
683_C. Symmetric Difference
You are given two sets of numbers. Your task is to print all numbers from the sets, that both sets don't contain simultaneously. Input The first line contains the description of the first set, the second line contains the description of the second set. Each description begins with the number of elements in this set. ...
{ "input": [], "output": [] }
{ "input": [ "3 1 2 3\n3 2 3 4\n", "5 1 4 8 9 10\n4 1 2 8 10\n" ], "output": [ "2 1 4", "3 2 4 9" ] }
{ "input": [], "output": [] }
cakewalk-3
You are given a collection of words, say as in a dictionary. You can represent it in the following compressed form: The first word will be followed by a sequence of pair of a integer (x) and a word. The number in the pair is the position till which the previous word's characters are included in the new word and ...
{ "input": [], "output": [] }
{ "input": [ "4\nzebra\n3 u\n2 nith\n1 iggurat\n\nSAMPLE" ], "output": [ "ziggurat\n" ] }
{ "input": [ "4\nzebra\n3 u\n2 htin\n1 iggurat\n\nSAMPLE", "4\nzebra\n3 u\n2 htin\n1 taruggi\n\nSAMPLE", "4\nzebra\n3 u\n2 htin\n0 taruggi\n\nSAMPLE", "4\nzebra\n3 u\n2 htin\n0 tasuggi\n\nSAMPLE", "4\nzebra\n3 u\n2 nith\n1 iggusat\n\nSAMPLE", "4\nzebra\n3 u\n2 nith\n1 iggusau\n\nSAMPLE", "...
use-bit
The problem statement is simple. You are given a string and you are supposed to print all the distinct permutations of the string, as they would appear in an dictionary. INPUT The first and only line of the input contains a single string, S. OUTPUT The output contains the required strings, each string in a seperate...
{ "input": [], "output": [] }
{ "input": [ "abc\n\nSAMPLE" ], "output": [ "abc\nacb\nbac\nbca\ncab\ncba" ] }
{ "input": [ "`bc\n\nSAMPLE", "`cc\n\nELPMAS", "`dc\n\nELPMAS", "adc\n\nELPM@S", "aec\n\nTON@LE", "cbd\n\nTONEL@", "cbc\n\nTONEL@", "bbc\n\nOTNFL@", "bac\n\n@NNFNT", "dbb\n\n@NNFNT", "bad\n\nN@FNNS", "bea\n\nSNOF@N", "ce`\n\nSNPG@N", "fac\n\nTNQH@N", "cag\n\...
p02592 AtCoder Grand Contest 047 - Product Simulation
This is an output-only problem. You shouldn't read anything from the input. In short, your task is to simulate multiplication by using only comparison (x < y) and addition (x + y). There is no input in this problem, you just print a sequence of operations. Imagine that there is a big array a[0], a[1], ..., a[N-1] of ...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p02723 AtCoder Beginner Contest 160 - Coffee
A string of length 6 consisting of lowercase English letters is said to be coffee-like if and only if its 3-rd and 4-th characters are equal and its 5-th and 6-th characters are also equal. Given a string S, determine whether it is coffee-like. Constraints * S is a string of length 6 consisting of lowercase English l...
{ "input": [], "output": [] }
{ "input": [ "coffee", "sippuu", "iphone" ], "output": [ "Yes", "Yes", "No" ] }
{ "input": [ "cofgee", "sjppvv", "uuppis", "ephoni", "cofgef", "uvppis", "eohoni", "fegfoc", "sippvu", "inohoe", "fegeoc", "uvppjs", "innhoe", "feoegc", "sjppvu", "innhof", "ffoegc", "fohnni", "gfoegc", "vvppjs", "fohnnh", "gfogec...
p02854 DISCO Presents Discovery Channel Code Contest 2020 Qual - Iron Bar Cutting
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be po...
{ "input": [], "output": [] }
{ "input": [ "3\n2 4 3", "12\n100 104 102 105 103 103 101 105 104 102 104 101" ], "output": [ "3", "0" ] }
{ "input": [ "3\n2 5 3", "12\n100 104 102 105 103 103 100 105 104 102 104 101", "3\n2 8 3", "12\n100 104 102 105 103 103 100 117 104 102 104 101", "3\n2 8 2", "12\n101 104 102 105 103 103 100 117 104 102 104 101", "12\n101 104 102 105 103 103 100 117 104 102 104 111", "3\n2 0 4", "...
p02990 AtCoder Beginner Contest 132 - Blue and Red Balls
There are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls. First, Snuke will arrange the N balls in a row from left to right. Then, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive ...
{ "input": [], "output": [] }
{ "input": [ "5 3", "2000 3" ], "output": [ "3\n6\n1", "1998\n3990006\n327341989" ] }
{ "input": [ "7 3", "1776 3", "7 5", "195 3", "5 5", "206 3", "96 3", "96 2", "2000 1", "7 4", "1776 1", "7 2", "203 3", "206 4", "72 3", "14 4", "5 2", "203 5", "158 4", "115 3", "14 5", "203 7", "158 7", "14 9", "203...
p03131 Yahoo Programming Contest 2019 - When I hit my pocket...
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maxi...
{ "input": [], "output": [] }
{ "input": [ "4 2 6", "7 3 4", "314159265 35897932 384626433" ], "output": [ "7", "8", "48518828981938099" ] }
{ "input": [ "5 2 6", "7 5 4", "314159265 35897932 35610649", "5 3 6", "7 1 4", "3 3 6", "407766107 35897932 14836778", "7 2 6", "407766107 9307229 14836778", "407766107 9307229 25447105", "296771207 9307229 25447105", "513602852 9307229 25447105", "513602852 930722...
p03274 AtCoder Beginner Contest 107 - Candles
There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light...
{ "input": [], "output": [] }
{ "input": [ "8 5\n-9 -7 -4 -3 1 2 3 4", "5 3\n-30 -10 10 20 50", "1 1\n0", "3 2\n10 20 30" ], "output": [ "10", "40", "0", "20" ] }
{ "input": [ "8 5\n-9 -7 -4 -3 1 2 4 4", "5 5\n-30 -10 10 20 50", "3 2\n10 18 30", "5 3\n-30 -5 10 20 50", "3 2\n10 20 43", "8 1\n-9 -7 -4 -3 1 2 4 4", "5 5\n-30 -10 8 20 76", "5 5\n-19 -10 8 20 76", "8 4\n-14 -7 -4 -11 1 2 3 4", "5 4\n-30 -5 16 20 67", "8 4\n-14 -7 -4 -11 ...
p03431 AtCoder Grand Contest 021 - Ball Eat Chameleons
In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage. A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules: * A Snuke Chameleon that is blue will change its color to ...
{ "input": [], "output": [] }
{ "input": [ "8 10", "3 7", "123456 234567", "8 3", "2 4" ], "output": [ "46", "57", "857617983", "0", "7" ] }
{ "input": [ "8 5", "0 7", "25732 234567", "0 5", "3 4", "0 11", "29001 234567", "4 7", "2 5", "4 8", "3 5", "4 12", "3 6", "4 18", "7 10", "4 13", "7 7", "4 15", "4 17", "7 17", "7 21", "10 21", "4 21", "2 21", "1 21"...
p03590 Tenka1 Programmer Beginner Contest - IntegerotS
Seisu-ya, a store specializing in non-negative integers, sells N non-negative integers. The i-th integer is A_i and has a utility of B_i. There may be multiple equal integers with different utilities. Takahashi will buy some integers in this store. He can buy a combination of integers whose bitwise OR is less than or ...
{ "input": [], "output": [] }
{ "input": [ "3 6\n3 3\n4 4\n2 5", "7 14\n10 5\n7 4\n11 4\n9 8\n3 6\n6 2\n8 9", "3 5\n3 3\n4 4\n2 5" ], "output": [ "9", "32", "8" ] }
{ "input": [ "3 6\n3 1\n4 4\n2 5", "7 14\n10 4\n7 4\n11 4\n9 8\n3 6\n6 2\n8 9", "3 1\n3 3\n4 4\n2 5", "3 6\n4 1\n4 4\n2 5", "7 14\n10 4\n7 4\n11 1\n9 8\n3 6\n6 2\n8 9", "7 14\n10 4\n7 4\n11 1\n9 8\n3 6\n6 2\n8 0", "7 14\n10 4\n7 8\n11 1\n9 8\n3 6\n8 2\n8 0", "7 14\n10 4\n7 8\n11 1\n9 8...
p03747 AtCoder Grand Contest 013 - Ants on a Circle
There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coor...
{ "input": [], "output": [] }
{ "input": [ "4 20 9\n7 2\n9 1\n12 1\n18 1", "3 8 3\n0 1\n3 2\n6 1" ], "output": [ "7\n18\n18\n1", "1\n3\n0" ] }
{ "input": [ "3 8 3\n0 2\n3 2\n6 1", "4 20 18\n7 2\n9 1\n12 1\n18 1", "2 8 3\n0 1\n3 2\n6 1", "3 8 3\n1 2\n3 2\n6 1", "4 20 18\n3 2\n9 1\n12 1\n18 1", "1 8 3\n1 2\n3 2\n6 1", "1 8 0\n1 2\n3 4\n6 1", "1 8 1\n1 2\n3 4\n6 1", "2 8 3\n1 1\n3 2\n6 1", "1 5 3\n1 2\n6 2\n6 1", "1 ...
p03909 CODE FESTIVAL 2016 Final - Where's Snuke?
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. <image> Exactly one of...
{ "input": [], "output": [] }
{ "input": [ "15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake s...
{ "input": [ "15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake s...
p00013 Switching Railroad Cars
<image> This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top-right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. We can simulate the movement (comings an...
{ "input": [], "output": [] }
{ "input": [ "1\n6\n0\n8\n10\n0\n0\n0" ], "output": [ "6\n10\n8\n1" ] }
{ "input": [ "1\n6\n0\n8\n10\n0\n1\n0", "1\n6\n-1\n8\n10\n0\n1\n0", "1\n4\n-1\n8\n10\n0\n1\n-1", "1\n7\n-1\n13\n9\n0\n1\n-2", "1\n3\n0\n8\n10\n0\n0\n0", "1\n2\n0\n8\n10\n0\n1\n0", "1\n4\n-1\n8\n17\n0\n1\n-1", "1\n7\n0\n13\n9\n0\n1\n-2", "1\n6\n-2\n18\n1\n0\n1\n-2", "1\n3\n0\n8\...
p00145 Cards
There is a set of cards with positive integers written on them. Stack the cards to make several piles and arrange them side by side. Select two adjacent piles of cards from them, and stack the left pile on top of the right pile. Repeat this operation until there is only one pile of cards. When stacking two piles of ca...
{ "input": [], "output": [] }
{ "input": [ "3\n3 5\n2 8\n5 4" ], "output": [ "440" ] }
{ "input": [ "3\n3 5\n2 16\n5 4", "3\n2 5\n2 16\n5 4", "3\n2 5\n4 16\n5 4", "3\n2 9\n4 16\n5 4", "3\n2 9\n6 16\n5 4", "3\n2 9\n6 11\n5 4", "3\n2 9\n6 18\n5 4", "3\n2 9\n6 18\n10 4", "3\n0 9\n6 18\n10 4", "3\n2 21\n0 48\n-1 9", "3\n2 21\n0 48\n-1 12", "3\n4 21\n0 48\n-1 ...
p00278 Study Session
At Akabe High School, a programmer training school, there is a unique study session run by the students themselves. It is important for programmers to constantly adopt new technologies, so the aim of this activity is to develop the habit of self-study through this study session. There are a total of N students, each w...
{ "input": [], "output": [] }
{ "input": [ "5 8\n5\n10\n8\n7\n3\nADD 1\nADD 3\nCHECK 0\nCHECK 1\nCHECK 2\nCHECK 3\nCHECK 4\nCHECK 5" ], "output": [ "NA\n2\n1\n0\n0\n0" ] }
{ "input": [ "5 8\n5\n10\n8\n7\n3\nADD 1\nADD 3\nCHECK 0\nCHECK 1\nCHECK 2\nCHFCK 3\nCHECK 4\nCHECK 5", "5 8\n5\n10\n8\n3\n3\nADD 1\nADD 3\nCHECK 0\nCHECK 1\nCHECK 2\nCHFCK 3\nCHECK 4\nCHECK 5", "5 8\n5\n10\n8\n3\n3\nADD 1\nADD 3\nCHECK 0\nCHECK 1\nCHEBK 2\nCHFCK 0\nCHECK 4\nCHECK 5", "5 8\n5\n10\n8\n...
p00466 Receipt
problem Taro bought 10 books. Later, I tried to find out the price based on the receipt, but the receipt was dirty and I could not read the price of a book. We decided to calculate the price of the book from the total price of 10 books and the prices of the other 9 books. Write a program that outputs the price of the...
{ "input": [], "output": [] }
{ "input": [ "9850\n1050\n800\n420\n380\n600\n820\n2400\n1800\n980\n0" ], "output": [ "600" ] }
{ "input": [ "9850\n1050\n800\n420\n380\n600\n820\n2400\n2983\n980\n0", "9850\n372\n800\n420\n380\n600\n820\n2400\n2983\n980\n0", "9850\n372\n800\n420\n380\n600\n820\n2795\n2983\n980\n0", "9850\n372\n800\n420\n380\n600\n946\n2795\n2983\n980\n0", "9850\n372\n800\n203\n380\n600\n946\n2795\n2983\n980...
p00657 Rearranging Seats
Haruna is a high school student. She must remember the seating arrangements in her class because she is a class president. It is too difficult task to remember if there are so many students. That is the reason why seating rearrangement is depress task for her. But students have a complaint if seating is fixed. One da...
{ "input": [], "output": [] }
{ "input": [ "1 1\n2 2\n0 0" ], "output": [ "no\nyes" ] }
{ "input": [ "2 1\n2 2\n0 0", "1 1\n2 0\n0 0", "3 1\n3 1\n0 0", "4 1\n1 1\n0 0", "3 0\n0 0\n0 0", "3 1\n0 0\n0 0", "4 1\n2 2\n0 0", "2 1\n2 3\n0 0", "1 1\n3 0\n0 0", "1 1\n4 0\n0 0", "1 2\n4 0\n0 0", "1 1\n1 2\n0 0", "2 1\n3 2\n0 0", "4 2\n2 2\n0 0", "1 1\n6...
p00801 Numoeba
A scientist discovered a strange variation of amoeba. The scientist named it numoeba. A numoeba, though it looks like an amoeba, is actually a community of cells, which always forms a tree. The scientist called the cell leader that is at the root position of the tree. For example, in Fig. 1, the leader is A. In a numo...
{ "input": [], "output": [] }
{ "input": [ "3\n5\n7\n15\n655\n2711\n6395\n7195\n8465\n0" ], "output": [ "2 3\n1 1\n9 11\n105 65\n398 332\n415 332\n430 332\n428 332\n190 421" ] }
{ "input": [ "3\n0\n7\n15\n655\n2711\n6395\n7195\n8465\n0", "3\n5\n7\n15\n655\n2711\n6395\n7195\n12527\n0", "3\n1\n0\n20\n48\n51\n2841\n107\n4773\n-2", "3\n1\n2\n0\n96\n75\n5541\n7\n97\n-2", "3\n2\n0\n27\n8\n17\n1404\n78\n1160\n-1", "3\n1\n1\n41\n818\n3\n18962\n0\n3838\n1", "3\n1\n1\n41\n3...
p00932 Sweet War
Example Input 2 5 4 5 7 4 8 Output 8 7
{ "input": [], "output": [] }
{ "input": [ "2 5 4\n5 7\n4 8" ], "output": [ "8 7" ] }
{ "input": [ "2 5 4\n5 7\n4 6", "2 2 4\n5 8\n4 6", "3 0 4\n0 3\n4 6", "3 -1 4\n0 6\n4 6", "3 -1 4\n0 6\n4 8", "3 -1 4\n0 6\n1 11", "3 5 4\n5 7\n4 8", "2 2 4\n5 7\n4 5", "3 3 4\n5 8\n4 0", "3 2 4\n5 15\n4 6", "3 2 4\n0 8\n4 8", "3 -1 4\n0 3\n4 11", "1 -1 4\n0 6\n4 6"...
p01065 Barter
Problem Nanatsu has x Umaka sticks and y puffs. There are n candy exchangers. Each exchanger i * Nanatsu-kun's Umaka stick ai book and exchanger's Fugashi bi book * Nanatsu-kun's Fugashi ci book and exchanger's pig meso di pieces It will be exchanged only once by either one of the methods. Under this constraint,...
{ "input": [], "output": [] }
{ "input": [ "4\n5 0\n5 1 1 1\n2 1 2 1\n4 1 1 1\n3 1 3 1", "3\n3 3\n3 2 4 1\n5 1 2 1\n3 1 3 2", "3\n3 4\n3 1 3 1\n3 1 4 1\n3 1 2 1", "4\n0 0\n1 10 1 10\n2 5 2 5\n3 25 5 6\n1 15 2 20" ], "output": [ "2", "3", "2", "0" ] }
{ "input": [ "4\n10 0\n5 1 1 1\n2 1 2 1\n4 1 1 1\n3 1 3 1", "3\n3 4\n3 2 4 1\n5 1 2 1\n3 1 3 2", "3\n3 4\n3 1 3 1\n3 1 4 1\n3 1 3 1", "4\n0 0\n1 10 1 10\n2 5 2 5\n3 25 0 6\n1 15 2 20", "4\n0 1\n1 10 1 10\n2 5 4 5\n2 25 0 6\n1 24 2 20", "3\n3 5\n2 0 8 1\n5 0 2 -1\n3 2 3 0", "3\n3 6\n1 0 6 2...
p01198 Dock to the Future
You had long wanted a spaceship, and finally you bought a used one yesterday! You have heard that the most difficult thing on spaceship driving is to stop your ship at the right position in the dock. Of course you are no exception. After a dozen of failures, you gave up doing all the docking process manually. You began...
{ "input": [], "output": [] }
{ "input": [ "1\n3\n2 4 6\n4\n10 100\n2 3\n10 6\n7 6" ], "output": [ "crash\ntry again\ngood 1.000\nperfect" ] }
{ "input": [ "1\n3\n2 1 6\n4\n10 100\n2 3\n10 6\n7 6", "1\n3\n2 0 6\n4\n10 100\n2 3\n10 6\n7 6", "1\n3\n2 4 6\n4\n10 100\n2 3\n10 4\n7 6", "1\n3\n2 1 6\n4\n10 100\n2 3\n10 12\n7 6", "1\n3\n1 4 6\n4\n10 100\n2 3\n10 4\n7 6", "1\n3\n2 1 6\n4\n10 100\n2 3\n10 12\n7 7", "1\n1\n1 2 6\n4\n10 100...
p01335 K Poker
Description In 200X, the mysterious circle K, which operates at K University, announced K Poker, a new game they created on the 4th floor of K East during the university's cultural festival. At first glance, this game is normal poker, but it is a deeper game of poker with the addition of basic points to the cards. The...
{ "input": [], "output": [] }
{ "input": [ "3\n0 1 0 1 0 0 0 0 0 1 0 0 0\n1 0 0 0 0 0 1 0 0 1 0 0 2\n0 1 1 0 1 1 1 0 0 0 0 5 5\n3 1 1 1 0 1 0 0 1 0 3 0 2\n1 1 2 4 5 10 20 50 100\n7H 6H 2H 5H 3H\n9S 9C 9H 8H 8D\nKS KH QH JD TS\n10\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 2 3...
{ "input": [ "3\n0 1 0 1 0 0 0 0 0 1 0 0 0\n1 0 0 0 0 0 1 0 0 1 0 0 2\n0 1 1 0 1 1 1 0 0 0 0 5 5\n3 1 1 1 0 1 0 0 1 0 3 0 2\n1 0 2 4 5 10 20 50 100\n7H 6H 2H 5H 3H\n9S 9C 9H 8H 8D\nKS KH QH JD TS\n10\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 2 3...
p01502 Sightseeing Tour
Example Input 3 0 2 7 2 0 4 5 8 0 Output 11
{ "input": [], "output": [] }
{ "input": [ "3\n0 2 7\n2 0 4\n5 8 0" ], "output": [ "11" ] }
{ "input": [ "3\n0 3 7\n2 0 4\n5 8 0", "3\n0 3 7\n0 0 4\n5 8 0", "3\n-1 2 7\n2 0 4\n9 8 1", "3\n0 3 7\n4 0 4\n5 8 0", "3\n-1 6 2\n2 0 4\n5 8 1", "3\n0 0 7\n16 0 4\n6 8 0", "3\n-1 2 7\n2 0 4\n0 8 1", "3\n0 3 7\n4 0 4\n10 8 0", "3\n-1 6 1\n2 0 4\n5 8 1", "3\n0 3 10\n4 0 4\n10 8 0...
p01673 Revenge of Minimum Cost Flow
G - Revenge of Minimum Cost Flow Problem Statement Flora is a freelance carrier pigeon. Since she is an excellent pigeon, there are too much task requests to her. It is impossible to do all tasks, so she decided to outsource some tasks to Industrial Carrier Pigeon Company. There are N cities numbered from 0 to N-1. ...
{ "input": [], "output": [] }
{ "input": [ "2 2 0 1 5\n0 1 3 0 3\n0 1 2 1 6" ], "output": [ "9" ] }
{ "input": [ "3 2 0 1 5\n0 1 3 0 3\n0 1 2 1 6", "3 2 0 1 3\n0 1 3 0 3\n0 1 2 1 6", "2 2 0 1 2\n0 1 3 0 3\n0 1 2 1 6", "3 2 0 1 3\n0 1 3 0 3\n0 1 1 1 6", "3 3 0 1 5\n0 0 3 0 3\n0 1 2 1 6", "3 3 1 1 5\n0 0 3 0 3\n0 1 2 1 6", "2 2 0 1 4\n0 1 3 0 3\n0 1 2 1 6", "3 3 0 1 5\n0 0 3 0 3\n0 1 4...
p01815 Escape
Escape An undirected graph with positive values ​​at the vertices is given. The vertices are numbered from 1 to N, and the i-th vertex has a value of w_i. You can start from the first vertex and move on the graph with the constraint that you cannot pass the edge that you just passed. At each vertex, you can get the sc...
{ "input": [], "output": [] }
{ "input": [ "6 6\n1 2 3 4 5 6\n1 2\n2 3\n3 4\n1 4\n4 5\n5 6" ], "output": [ "21" ] }
{ "input": [ "6 6\n1 2 3 4 5 6\n1 2\n2 3\n3 4\n1 1\n4 5\n5 6", "6 6\n1 3 3 4 5 6\n1 2\n2 3\n3 4\n1 1\n4 5\n5 6", "6 10\n1 3 3 1 5 6\n1 2\n2 3\n2 4\n1 1\n4 5\n5 6", "6 6\n2 4 3 4 5 6\n1 2\n2 3\n3 4\n1 3\n4 5\n5 6", "6 10\n1 3 3 4 10 6\n1 3\n2 3\n3 4\n1 1\n4 5\n5 6", "6 10\n0 5 3 1 5 6\n1 2\n2 3...
p01950 Endless BFS
Mr. Endo wanted to write the code that performs breadth-first search (BFS), which is a search algorithm to explore all vertices on an undirected graph. An example of pseudo code of BFS is as follows: 1: $current \leftarrow \{start\_vertex\}$ 2: $visited \leftarrow current$ 3: while $visited \ne $ the set of all the v...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 2\n2 3\n3 4\n4 1", "4 3\n1 2\n2 3\n3 4", "3 3\n1 2\n1 3\n2 3", "8 9\n2 1\n3 5\n1 6\n2 5\n3 1\n8 4\n2 7\n7 1\n7 4" ], "output": [ "-1", "-1", "2", "3" ] }
{ "input": [ "4 4\n1 2\n2 3\n3 1\n4 1", "4 3\n1 2\n2 4\n3 4", "8 9\n2 1\n3 5\n1 6\n2 5\n3 1\n8 4\n2 7\n7 1\n6 4", "4 4\n1 2\n2 3\n3 1\n4 2", "4 4\n1 2\n2 3\n4 4\n4 1", "8 9\n2 1\n6 5\n1 6\n4 5\n3 1\n8 4\n2 7\n2 1\n6 4", "4 4\n1 2\n4 3\n3 1\n4 2", "8 9\n2 1\n3 5\n1 6\n2 5\n3 1\n8 7\n2 7...
p02099 GPA JANKEN
Problem GPA is an abbreviation for "Galaxy Point of Aizu" and takes real numbers from 0 to 4. GPA rock-paper-scissors is a game played by two people. After each player gives a signal of "rock-paper-scissors, pon (hoi)" to each other's favorite move, goo, choki, or par, the person with the higher GPA becomes the winner...
{ "input": [], "output": [] }
{ "input": [ "3\n1.000\n2.000\n3.000", "3\n1.000\n3.000\n3.000" ], "output": [ "0\n3\n6", "0\n4\n4" ] }
{ "input": [ "3\n1.000\n2.000\n3.4274102096399073", "3\n1.3153899733914476\n3.000\n3.000", "3\n1.000\n3.512063887057689\n3.1230319554116766", "3\n3.0191870253634328\n3.000\n3.1230319554116766", "3\n3.577786126306406\n3.000\n3.1230319554116766", "3\n3.777463945799447\n3.960832526665802\n3.57651...
p02237 Graph
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation. An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$ lists, one for each vertex in $V$. For each $u \in V$, th...
{ "input": [], "output": [] }
{ "input": [ "4\n1 2 2 4\n2 1 4\n3 0\n4 1 3" ], "output": [ "0 1 0 1\n0 0 0 1\n0 0 0 0\n0 0 1 0" ] }
{ "input": [ "4\n1 2 2 4\n2 1 1\n3 0\n4 1 3", "4\n1 2 0 4\n2 1 1\n3 0\n4 1 3", "4\n1 2 1 4\n2 1 1\n3 0\n4 1 3", "4\n1 2 2 4\n2 1 4\n3 -1\n4 1 3", "4\n1 2 1 4\n2 1 2\n3 0\n4 1 3", "4\n1 2 1 4\n2 1 4\n1 -1\n4 1 3", "4\n1 2 2 4\n2 1 4\n3 -1\n4 1 1", "4\n1 2 0 4\n2 1 2\n3 0\n4 1 3", "4...
p02383 Dice I
Write a program to simulate rolling a dice, which can be constructed by the following net. <image> <image> As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the d...
{ "input": [], "output": [] }
{ "input": [ "1 2 4 8 16 32\nEESWN", "1 2 4 8 16 32\nSE" ], "output": [ "32", "8" ] }
{ "input": [ "0 2 4 8 16 32\nEESWN", "1 2 4 6 16 32\nSE", "0 2 4 8 16 30\nEESWN", "1 2 4 0 16 32\nSE", "1 2 4 -1 16 32\nSE", "0 2 0 8 16 23\nEESWN", "1 2 4 8 16 32\nES", "1 2 4 8 27 32\nES", "0 4 4 8 16 5\nEESWN", "1 4 4 -1 24 32\nES", "1 2 4 8 48 32\nES", "1 2 3 0 21 3...
aehash
Chef Ash and Chef Elsh invented a new hash function! Their hash function will map a binary string consisting of characters 'A' and 'E' into an integer called the hash value of the string. The pseudocode of the hash function is as below. hash(S) is the hash value of a binary string S. |S| denotes the length of S. funct...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0 0\n1 0 1\n3 2 6\n4 2 8" ], "output": [ "1\n1\n3\n4\n" ] }
{ "input": [ "4\n0 0 0\n1 0 1\n3 2 12\n4 2 8", "4\n0 0 0\n1 1 1\n-1 2 12\n4 2 8", "4\n0 0 0\n1 1 1\n-1 2 12\n2 2 8", "4\n0 0 0\n1 1 1\n-1 2 12\n3 2 8", "4\n0 0 0\n1 1 2\n-1 2 12\n3 -1 7", "4\n0 0 0\n1 0 1\n3 2 6\n6 2 8", "4\n-1 0 0\n1 0 1\n3 2 12\n4 2 8", "4\n0 0 0\n1 0 1\n0 2 12\n4 2 ...
chefsqua
Chef loves squares! You are given N points with integers coordinates, Chef asks you to find out how many points he should add to these set of N points, so that one could create at least one square having its vertices from the points of the resulting set. Note that the square created need not to be parallel to the axis....
{ "input": [], "output": [] }
{ "input": [ "5\n0 0\n100 100\n200 200\n100 0\n0 100", "3\n0 0\n2 2\n3 3" ], "output": [ "0", "2" ] }
{ "input": [], "output": [] }
drctnsrm
Problem description. Sumit is enjoying his vacations alone in a 2D world (yes, he knows magic), until his GPS tracker stopped working. The great thing about his GPS tracker is that it sends the direction of his traveled path from the starting of his adventure to his best friend. Being his best friend, find Sumit's dire...
{ "input": [], "output": [] }
{ "input": [ "3\nNEW\nNNSSE\nNE" ], "output": [ "NORTH\nEAST\nNORTHEAST" ] }
{ "input": [], "output": [] }
jntuv3
Problem Description.  Nithin proposed to his girl friend on valentines day. But she had kept a condition that if he answers her task then she will accept his proposal. As Nithin is new to programming, help him in solving the task. Your task is so simple.i.e...you need to find the factorial of a given number.   Input ...
{ "input": [], "output": [] }
{ "input": [ "5" ], "output": [ "120" ] }
{ "input": [ "6", "1", "2", "3", "10", "17", "26", "15", "14", "27", "13", "20", "24", "18", "4", "8", "9", "11", "7", "25", "31", "22", "19", "16", "32", "38", "21", "23", "12", "44", "56", ...
numbers
Lucy had recently learned the game, called Natural Numbers. The rules of the game are really simple. There are N players. At the same time, every player says one natural number. Let's call the number said by the i-th player Ai. The person with the smallest unique number (that is, the smallest number that was not said b...
{ "input": [], "output": [] }
{ "input": [ "2\n5\nKouta 1\nYuka 1\nMayu 3\nLucy 2\nNana 5\n2\nLucy 2\nNana 2" ], "output": [ "Lucy\nNobody wins.\n" ] }
{ "input": [ "2\n5\nKouta 1\nYuka 1\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2", "2\n5\nKouta 1\nYuka 0\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2", "2\n5\nKouta 2\nakuY 0\nMayu 3\nyucL 2\nNana 5\n2\nLucy 2\nNana 2", "2\n5\nKouta 1\nYuka 1\nMayu 3\nLucy 2\nNana 5\n2\nLucy 2\nOana 2", "2\n5\nKouta ...
sislove
Neha is a cute little sweet girl and considers herself as one of the luckiest girls in the world for having a caring and supporting family especially her cute little younger sister Shreya. But one fine day, due to the harsh side of fate, she loses her family in a car accident. She stays depressed and sadistic for days...
{ "input": [], "output": [] }
{ "input": [ "3\nowe\nseren\nrix" ], "output": [ "1\n7\n6\n" ] }
{ "input": [ "3\newo\nseren\nrix", "3\newo\nteren\nrix", "3\nexo\nteren\nqix", "3\nexo\nteren\nqiy", "3\nbwo\npecqv\n|hs", "3\noue\nfvqrb\nx~f", "3\nsi|\nq`qsb\nl}", "3\newo\nteren\nqix", "3\nexo\nneret\nqiy", "3\nexo\nneret\nyiq", "3\nexo\nteren\nyiq", "3\nexo\nteren\...
1140_G. Double Tree
You are given a special undirected graph. It consists of 2n vertices numbered from 1 to 2n. The following properties hold for the graph: * there are exactly 3n-2 edges in the graph: n edges connect vertices having odd numbers with vertices having even numbers, n - 1 edges connect vertices having odd numbers with eac...
{ "input": [], "output": [] }
{ "input": [ "5\n3 6 15 4 8\n1 2 5 4\n2 3 5 7\n1 4 1 5\n1 5 2 1\n3\n1 2\n5 6\n1 10\n" ], "output": [ "3\n15\n4\n" ] }
{ "input": [ "5\n3 6 15 4 8\n1 2 5 4\n2 3 5 7\n1 4 1 5\n1 5 2 2\n3\n1 2\n5 6\n1 10\n", "5\n3 6 15 4 8\n1 2 5 4\n2 3 5 7\n1 4 1 5\n2 5 2 1\n3\n1 2\n5 6\n1 10\n", "5\n3 6 15 4 8\n1 2 5 4\n4 3 5 7\n1 4 1 5\n1 5 2 1\n3\n1 2\n5 6\n1 10\n", "5\n3 6 15 4 8\n1 2 5 4\n2 3 5 7\n1 4 1 5\n1 5 2 1\n3\n1 2\n5 6\n1 ...
1282_A. Temporarily unavailable
Polycarp lives on the coordinate axis Ox and travels from the point x=a to x=b. It moves uniformly rectilinearly at a speed of one unit of distance per minute. On the axis Ox at the point x=c the base station of the mobile operator is placed. It is known that the radius of its coverage is r. Thus, if Polycarp is at a ...
{ "input": [], "output": [] }
{ "input": [ "9\n1 10 7 1\n3 3 3 0\n8 2 10 4\n8 2 10 100\n-10 20 -17 2\n-3 2 2 0\n-3 1 2 0\n2 3 2 3\n-1 3 -2 2\n" ], "output": [ "7\n0\n4\n0\n30\n5\n4\n0\n3\n" ] }
{ "input": [ "9\n1 10 7 1\n3 3 3 0\n8 2 10 4\n8 2 10 100\n-10 20 -17 2\n-3 1 2 0\n-3 1 2 0\n2 3 2 3\n-1 3 -2 2\n", "9\n1 10 7 1\n3 3 3 0\n8 2 10 4\n8 2 10 100\n-10 13 -17 2\n-3 1 0 0\n-3 1 2 0\n2 3 2 3\n-1 3 -2 2\n", "9\n1 10 7 1\n3 3 3 0\n8 2 10 4\n8 2 10 101\n-10 20 -17 2\n-3 2 2 0\n-3 1 2 0\n2 3 2 3\n-...
1302_A. Nash equilibrium
This is an unusual problem in an unusual contest, here is the announcement: [http://codeforces.com/blog/entry/73543](//codeforces.com/blog/entry/73543) You are given a table A of integers n × m. The cell (x, y) is called Nash equilibrium if both of the following conditions hold: * for each x_1 ≠ x A_{xy} > A_{x_1y...
{ "input": [], "output": [] }
{ "input": [ "4 4\n1 2 3 4\n1 2 3 5\n1 2 3 6\n2 3 5 7\n", "3 5\n7 7 7 7 7\n7 7 7 7 7\n7 7 7 7 7\n" ], "output": [ "\n1 4\n", "\n0 0\n" ] }
{ "input": [], "output": [] }
530_H. Points in triangle
You are given a set of points on a plane with positive integer coordinates. Find a triangle of minimum area with vertices in points (0, 0), (A, 0) and (0, B) (A and B are unknown positive integers) that contains all the given points inside it (points on the edges count towards being inside). Input The first line of t...
{ "input": [], "output": [] }
{ "input": [ "2\n1 1\n1 3\n", "2\n2 1\n1 2\n" ], "output": [ "6.0\n", "4.5\n" ] }
{ "input": [], "output": [] }
856_B. Similar Words
Let us call a non-empty sequence of lowercase English letters a word. Prefix of a word x is a word y that can be obtained from x by removing zero or more last letters of x. Let us call two words similar, if one of them can be obtained from the other by removing its first letter. You are given a set S of words. Find t...
{ "input": [], "output": [] }
{ "input": [ "2\n3\naba\nbaba\naaab\n2\naa\na\n" ], "output": [ "6\n1\n" ] }
{ "input": [ "2\n3\naba\nbaba\naaab\n2\nab\na\n", "2\n3\naba\nbaba\ncaaa\n2\nab\na\n", "2\n3\naba\nabab\nacaa\n2\nab\nb\n", "2\n3\naab\nbaba\nacaa\n2\nbb\na\n", "2\n3\naba\nbaba\naaab\n1\naa\na\n", "2\n3\naba\nabab\naaac\n2\nab\nc\n", "2\n3\naba\nbaca\naaab\n2\naa\na\n", "2\n3\naba\nba...
finding-dinosaurs-1
Ross and Rachel are on a date. Ross, being the super geek he is, takes Rachel to see dinosaur exhibits. Each dinosaur has a name and K attributes which are described by an ordered K-tuple ( A1, A2, A3,..., AK ). Each attribute Ai is an integer between 0 to L inclusive. Ross tells Rachel about N dinosaurs. For each din...
{ "input": [], "output": [] }
{ "input": [ "5 3 9 5\nbaryonyx 5 1 7\njobaria 1 2 3\noviraptor 9 7 1\ntroodon 6 9 5\nminmi 7 4 5\n9 7 1\n1 2 3\n5 8 8\n1 2 3\n7 4 5\n\nSAMPLE" ], "output": [ "oviraptor\njobaria\nYou cant fool me :P\njobaria\nminmi\n" ] }
{ "input": [ "5 3 9 5\nbaryonyx 5 1 7\njobbria 1 2 3\noviraptor 9 7 1\ntroodon 6 9 5\nminmi 7 4 5\n9 7 1\n1 2 3\n5 8 8\n1 2 3\n7 4 5\n\nSAMPLE", "5 3 9 5\nbaryonyx 5 1 7\njobbria 1 2 3\noviraptor 9 7 1\ntroodon 6 9 5\nminmi 7 4 5\n9 7 1\n1 2 3\n5 8 3\n1 1 3\n7 4 5\n\nSAMPLE", "5 3 3 5\nbaryonyx 5 1 7\njob...
optimal-permutation
Miraya and her best Alice friend are now ending their studies and they are willing to work together in a software company, but before this Alice will be tested by the Miraya through the following procedure, Miraya is obviously Computer Science person while her best friend belongs to Arts. However, as Miraya didn't want...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n7\n\nSAMPLE" ], "output": [ "1\n23" ] }
{ "input": [], "output": [] }
p02553 AtCoder Beginner Contest 178 - Product Max
Given are integers a,b,c and d. If x and y are integers and a \leq x \leq b and c\leq y \leq d hold, what is the maximum possible value of x \times y? Constraints * -10^9 \leq a \leq b \leq 10^9 * -10^9 \leq c \leq d \leq 10^9 * All values in input are integers. Input Input is given from Standard Input in the follo...
{ "input": [], "output": [] }
{ "input": [ "-1000000000 0 -1000000000 0", "1 2 1 1", "3 5 -4 -2" ], "output": [ "1000000000000000000", "2", "-6" ] }
{ "input": [ "-452063450 0 -1000000000 0", "1 0 1 1", "5 5 -4 -2", "-452063450 0 -1763699314 0", "5 5 -4 -4", "-452063450 0 -1612807650 0", "0 0 0 1", "-452063450 0 -1164863873 0", "5 5 -1 -4", "-452063450 -1 -2145079035 0", "-374524011 -1 -2145079035 0", "-374524011 -1...
p02684 AtCoder Beginner Contest 167 - Teleporter
The Kingdom of Takahashi has N towns, numbered 1 through N. There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i. Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K...
{ "input": [], "output": [] }
{ "input": [ "6 727202214173249351\n6 5 2 5 3 2", "4 5\n3 2 4 1" ], "output": [ "2", "4" ] }
{ "input": [ "6 727202214173249351\n6 5 1 5 3 2", "4 9\n3 2 4 1", "6 1007784494318310970\n6 5 2 5 3 2", "6 237500909755776657\n6 4 1 5 3 2", "6 727202214173249351\n4 5 2 5 3 2", "6 165759462200935729\n4 5 2 5 3 2", "6 727202214173249351\n6 4 1 5 3 2", "4 0\n3 2 4 1", "6 72720221417...
p02812 AtCoder Beginner Contest 150 - Count ABC
We have a string S of length N consisting of uppercase English letters. How many times does `ABC` occur in S as contiguous subsequences (see Sample Inputs and Outputs)? Constraints * 3 \leq N \leq 50 * S consists of uppercase English letters. Input Input is given from Standard Input in the following format: N S ...
{ "input": [], "output": [] }
{ "input": [ "19\nTHREEONEFOURONEFIVE", "33\nABCCABCBABCCABACBCBBABCBCBCBCABCB", "10\nZABCDBABCQ" ], "output": [ "0", "5", "2" ] }
{ "input": [ "19\nEVIFENORUOFENOEERHT", "33\nABCCABCBABCCABACBCBBABCBCBCBCABDB", "33\nBDBACBCBCBCBABBCBCABACCBABCBACCBA", "33\nABCCABCBABCCABACBCBBABCBCBDBCABCB", "33\nBCBACBDBCBCBABBCBCABCACBABCBACCBA", "33\nABBCABCBCBCACBACBCBAABCDCCBBCABCA", "10\nQCBABDCBAZ", "19\nTHREEONEFOURONEFIV...
p02949 AtCoder Beginner Contest 137 - Coins Respawn
There is a directed graph with N vertices numbered 1 to N and M edges. The i-th edge is directed from Vertex A_i to Vertex B_i, and there are C_i coins placed along that edge. Additionally, there is a button on Vertex N. We will play a game on this graph. You start the game on Vertex 1 with zero coins, and head for V...
{ "input": [], "output": [] }
{ "input": [ "2 2 10\n1 2 100\n2 2 100", "4 5 10\n1 2 1\n1 4 1\n3 4 1\n2 2 100\n3 3 100", "3 3 10\n1 2 20\n2 3 30\n1 3 45" ], "output": [ "-1", "0", "35" ] }
{ "input": [ "4 5 10\n1 2 1\n1 4 1\n2 4 1\n2 2 100\n3 3 100", "2 1 10\n1 2 100\n2 2 100", "4 5 10\n1 2 1\n1 4 1\n3 4 1\n2 2 101\n3 3 100", "3 3 10\n1 2 20\n2 3 56\n1 3 45", "4 5 10\n2 2 2\n1 4 -1\n3 4 0\n1 4 101\n3 3 100", "4 1 2\n1 4 3\n2 2 1\n2 1 1\n2 1 100\n3 3 100", "4 5 10\n1 3 2\n2 4...
p03085 AtCoder Beginner Contest 122 - Double Helix
On the Planet AtCoder, there are four types of bases: `A`, `C`, `G` and `T`. `A` bonds with `T`, and `C` bonds with `G`. You are given a letter b as input, which is `A`, `C`, `G` or `T`. Write a program that prints the letter representing the base that bonds with the base b. Constraints * b is one of the letters `A`...
{ "input": [], "output": [] }
{ "input": [ "G", "A" ], "output": [ "C", "T" ] }
{ "input": [ "C", "T", "C", "T" ], "output": [ "G\n", "A\n", "G\n", "A\n" ] }
p03230 Tenka1 Programmer Beginner Contest - Crossing
You are given an integer N. Determine if there exists a tuple of subsets of \\{1,2,...N\\}, (S_1,S_2,...,S_k), that satisfies the following conditions: * Each of the integers 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k. * Any two of the sets S_1,S_2,...,S_k have exactly one element in common. ...
{ "input": [], "output": [] }
{ "input": [ "4", "3" ], "output": [ "No", "Yes\n3\n2 1 2\n2 3 1\n2 2 3" ] }
{ "input": [ "2", "1", "-1", "-2", "-4", "-3", "-8", "-16", "-10", "-5", "-6", "-7", "-15", "-28", "-18", "-20", "5", "7", "8", "11", "-12", "-11", "9", "20", "-14", "-27", "-23", "12", "13", "-17",...
p03380 AtCoder Beginner Contest 094 - Binomial Coefficients
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. Constraints * 2 ...
{ "input": [], "output": [] }
{ "input": [ "5\n6 9 4 2 11", "2\n100 0" ], "output": [ "11 6", "100 0" ] }
{ "input": [ "5\n6 9 1 2 11", "5\n6 9 1 2 20", "5\n3 9 4 2 11", "2\n010 0", "5\n6 9 1 2 16", "5\n10 9 1 4 20", "2\n001 0", "5\n6 9 1 2 0", "5\n3 9 4 0 9", "2\n101 0", "2\n111 0", "2\n110 0", "5\n1 5 2 6 20", "5\n3 5 4 -1 1", "2\n110 1", "2\n100 1", "...
p03545 AtCoder Beginner Contest 079 - Train Ticket
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in...
{ "input": [], "output": [] }
{ "input": [ "1222", "3242", "0290" ], "output": [ "1+2+2+2=7", "3+2+4-2=7", "0-2+9+0=7" ] }
{ "input": [ "2364", "1114", "2005", "1455", "1152", "3246", "6120", "2768", "1183", "1024", "1181", "1785", "1372", "1765", "1280", "2308", "1824", "2162", "1802", "1226", "2412", "1699", "4212", "2632", "2195", "...
p03699 AtCoder Beginner Contest 063 - Bugged
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When...
{ "input": [], "output": [] }
{ "input": [ "3\n10\n10\n15", "3\n10\n20\n30", "3\n5\n10\n15" ], "output": [ "35", "0", "25" ] }
{ "input": [ "3\n4\n10\n15", "3\n10\n20\n40", "3\n5\n10\n12", "3\n8\n10\n15", "3\n7\n20\n40", "3\n5\n10\n8", "3\n1\n10\n15", "3\n7\n34\n40", "3\n5\n10\n10", "3\n7\n38\n40", "3\n5\n10\n19", "3\n1\n5\n22", "3\n7\n38\n0", "3\n5\n10\n2", "3\n0\n10\n22", "3\n...
p03854 AtCoder Beginner Contest 049 - Daydream
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. Constrain...
{ "input": [], "output": [] }
{ "input": [ "dreamerer", "erasedream", "dreameraser" ], "output": [ "NO", "YES", "YES" ] }
{ "input": [ "dre`merer", "maerdesare", "resaremaerd", "dre`meqer", "er`sedream", "ersaremaerd", "reqem`erd", "eq`sedream", "ersaremadrd", "reqem`erc", "eq`sfdream", "ersarfmadrd", "cre`meqer", "eq_sfdream", "errarfmadrd", "bre`meqer", "eq_tfdream", ...
p04021 AtCoder Grand Contest 003 - BBuBBBlesort!
Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the sequence in any order: ...
{ "input": [], "output": [] }
{ "input": [ "5\n10\n8\n5\n3\n2", "4\n2\n4\n3\n1" ], "output": [ "0", "1" ] }
{ "input": [ "4\n2\n4\n2\n1", "4\n2\n4\n6\n1", "4\n0\n13\n10\n1", "4\n2\n4\n2\n0", "4\n2\n4\n8\n1", "4\n2\n4\n10\n1", "4\n2\n4\n13\n1", "5\n10\n8\n5\n6\n2", "4\n2\n4\n11\n1", "4\n2\n5\n10\n1", "5\n10\n8\n10\n6\n2", "4\n0\n4\n11\n1", "4\n2\n7\n10\n1", "5\n10\n8\n...
p00105 Book Index
Books are indexed. Write a program which reads a list of pairs of a word and a page number, and prints the word and a list of the corresponding page numbers. You can assume that a word consists of at most 30 characters, and the page number is less than or equal to 1000. The number of pairs of a word and a page number ...
{ "input": [], "output": [] }
{ "input": [ "style 12\neven 25\nintroduction 3\neasy 9\nstyle 7\ndocument 13\nstyle 21\neven 18" ], "output": [ "document\n13\neasy\n9\neven\n18 25\nintroduction\n3\nstyle\n7 12 21" ] }
{ "input": [ "style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ndocument 13\nstyle 21\neven 18", "style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ntnemucod 13\nstyle 21\neven 18", "style 12\neven 25\nintroduction 3\neasy 9\nstyle 9\ntnemucod 13\nstyle 21\neven 10", "style 12\neven 25\nintroductio...
p00239 Calorie Counting
Food contains three nutrients called "protein", "fat" and "carbohydrate", which are called three major nutrients. It is calculated that protein and carbohydrate are 4 kcal (kilocalories) and fat is 9 kcal per 1 g (gram). For example, according to the table below, the number 1 cake contains 7 g of protein, 14 g of fat a...
{ "input": [], "output": [] }
{ "input": [ "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 400\n2\n1 8 10 78\n2 4 18 33\n10 10 50 300\n0" ], "output": [ "1\n4\nNA" ] }
{ "input": [ "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 110\n2\n1 8 10 78\n2 4 18 33\n10 10 50 300\n0", "4\n1 7 14 47\n2 7 35 55\n3 6 3 78\n4 2 7 15\n10 15 50 110\n2\n1 8 10 215\n0 4 8 33\n4 10 50 300\n0", "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 318\n2\n1 8 10 78\n2 4 18 33\n10 ...
p00410 Dungeon 3
You are a famous adventurer and have already won two dungeons. You got a new dungeon map with some walkways and a treasure trove. The map shows the value of the treasure in each treasure chest. You can enter the dungeon from any treasure chest and escape the dungeon from any treasure chest. From invasion to escape, yo...
{ "input": [], "output": [] }
{ "input": [ "5 4\n2\n1\n3\n6\n4\n1 2\n2 3\n2 4\n4 5", "None" ], "output": [ "14", "None" ] }
{ "input": [ "5 4\n4\n1\n3\n6\n4\n1 2\n2 3\n2 4\n4 5", "enoN", "5 4\n4\n1\n3\n6\n4\n1 2\n2 3\n2 4\n4 3", "emoN", "5 4\n4\n1\n3\n6\n4\n1 3\n2 3\n2 4\n4 3", "dmoN", "5 4\n4\n1\n3\n6\n4\n1 3\n2 3\n2 4\n4 2", "dmoO", "dmoP", "dmpO", "dnpO", "Opnd", "Opod", "dopO", ...
p00615 Traffic Analysis
There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red line in the figure) <image> Monitoring systems are connected to the cam...
{ "input": [], "output": [] }
{ "input": [ "4 5\n20 35 60 70\n15 30 40 80 90\n3 2\n10 20 30\n42 60\n0 1\n100\n1 1\n10\n50\n0 0" ], "output": [ "20\n18\n100\n40" ] }
{ "input": [ "4 5\n20 35 60 70\n15 30 40 80 91\n3 2\n10 20 30\n42 60\n0 1\n100\n1 1\n10\n50\n0 0", "4 5\n20 35 60 70\n15 30 40 80 170\n3 2\n10 20 30\n42 60\n0 1\n100\n1 1\n10\n50\n0 0", "4 5\n20 35 87 70\n15 30 40 80 91\n3 2\n10 20 30\n42 60\n0 1\n100\n1 1\n10\n50\n0 0", "4 5\n20 35 87 70\n15 30 40 80...
p00754 The Balance of the World
The Balance of the World The world should be finely balanced. Positive vs. negative, light vs. shadow, and left vs. right brackets. Your mission is to write a program that judges whether a string is balanced with respect to brackets so that we can observe the balance of the world. A string that will be given to the p...
{ "input": [], "output": [] }
{ "input": [ "" ], "output": [ "" ] }
{ "input": [], "output": [] }
p00891 Where's Wally
Do you know the famous series of children's books named "Where's Wally"? Each of the books contains a variety of pictures of hundreds of people. Readers are challenged to find a person called Wally in the crowd. We can consider "Where's Wally" as a kind of pattern matching of two-dimensional graphical images. Wally's ...
{ "input": [], "output": [] }
{ "input": [ "48 3 3\ngAY4I4wA\ngIIgIIgg\nw4IAYAg4\ng\ng\nw\n153 3 3\nkkkkkkkkkkkkkkkkkkkkkkkkkg\nSSSSSSSSSSSSSSSSSSSSSSSSSQ\nJJJJJJJJJJJJJJJJJJJJJJJJJI\ng\nQ\nI\n1 1 2\nA\nA\nA\n384 3 2\nABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\nBCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678...
{ "input": [ "48 3 3\ngAY4I4wA\ngIIgIIgg\nw4IAYAg4\ng\ng\nw\n153 3 3\nkkkkkkkkkkkkkkkkkkkkkkkkkg\nSSSSSSSSSSSSSSSSSSSSSSSSSQ\nJJJJJJJJJJJJJJJJJJJJJJJJJI\ng\nQ\nJ\n1 1 2\nA\nA\nA\n384 3 2\nABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\nBCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678...
p01023 Caterpillar
G, a college student living in a certain sky city, has a hornworm, Imotaro. He disciplined Imotaro to eat all the food in order with the shortest number of steps. You, his friend, decided to write a program because he asked me to find out if Imotaro was really disciplined. Input H W N area Input is given in H + ...
{ "input": [], "output": [] }
{ "input": [ "5 8 3\n#.......\n#.####2#\n#.#.3..#\n#.######\n.1Sabcde", "2 6 2\n.1.baS\n.2.cde", "2 6 2\n.1#baS\n.2.cde", "5 8 3\n.......\n.####2#\n.#.3..#\n.######\n.1Sabcde" ], "output": [ "14", "7", "-1", "14" ] }
{ "input": [ "5 8 3\n#.......\n#.####2#\n#.#.3..#\n######.#\n.1Sabcde", "5 8 2\n.......\n.####2#\n.#.3..#\n.######\n.1Sabcde", "5 8 3\n.......\n.####2#\n.\".3..#\n.######\n.1Sabcde", "5 8 3\n.......#\n#.####2#\n#.#.3..#\n#.######\n.1Sabcde", "5 8 2\n.......#\n#.#\"##2#\n#..3.#.#\n#.######\n.1Sabcd...
p01155 Ruins
In 1936, a dictator Hiedler who aimed at world domination had a deep obsession with the Lost Ark. A person with this ark would gain mystic power according to legend. To break the ambition of the dictator, ACM (the Alliance of Crusaders against Mazis) entrusted a secret task to an archeologist Indiana Johns. Indiana ste...
{ "input": [], "output": [] }
{ "input": [ "33 40\n57 144\n0 0" ], "output": [ "22\n94" ] }
{ "input": [ "66 40\n57 144\n0 0", "66 40\n57 41\n0 0", "66 40\n108 41\n0 0", "66 65\n108 41\n0 0", "132 65\n108 41\n0 0", "77 65\n108 41\n0 0", "33 39\n57 144\n0 0", "66 40\n52 144\n0 0", "66 40\n57 51\n0 0", "104 40\n108 41\n0 0", "66 65\n108 38\n0 0", "132 65\n10 41\...
p01294 For the Peace
This is a story of a world somewhere far from the earth. In this world, the land is parted into a number of countries ruled by empires. This world is not very peaceful: they have been involved in army race. They are competing in production of missiles in particular. Nevertheless, no countries have started wars for yea...
{ "input": [], "output": [] }
{ "input": [ "3 3\n3 4 1 1\n2 1 5\n2 3 3\n3 3\n3 2 3 1\n2 1 5\n2 3 3\n0 0" ], "output": [ "Yes\nNo" ] }
{ "input": [ "3 3\n3 8 1 1\n2 1 5\n2 3 3\n3 3\n3 2 3 1\n2 1 5\n2 3 3\n0 0", "3 6\n3 8 1 1\n2 1 5\n2 3 3\n3 3\n3 2 5 1\n2 1 8\n2 3 3\n0 0", "3 3\n3 4 1 1\n2 1 5\n2 3 3\n3 6\n3 2 5 1\n2 1 5\n2 3 3\n0 0", "3 3\n3 8 1 1\n2 1 6\n2 3 3\n3 3\n3 2 3 1\n2 2 5\n2 2 3\n0 0", "3 3\n3 8 1 1\n2 1 5\n2 3 3\n3 3\...
p01463 Runaway Domino
``Domino effect'' is a famous play using dominoes. A player sets up a chain of dominoes stood. After a chain is formed, the player topples one end of the dominoes. The first domino topples the second domino, the second topples the third and so on. You are playing domino effect. Before you finish to set up a chain of d...
{ "input": [], "output": [] }
{ "input": [ "2\n0 0\n15 0\n5 0 1\n10 10 2", "2\n0 0\n10 0\n5 0 1\n9 0 3", "3\n-10 0\n0 0\n0 10\n-1 0 1\n3 0 2" ], "output": [ "5.0", "2.0", "4.072027" ] }
{ "input": [ "2\n0 0\n7 0\n5 0 1\n10 10 2", "2\n0 0\n10 0\n5 0 1\n9 0 6", "3\n-5 0\n0 0\n0 10\n-1 0 1\n3 0 2", "3\n-5 0\n0 0\n0 10\n-1 0 1\n3 0 0", "3\n-5 0\n0 0\n0 14\n-1 0 1\n3 0 0", "2\n0 0\n15 0\n9 0 1\n10 10 2", "3\n-10 0\n0 0\n0 10\n-1 0 2\n3 0 2", "2\n0 0\n10 0\n5 0 1\n17 0 6", ...
p01622 Twin book report
At the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing any homework today. It is obvious that you will see crying on the last day of summer vacation as it...
{ "input": [], "output": [] }
{ "input": [ "4\n1 1\n3 1\n4 1\n2 1\n3\n5 3\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15 72\n20 73\n25 75\n30 77\n35 79\n40 82\n45 100\n815 283\n6\n74 78\n53 55\n77 77\n12 13\n39 42\n1 1\n0" ], "output": [ "14\n15\n3000\n2013\n522" ] }
{ "input": [ "4\n1 1\n3 1\n4 1\n2 1\n3\n5 2\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15 72\n20 73\n25 75\n30 77\n35 79\n40 82\n45 100\n815 283\n6\n74 78\n53 55\n77 77\n12 13\n39 42\n1 1\n0", "4\n1 1\n3 1\n4 1\n2 1\n3\n5 2\n1 2\n1 2\n1\n1000 1001\n10\n5 62\n10 68\n15 72\n20 73\n25 75\n30 77\n35 79\n40 82\n45 ...
p01775 Rescue a Postal Worker
D: Rescue a Postal Worker story You got a job at the post office, which you have long dreamed of this spring. I decided on the delivery area I was in charge of, and it was my first job with a feeling of excitement, but I didn't notice that there was a hole in the bag containing the mail because it was so floating tha...
{ "input": [], "output": [] }
{ "input": [ "5 6 1 1\n1 3 5\n1 2 2\n2 3 1\n3 5 4\n3 4 2\n4 5 3\n3 5" ], "output": [ "7" ] }
{ "input": [ "5 6 1 1\n1 3 5\n1 1 2\n2 3 1\n3 5 4\n3 4 2\n4 5 3\n3 5", "5 6 1 1\n1 3 5\n2 1 2\n2 3 1\n3 5 4\n3 4 2\n4 5 3\n3 5", "5 6 1 2\n1 3 5\n2 1 2\n2 3 1\n3 5 4\n3 4 2\n4 5 3\n3 5", "5 6 1 1\n1 3 5\n2 1 2\n2 3 1\n3 1 4\n3 4 2\n4 5 3\n3 5", "5 6 1 1\n1 3 4\n1 2 1\n2 3 1\n3 5 4\n3 4 2\n4 5 3\n3...
p01909 Graduation Ceremony
problem The point $ P $ is placed at the origin on the coordinate plane. I want to move the point $ P $ to a position where the Manhattan distance from the origin is as far as possible. First, the string $ S = s_1s_2 \ cdots s_ {| S |} $ ($ | S | $ is the number of characters in $ S $) is given. The point $ P $ is mo...
{ "input": [], "output": [] }
{ "input": [ "RRLUDDD\n2" ], "output": [ "7" ] }
{ "input": [ "RRLUDDD\n1", "RRLUDDD\n0", "RSLUDDD\n4", "DDDULRR\n1", "RRULDDD\n0", "RSLUDDD\n5", "DDDULRR\n2", "RSLDDDU\n4", "DDUDLRR\n2", "DSLRDDU\n4", "DDUDLRR\n1", "DSMRDDU\n4", "RRLDUDD\n1", "DSMSDDU\n4", "RRLDUDD\n0", "DSLSDDU\n4", "DSLTDDU\n4",...
p02048 Great Strategy for Bring Up Grade
Great performance strategy Taro, an examinee, participated in an N-day study camp. In this training camp, M subjects are tested every day, and after the training camp, a report card with all the test scores is distributed. The report card consists of N sheets of paper, and on the i-th sheet, only the subject names and...
{ "input": [], "output": [] }
{ "input": [ "3 3\n1 2 3\n2 1 3\n3 3 3\n8 5\n3 3 4 3 4\n2 1 2 3 2\n7 9 7 8 7\n3 4 3 3 4\n1 2 2 3 2\n4 5 6 5 6\n7 9 7 7 8\n4 5 5 6 6\n5 5\n1 2 3 4 5\n2 3 4 5 1\n3 4 5 1 2\n4 5 1 2 3\n5 1 2 3 4\n5 9\n1 1 1 1 1 1 1 1 1\n2 2 2 2 2 2 2 2 2\n3 3 3 3 3 3 3 3 3\n4 4 4 4 4 4 4 4 4\n5 5 5 5 5 5 5 5 5\n0 0" ], "output":...
{ "input": [ "3 3\n1 2 3\n2 1 3\n3 3 3\n8 5\n3 3 4 3 4\n2 1 2 3 2\n7 9 7 8 7\n3 4 3 3 4\n0 2 2 3 2\n4 5 6 5 6\n7 9 7 7 8\n4 5 5 6 6\n5 5\n1 2 3 4 5\n2 3 4 5 1\n3 4 5 1 2\n4 5 1 2 3\n5 1 2 3 4\n5 9\n1 1 1 1 1 1 1 1 1\n2 2 2 2 2 2 2 2 2\n3 3 3 3 3 3 3 3 3\n4 4 4 4 4 4 4 4 4\n5 5 5 5 5 5 5 5 5\n0 0", "3 3\n1 2 3...
p02190 Set
Set Given the sequence a_1, a_2, .., a_N. How many values ​​are there in this sequence? input N a_1 a_2 ... a_N output Output the number of types of values ​​in the sequence. Constraint * 1 \ leq N \ leq 10 ^ 5 * 1 \ leq a_i \ leq 10 ^ 9 Input example 6 8 6 9 1 2 1 Output example Five Example ...
{ "input": [], "output": [] }
{ "input": [ "6\n8 6 9 1 2 1" ], "output": [ "5" ] }
{ "input": [ "6\n8 5 9 1 2 1", "6\n8 5 9 0 2 1", "6\n1 2 9 0 2 0", "6\n-1 1 1 -1 7 1", "6\n-2 0 -2 0 0 0", "6\n1 5 9 0 2 1", "6\n1 5 9 0 2 0", "6\n1 2 15 0 2 0", "6\n1 2 15 0 2 -1", "6\n1 2 21 0 2 -1", "6\n1 2 29 0 2 -1", "6\n1 2 29 0 3 -1", "6\n1 2 58 0 3 -1", ...
p02344 Weighted Union Find Trees
There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions. * relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$ * diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$ Constraints * $2 \leq n \leq 100,000$ * $1 \leq q \leq 200,000$ * $0 \leq x, y <...
{ "input": [], "output": [] }
{ "input": [ "5 6\n0 0 2 5\n0 1 2 3\n1 0 1\n1 1 3\n0 1 4 8\n1 0 4" ], "output": [ "2\n?\n10" ] }
{ "input": [ "5 6\n0 0 2 5\n0 1 2 3\n1 0 1\n1 1 3\n0 1 4 4\n1 0 4", "5 6\n0 0 2 5\n0 2 2 3\n1 0 1\n1 1 3\n0 1 4 4\n1 0 4", "5 6\n0 0 2 5\n0 1 2 3\n1 0 1\n1 1 3\n0 1 4 3\n1 0 4", "5 6\n0 0 2 5\n0 1 2 5\n1 0 1\n1 1 3\n0 1 4 3\n1 0 4", "5 6\n0 0 2 5\n0 2 2 3\n1 0 1\n1 0 0\n0 1 4 4\n1 0 4", "5 6\n...
p02477 Multiplication of Big Integers II
Multiplication of Big Integers II Given two integers $A$ and $B$, compute the product, $A \times B$. Input Two integers $A$ and $B$ separated by a space character are given in a line. Output Print the product in a line. Constraints * $-1 \times 10^{200000} \leq A, B \leq 10^{200000}$ Sample Input 1 5 8 Sa...
{ "input": [], "output": [] }
{ "input": [ "5 8" ], "output": [ "40" ] }
{ "input": [ "2 8", "4 8", "0 8", "1 8", "1 2", "2 2", "2 3", "1 3", "-1 3", "-1 4", "-1 2", "4 3", "3 3", "-2 3", "-3 3", "-5 3", "-1 1", "-1 -1", "-1 5", "1 11", "1 22", "1 18", "1 17", "-1 7", "-1 13", "-2 13", ...
aran03
We are very near to our goal now. The enemy is being weakened continuously. But alas, sensing his fall, the hacker has spread a worm into our network. It is consuming all our files at a tremendous rate and must be stopped at all costs. The only way to stop it is to enter a specific code number in to the worm. It is up ...
{ "input": [], "output": [] }
{ "input": [ "3\n34\n156\n893" ], "output": [ "6\n0\n13\n" ] }
{ "input": [ "3\n34\n156\n1132", "3\n34\n11\n1132", "3\n48\n11\n1132", "3\n68\n11\n1132", "3\n68\n11\n238", "3\n68\n11\n401", "3\n68\n11\n416", "3\n14\n11\n416", "3\n21\n11\n416", "3\n21\n11\n823", "3\n21\n11\n1347", "3\n21\n11\n690", "3\n21\n11\n1286", "3\n21\n...
cinema
Chef likes to watch movies very much.A movie of his favorite actress has recently released and he wants to go to cinema hall with his friends to watch the movie. But he will book tickets for him and his friends only if he gets the seats in his desired block size. eg. if he has 9 friends, then he has to book 10 tickets,...
{ "input": [], "output": [] }
{ "input": [ "1\n2 6\n2 3\n.####.\n.#####" ], "output": [ "2\n0 1\n0 2" ] }
{ "input": [ "1\n1 6\n2 3\n.####.\n.#####", "1\n2 6\n2 2\n.####.\n.#####", "1\n2 6\n1 3\n.####.\n.#####", "1\n1 2\n1 1\n.##\"#/\n#####.", "1\n2 1\n1 1\n.##\"#/\n####.#", "1\n1 0\n1 0\n###0$.\n#####.", "1\n1 5\n2 3\n.####.\n.#####", "1\n1 5\n2 3\n.####/\n.#####", "1\n1 5\n3 3\n.####...
facteasy
Given a number n , find its factorial. Input There is a single positive integer T on the first line of input. It stands for the number of numbers to follow. Then there are T lines, each containing exactly one positive integer number N, 1 ≤ N ≤ 10000 Output For every input number N, output a single line contain...
{ "input": [], "output": [] }
{ "input": [ "3\n5\n2\n7" ], "output": [ "120\n2\n5040\n" ] }
{ "input": [ "3\n9\n2\n7", "3\n4\n2\n7", "3\n4\n2\n13", "3\n3\n2\n13", "3\n3\n1\n13", "3\n3\n1\n4", "3\n5\n3\n7", "3\n15\n2\n7", "3\n4\n4\n7", "3\n3\n2\n7", "3\n3\n2\n4", "3\n5\n4\n7", "3\n10\n2\n7", "3\n5\n5\n7", "3\n1\n2\n7", "3\n3\n2\n8", "3\n2\n2...
lch15jef
Leonid is developing new programming language. The key feature of his language is fast multiplication and raising to a power operations. He is asking you to help with the following task. You have an expression S and positive integer M. S has the following structure: A1*A2*...*An where "*" is multiplication operation. ...
{ "input": [], "output": [] }
{ "input": [ "2\n1000 2**3*3**1\n100000 11**2*2**4" ], "output": [ "24\n1936\n" ] }
{ "input": [ "2\n1000 2**3*3**1\n100000 4**2*2**11", "2\n1001 2**3*2**1\n100000 4**2*2**11", "2\n1000 2**3*3**1\n101000 11**2*2**4", "2\n1001 1**3*3**2\n100000 4**2*2**11", "2\n1001 1**3*3**2\n100000 4**2*2**01", "2\n1001 1**3*3**1\n110000 11**2*2**4", "2\n1100 2**3*3**1\n110000 4**1*2**11...
permut2
Some programming contest problems are really tricky: not only do they require a different output format from what you might have expected, but also the sample output does not show the difference. For an example, let us look at permutations. A permutation of the integers 1 to n is an ordering of these integers. So the n...
{ "input": [], "output": [] }
{ "input": [ "4\n1 4 3 2\n5\n2 3 4 5 1\n1\n1\n0" ], "output": [ "ambiguous\nnot ambiguous\nambiguous\n" ] }
{ "input": [ "4\n1 4 3 4\n5\n2 3 4 5 1\n1\n1\n0", "4\n1 4 3 2\n5\n1 3 4 5 1\n1\n1\n0", "4\n1 4 3 4\n5\n0 3 4 5 0\n0\n1\n0", "4\n1 3 3 0\n0\n3 3 3 1 1\n1\n1\n0", "4\n1 2 3 4\n5\n0 3 4 5 -1\n0\n1\n-1", "4\n1 4 3 2\n0\n2 3 4 0 1\n1\n1\n1", "4\n1 4 3 4\n5\n0 3 4 5 1\n1\n1\n0", "4\n1 4 3 4\...
stkenc
For Turbo C++ Users : Read the following document before attempting the question : For C and C++ users, use long long instead of int. For Java users, use long. Problem description Data here, Data There. Data Everywhere. Which one is mine though? Main Proconist Dhruv has been given the task of encrypting a clas...
{ "input": [], "output": [] }
{ "input": [ "3\n50\n34\n23" ], "output": [ "2\n2\n1\n" ] }
{ "input": [ "3\n20\n34\n23", "3\n50\n35\n23", "3\n20\n34\n43", "3\n36\n9\n23", "3\n4\n4\n23", "3\n35\n34\n38", "3\n8\n4\n35", "3\n55\n34\n22", "3\n55\n68\n22", "3\n91\n68\n22", "3\n91\n79\n22", "3\n91\n79\n28", "3\n101\n9\n52", "3\n101\n9\n87", "3\n101\n9\n...
riyas-birthday-party-1
Madhav went to Riya's Birthday Party. He was a geek so he had no idea regarding which gift she'l like. So he took an array of integers with him. The array followed a particular order. First element of array is 1. Second element of array is 6. Other elements of the array are two less than the mean of the number precedin...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n3\n\nSAMPLE" ], "output": [ "1\n15\n" ] }
{ "input": [ "2\n2\n3\n\nSAMPLE", "2\n2\n2\n\nELPMAS", "2\n1\n3\n\nELPMAS", "2\n2\n6\n\nELPNAS", "2\n2\n1\n\nSAMPLD", "2\n2\n12\n\nELPNAS", "2\n3\n1\n\nSAMPLD", "2\n2\n20\n\nELPNAS", "2\n1\n1\n\nEAPMKS", "2\n1\n20\n\nELPNAS", "2\n2\n4\n\nDMPMAS", "2\n1\n2\n\nSKMPAE", ...
square-mode
Your friend gives you an equation A≡X2(modM) and asks you to find an integer solution for X. However, you know your friend's mischievous nature and suspect that there is no solution to such an equation. Thus, you first want to find out whether there is a solution to it. You may find this link helpful: http://en.wikip...
{ "input": [], "output": [] }
{ "input": [ "2 \n5 7 \n4 7\n\nSAMPLE" ], "output": [ "NO \nYES" ] }
{ "input": [ "2 \n5 7 \n3 7\n\nSAMPLE", "2 \n5 11 \n3 7\n\nSAMPLE", "2 \n5 2 \n0 7\n\nS@MPLE", "2 \n5 1 \n0 7\n\nS@MPLE", "2 \n5 2 \n3 7\n\nSAMPLE", "2 \n5 2 \n3 7\n\nS@MPLE", "2 \n3 1 \n0 7\n\nS@MPLE", "2 \n3 1 \n0 11\n\nS@MPLE", "2 \n3 1 \n0 16\n\nS@MPLE", "...
p02580 AtCoder Beginner Contest 176 - Bomber
We have a two-dimensional grid with H \times W squares. There are M targets to destroy in this grid - the position of the i-th target is \left(h_i, w_i \right). Takahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb will destroy all targets that are in the row or the column where th...
{ "input": [], "output": [] }
{ "input": [ "2 3 3\n2 2\n1 1\n1 3", "3 3 4\n3 3\n3 1\n1 1\n1 2", "5 5 10\n2 5\n4 3\n2 3\n5 5\n2 2\n5 4\n5 3\n5 1\n3 5\n1 4" ], "output": [ "3", "3", "6" ] }
{ "input": [ "2 3 3\n2 2\n1 1\n1 2", "5 5 10\n2 5\n4 5\n2 3\n5 5\n2 2\n5 4\n5 3\n5 1\n3 5\n1 4", "5 5 10\n2 5\n4 5\n2 3\n5 5\n2 4\n5 4\n5 1\n1 1\n4 5\n1 4", "5 5 10\n2 5\n4 2\n2 3\n5 5\n2 3\n5 4\n5 1\n1 1\n4 5\n1 4", "6 3 4\n1 3\n3 1\n1 1\n1 2", "5 5 10\n2 5\n4 5\n2 1\n5 5\n2 2\n5 4\n5 1\n5 2\...
p02711 AtCoder Beginner Contest 162 - Lucky 7
Given is a three-digit integer N. Does N contain the digit 7? If so, print `Yes`; otherwise, print `No`. Constraints * 100 \leq N \leq 999 Input Input is given from Standard Input in the following format: N Output If N contains the digit 7, print `Yes`; otherwise, print `No`. Examples Input 117 Output Y...
{ "input": [], "output": [] }
{ "input": [ "777", "123", "117" ], "output": [ "Yes", "No", "Yes" ] }
{ "input": [ "1413", "187", "68", "1760", "89", "144", "2610", "151", "91", "3439", "198", "3", "430", "242", "6", "739", "147", "8", "321", "42", "13", "348", "21", "15", "471", "20", "10", "848", "9",...
p02840 AtCoder Beginner Contest 147 - Sum Difference
We have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 \leq i < N ) holds. Takahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others. Let S and T be the sum of the numbers taken by Takahashi and Aoki, respectively. How many possible ...
{ "input": [], "output": [] }
{ "input": [ "2 3 -3", "3 4 2", "100 14 20" ], "output": [ "2", "8", "49805" ] }
{ "input": [ "1 3 -3", "3 3 2", "100 13 20", "3 3 3", "110 13 20", "0 3 2", "110 14 20", "010 14 20", "011 22 20", "2 4 3", "101 22 4", "101 36 4", "101 177 4", "101 92 4", "100 92 4", "100 48 4", "110 48 4", "110 5 4", "111 5 4", "110 2 ...
p02977 AtCoder Grand Contest 035 - Skolem XOR Tree
You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. * Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, th...
{ "input": [], "output": [] }
{ "input": [ "1", "3" ], "output": [ "No", "Yes\n1 2\n2 3\n3 4\n4 5\n5 6" ] }
{ "input": [ "4", "8", "2", "16", "32", "64", "001", "128", "256", "2", "4", "8", "16", "32", "001", "64", "256", "128" ], "output": [ "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n", "No\n",...
p03114 World Tour Finals 2019 Open Contest - Multiple of Nine
Count the number of strings S that satisfy the following constraints, modulo 10^9 + 7. * The length of S is exactly N. * S consists of digits (`0`...`9`). * You are given Q intervals. For each i (1 \leq i \leq Q), the integer represented by S[l_i \ldots r_i] (the substring of S between the l_i-th (1-based) character a...
{ "input": [], "output": [] }
{ "input": [ "6\n3\n2 5\n3 5\n1 3", "20\n10\n2 15\n5 6\n1 12\n7 9\n2 17\n5 15\n2 4\n16 17\n2 12\n8 17", "4\n2\n1 2\n2 4" ], "output": [ "2720", "862268030", "136" ] }
{ "input": [ "20\n10\n2 15\n5 6\n1 12\n7 9\n2 5\n5 15\n2 4\n16 17\n2 12\n8 17", "4\n1\n1 2\n2 4", "20\n10\n4 15\n5 6\n1 12\n7 9\n2 5\n5 15\n2 4\n16 17\n2 12\n8 17", "4\n1\n1 1\n2 8", "6\n3\n2 5\n3 5\n1 6", "20\n10\n2 15\n5 6\n1 12\n7 9\n2 17\n3 15\n2 4\n16 17\n2 12\n8 17", "4\n2\n1 2\n2 2"...
p03260 AtCoder Beginner Contest 109 - ABC333
You are given integers A and B, each between 1 and 3 (inclusive). Determine if there is an integer C between 1 and 3 (inclusive) such that A \times B \times C is an odd number. Constraints * All values in input are integers. * 1 \leq A, B \leq 3 Input Input is given from Standard Input in the following format: A...
{ "input": [], "output": [] }
{ "input": [ "3 1", "1 2", "2 2" ], "output": [ "Yes", "No", "No" ] }
{ "input": [ "1 1", "2 4", "1 3", "2 0", "2 3", "2 6", "2 1", "3 -1", "2 -1", "3 3", "1 -1", "4 2", "-1 1", "0 2", "-1 2", "-1 -1", "2 7", "2 -2", "0 -2", "5 1", "3 5", "-1 -2", "-2 2", "-2 0", "1 -2", "-2 -1", ...
p03416 AtCoder Beginner Contest 090 - Palindromic Numbers
Find the number of palindromic numbers among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. Constraints * 10000 \leq A \leq B \leq 99999 * All input values are integers. Inp...
{ "input": [], "output": [] }
{ "input": [ "11009 11332", "31415 92653" ], "output": [ "4", "612" ] }
{ "input": [ "31415 27129", "31415 97709", "31415 41187", "38168 41187", "53417 77120", "44323 77120", "18202 20736", "44323 83416", "15858 24247", "44323 46102", "15858 40262", "31406 46102", "15858 66358", "15858 19549", "36382 43069", "15714 19549", ...
p03576 AtCoder Beginner Contest 075 - Axis-Parallel Rectangle
We have N points in a two-dimensional plane. The coordinates of the i-th point (1 \leq i \leq N) are (x_i,y_i). Let us consider a rectangle whose sides are parallel to the coordinate axes that contains K or more of the N points in its interior. Here, points on the sides of the rectangle are considered to be in the inte...
{ "input": [], "output": [] }
{ "input": [ "4 3\n-1000000000 -1000000000\n1000000000 1000000000\n-999999999 999999999\n999999999 -999999999", "4 2\n0 0\n1 1\n2 2\n3 3", "4 4\n1 4\n3 3\n6 2\n8 1" ], "output": [ "3999999996000000001", "1", "21" ] }
{ "input": [ "4 3\n-1000000000 -1000000000\n1000000000 1001000000\n-999999999 999999999\n999999999 -999999999", "4 4\n1 4\n2 3\n6 2\n8 1", "4 3\n-1000000000 -1000000000\n1000000000 1001000000\n-999999999 999999999\n195439962 -999999999", "4 4\n1 4\n2 3\n6 2\n8 0", "4 3\n-1000000000 -1000000000\n10...
p03733 AtCoder Regular Contest 073 - Sentou
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will pus...
{ "input": [], "output": [] }
{ "input": [ "9 10\n0 3 5 7 100 110 200 300 311", "2 4\n0 3", "1 1\n0", "2 4\n0 5", "4 1000000000\n0 1000 1000000 1000000000" ], "output": [ "67", "7", "1", "8", "2000000000" ] }
{ "input": [ "2 4\n0 2", "1 0\n0", "2 4\n0 4", "4 1000000000\n0 1100 1000000 1000000000", "4 1000000000\n0 1100 1000000 1010000000", "9 10\n0 3 5 7 100 110 200 272 311", "4 1000010000\n0 1000 1000000 1000000000", "4 1000000000\n0 1100 1100000 1010000000", "9 10\n0 3 5 7 000 110 200...
p03895 CODE FESTIVAL 2016 Relay (Parallel) - Early Bird
Takahashi recorded his daily life for the last few days as a integer sequence of length 2N, as follows: * a_1, b_1, a_2, b_2, ... , a_N, b_N This means that, starting from a certain time T, he was: * sleeping for exactly a_1 seconds * then awake for exactly b_1 seconds * then sleeping for exactly a_2 seconds * : *...
{ "input": [], "output": [] }
{ "input": [ "3\n28800 57600\n28800 57600\n57600 28800", "10\n28800 57600\n4800 9600\n6000 1200\n600 600\n300 600\n5400 600\n6000 5760\n6760 2880\n6000 12000\n9000 600" ], "output": [ "2", "5" ] }
{ "input": [ "3\n28800 76029\n28800 57600\n57600 28800", "10\n43196 57600\n4800 9600\n6000 1200\n600 600\n300 600\n5400 600\n6000 5760\n6760 2880\n6000 12000\n9000 600", "3\n28800 46734\n43482 57600\n54999 28800", "10\n43196 21072\n8364 9600\n6000 1200\n600 600\n300 600\n5400 153\n6000 5760\n6760 2880...
p00001 List of Top 3 Hills
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order. Constraints 0 ≤ height of mountain (integer) ≤ 10,000 Input Height of mountain 1 Height of mountain 2 Height of mountain 3 . . He...
{ "input": [], "output": [] }
{ "input": [ "1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922", "100\n200\n300\n400\n500\n600\n700\n800\n900\n900" ], "output": [ "3776\n2848\n2840", "900\n900\n800" ] }
{ "input": [ "1819\n2003\n876\n2840\n1723\n1799\n3776\n2848\n1592\n922", "100\n200\n300\n568\n500\n600\n700\n800\n900\n900", "1819\n2003\n876\n2840\n1723\n1799\n4419\n2848\n1592\n922", "100\n200\n300\n568\n500\n600\n700\n1096\n900\n900", "100\n200\n300\n568\n500\n600\n700\n1096\n900\n205", "10...
p00133 Rotation of a Pattern
Create a program that rotates the pattern of 8 characters x 8 lines clockwise by 90 degrees, 180 degrees, and 270 degrees and outputs it. Input A pattern consisting of 8 characters x 8 lines is given. Characters consist of alphanumeric characters, half-width pound'#', and asterisk'*'. Output Output the rotated pa...
{ "input": [], "output": [] }
{ "input": [ "#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n########", "*******\n*******\n*******\n*******\n*******\n*******\n*******" ], "output": [ "90\n########\n#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n#*******\n180\n########\n*******#\n*******#\n*******#...
{ "input": [ "#*******\n#*******\n\"*******\n#*******\n#*******\n#*******\n#*******\n########", "****)**\n*******\n*******\n*******\n*******\n*******\n*******", "#*******\n#*******\n\"*******\n#*******\n#*******\n#*******\n#*******\n$#######", "****)**\n*******\n*******\n*******\n*******\n*****+*\n***...
p00266 Izua Dictionary
You have obtained the Izua Japanese dictionary, which is the official language of Izua, and the Izua alphabet (list of letters). There are N types of letters in the Izua alphabet. The order of the words that appear in the Izua Japanese dictionary is in the alphabetical order of Izua. Looking at the dictionary, I found...
{ "input": [], "output": [] }
{ "input": [ "3\n2\n1 2\n2 3\n4\n2\n2 3\n2 4\n0" ], "output": [ "3\n4" ] }
{ "input": [ "3\n2\n1 2\n2 1\n4\n2\n2 3\n2 4\n0", "3\n2\n1 2\n2 1\n4\n2\n2 2\n2 4\n0", "3\n2\n1 2\n3 1\n4\n2\n2 2\n2 4\n0", "3\n2\n1 2\n3 1\n4\n2\n2 2\n1 4\n0", "3\n2\n1 2\n2 1\n4\n2\n2 2\n4 4\n0", "3\n2\n1 1\n3 1\n4\n2\n2 2\n1 4\n0", "3\n2\n1 2\n1 1\n4\n2\n2 3\n2 4\n0", "3\n2\n1 2\n3 ...
p00453 Pyon-Pyon River Crossing
problem In one river, there is a slightly dangerous game of jumping from one shore to the other on a stone. <image> Now, as shown in Figure 4-1 we consider the stone to be above the squares. The number of rows is n. In Figure 4-1 we have n = 5. In this game, you start with one shore and make a normal jump or a on...
{ "input": [], "output": [] }
{ "input": [ "5 1\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n5 0\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n0 0" ], "output": [ "17\n40" ] }
{ "input": [ "5 1\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n5 0\n2 1 3 0 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n0 0", "5 1\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n5 0\n2 1 3 2 2\n1 4 2\n1 1 7\n1 2 1\n1 4 4\n0 0", "5 1\n2 1 3 2 2\n1 3 2\n1 1 7\n1 2 1\n1 4 4\n5 0\n2 1 3 0 2\n1 3 2\n1 1 1\n1 2 1\n1 4 4\n0 0", "5 1...
p00644 Winter Bells
The best night ever in the world has come! It's 8 p.m. of December 24th, yes, the night of Cristmas Eve. Santa Clause comes to a silent city with ringing bells. Overtaking north wind, from a sleigh a reindeer pulls she shoot presents to soxes hanged near windows for children. The sleigh she is on departs from a big ch...
{ "input": [], "output": [] }
{ "input": [ "3 2 1\n0 1 2\n1 2 3\n1\n4 5 2\n0 1 1\n0 2 1\n1 2 1\n1 3 1\n2 3 1\n1\n2\n0 0 0" ], "output": [ "1.00000000\n\n0.50000000\n0.50000000" ] }
{ "input": [ "3 2 1\n0 1 2\n1 2 3\n1\n4 5 2\n0 1 1\n0 2 1\n1 2 1\n1 3 1\n2 3 1\n1\n2\n0 0 1", "3 2 1\n0 1 2\n1 2 3\n1\n4 5 2\n0 1 2\n0 2 1\n1 2 1\n1 3 1\n2 3 1\n1\n2\n0 0 1", "3 2 1\n0 1 2\n1 2 3\n1\n4 5 2\n0 1 2\n0 3 1\n1 2 1\n1 3 1\n2 3 1\n1\n2\n0 0 1", "3 2 1\n0 1 2\n1 2 3\n1\n4 5 2\n0 1 1\n0 2 1\n...