name
stringlengths
2
112
description
stringlengths
29
13k
private_tests
dict
public_tests
dict
generated_tests
dict
p03791 Mujin Programming Challenge 2017 - Robot Racing
You are developing frog-shaped robots, and decided to race them against each other. First, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N. You will repeatedly perform the following opera...
{ "input": [], "output": [] }
{ "input": [ "13\n4 6 8 9 10 12 14 15 16 18 20 21 22", "3\n1 2 3", "3\n2 3 4", "8\n1 2 3 5 7 11 13 17" ], "output": [ "311014372", "4", "6", "10080" ] }
{ "input": [ "13\n4 11 8 9 10 12 14 15 16 18 20 21 22", "3\n0 2 3", "3\n2 3 8", "13\n3 16 8 9 10 19 12 24 16 18 20 21 6", "3\n9 1 14", "8\n2 2 3 5 7 11 13 17", "3\n0 0 8", "13\n4 16 8 9 10 19 14 24 18 18 20 21 22", "13\n4 11 8 6 10 19 14 24 16 18 20 21 22", "13\n3 1 8 9 18 19 1...
p03959 CODE FESTIVAL 2016 qual C - Two Alpinists
Mountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range. The mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N. Mr. Takahashi traversed the range from the west and Mr. Aoki from the east. The height of Mt. i is h_i...
{ "input": [], "output": [] }
{ "input": [ "5\n1 3 3 3 3\n3 3 2 2 2", "10\n1 3776 3776 8848 8848 8848 8848 8848 8848 8848\n8848 8848 8848 8848 8848 8848 8848 8848 3776 5", "1\n17\n17", "5\n1 1 1 2 2\n3 2 1 1 1" ], "output": [ "4", "884111967", "1", "0" ] }
{ "input": [ "5\n2 3 3 3 3\n3 3 2 2 2", "5\n1 1 1 2 2\n6 2 1 1 1", "5\n1 1 1 4 2\n6 2 1 1 1", "5\n1 1 1 4 2\n6 2 1 1 0", "5\n1 1 1 4 2\n6 0 1 1 0", "5\n1 1 1 4 2\n6 1 1 1 0", "5\n1 1 1 4 2\n6 2 1 2 0", "5\n1 1 1 4 2\n9 2 1 2 0", "5\n1 1 1 1 2\n9 2 1 2 0", "5\n1 1 1 1 2\n9 2 1 2...
p00051 Differential II
When you enter 8 numbers from 0 to 9, write a program that outputs the difference between the largest integer and the smallest integer that can sort the 8 numbers. The number that can be sorted may start from 0, such as 00135569. Input Given multiple datasets. The number of datasets n (n ≤ 50) is given on the first...
{ "input": [], "output": [] }
{ "input": [ "2\n65539010\n65539010" ], "output": [ "96417531\n96417531" ] }
{ "input": [ "2\n65539010\n102034250", "2\n65539010\n31390532", "2\n65539010\n31927280", "2\n65539010\n40089442", "2\n65539010\n45258123", "2\n65539010\n53937586", "2\n65539010\n66277190", "2\n124008976\n66277190", "2\n188122632\n66277190", "2\n169123376\n66277190", "2\n211...
p00181 Bookshelf
Taro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshelf in the room, it will be quite small, so you have to devise to make the width of the bookshelf as...
{ "input": [], "output": [] }
{ "input": [ "3 9\n500\n300\n800\n200\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1000\n0 0" ], "output": [ "1800\n1000" ] }
{ "input": [ "3 9\n500\n300\n800\n200\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1010\n0 0", "3 9\n500\n311\n800\n335\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1010\n0 0", "3 9\n559\n311\n800\n335\n100\n563\n900\n700\n400\n4 3\n1000\n1000\n1010\n0 0", "3 9\n500\n300\n800\n200\n100\n600\n900\n1032\n40...
p00337 Road Planning
Villages were scattered in the Wakamatsu Plain of Aizu. Several settlements are connected by straight roads that allow them to travel to and from each other, and any settlement in the plain can be traced back and forth. Each road has a lengthy maintenance fee, but all the settlements funded the road to maintain it. At...
{ "input": [], "output": [] }
{ "input": [ "5 5\n0 0\n1 1\n3 0\n3 2\n0 2\n1 2\n2 3\n2 4\n3 4\n1 5", "7 6\n0 2\n3 0\n2 2\n1 0\n4 1\n2 3\n3 5\n1 3\n2 4\n2 3\n3 5\n3 7\n6 7" ], "output": [ "11.4142", "18.2521" ] }
{ "input": [ "5 5\n0 0\n1 1\n3 0\n3 2\n0 2\n1 2\n3 3\n2 4\n3 4\n1 5", "7 6\n0 2\n3 0\n2 2\n1 0\n4 1\n2 3\n3 4\n1 3\n2 4\n2 3\n3 5\n3 7\n6 7", "7 6\n0 2\n3 0\n2 2\n1 0\n4 1\n2 3\n2 4\n1 3\n2 4\n2 3\n3 5\n3 7\n6 7", "7 6\n-1 2\n3 0\n2 2\n1 0\n4 1\n2 3\n2 4\n1 3\n3 4\n2 3\n3 5\n3 7\n6 7", "7 6\n0 2\n...
p00528 Modern Mansion
Modern Mansion You got lost in a big mansion. This mansion has a structure in which square rooms are arranged in a grid pattern from north, south, east, and west, with M columns in the east-west direction and N rows in the north-south direction, for a total of M x N. The room in the xth column (1 ≤ x ≤ M) from the wes...
{ "input": [], "output": [] }
{ "input": [ "3 2 1\n1 2" ], "output": [ "4" ] }
{ "input": [ "3 2 1\n2 2", "4 2 2\n1 2", "2 2 1\n1 2", "3 2 1\n2 0", "3 2 1\n4 0", "3 2 1\n0 0", "3 1 1\n1 2", "3 2 1\n2 1", "3 0 1\n2 0", "6 2 1\n4 0", "3 1 1\n0 2", "0 0 1\n2 0", "6 2 1\n4 1", "3 1 2\n0 2", "0 0 1\n4 0", "6 2 1\n4 2", "3 1 2\n0 1",...
p00695 Get a Rectangular Field
Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom to get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular land suitable for reclamation. The map o...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1 0 1 0\n0 1 1 1 1\n1 0 1 0 1\n0 1 1 1 0\n0 1 1 0 0\n\n0 1 0 1 1\n0 1 0 1 0\n0 0 1 0 0\n0 0 1 1 0\n1 0 1 0 0\n\n1 1 1 1 0\n0 1 1 1 0\n0 1 1 0 1\n0 1 1 1 0\n0 0 0 0 1" ], "output": [ "4\n3\n8" ] }
{ "input": [ "3\n1 1 0 1 0\n0 1 1 1 1\n1 0 1 0 1\n0 1 1 1 0\n0 1 1 0 0\n\n0 1 0 1 1\n0 1 0 1 0\n0 0 1 0 0\n0 0 1 1 0\n1 0 0 0 0\n\n1 1 1 1 0\n0 1 1 1 0\n0 1 1 0 1\n0 1 1 1 0\n0 0 0 0 1", "3\n1 1 0 1 0\n0 1 1 1 1\n1 0 1 0 1\n0 1 1 1 0\n0 1 1 0 0\n\n0 1 0 1 1\n0 1 0 1 0\n0 0 1 0 0\n0 0 1 1 0\n1 0 0 0 0\n\n1 1 1...
p00836 Sum of Consecutive prime Numbers
Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive integer have? For example, the integer 53 has two representations 5 + 7 + 11 + 13 + 17 and 53. The integer 41 has three representations 2 + 3 + 5 + 7 + 11 + 13, 11 + 13 + 17, ...
{ "input": [], "output": [] }
{ "input": [ "2\n3\n17\n41\n20\n666\n12\n53\n0" ], "output": [ "1\n1\n2\n3\n0\n0\n1\n2" ] }
{ "input": [ "2\n3\n17\n41\n20\n666\n24\n53\n0", "2\n3\n17\n41\n20\n666\n24\n56\n0", "2\n3\n17\n41\n20\n666\n24\n20\n0", "2\n3\n17\n41\n20\n666\n46\n53\n0", "2\n3\n17\n70\n20\n666\n24\n56\n0", "2\n3\n17\n34\n20\n666\n24\n20\n0", "2\n6\n17\n34\n20\n666\n24\n20\n0", "2\n3\n2\n41\n20\n666...
p00968 Digits Are Not Just Characters
Digits Are Not Just Characters Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequences, not as numb...
{ "input": [], "output": [] }
{ "input": [ "2\nfile10\nfile20\nfile3" ], "output": [ "+\n-" ] }
{ "input": [ "2\nfile10\nfi2el0\nfile3", "2\nfjle10\nfi2el0\niele3", "2\n01eljf\nfi2el0\niele3", "2\nflje10\nif3el0\n2elei", "2\nfile10\nfi2el0\neile3", "2\nfjle10\nfi2el0\neile3", "2\n01eljf\nfi2el0\niele2", "2\n01ejlf\nfi2el0\niele2", "2\n01ejlf\nfi3el0\niele2", "2\n01ejlf\ni...
p01100 Gift Exchange Party
Gift Exchange Party A gift exchange party will be held at a school in TKB City. For every pair of students who are close friends, one gift must be given from one to the other at this party, but not the other way around. It is decided in advance the gift directions, that is, which student of each pair receives a gift....
{ "input": [], "output": [] }
{ "input": [ "3 3\n1 2\n2 3\n1 3\n4 3\n1 2\n1 3\n1 4\n4 6\n1 2\n1 3\n1 4\n2 3\n3 4\n2 4\n0 0" ], "output": [ "1 1\n0 1\n1 2" ] }
{ "input": [ "3 3\n1 2\n2 3\n1 3\n4 3\n1 2\n1 3\n1 4\n4 6\n1 2\n1 3\n1 2\n2 3\n3 4\n2 4\n0 0", "3 3\n2 2\n2 3\n2 3\n4 3\n1 2\n1 3\n1 4\n4 6\n1 4\n1 3\n1 4\n2 3\n3 4\n2 4\n0 0", "3 3\n2 2\n2 3\n2 3\n4 3\n1 2\n1 3\n1 4\n6 6\n1 4\n1 3\n1 4\n2 3\n3 4\n2 4\n0 0", "4 3\n1 2\n2 3\n2 3\n4 3\n1 2\n1 3\n1 4\n4 ...
p01237 Life Game
You are working at a production plant of biological weapons. You are a maintainer of a terrible virus weapon with very high reproductive power. The virus has a tendency to build up regular hexagonal colonies. So as a whole, the virus weapon forms a hexagonal grid, each hexagon being a colony of the virus. The grid itse...
{ "input": [], "output": [] }
{ "input": [ "3 3 1\n1 0 0\n0 0 0 0\n0 0 0 0 0\n0 0 0 0\n0 0 1\n3 3 2\n1 0 0\n0 0 0 0\n0 0 0 0 0\n0 0 0 0\n0 0 1\n0 0 0" ], "output": [ "Case 1: 8\nCase 2: 18" ] }
{ "input": [ "3 3 1\n1 0 0\n0 0 0 0\n0 0 0 0 0\n0 0 0 0\n0 0 1\n2 3 2\n1 0 0\n0 0 0 0\n0 0 0 0 0\n0 0 0 0\n0 0 1\n0 0 0", "3 3 1\n2 0 0\n0 0 0 0\n0 0 0 0 0\n0 0 0 0\n0 0 1\n2 3 2\n1 0 0\n0 0 0 0\n0 0 0 0 0\n0 0 0 0\n0 0 1\n0 0 0", "3 3 1\n1 0 0\n0 0 0 0\n0 0 0 0 0\n0 0 0 0\n0 0 1\n3 3 2\n1 0 1\n0 0 0 0\n0...
p01399 Problem B
Problem B: B problem 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. 2DRespecters also ended up creating some issues. However, even three days b...
{ "input": [], "output": [] }
{ "input": [ "3 100\n3 7 4\n5 24\n4 6 12 3 8\n5 1\n1 1 2 2 3\n0 0" ], "output": [ "2\n4\n5" ] }
{ "input": [ "3 101\n3 7 4\n5 24\n4 6 12 3 8\n5 1\n1 1 2 2 3\n0 0", "3 101\n3 7 4\n5 24\n4 5 12 3 8\n5 1\n1 1 2 2 3\n0 0", "3 101\n1 7 7\n5 24\n4 5 12 4 8\n5 1\n1 1 2 2 3\n0 0", "3 100\n3 7 4\n5 6\n4 6 12 3 8\n5 1\n1 1 2 2 3\n0 0", "3 101\n1 7 4\n5 24\n4 5 12 3 8\n5 1\n1 1 4 2 3\n0 0", "3 101\...
p01552 YAML
YAML (YAML Ain't Markup Language) is one of the formats for expressing an object as a character string. You will be given an object represented by a subset of YAML and a query that specifies the property, so please answer the value of the specified property. Subset of YAML A subset of YAML follows the syntax rules e...
{ "input": [], "output": [] }
{ "input": [ ".tweets.1\nname: shimeji\nid: shimejitan\ntweets:\n1: shimejilove\n2: azupero", ".no.such.property\nobject:\nprop1: str\nprop2: str", ".tweets.1\nname: shimeji\nid: shimejitan\ntweets:\n 1: shimejilove\n 2: azupero", ".my.obj\nmy:\nstr: string value\nobj:\na: a\nb: b\nc: c", ".a\na...
{ "input": [ ".tweets.1\nname: shimeji\nid: shimejitan\ntweets:\n1: shimejilove\n:2 azupero", ".tweets.1\nname: shimeki\nid: shimejitan\ntweets:\n 1: shimejilove\n 2: azupero", ".a\na: s`mple case", ".tweets.1\nname: shimeji\nid: shimejitan\ntweets:\n 1: shivejilome\n :2 azupero", ".a\na: s`mp...
p01708 Points and Lines
Problem Statement One day, you found an old scroll with strange texts on it. You revealed that the text was actually an expression denoting the position of treasure. The expression consists of following three operations: * From two points, yield a line on which the points lie. * From a point and a line, yield a poin...
{ "input": [], "output": [] }
{ "input": [ "((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,1)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((30,40))))))\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\n#" ], "output": [ "3.00000000 3.00000000\n3.00000000 1.00000000\n1.00000000 4.00000000\n0.00000000 2.000000...
{ "input": [ "((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,1)\n(0,0)@((1,1)@(4,1))\n(((0,0)@((10,20)@(((20,40))))))\n((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)\n#", "((0,0)@(1,1))@((4,1)@(2,5))\n((0,0)@(3,1))@((1,-3)@(2,-1))\n(0,0)@(1,1)@(4,2)\n(0,0)@((1,1)@(4,1))\n(((0,0...
p01853 Lie with Mean Value
Problem statement N first-year students of the Faculty of Information Science and Technology of R University take the final exam of the lecture called Programming Exercise 1. The test is a perfect score of m. In other words, the score that one student can get is an integer between 0 and m. Since the teacher in charge...
{ "input": [], "output": [] }
{ "input": [ "3 100" ], "output": [ "0 0 100" ] }
{ "input": [ "5 100", "5 110", "5 111", "6 110", "9 110", "9 100", "5 101", "10 110", "14 110", "9 000", "5 000", "20 110", "11 110", "9 010", "5 001", "20 010", "15 110", "14 100", "20 000", "16 110", "14 101", "22 000", "16 ...
p01988 NINJA GAME
NINJA GAME The new game "NINJA GAME" has finally been released. In this game, the player operates a ninja on a two-dimensional map to move. A two-dimensional map is represented by a non-self-intersecting polygon consisting of only sides parallel to either the x-axis or the y-axis. Now, we need to move from the start p...
{ "input": [], "output": [] }
{ "input": [ "8\n1 1 2 2\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n1 3\n1 2\n12\n-9 5 9 -9\n0 0\n0 -13\n3 -13\n3 -10\n10 -10\n10 10\n-1 10\n-1 13\n-4 13\n-4 10\n-10 10\n-10 0\n12\n3 57 53 2\n0 0\n64 0\n64 18\n47 18\n47 39\n64 39\n64 60\n0 60\n0 44\n33 44\n33 30\n0 30\n0" ], "output": [ "1\n1\n2" ] }
{ "input": [ "8\n1 1 2 2\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n1 3\n1 2\n12\n-9 5 9 -9\n0 0\n0 -13\n3 -13\n3 -10\n10 -10\n10 10\n-1 10\n-1 13\n-4 13\n-4 10\n-10 10\n-10 0\n12\n3 57 53 2\n0 0\n64 0\n64 18\n47 18\n21 39\n64 39\n64 60\n0 60\n0 44\n33 44\n33 30\n0 30\n0", "8\n1 1 2 2\n0 2\n0 0\n2 0\n2 1\n3 1\n3 3\n1 3\n...
p02134 Move on Ice
Problem The penguins Fluoro is in an infinitely wide ice cube ($ sx $, $ sy $). There is a hole in the trout ($ tx $, $ ty $) through which water can enter. There are $ n $ lumps of ice on the ice, each in the square ($ x_i $, $ y_i $). Fluoro can move up, down, left and right in four directions. It's slippery on th...
{ "input": [], "output": [] }
{ "input": [ "0 0\n0 2\n1\n0 1", "0 1\n5 0\n4\n2 1\n1 3\n4 2\n3 0", "0 0\n13 33\n2\n0 34\n14 0" ], "output": [ "-1", "4", "0" ] }
{ "input": [ "0 0\n0 2\n0\n0 1", "0 1\n5 0\n4\n2 1\n1 3\n4 1\n3 0", "0 1\n5 1\n4\n3 1\n1 3\n4 1\n3 0", "1 1\n6 0\n6\n2 -1\n1 5\n4 1\n3 0", "-1 1\n5 0\n4\n2 1\n1 3\n4 2\n3 0", "0 1\n13 33\n2\n0 34\n14 0", "-1 0\n0 2\n0\n0 1", "0 1\n5 0\n4\n2 1\n1 3\n6 1\n3 0", "0 1\n13 12\n2\n0 34\n...
p02275 Counting Sort
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in ...
{ "input": [], "output": [] }
{ "input": [ "7\n2 5 1 3 2 3 0" ], "output": [ "0 1 2 2 3 3 5" ] }
{ "input": [ "7\n2 5 1 3 2 3 1", "7\n2 5 1 3 4 3 1", "7\n2 5 2 3 4 3 1", "7\n4 5 2 3 4 3 1", "7\n4 9 2 3 4 3 1", "7\n4 9 2 3 4 3 2", "7\n4 9 2 1 4 3 2", "7\n4 9 2 0 4 3 3", "7\n8 9 2 0 4 3 3", "7\n8 9 2 0 6 3 3", "7\n8 9 3 0 6 3 3", "7\n5 9 3 0 6 3 3", "7\n5 9 4 0 6...
p02422 Transformation
Transformation Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th charact...
{ "input": [], "output": [] }
{ "input": [ "abcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4", "xyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2" ], "output": [ "xaze", "xyz\nabc" ] }
{ "input": [ "abcde\n3\nreplace 1 3 xy{\nreverse 0 2\nprint 1 4", "xyz\n3\nprint 0 2\nreplace 1 2 abc\nprint 0 2", "abcde\n3\nreplace 1 3 xy{\nreverse 0 2\nprint 1 2", "abcde\n3\nreplace 1 3 yy{\nreverse 0 2\nprint 1 2", "abcde\n3\nreplace 1 3 yy{\nreverse 0 2\nprint 1 1", "xyz\n1\nprint 0 2\n...
bintree
Consider an infinite full binary tree (each node has two children except the leaf nodes) defined as follows. For a node labelled v its left child will be labelled 2*v and its right child will be labelled 2*v+1. The root is labelled as 1. You are given N queries of the form i j. For each query, you have to print the len...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n2 3\n4 3" ], "output": [ "1\n2\n3\n" ] }
{ "input": [ "3\n1 2\n2 5\n4 3", "3\n1 2\n1 5\n4 3", "3\n1 2\n1 5\n2 3", "3\n1 4\n1 5\n2 3", "3\n1 2\n2 7\n4 3", "3\n1 4\n1 5\n3 3", "3\n1 2\n2 14\n4 3", "3\n1 4\n1 5\n1 3", "3\n1 4\n1 5\n2 6", "3\n1 4\n2 5\n2 20", "3\n1 4\n2 7\n2 20", "3\n2 2\n2 5\n4 3", "3\n1 2\n1...
coadies2
Problem description : The fight between Raghu and Rannvijay is becoming more intense.This time Rannvijay asked Raghu a question. He gives him a number N and asked him to find the number of all pairs (a, b) of positive integers such that 1 <= a < b <= N and the sum a + b divides the product a * b. Since you are in ...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n15" ], "output": [ "0\n4" ] }
{ "input": [ "2\n3\n15", "2\n3\n29", "2\n3\n14", "2\n1\n11", "2\n1\n2", "2\n6\n2", "2\n16\n1", "2\n32\n0", "2\n61\n0", "2\n85\n1", "2\n116\n3", "2\n116\n6", "2\n156\n6", "2\n234\n6", "2\n234\n20", "2\n65\n20", "2\n74\n20", "2\n55\n20", "2\n55...
fruits
Today is Chef's birthday. His mom has surprised him with truly fruity gifts: 2 fruit baskets. The first basket contains N apples, and the second one contains M oranges. Chef likes apples and oranges very much but he likes them equally, and therefore, wants to have the minimum possible difference between the number of a...
{ "input": [], "output": [] }
{ "input": [ "3\n3 4 1\n5 2 1\n3 4 3" ], "output": [ "0\n2\n0\n" ] }
{ "input": [ "3\n3 4 1\n5 2 2\n3 4 3", "3\n3 4 1\n5 0 2\n3 4 3", "3\n3 0 1\n5 0 2\n1 4 3", "3\n3 0 1\n7 0 2\n1 4 3", "3\n3 1 1\n7 0 2\n1 4 3", "3\n0 1 1\n7 0 2\n1 4 3", "3\n0 1 1\n0 0 2\n1 4 3", "3\n0 1 0\n0 0 2\n1 4 4", "3\n0 2 0\n0 1 2\n1 4 4", "3\n3 4 1\n5 2 1\n4 4 3", "...
luckfour
Kostya likes the number 4 much. Of course! This number has such a lot of properties, like: Four is the smallest composite number; It is also the smallest Smith number; The smallest non-cyclic group has four elements; Four is the maximal degree of the equation that can be solved in radicals; There is four-color theorem...
{ "input": [], "output": [] }
{ "input": [ "5\n447474\n228\n6664\n40\n81" ], "output": [ "4\n0\n1\n1\n0\n" ] }
{ "input": [ "5\n447474\n228\n6664\n40\n35", "5\n447474\n228\n2424\n40\n57", "5\n447474\n340\n2424\n40\n57", "5\n447474\n340\n2424\n40\n42", "5\n742529\n340\n2424\n40\n42", "5\n1167956\n340\n2424\n40\n42", "5\n1167956\n340\n2424\n40\n7", "5\n1167956\n580\n2424\n40\n7", "5\n1167956\...
prmarth
Children are taught to add multi-digit numbers from right to left, one digit at a time. Many find the “carry” operation, where a 1 is carried from one digit position to the next, to be a significant challenge. Your job is to count the number of carry operations for each of a set of addition problems so that educators m...
{ "input": [], "output": [] }
{ "input": [ "123 456\n555 555\n123 594\n0 0" ], "output": [ "No carry operation.\n3 carry operations.\n1 carry operation." ] }
{ "input": [], "output": [] }
tcfst05
You always wanted to be a soldier and play it out at the battleground live. When you came at Techfest 2013, you encountered Lazer Tag, a game that satiated your innate hunger for taking aim and shooting enemies. Lazer Tag consists of a group play, where you are assigned a fixed number of bullets (popularly known as La...
{ "input": [], "output": [] }
{ "input": [ "4\n0.6 0.5 0.8 0.2", "3\n1 1 1" ], "output": [ "4.556000", "9.000000" ] }
{ "input": [], "output": [] }
1512_C. A-B Palindrome
You are given a string s consisting of the characters '0', '1', and '?'. You need to replace all the characters with '?' in the string s by '0' or '1' so that the string becomes a palindrome and has exactly a characters '0' and exactly b characters '1'. Note that each of the characters '?' is replaced independently fro...
{ "input": [], "output": [] }
{ "input": [ "9\n4 4\n01?????0\n3 3\n??????\n1 0\n?\n2 2\n0101\n2 2\n01?0\n0 1\n0\n0 3\n1?1\n2 2\n?00?\n4 3\n??010?0\n" ], "output": [ "\n01011010\n-1\n0\n-1\n0110\n-1\n111\n1001\n0101010\n" ] }
{ "input": [ "9\n4 4\n01?????0\n3 3\n??????\n1 0\n?\n2 2\n1101\n2 2\n01?0\n0 1\n0\n0 3\n1?1\n2 2\n?00?\n4 3\n??010?0\n", "9\n4 4\n01?????0\n3 3\n??????\n1 0\n?\n2 2\n1101\n2 2\n01?0\n0 1\n0\n0 3\n1?1\n2 2\n?00?\n4 3\n??000?0\n", "9\n4 4\n0????1?0\n3 3\n??????\n1 0\n?\n2 2\n1101\n2 2\n01?0\n0 1\n0\n0 3\n1?...
153_A. A + B
You are given two integers A and B. Calculate their sum and output it without leading zeros. Input Two lines of input data contain integers A and B (1 ≤ A, B ≤ 105). Output Output A + B without leading zeros. Examples Input 12 3 Output 15 Input 100 5 Output 105 Note The code provided in the post about...
{ "input": [], "output": [] }
{ "input": [ "12\n3\n", "100\n5\n" ], "output": [ "15\n", "105\n" ] }
{ "input": [], "output": [] }
661_G. Hungarian Notation
In Hungarian notation, a variable name is prefixed with a letter or a group of letters which are mnemonics for the type of that variable. For the purposes of this problem we will consider only two data types: integer and real. You are given the meaningful part of variable name in lowercase and a sample value that it w...
{ "input": [], "output": [] }
{ "input": [ "count\n18\n", "weight\n3.95\n" ], "output": [ "iCount\n", "fWeight\n" ] }
{ "input": [], "output": [] }
monk-in-the-land-of-pokemons
Monk has to visit a land where strange creatures, known as Pokemons, roam around in the wild. Each Pokemon in the land will attack any visitor. They can only be pacified by feeding them their favorite food. The Pokemon of type X eats one food item of type X. Monk knows that he will encounter N ponds on the way. At ea...
{ "input": [], "output": [] }
{ "input": [ "1\n5\n1 1\n2 2\n3 4\n4 3\n2 4\n\nSAMPLE" ], "output": [ "1\n" ] }
{ "input": [ "1\n5\n1 1\n2 4\n3 4\n4 3\n2 4\n\nSAMPLE", "1\n5\n1 1\n2 2\n3 4\n4 3\n2 4\n\nSAEPLM", "1\n5\n1 1\n1 2\n3 4\n4 3\n2 8\n\nSAMPLE", "1\n1\n1 1\n1 1\n3 4\n4 3\n1 8\n\nSAMPLE", "1\n5\n2 1\n2 2\n3 1\n4 7\n2 10\n\nEMPMAS", "1\n5\n1 2\n2 6\n3 5\n1 5\n2 4\n\nSAEPMM", "1\n5\n1 1\n2 2\n3...
pink-and-blue
Xenny was a teacher and he had N students. The N children were sitting in a room. Each child was wearing a white T-shirt, with a unique number from the range 1 to N written on it. T-Shirts of pink and blue color were to be distributed among the students by Xenny. This made the students very happy. Xenny felt that a ra...
{ "input": [], "output": [] }
{ "input": [ "3 2\nB G B\n1 2\n1 3\n\nSAMPLE" ], "output": [ "1" ] }
{ "input": [], "output": [] }
roy-and-shopping-20
Alfi asked Roy to go for shopping with her. Witty Roy came up with a condition. He said, for each product of MRP (Maximum Retail Price) R, she'll have to pay minimum of all the prime factors of R and he himself will pay rest of the amount. Without giving it a second thought Alfi agreed. Now they bought N number of pr...
{ "input": [], "output": [] }
{ "input": [ "2\n5\n10\n\nSAMPLE" ], "output": [ "0\n8\n" ] }
{ "input": [ "2\n5\n10\n\nSAMPKE", "2\n5\n18\n\nSAMPKE", "2\n5\n20\n\nEKPLAS", "2\n5\n28\n\nEKPLAS", "2\n1\n38\n\nEKPLAS", "2\n1\n64\n\nLKPEAS", "2\n5\n13\n\nSAMPKE", "2\n10\n18\n\nEKPLAS", "2\n4\n18\n\nEKPLAS", "2\n5\n34\n\nEKPLAS", "2\n1\n40\n\nEKPLAS", "2\n1\n66\n\nL...
subset-sum-2
Peter is very weak in mathematics. His father gave him a problem and left to work. He is a lazy lad and he wants you to find the solution. Given a set A which contains elements ranging from 1 to N.Find the sum of the elements in all possible subsets of the given set. Input Format: T, the number of test cases. Follow...
{ "input": [], "output": [] }
{ "input": [ "2\n6\n3\n\nSAMPLE" ], "output": [ "672\n24\n" ] }
{ "input": [ "2\n4\n3\n\nSAMPLE", "2\n4\n5\n\nSAMPLE", "2\n7\n3\n\nSAMPLE", "2\n3\n5\n\nSAMPLE", "2\n3\n2\n\nSAMPLE", "2\n3\n3\n\nSAMPLE", "2\n6\n2\n\nSAMPLE", "2\n9\n2\n\nSAMPLE", "2\n4\n2\n\nASMPLE", "2\n8\n3\n\nSAMPLE", "2\n4\n6\n\nSAMPLE", "2\n6\n5\n\nSAMPLE", "...
vasu-and-inversions
Vasu has N Numbers ( Value either 0 or 1 ) . He is performing Inversions on it. In each Inversion he can select one number. If number is 0 then he converts it in 1 and if number is 1 then he converts it in 0. He has to perform the Inversions exactly K times and wants to maximize total numbers of 1's . Find out po...
{ "input": [], "output": [] }
{ "input": [ "3\n1 1\n1\n2 1\n0 0\n3 2\n1 0 0\n\nSAMPLE" ], "output": [ "0\n1\n3\n" ] }
{ "input": [ "3\n1 1\n1\n2 1\n0 0\n3 4\n1 0 0\n\nSAMPLE", "3\n1 1\n0\n2 1\n0 0\n3 2\n1 0 0\n\nSAMPLE", "3\n1 1\n1\n2 1\n0 0\n3 4\n1 0 1\n\nSAMPLE", "3\n1 1\n0\n2 1\n0 0\n3 2\n0 0 0\n\nSAMPLE", "3\n1 1\n0\n2 1\n0 0\n3 0\n1 0 0\n\nSALPLE", "3\n1 1\n0\n2 2\n0 0\n3 2\n0 0 0\n\nSAMPLE", "3\n1 1...
p02606 AIsing Programming Contest 2020 - Number of Multiples
How many multiples of d are there among the integers between L and R (inclusive)? Constraints * All values in input are integers. * 1 \leq L \leq R \leq 100 * 1 \leq d \leq 100 Input Input is given from Standard Input in the following format: L R d Output Print the number of multiples of d among the integers b...
{ "input": [], "output": [] }
{ "input": [ "1 100 1", "6 20 7", "5 10 2" ], "output": [ "100", "2", "3" ] }
{ "input": [ "1 100 2", "9 20 7", "5 10 1", "9 20 3", "5 4 1", "9 31 3", "2 4 1", "9 21 3", "2 3 1", "2 10 1", "2 110 2", "2 8 1", "0 100 1", "2 24 1", "0 110 1", "1 32 3", "2 110 1", "2 12 1", "1 110 1", "1 58 4", "1 67 4", "2 73...
p02737 AtCoder Grand Contest 043 - Giant Graph
Given are simple undirected graphs X, Y, Z, with N vertices each and M_1, M_2, M_3 edges, respectively. The vertices in X, Y, Z are respectively called x_1, x_2, \dots, x_N, y_1, y_2, \dots, y_N, z_1, z_2, \dots, z_N. The edges in X, Y, Z are respectively (x_{a_i}, x_{b_i}), (y_{c_i}, y_{d_i}), (z_{e_i}, z_{f_i}). Bas...
{ "input": [], "output": [] }
{ "input": [ "3\n3\n1 3\n1 2\n3 2\n2\n2 1\n2 3\n1\n2 1", "100000\n1\n1 2\n1\n99999 100000\n1\n1 100000", "2\n1\n1 2\n1\n1 2\n1\n1 2" ], "output": [ "883188316", "318525248", "46494701" ] }
{ "input": [ "3\n3\n1 3\n2 2\n3 2\n2\n2 1\n2 3\n1\n2 1", "100000\n1\n1 3\n1\n99999 100000\n1\n1 100000", "2\n1\n1 2\n1\n1 3\n1\n1 2", "3\n3\n1 3\n2 2\n3 2\n2\n2 1\n1 3\n1\n2 1", "100000\n1\n0 3\n1\n99999 100000\n1\n1 100000", "100000\n1\n0 1\n1\n38150 100000\n1\n1 100000", "100000\n0\n0 0\...
p02871 Hitachi Hokudai Labo & Hokkaido University Contest 2019-1 - Problem A
Requirements * All inputs are of non-negative integer value. * T_{\text{max}} = 10000 * 200 \leq |V| \leq 400 * 1.5 |V| \leq |E| \leq 2 |V| * 1 \leq u_{i}, v_{i} \leq |V| (1 \leq i \leq |E|) * 1 \leq d_{u_i, v_i} \leq \lceil 4\sqrt{2|V|} \rceil (1 \leq i \leq |E|) * The given graph has no self-loops / multiple edges a...
{ "input": [], "output": [] }
{ "input": [ "5 7\n1 2 5\n5 3 4\n2 4 8\n1 5 1\n2 3 3\n4 5 3\n4 3 9\n4\n1\n1 2\n1\n2 5\n1\n3 4\n0" ], "output": [ "2\n-1\n1\n5" ] }
{ "input": [ "5 7\n1 2 5\n5 3 4\n2 4 12\n1 5 1\n2 3 3\n4 5 3\n4 3 9\n4\n1\n1 2\n1\n2 5\n1\n3 4\n0", "5 7\n1 2 5\n5 3 4\n2 4 12\n1 5 1\n2 1 3\n4 5 3\n4 3 5\n7\n1\n1 1\n1\n2 5\n1\n3 4\n0", "5 7\n1 2 5\n5 3 4\n2 4 12\n1 5 1\n2 1 3\n4 5 3\n4 3 9\n6\n1\n1 1\n1\n2 6\n1\n3 4\n0", "5 7\n1 2 5\n5 3 4\n2 4 12\n...
p03006 diverta 2019 Programming Contest 2 - Picking Up
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates...
{ "input": [], "output": [] }
{ "input": [ "3\n1 4\n4 6\n7 8", "4\n1 1\n1 2\n2 1\n2 2", "2\n1 1\n2 2" ], "output": [ "1", "2", "1" ] }
{ "input": [ "3\n1 4\n4 6\n11 8", "2\n1 2\n2 2", "4\n1 1\n1 4\n2 1\n2 2", "3\n1 4\n4 6\n11 3", "3\n0 4\n4 6\n11 3", "3\n-1 4\n4 6\n11 3", "3\n-2 4\n4 6\n11 3", "3\n-2 4\n5 6\n11 3", "3\n-2 4\n5 6\n11 4", "3\n-1 4\n5 6\n11 4", "3\n-1 4\n5 10\n11 4", "3\n-1 7\n5 10\n11 4"...
p03146 AtCoder Beginner Contest 116 - Collatz Problem
A sequence a=\\{a_1,a_2,a_3,......\\} is determined as follows: * The first term s is given as input. * Let f(n) be the following function: f(n) = n/2 if n is even, and f(n) = 3n+1 if n is odd. * a_i = s when i = 1, and a_i = f(a_{i-1}) when i > 1. Find the minimum integer m that satisfies the following conditio...
{ "input": [], "output": [] }
{ "input": [ "54", "8", "7" ], "output": [ "114", "5", "18" ] }
{ "input": [ "87", "11", "10", "82", "17", "20", "65", "2", "22", "43", "18", "15", "27", "6", "35", "5", "38", "31", "28", "9", "12", "25", "16", "39", "55", "44", "50", "41", "26", "47", "59",...
p03290 AtCoder Beginner Contest 104 - All Green
A programming competition site AtCode provides algorithmic problems. Each problem is allocated a score based on its difficulty. Currently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points. These p_1 + … + p_D problems are all of the problems available on AtCode. A user...
{ "input": [], "output": [] }
{ "input": [ "5 25000\n20 1000\n40 1000\n50 1000\n30 1000\n1 1000", "2 400\n3 500\n5 800", "2 700\n3 500\n5 800", "2 2000\n3 500\n5 800" ], "output": [ "66", "2", "3", "7" ] }
{ "input": [ "5 25000\n20 0000\n40 1000\n50 1000\n30 1000\n1 1000", "2 431\n3 500\n5 800", "2 1328\n3 500\n5 800", "2 2000\n3 500\n7 800", "5 25000\n20 0010\n40 1000\n50 1000\n60 1000\n1 1000", "5 10847\n20 0010\n40 1000\n50 1000\n60 1000\n1 1000", "2 1328\n3 890\n10 800", "3 10847\n26...
p03446 AtCoder Petrozavodsk Contest 001 - Rectangles
We have a rectangular parallelepiped of dimensions A×B×C, divided into 1×1×1 small cubes. The small cubes have coordinates from (0, 0, 0) through (A-1, B-1, C-1). Let p, q and r be integers. Consider the following set of abc small cubes: \\{(\ (p + i) mod A, (q + j) mod B, (r + k) mod C\ ) | i, j and k are integers s...
{ "input": [], "output": [] }
{ "input": [ "2 2 2 4 4 4", "2 3 4 98 99 100", "1 1 1 2 2 2", "2 3 4 6 7 8" ], "output": [ "744", "471975164", "1", "0" ] }
{ "input": [ "2 2 2 4 7 4", "1 1 2 2 2 2", "2 3 1 98 99 100", "1 1 2 2 3 2", "2 3 2 98 99 100", "2 3 2 98 171 100", "2 3 2 138 171 100", "2 1 4 98 99 100", "1 1 1 1 2 2", "2 3 4 98 171 100", "2 3 2 64 171 100", "2 1 4 98 115 100", "1 1 4 6 4 8", "2 3 2 98 84 100...
p03606 AtCoder Beginner Contest 073 - Theater
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now? Constrai...
{ "input": [], "output": [] }
{ "input": [ "1\n24 30", "2\n6 8\n3 3" ], "output": [ "7", "4" ] }
{ "input": [ "1\n0 30", "2\n6 12\n3 3", "1\n1 30", "2\n6 12\n0 3", "1\n2 30", "2\n6 10\n0 3", "1\n2 0", "2\n6 10\n0 1", "1\n2 -1", "2\n3 10\n0 1", "2\n3 2\n0 1", "1\n1 0", "2\n3 3\n0 1", "1\n1 1", "1\n4 0", "1\n8 0", "1\n7 0", "2\n0 0\n-2 0", ...
p03767 AtCoder Grand Contest 012 - AtCoder Group Contest
There are 3N participants in AtCoder Group Contest. The strength of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams. The strength of a team is defined as the second largest strength among its members. For ...
{ "input": [], "output": [] }
{ "input": [ "2\n5 2 8 5 1 5", "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000...
{ "input": [ "2\n2 2 8 5 1 5", "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1100000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000...
p03935 square869120Contest #3 - Sum of Fibonacci Sequence
E869120 defined a sequence $a$ like this: * $a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \ (k \ge 1)$ He also defined sequences $d_1, d_2, d_3, \dots , d_n$, as the following recurrence relation : * $d_{1, j} = a_j$ * $d_{i, j} = \sum_{k = 1}^j d_{i - 1, k} \ (i \ge 2)$ You are given integers $n$ and $m$. Please calculate...
{ "input": [], "output": [] }
{ "input": [ "4 7", "12 20", "16 30" ], "output": [ "176", "174174144", "102292850" ] }
{ "input": [ "6 7", "12 2", "16 38", "1 7", "12 1", "16 25", "2 7", "12 0", "16 29", "2 9", "16 46", "3 9", "16 31", "4 9", "27 31", "4 18", "27 51", "4 10", "27 102", "1 10", "42 102", "42 123", "46 123", "70 123", "7...
p00028 Mode Value
Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently. Input A sequence of integers ai (1 ≤ ai ≤ 100). The number of integers is less than or equals to 100. Output Print the mode values. If there are se...
{ "input": [], "output": [] }
{ "input": [ "5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4" ], "output": [ "3\n5" ] }
{ "input": [ "5\n6\n3\n5\n8\n7\n6\n3\n9\n7\n3\n4", "5\n5\n3\n5\n8\n7\n6\n3\n9\n7\n3\n4", "5\n3\n3\n1\n15\n7\n6\n6\n16\n2\n1\n4", "5\n3\n3\n1\n15\n7\n6\n6\n16\n1\n1\n4", "5\n3\n2\n1\n15\n7\n6\n6\n16\n2\n1\n4", "5\n5\n1\n1\n15\n7\n6\n6\n16\n2\n2\n4", "5\n5\n1\n1\n28\n7\n6\n6\n16\n2\n0\n4", ...
p00159 The Best Body
There is BMI (Body Mass Index) as an index showing the degree of obesity. The BMI value is calculated using the following formula. BMI = weight (kg) / (height (m)) 2 The closer the BMI value is to the standard value, the more "ideal body shape" is considered. Therefore, if the standard value of BMI is 22, create a pr...
{ "input": [], "output": [] }
{ "input": [ "6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 70\n1 170 75\n0" ], "output": [ "3\n2" ] }
{ "input": [ "6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 32\n1 170 75\n0", "6\n1 165 66\n2 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 65\n2 180 70\n1 170 103\n0", "6\n1 165 93\n0 178 60\n3 180 72\n4 160 65\n5 185 62\n6 182 62\n3\n3 160 94\n2 180 32\n1 1...
p00316 Investigation of Club Activities
Akira, the student council president of A High School, decided to investigate which club activities the A High School students belong to. A High School has N students numbered 1 to N and M types of club activities numbered 1 to M. There is no limit to the number of people in each club activity, and there can be 0 club ...
{ "input": [], "output": [] }
{ "input": [ "3 2 5\n1 1 2\n1 2 3\n2 1 1\n2 3 2\n2 2 1", "3 2 4\n1 1 2\n2 1 1\n2 3 2\n2 2 1", "3 2 2\n1 1 2\n2 1 1" ], "output": [ "4", "0", "0" ] }
{ "input": [ "3 2 7\n1 1 2\n1 2 3\n2 1 1\n2 3 2\n2 2 1", "3 2 4\n1 1 2\n2 1 1\n2 3 2\n1 2 1", "3 2 4\n2 1 2\n2 1 1\n2 3 2\n2 2 1", "3 2 5\n2 1 2\n1 2 3\n2 1 1\n2 3 2\n2 2 1", "3 2 6\n1 1 2\n1 2 3\n2 1 1\n2 3 1\n2 2 2", "3 1 2\n1 1 2\n2 1 1", "3 2 7\n1 1 3\n1 2 3\n2 1 1\n2 3 2\n2 2 1", ...
p00486 Walking Santa
At the end of last year, Santa Claus forgot to give Christmas presents to the children in JOI village. Therefore, I decided to deliver the chocolate cake to the children as an apology. The day to deliver is approaching tomorrow, so it's time to come up with a move plan. JOI village is divided into a grid shape by W ro...
{ "input": [], "output": [] }
{ "input": [ "5 4\n3\n1 1\n3 4\n5 3" ], "output": [ "10\n3 3" ] }
{ "input": [ "5 4\n3\n1 1\n3 4\n5 6", "6 4\n3\n1 1\n1 4\n5 6", "6 4\n3\n1 1\n1 4\n5 12", "6 4\n3\n0 1\n1 4\n5 12", "5 4\n3\n1 1\n3 4\n5 2", "5 4\n3\n1 1\n3 4\n7 6", "6 4\n3\n1 0\n1 4\n5 6", "6 4\n3\n1 1\n1 3\n5 12", "6 4\n3\n0 1\n1 4\n5 0", "5 4\n3\n1 1\n3 3\n5 2", "5 4\n3\...
p00672 Dimensional Analysis
The dimension of quantity is a concept that ignores concrete numerical values ​​from the relational expressions between different quantities and focuses only on the type of quantity and its power. Specifically, the relational expression of the dimension is expressed as an equation ignoring the constant coefficient. Tha...
{ "input": [], "output": [] }
{ "input": [ "2 3 2\nlength\n1 0\ntime\n0 1\nspeed\n1 -1\na/b\na length\nb time\n2 3 3\nlength\n1 0\ntime\n0 1\nspeed\n1 -1\na/b+c\na length\nb time\nc speed\n2 3 3\nlength\n1 0\ntime\n0 1\nspeed\n1 -1\na/b+c\na length\nb time\nc time\n2 3 2\nlength\n1 0\ntime\n0 1\nspeed\n1 -1\na/b/b\na length\nb time\n3 6 6\nsp...
{ "input": [ "2 3 2\nlength\n1 0\ntime\n0 1\nspeed\n1 -1\na/b\na length\nb time\n2 3 3\nlength\n1 0\ntime\n0 1\nspeed\n1 -1\na/b+c\na length\nb time\nc speed\n2 3 3\nlength\n1 0\ntime\n0 1\nspeed\n1 -1\na/b+c\na length\nb time\nc time\n2 3 2\nlength\n2 0\ntime\n0 1\nspeed\n1 -1\na/b/b\na length\nb time\n3 6 6\nsp...
p00815 Map of Ninja House
An old document says that a Ninja House in Kanazawa City was in fact a defensive fortress, which was designed like a maze. Its rooms were connected by hidden doors in a complicated manner, so that any invader would become lost. Each room has at least two doors. The Ninja House can be modeled by a graph, as shown in Fi...
{ "input": [], "output": [] }
{ "input": [ "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 5 4 -2 4 -3 -2 -2 -1 0" ], "output": [ "1 2 4 6\n2 1 3 8\n3 2 4 7\n4 1 3 5\n5 4 6 7\n6 1 5\n7 3 5 8\n8 2 7\n1 2 3 4\n2 1 3 3 4 4\n3 1 2 2 4\n4 1 2 2 3" ] }
{ "input": [ "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 5 3 -2 4 -3 -2 -2 -1 0", "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 5 4 -2 4 -1 -2 -2 -1 0", "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 2 4 -2 4 -3 -2 -2 -1 0", "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 2 4 -2 5 -3 -2 -2 -1 0", "2\n3 3 3 3 -3 3 2 -5 3 2 -5 -3 0\n3 ...
p00946 Rearranging a Sequence
Example Input 5 3 4 2 5 Output 5 2 4 1 3
{ "input": [], "output": [] }
{ "input": [ "5 3\n4\n2\n5" ], "output": [ "5\n2\n4\n1\n3" ] }
{ "input": [ "5 0\n4\n2\n5", "2 0\n4\n2\n6", "5 3\n5\n2\n5", "3 0\n4\n0\n6", "7 0\n3\n0\n6", "9 0\n3\n0\n6", "9 1\n4\n0\n6", "1 0\n10\n0\n0", "10 1\n4\n0\n6", "10 1\n8\n0\n6", "5 1\n4\n1\n5", "4 0\n4\n0\n6", "11 0\n3\n0\n6", "10 0\n4\n0\n0", "17 1\n4\n0\n6",...
p01079 Hogemon Get
Problem Gaccho is enthusiastic about the popular game Hogemon Get. The country of Aizu, where Gaccho lives, consists of N towns, each numbered from 1 to N. In addition, there are M roads in Aizu, and all roads connect two different towns. Gaccho can move in both directions, but he can't go from one town to another thr...
{ "input": [], "output": [] }
{ "input": [ "5 4 50\n0 1 1 10 0\n1 2 10\n2 3 10\n2 4 10\n4 5 10", "5 4 40\n0 1 1 1 0\n1 2 5\n2 3 5\n3 4 5\n4 5 5", "4 3 100\n0 3 1 0\n1 2 5\n2 3 30\n3 4 5" ], "output": [ "22", "6", "16" ] }
{ "input": [ "5 4 50\n0 1 1 10 0\n1 2 17\n2 3 10\n2 4 10\n4 5 10", "5 4 50\n0 1 1 12 0\n1 2 17\n2 3 10\n2 4 10\n4 5 10", "5 4 40\n0 0 1 1 0\n1 2 5\n2 3 5\n3 4 5\n4 5 5", "5 4 50\n0 1 1 12 0\n1 2 17\n2 3 10\n2 4 7\n4 5 10", "5 4 50\n0 1 1 10 0\n1 2 17\n2 3 10\n1 4 9\n4 5 10", "4 3 100\n0 6 1 0\...
p01213 Repeated Subsequences
You are a treasure hunter traveling around the world. Finally, you’ve got an ancient text indicating the place where the treasure was hidden. The ancient text looks like a meaningless string of characters at first glance. Actually, the secret place is embedded as the longest repeated subsequence of the text. Well, the...
{ "input": [], "output": [] }
{ "input": [ "ABCABCABAB\nZZZZZZZZZZZZ\nEND", "ABCABCABAB\nZZZZZZZZZZZZ\n#END" ], "output": [ "ABAB\nZZZZZZ", "ABAB\nZZZZZZ" ] }
{ "input": [ "ABCABCABAB\nZZZZZZZZZZZZ\nNED", "ABCABCABAB\nZZZZZZZZZZZZ\nNDD", "ABCABCACAB\nZZZZZZZZZZZZ\nNDD", "ABBABCACAB\nZZZZZZZZZZZZ\nNDD", "ABBABCACAB\nZ[ZZZZZZZZZZ\nNDD", "ABCABCABAB\nZZZZZZZZZZZZ\nNEE", "ABBABCACAB\nZZZZZZZZZZZZ\nNED", "ABCABCABAB\nZZZZZZZZZZZY\nNEE", "BACA...
p01349 Ennichi
A rabbit who came to the fair found that the prize for a game at a store was a carrot cake. The rules for this game are as follows. There is a grid-like field of vertical h squares x horizontal w squares, and each block has at most one block. Each block is a color represented by one of the uppercase letters ('A'-'Z')....
{ "input": [], "output": [] }
{ "input": [ "4 6 3\n......\n...Y..\n...Y..\nRRYRYY", "4 6 3\n......\n...Y..\n...Y..\nRRYRY." ], "output": [ "YES", "NO" ] }
{ "input": [ "4 6 3\n......\n..Y...\n...Y..\nRRYRYY", "4 6 1\n......\n...Y..\n/..Z..\nYRRRYY", "4 6 3\n......\n...Y..\n...Y..\nRRYRZ.", "4 6 3\n......\n...Y..\n/..Y..\nRRYRYY", "4 6 3\n......\n...Y..\n...Y..\n.RYRYR", "4 6 3\n......\n...Y..\n...Z..\nRRYRZ.", "4 6 3\n......\n...Y..\n/..Z..\...
p01531 Flick Input
A: Flick input A college student who loves 2D, commonly known as 2D, replaced his long-used Galapagos mobile phone with a smartphone. 2D, who operated the smartphone for the first time, noticed that the character input method was a little different from that of old mobile phones. On smartphones, a method called flick ...
{ "input": [], "output": [] }
{ "input": [ "5R2D" ], "output": [ "neko" ] }
{ "input": [ "5R3D", "5D2R", "5T2D", "5D3R", "5U2D", "4D2R", "6T2D", "3R5D", "4R2D", "6D2T", "4R5D", "4R3D", "5D2T", "5U1D", "7T2D", "4D3R", "4R6D", "3R3D", "3D3R", "5R4D", "6R3D", "6U2D", "5D1T", "8T2D", "3R4D", "...
p01687 D's Ambition
A --D's Ambition / D's Yabou Story Aizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. cute. The person in D is horrified by the cute Aizu Nyan like an angel, and is a metamorphosis who plans to make a mess if there is a chance. ...
{ "input": [], "output": [] }
{ "input": [ "AIDUNYAN" ], "output": [ "AIZUNYAN" ] }
{ "input": [ "NAYNUDIA", "AIDTNYAN", "AIDTNXAN", "NIDTAXAN", "NIDTAX@N", "NIDTAY@N", "NIDTAY?N", "NICTAY?N", "NI?TAYCN", "NCYAT?IN", "NI?SAYCN", "NI?SBYCN", "NI?RBYCN", "YI?RBNCN", "NCNBR?IY", "NCMBR?IY", "MCMBR?IY", "YI?RBMCM", "YIR?BMCM", ...
p01831 Line Gimmick
Example Input 7 >> Output 7
{ "input": [], "output": [] }
{ "input": [ "7\n>>" ], "output": [ "7" ] }
{ "input": [ "7\n>=", "7\n=>", "7\n?=", "7\n=?", "7\n<?", "7\n?<", "7\n><", "7\n>?", "7\n?>", "7\n?;", "7\n@=", "7\n;?", "7\n:?", "7\n<=", "7\n=<", "7\n@>", "7\n=@", "7\n@;", "7\n==", "7\n@:", "7\n:>", "7\n;=", "7\n;>", "7...
p01966 Conveyor Belt
Awesome Conveyor Machine (ACM) is the most important equipment of a factory of Industrial Conveyor Product Corporation (ICPC). ACM has a long conveyor belt to deliver their products from some points to other points. You are a programmer hired to make efficient schedule plan for product delivery. ACM's conveyor belt go...
{ "input": [], "output": [] }
{ "input": [ "5 2\n1 4 1\n2 3 1", "5 2\n1 3 3\n3 5 1", "5 2\n1 4 1\n2 3 5", "10 4\n3 5 2\n5 7 5\n8 9 2\n1 7 5" ], "output": [ "4\n4", "5\n6", "4\n8", "6\n11\n11\n16" ] }
{ "input": [ "10 2\n1 4 1\n2 3 1", "5 2\n1 3 3\n3 5 2", "10 2\n1 5 1\n2 3 1", "5 2\n1 4 0\n2 3 5", "10 4\n3 5 2\n5 7 5\n8 9 4\n1 7 5", "10 1\n1 4 1\n2 3 1", "10 4\n3 5 1\n5 7 5\n8 9 2\n1 7 5", "9 2\n1 7 1\n2 3 1", "5 2\n1 1 0\n2 3 5", "10 1\n1 4 0\n2 3 1", "5 2\n1 4 1\n2 4 ...
p02113 Palindrome
Problem Taro has N character strings, each of which is L in length. Taro loves palindromes, so I want to make palindromes as long as possible by selecting some of the N character strings and arranging them in any order. Find the longest palindrome that Taro can make. If there are more than one, output the smallest on...
{ "input": [], "output": [] }
{ "input": [ "5 1\na\nb\nc\na\nc", "3 3\nuki\nuku\nuke", "4 2\noi\nio\nrr\nrr" ], "output": [ "acbca", "uku", "iorrrroi" ] }
{ "input": [ "5 2\na\nb\nc\na\nc", "3 2\nuki\nuku\nuke", "4 2\npi\nio\nrr\nrr", "4 2\npi\nio\nrr\nqr", "7 2\na\nb\nc\n`\nc", "2 3\na\nb\nc\n`\nc", "5 1\na\nb\nc\nb\nc", "4 2\noi\nio\nrr\nsr", "5 2\na\na\nc\na\nc", "7 2\na\nb\nc\na\nb", "7 2\na\nb\nc\n`\nb", "4 3\na\nb\n...
p02253 Activity Selection Problem
There are $ n $ acitivities with start times $ \\ {s_i \\} $ and finish times $ \\ {t_i \\} $. Assuming that a person can only work on a single activity at a time, find the maximum number of activities that can be performed by a single person. Constraints * $ 1 \ le n \ le 10 ^ 5 $ * $ 1 \ le s_i \ lt t_i \ le 10 ^ 9...
{ "input": [], "output": [] }
{ "input": [ "5\n1 2\n3 9\n3 5\n5 9\n6 8", "3\n1 2\n2 3\n3 4", "3\n1 5\n3 4\n2 5" ], "output": [ "3", "2", "1" ] }
{ "input": [ "5\n2 2\n3 9\n3 5\n5 9\n6 8", "3\n1 1\n2 3\n3 4", "3\n0 5\n3 4\n2 5", "5\n3 2\n5 5\n4 3\n0 3\n6 8", "5\n2 2\n3 9\n4 5\n5 9\n6 8", "3\n1 1\n2 4\n3 4", "3\n-1 5\n3 4\n2 5", "5\n2 2\n3 9\n4 5\n1 9\n6 8", "3\n1 1\n2 4\n3 3", "3\n-1 5\n3 4\n2 7", "5\n2 2\n3 9\n4 4\n...
p02401 Simple Calculator
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. Constraints * 0 ≤ a, b ≤ 20000 * No divisions by zero are given. Input The input c...
{ "input": [], "output": [] }
{ "input": [ "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0" ], "output": [ "3\n38\n26\n10\n108" ] }
{ "input": [ "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n-1 ? 0", "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 , 81\n-1 ? 0", "1 + 2\n56 - 18\n21 * 2\n100 / 10\n27 , 81\n-1 ? 0", "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 136\n-1 ? 0", "1 + 2\n56 - 18\n21 * 2\n100 / 10\n9 , 81\n-1 ? 0", "2 + 2\n56 - 18\...
alg2n
The chef won a duet singing award at Techsurge & Mridang 2012. From that time he is obsessed with the number 2. He just started calculating the powers of two. And adding the digits of the results. But he got puzzled after a few calculations. So gave you the job to generate the solutions to 2^n and find their sum of di...
{ "input": [], "output": [] }
{ "input": [ "3\n5\n10\n4" ], "output": [ "5\n7\n7\n" ] }
{ "input": [ "3\n5\n12\n4", "3\n3\n12\n4", "3\n2\n12\n4", "3\n2\n12\n7", "3\n4\n12\n7", "3\n4\n12\n0", "3\n4\n12\n1", "3\n4\n6\n1", "3\n4\n6\n0", "3\n4\n8\n0", "3\n4\n14\n0", "3\n4\n22\n0", "3\n4\n22\n1", "3\n4\n19\n1", "3\n3\n19\n1", "3\n3\n32\n1", ...
chefston
Chef is playing a game. Currently in the game, he is at a field full of stones. There are total N kinds of stones. There is unlimited supply of each kind of stone. Chef knows that one stone of kind i needs Ai minutes to pick it from the ground and it will give Chef a profit of Bi Rs. Chef has K minutes of free time. ...
{ "input": [], "output": [] }
{ "input": [ "1\n3 10\n3 4 5\n4 4 5" ], "output": [ "12\n" ] }
{ "input": [ "1\n3 10\n3 4 5\n4 4 0", "1\n3 0\n3 8 2\n4 4 0", "1\n3 10\n3 4 2\n4 4 5", "1\n3 10\n3 1 5\n4 4 0", "1\n3 10\n5 8 5\n4 4 0", "1\n3 11\n3 8 3\n8 4 0", "1\n3 11\n3 8 3\n3 4 0", "1\n3 10\n6 5 5\n4 -1 0", "1\n3 6\n3 6 3\n3 4 1", "1\n3 5\n3 6 3\n3 4 1", "1\n3 5\n5 11...
drgnbool
In the world of DragonBool there are fierce warriors called Soints. Also there are even fiercer warriors called Sofloats – the mortal enemies of Soints. The power of each warrior is determined by the amount of chakra he possesses which is some positive integer. Warriors with zero level of chakra are dead warriors :) ...
{ "input": [], "output": [] }
{ "input": [ "2\n2 3\n10 1\n20 2\n5 2\n5 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n43 93\n49 46\n74 93\n78 87\n99 13\n59 36" ], "output": [ "8\n89\n" ] }
{ "input": [ "2\n2 3\n10 1\n20 2\n5 2\n4 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n43 93\n49 46\n74 93\n78 87\n99 13\n59 36", "2\n2 3\n10 1\n20 2\n5 2\n4 2\n18 1\n5 5\n73 87\n69 13\n36 36\n77 46\n16 93\n49 46\n74 93\n78 87\n99 13\n59 36", "2\n2 3\n10 1\n20 2\n5 2\n4 2\n18 1\n5 5\n100 87\n69 13\n36 36\n77 ...
junongf
Problem description Chef Juno's girlfriend, May, is a programmer and a mathematician, and she loves solving problems. Everyday Chef Juno comes up with new problems for her to solve, otherwise she gets bored and depressed. He doesn't want her to feel so, but he has run out of all problems. He consults his Chef friends, ...
{ "input": [], "output": [] }
{ "input": [ "3\n1 2\n1 1 1 1 1 1\n1 1 1 1 1 1\n3 2\n1 1 1 1 1 2\n2 1 1 1 1 1\n3 3\n1 1 1 1 1 2\n1 1 0 0 0 2" ], "output": [ "1\n729\n387420489\n" ] }
{ "input": [ "3\n1 2\n1 1 1 1 1 1\n1 1 1 1 2 1\n3 2\n1 1 1 1 1 2\n2 1 1 1 1 1\n3 3\n1 1 1 1 1 2\n1 1 0 0 0 2", "3\n1 2\n1 1 1 1 1 1\n2 1 1 1 2 1\n3 2\n1 1 1 1 1 2\n2 1 1 1 1 1\n3 3\n2 1 1 1 1 2\n1 1 0 0 0 2", "3\n1 2\n1 1 1 1 1 1\n2 1 1 1 2 1\n3 2\n2 1 1 1 1 2\n2 1 1 1 1 1\n3 3\n2 1 1 1 1 2\n2 1 0 0 0 2",...
numgame
Alice and Bob play the following game. They choose a number N to play with. The rules are as follows : 1) Alice plays first, and the two players alternate. 2) In his/her turn, a player can subtract from N any proper divisor (not equal to N) of N. The number thus obtained is the new N. 3) The person who cannot mak...
{ "input": [], "output": [] }
{ "input": [ "2\n1\n2" ], "output": [ "BOB\nALICE\n" ] }
{ "input": [ "2\n2\n2", "2\n2\n1", "2\n1\n1", "2\n9\n2", "2\n6\n2", "2\n9\n1", "2\n15\n1", "2\n22\n1", "2\n8\n1", "2\n8\n2", "2\n12\n2", "2\n18\n2", "2\n29\n1", "2\n15\n2", "2\n12\n1", "2\n29\n2", "2\n25\n1", "2\n20\n2", "2\n16\n1", "2\n3...
smcd1
Problem description. Ram over slept and is late for class! Ram doesn’t like to goto college, so he decides to give his card to his friend. Unfortunately, Teacher got to know that number of students are less then present in the class. Help Teacher! finding number of proxies.   Input Input description. First line of inp...
{ "input": [], "output": [] }
{ "input": [ "5\n.###." ], "output": [ "2" ] }
{ "input": [ "5\n.#\"#.", "5\n/#\"#.", "5\n\"#-/#", "5\n.#\"#/", "5\n#.\"#/", "5\n#.\"#.", "5\n#.!#.", "5\n#.!\".", "5\n#.!#/", "5\n.#!.#", "5\n.#!/#", "5\n!#./#", "5\n\"#./#", "5\n\"#./\"", "5\n\"#..\"", "5\n\"..#\"", "5\n\"..##", "5\n\"#..#", ...
1302_C. Segment tree or Fenwick?
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 an array A of length n, initially filled with zeros. You need to process q queries to the array, each of one of the following types: 1. 1 x y: you ne...
{ "input": [], "output": [] }
{ "input": [ "2\n6 5\n2 1 6\n1 3 2\n2 2 4\n1 6 3\n2 1 6\n5 3\n1 3 7\n1 1 4\n2 1 5\n" ], "output": [ "\n0\n2\n5\n11\n" ] }
{ "input": [], "output": [] }
1408_H. Rainbow Triples
You are given a sequence a_1, a_2, …, a_n of non-negative integers. You need to find the largest number m of triples (i_1, j_1, k_1), (i_2, j_2, k_2), ..., (i_m, j_m, k_m) such that: * 1 ≤ i_p < j_p < k_p ≤ n for each p in 1, 2, …, m; * a_{i_p} = a_{k_p} = 0, a_{j_p} ≠ 0; * all a_{j_1}, a_{j_2}, …, a_{j_m} are ...
{ "input": [], "output": [] }
{ "input": [ "8\n1\n1\n2\n0 0\n3\n0 1 0\n6\n0 0 1 2 0 0\n6\n0 1 0 0 1 0\n6\n0 1 3 2 0 0\n6\n0 0 0 0 5 0\n12\n0 1 0 2 2 2 0 0 3 3 4 0\n" ], "output": [ "0\n0\n1\n2\n1\n1\n1\n2\n" ] }
{ "input": [ "8\n1\n1\n2\n0 0\n3\n0 1 0\n6\n0 0 1 4 0 0\n6\n0 1 0 0 1 0\n6\n0 1 3 2 0 0\n6\n0 0 0 0 5 0\n12\n0 1 0 2 2 2 0 0 3 3 4 0\n", "8\n1\n1\n2\n0 0\n3\n0 1 0\n6\n0 1 1 4 0 0\n6\n0 1 0 0 1 0\n6\n0 1 3 2 0 0\n6\n0 0 0 0 5 0\n12\n0 1 0 2 3 2 0 0 3 3 4 0\n", "8\n1\n1\n2\n0 0\n3\n0 1 0\n6\n0 0 1 4 0 0\n6...
1476_D. Journey
There are n + 1 cities, numbered from 0 to n. n roads connect these cities, the i-th road connects cities i - 1 and i (i ∈ [1, n]). Each road has a direction. The directions are given by a string of n characters such that each character is either L or R. If the i-th character is L, it means that the i-th road initiall...
{ "input": [], "output": [] }
{ "input": [ "2\n6\nLRRRLL\n3\nLRL\n" ], "output": [ "\n1 3 2 3 1 3 2\n1 4 1 4\n" ] }
{ "input": [ "2\n6\nLLRRRL\n3\nLRL\n", "2\n6\nLLRRRL\n3\nRLL\n", "2\n6\nLRRRLL\n3\nRLL\n", "2\n6\nLLRRRL\n3\nLLR\n", "2\n6\nLRRRLL\n3\nLLR\n", "2\n6\nLRLRRL\n3\nLRL\n", "2\n6\nRRLRLL\n3\nRLL\n", "2\n6\nRRRLLL\n3\nLLR\n", "2\n6\nRLRRLL\n3\nLLR\n", "2\n6\nLLLRRR\n3\nLLR\n", "...
big-p-and-punishment-5
Big P has become a Physical Education teacher at Hack International School. Today, the students of class XII have been very undisciplined and he decides to punish them all. He makes all of the N student (numbered 1 to N ) to stand in a line and asks them to sit down on their knees. Students know that Big P is a very...
{ "input": [], "output": [] }
{ "input": [ "1\n3 2 1\n1 2\n2 3\n2\n\nSAMPLE" ], "output": [ "2" ] }
{ "input": [ "1\n6 2 1\n1 2\n2 3\n2\n\nSAMPLE", "1\n6 2 1\n1 2\n4 3\n2\n\nSAMPLD", "1\n6 2 0\n1 2\n4 3\n2\n\nSAMPLD", "1\n6 2 1\n1 4\n4 2\n1\n\nDLPSAM", "1\n6 2 1\n1 2\n2 3\n2\n\nSAMPLD", "1\n6 2 1\n1 3\n2 3\n2\n\nSAMPLD", "1\n6 2 1\n1 2\n4 3\n2\n\nMASPLD", "1\n3 2 1\n2 2\n2 3\n2\n\nSA...
finding-numbers
Alice has just learnt multiplying two integers. He wants to multiply two integers X and Y to form a number Z. To make the problem interesting he will choose X in the range [1,M] and Y in the range [1,N]. Help him to find the number of ways in which he can do this. Input First line of the input is the number of test ca...
{ "input": [], "output": [] }
{ "input": [ "4\n4 7 9\n5 2 10\n5 5 6\n2 8 1\n\nSAMPLE" ], "output": [ "3\n1\n2\n1\n" ] }
{ "input": [ "4\n4 7 9\n10 2 10\n5 5 6\n2 8 1\n\nSAMPLE", "4\n4 7 9\n5 2 18\n5 5 6\n2 8 1\n\nSAMPLE", "4\n4 2 9\n10 2 10\n5 5 6\n2 8 1\n\nSAMPLE", "4\n4 2 9\n10 2 10\n5 5 3\n2 8 1\n\nSAMPLE", "4\n4 7 8\n6 4 20\n5 5 6\n1 28 1\n\nSAMPLE", "4\n4 7 8\n6 4 20\n5 5 3\n2 28 1\n\nSAMPLE", "4\n4 7 ...
maximum-subset
You will be given a set of distinct numbers. Your task is to find that even length subset which will give you a maximum value of P % (10^9 + 7). This value of P for a subset of length N is defined as below : P = (product of N/2 maximum values) / (product of N/2 minimum values) Now suppose we have a subset S...
{ "input": [], "output": [] }
{ "input": [ "2\n2\n2 4\n3\n2 4 8\n\nSAMPLE" ], "output": [ "2\n4" ] }
{ "input": [ "2\n2\n2 4\n3\n4 4 8\n\nSAMPLE", "2\n2\n2 2\n3\n4 4 8\n\nSAMPLE", "2\n2\n2 4\n3\n2 4 10\n\nSAMPLE", "2\n2\n2 4\n3\n1 4 8\n\nSAMPLE", "2\n2\n2 2\n3\n5 4 8\n\nSAMPLE", "2\n2\n2 4\n0\n2 4 10\n\nSAMPLE", "2\n2\n2 2\n3\n5 5 8\n\nSAMPLE", "2\n2\n1 2\n3\n2 4 8\n\nELPLAS", "2\...
p02555 AtCoder Beginner Contest 178 - Redistribution
Given is an integer S. Find how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S. The answer can be very large, so output it modulo 10^9 + 7. Constraints * 1 \leq S \leq 2000 * All values in input are integers. Input Input is given from Standard Input in ...
{ "input": [], "output": [] }
{ "input": [ "7", "1729", "2" ], "output": [ "3", "294867501", "0" ] }
{ "input": [ "13", "3", "26", "1", "35", "20", "11", "15", "8", "10", "70", "22", "25", "14", "9", "19", "21", "27", "6", "1175", "23", "66", "37", "29", "41", "39", "48", "12", "16", "32", "40"...
p02686 AtCoder Beginner Contest 167 - Bracket Sequencing
A bracket sequence is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be forme...
{ "input": [], "output": [] }
{ "input": [ "3\n(((\n)\n)", "2\n)\n(()", "4\n((()))\n((((((\n))))))\n()()()", "2\n)(\n()" ], "output": [ "No", "Yes", "Yes", "No" ] }
{ "input": [ "3\n()(\n)\n)", "2\n)\n()(", "4\n((()))\n((((()\n))))))\n()()()", "2\n)(\n)(", "3\n()(\n)\n(", "2\n((\n)(", "3\n())\n)\n(", "2\n((\n()", "3\n(((\n)\n(", "2\n)\n(((", "4\n((()))\n((((((\n))))))\n)()()(", "2\n)(\n))", "3\n()(\n(\n)", "2\n)\n())", ...
p02815 AtCoder Beginner Contest 150 - Change a Little Bit
For two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows: * Consider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost of those operations. * Change S_i (from 0 to 1 or vice versa). The cost of this operation is D \time...
{ "input": [], "output": [] }
{ "input": [ "2\n5 8", "1\n1000000000", "5\n52 67 72 25 79" ], "output": [ "124", "999999993", "269312" ] }
{ "input": [ "2\n8 8", "1\n1000010000", "5\n20 67 72 25 79", "2\n8 6", "1\n1000000010", "5\n2 67 72 25 79", "1\n1000000110", "5\n2 67 72 25 55", "2\n11 0", "1\n1000000111", "5\n2 67 16 25 55", "1\n1000000101", "5\n2 67 30 25 55", "1\n1000100111", "5\n2 124 3...
p02951 AtCoder Beginner Contest 136 - Transfer
We have two bottles for holding water. Bottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water. Bottle 2 contains C milliliters of water. We will transfer water from Bottle 2 to Bottle 1 as much as possible. How much amount of water will remain in Bottle 2? Constraints * All val...
{ "input": [], "output": [] }
{ "input": [ "12 3 7", "8 3 9", "6 4 3" ], "output": [ "0", "4", "1" ] }
{ "input": [ "12 0 7", "8 3 16", "8 6 16", "1 6 16", "0 2 0", "0 6 16", "0 4 0", "0 6 4", "1 4 0", "1 7 0", "-1 6 0", "3 -1 5", "-1 1 3", "-4 4 0", "-7 1 1", "-12 0 1", "-12 -1 1", "-11 1 3", "-11 1 5", "-14 1 5", "-25 1 5", "-25 ...
p03087 AtCoder Beginner Contest 122 - GeT AC
You are given a string S of length N consisting of `A`, `C`, `G` and `T`. Answer the following Q queries: * Query i (1 \leq i \leq Q): You will be given integers l_i and r_i (1 \leq l_i < r_i \leq N). Consider the substring of S starting at index l_i and ending at index r_i (both inclusive). In this string, how many t...
{ "input": [], "output": [] }
{ "input": [ "8 3\nACACTACG\n3 7\n2 3\n1 8" ], "output": [ "2\n0\n3" ] }
{ "input": [ "8 3\nACACTACG\n3 7\n2 3\n1 6", "8 3\nGCATCACA\n3 7\n2 3\n1 8", "8 3\nACBCTADG\n3 7\n2 3\n1 6", "8 3\nACACTACG\n3 7\n2 3\n1 2", "8 3\nACACTACG\n3 7\n4 3\n1 2", "8 3\nGAATCCCA\n3 7\n3 3\n2 8", "8 3\nACACTADG\n3 7\n2 4\n1 6", "8 2\nACBCTACG\n6 7\n3 3\n1 6", "8 3\nACACTAD...
p03232 AtCoder Grand Contest 028 - Removing Blocks
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of t...
{ "input": [], "output": [] }
{ "input": [ "10\n1 2 4 8 16 32 64 128 256 512", "2\n1 2", "4\n1 1 1 1" ], "output": [ "880971923", "9", "212" ] }
{ "input": [ "10\n1 2 4 8 16 32 64 128 22 512", "2\n1 1", "4\n1 2 1 1", "10\n1 2 4 8 16 32 64 128 21 512", "2\n2 1", "4\n1 2 2 1", "10\n1 2 4 8 20 32 64 128 21 512", "2\n2 2", "4\n1 2 2 2", "10\n1 2 4 8 20 32 89 128 21 512", "2\n1 0", "10\n1 2 4 8 20 26 89 128 21 512", ...
p03383 AtCoder Regular Contest 095 - Symmetric Grid
There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i. Snuke can apply the following operation to this grid any number of times: * Choose two...
{ "input": [], "output": [] }
{ "input": [ "3 7\natcoder\nregular\ncontest", "12 12\nbimonigaloaf\nfaurwlkbleht\ndexwimqxzxbb\nlxdgyoifcxid\nydxiliocfdgx\nnfoabgilamoi\nibxbdqmzxxwe\npqirylfrcrnf\nwtehfkllbura\nyfrnpflcrirq\nwvcclwgiubrk\nlkbrwgwuiccv", "2 3\narc\nrac" ], "output": [ "NO", "YES", "YES" ] }
{ "input": [ "3 7\natcocer\nregular\ncontest", "2 3\nacr\ncar", "12 12\nbimonigaloaf\nfaurwlkbleht\ndexwimqxzxbb\nlxdgyoifcxid\nydxilincfdgx\nnfoabgilamoi\nibxbdqmzxxwe\npqirylfrcrnf\nwtehfkllbura\nyfrnpflcrirq\nwvcclwgiubrk\nlkbrwgwuiccv", "12 12\nbimonigaloaf\nfaurwlkbleht\ndexwimqxzxbb\nlxdgyoifcxi...
p03547 AtCoder Beginner Contest 078 - HEX
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`,...
{ "input": [], "output": [] }
{ "input": [ "F F", "A B", "E C" ], "output": [ "=", "<", ">" ] }
{ "input": [ "E F", "A A", "E B", "D F", "A C", "E A", "E E", "A D", "D B", "F E", "A E", "D C", "F D", "A F", "E D", "F C", "B E", "G E", "G D", "C E", "H E", "D D", "C D", "H D", "F B", "C C", "I E", "G B...
p03703 AtCoder Regular Contest 075 - Meaningful Mean
You are given an integer sequence of length N, a = {a_1, a_2, …, a_N}, and an integer K. a has N(N+1)/2 non-empty contiguous subsequences, {a_l, a_{l+1}, …, a_r} (1 ≤ l ≤ r ≤ N). Among them, how many have an arithmetic mean that is greater than or equal to K? Constraints * All input values are integers. * 1 ≤ N ≤ 2 ...
{ "input": [], "output": [] }
{ "input": [ "1 2\n1", "3 6\n7\n5\n7", "7 26\n10\n20\n30\n40\n30\n20\n10" ], "output": [ "0", "5", "13" ] }
{ "input": [ "1 4\n1", "3 6\n7\n5\n10", "7 26\n10\n20\n30\n43\n30\n20\n10", "1 6\n10\n20\n27\n12\n30\n20\n12", "2 1\n1\n12\n34\n45\n2\n9\n1", "2 1\n0\n18\n19\n56\n0\n4\n-4", "3 5\n7\n5\n7", "7 26\n10\n20\n30\n40\n3\n20\n10", "4 1\n1\n12\n34\n45\n4\n3\n1", "6 1\n0\n12\n61\n45\n2...
p03858 AtCoder Regular Contest 065 - Manhattan Compass
There are N pinholes on the xy-plane. The i-th pinhole is located at (x_i,y_i). We will denote the Manhattan distance between the i-th and j-th pinholes as d(i,j)(=|x_i-x_j|+|y_i-y_j|). You have a peculiar pair of compasses, called Manhattan Compass. This instrument always points at two of the pinholes. The two legs ...
{ "input": [], "output": [] }
{ "input": [ "6 2 3\n1 3\n5 3\n3 5\n8 4\n4 7\n2 5", "5 1 2\n1 1\n4 3\n6 1\n5 5\n4 8", "8 1 2\n1 5\n4 3\n8 2\n4 7\n8 8\n3 3\n6 6\n4 8" ], "output": [ "4", "4", "7" ] }
{ "input": [ "6 2 3\n1 3\n5 3\n3 5\n8 4\n4 10\n2 5", "5 1 2\n1 1\n4 1\n6 1\n5 5\n4 8", "8 1 2\n1 5\n4 3\n8 2\n4 7\n7 8\n3 3\n6 6\n4 8", "6 2 3\n1 3\n5 2\n3 5\n8 4\n4 10\n2 5", "6 2 3\n1 3\n9 2\n3 5\n8 4\n4 10\n2 5", "4 0 3\n-1 2\n23 0\n0 6\n8 10\n5 1\n1 10", "6 1 3\n1 3\n5 3\n3 5\n8 4\n4 8...
p04023 AtCoder Grand Contest 003 - Sequential operations on Sequence
Snuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i. Snuke performs the following Q operations on this sequence. The i-th operation, described by a parameter q_i, is as follows: * Take the first q_i elements from the sequence obtained by concaten...
{ "input": [], "output": [] }
{ "input": [ "10 10\n9\n13\n18\n8\n10\n10\n9\n19\n22\n27", "5 3\n6\n4\n11" ], "output": [ "7\n4\n4\n3\n3\n2\n2\n2\n0\n0", "3\n3\n3\n2\n0" ] }
{ "input": [ "10 10\n9\n13\n18\n8\n10\n10\n9\n19\n33\n27", "10 10\n9\n13\n18\n8\n10\n1\n9\n19\n33\n27", "10 8\n9\n13\n18\n8\n10\n1\n9\n19\n33\n27", "10 10\n9\n13\n18\n7\n10\n10\n9\n19\n22\n27", "5 3\n6\n4\n6", "20 10\n9\n13\n18\n8\n10\n10\n9\n19\n33\n27", "10 10\n9\n13\n18\n8\n10\n5\n9\n19...
p00107 Carry a Cheese
Jerry is a little mouse. He is trying to survive from the cat Tom. Jerry is carrying a parallelepiped-like piece of cheese of size A × B × C. It is necessary to trail this cheese to the Jerry's house. There are several entrances in the Jerry's house. Each entrance is a rounded hole having its own radius R. Could you he...
{ "input": [], "output": [] }
{ "input": [ "10 6 8\n5\n4\n8\n6\n2\n5\n0 0 0" ], "output": [ "NA\nOK\nOK\nNA\nNA" ] }
{ "input": [ "10 6 8\n5\n4\n1\n6\n2\n5\n0 0 0", "10 6 8\n5\n4\n0\n0\n2\n5\n0 0 0", "10 6 8\n5\n4\n0\n0\n2\n7\n0 0 0", "10 6 8\n5\n1\n8\n6\n2\n5\n0 0 0", "10 6 4\n5\n4\n0\n-1\n2\n7\n0 0 0", "10 6 4\n5\n4\n0\n-1\n4\n7\n0 0 0", "10 3 8\n5\n4\n0\n6\n2\n5\n0 0 0", "10 6 8\n5\n1\n8\n3\n2\n5\...
p00241 Quaternion Multiplication
An extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using four real numbers $ x $, $ y $, $ z $, $ w $ and special numbers (extended imaginary numbers) $ i $...
{ "input": [], "output": [] }
{ "input": [ "2\n1 2 3 4 7 6 7 8\n5 6 7 8 3 2 3 4\n0" ], "output": [ "-58 16 36 32\n-50 32 28 48" ] }
{ "input": [ "2\n1 2 3 4 7 6 7 8\n5 6 4 8 3 2 3 4\n0", "2\n1 2 3 4 7 6 14 8\n5 6 4 8 3 2 3 4\n0", "2\n1 3 3 4 7 6 14 8\n5 6 4 8 3 2 3 4\n0", "2\n1 3 3 4 7 6 14 8\n5 11 4 8 3 2 3 4\n0", "2\n1 3 3 7 7 6 14 8\n5 11 4 8 3 2 3 4\n0", "2\n1 3 3 7 7 6 14 8\n5 11 4 5 3 2 3 4\n0", "2\n1 3 3 7 7 6 1...
p00420 Chemical Substance Alpha
At Aiz Pharmaceutical, research on chemical substances is carried out every day. I am currently studying the code name "Alpha", a chemical substance that has a structure in which molecules from $ 1 $ to $ N $ are linearly arranged from the left end to the right end. Using the technology developed by Aiz Pharmaceutical...
{ "input": [], "output": [] }
{ "input": [ "6 5 8\n1 3\n2 5\n3 4\n2 4\n2 5\n1 1 5 1\n1 1 5 2\n1 1 5 3\n1 1 5 4\n1 1 5 5\n1 1 5 6\n2 3 4 2\n1 1 1 1" ], "output": [ "3\n2\n4\n5\n1\n6\n4\n3" ] }
{ "input": [ "6 5 8\n1 3\n2 5\n3 4\n3 4\n2 5\n1 1 5 1\n1 1 5 2\n1 1 5 3\n1 1 5 4\n1 1 5 5\n1 1 5 6\n2 3 4 2\n1 1 1 1", "6 5 8\n1 3\n2 5\n3 4\n2 4\n2 5\n1 1 5 1\n1 1 5 2\n1 1 5 3\n1 1 5 4\n1 1 5 5\n1 1 5 6\n2 3 4 4\n1 1 1 1", "6 5 8\n1 3\n2 5\n3 4\n2 4\n2 4\n1 1 5 1\n1 1 5 2\n1 1 5 3\n1 1 5 4\n1 1 5 5\n1 1...
p00617 Simple GUI Application
Advanced Creative Mobile (ACM) has decided to develop a GUI application to be installed in a new portable computer. As shown in the figure below, the GUI has a nested structure in which it has one main panel, several panels are arranged on it, and some panels are arranged on top of those panels. .. All panels are rect...
{ "input": [], "output": [] }
{ "input": [ "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n10 10\n15 15\n40 60\n2 3\n130 80\n0" ], "output": [ "main 2\nmain 2\nmenu 0\nOUT OF MAIN PANEL 1\nprimary 0" ] }
{ "input": [ "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n10 10\n15 15\n40 60\n1 3\n130 80\n0", "5\n<main>10,10,190,150<menu>20,20,70,140</menu><primary>80,20,180,140</primary></main>\n9 10\n15 15\n40 60\n1 3\n130 80\n0", "5\n<main>10,10,190,150<menu>20,00,72,14...
p00761 Recurring Decimals
A decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Let us make a sequence using this fact. A non-negative integer a0 and the number of digits L are given first. Applying the following rules, we obtain ai+1 from ai. 1. Express the integer ai in decimal nota...
{ "input": [], "output": [] }
{ "input": [ "2012 4\n83268 6\n1112 4\n0 1\n99 2\n0 0" ], "output": [ "3 6174 1\n1 862632 7\n5 6174 1\n0 0 1\n1 0 1" ] }
{ "input": [ "2012 4\n83268 3\n1112 4\n0 1\n99 2\n0 0", "2012 4\n83268 6\n1112 4\n0 1\n99 1\n0 0", "2012 4\n83268 3\n1112 4\n0 1\n17 2\n0 0", "2012 4\n83268 6\n1112 3\n0 1\n99 1\n0 0", "2012 4\n83268 6\n1112 4\n0 0\n99 1\n0 0", "2012 4\n83268 3\n1112 6\n0 1\n17 2\n0 0", "2012 4\n83268 3\n1...
p00893 Matrix Calculator
Dr. Jimbo, an applied mathematician, needs to calculate matrices all day for solving his own problems. In his laboratory, he uses an excellent application program for manipulating matrix expressions, however, he cannot use it outside his laboratory because the software consumes much of resources. He wants to manipulate...
{ "input": [], "output": [] }
{ "input": [ "1\nA=[1 2 3;4 5 6].\n1\nA=[[1 2 3;4 5 6] [7 8;9 10] [11;12];13 14 15 16 17 18].\n3\nB=[3 -2 1;-9 8 7].\nC=([1 2 3;4 5 6]+B)(2,3).\nD=([1 2 3;4 5 6]+B)([1 2],[2 3]).\n5\nA=2*[1 2;-3 4]'.\nB=A([2 1 2],[2 1]).\nA=[1 2;3 4]*3.\nA=[2]*[1 2;3 4].\nA=[1 2;3 4]*[3].\n2\nA=[11 12 13;0 22 23;0 0 33].\nA=[A A'...
{ "input": [ "1\nA=[1 2 3;4 5 6].\n1\nA=[[1 4 3;4 5 6] [7 8;9 10] [11;12];13 14 15 16 17 18].\n3\nB=[3 -2 1;-9 8 7].\nC=([1 2 3;4 5 6]+B)(2,3).\nD=([1 2 3;4 5 6]+B)([1 2],[2 3]).\n5\nA=2*[1 2;-3 4]'.\nB=A([2 1 2],[2 1]).\nA=[1 2;3 4]*3.\nA=[2]*[1 2;3 4].\nA=[1 2;3 4]*[3].\n2\nA=[11 12 13;0 22 23;0 0 33].\nA=[A A'...
p01026 Witch Craft Moves
Problem Aizu Magic School is a school where people who can use magic gather. Aizu Magic School has classrooms numbered from 1 to N and a corridor connecting the classrooms. You can go through the classrooms and corridors as many times as you like. In addition, Aizu Magic School has only one route that allows you to mo...
{ "input": [], "output": [] }
{ "input": [ "7\n1\n2\n3\n4\n5\n6\n7\n1 2\n1 3\n3 4\n3 5\n5 6\n5 7\n10\n0 1 7\n0 2 7\n1 1 15\n0 1 7\n0 2 7\n0 1 1\n1 1 -15\n0 1 7\n0 2 7\n0 1 1" ], "output": [ "16\n18\n31\n33\n16\n16\n18\n1" ] }
{ "input": [ "7\n1\n2\n3\n4\n5\n6\n7\n1 2\n1 3\n3 4\n3 5\n5 6\n5 7\n10\n0 1 7\n0 2 7\n1 1 15\n0 1 7\n0 3 7\n0 1 1\n1 1 -15\n0 1 7\n0 2 7\n0 1 1", "7\n1\n2\n3\n4\n5\n6\n7\n1 2\n1 3\n3 4\n3 5\n5 6\n5 7\n10\n0 1 7\n0 2 7\n1 1 15\n0 1 7\n0 3 7\n0 1 1\n1 1 -15\n0 1 7\n0 2 7\n0 1 2", "7\n1\n2\n3\n4\n5\n6\n7\n1 ...
p01157 Online Quiz System
ICPC (Internet Contents Providing Company) is working on a killer game named Quiz Millionaire Attack. It is a quiz system played over the Internet. You are joining ICPC as an engineer, and you are responsible for designing a protocol between clients and the game server for this system. As bandwidth assigned for the ser...
{ "input": [], "output": [] }
{ "input": [ "3 2\n1 2 10\n3\n0 3420 o\n1 4589 o\n2 4638 x\n3\n1 6577 SUZUMIYA\n2 7644 SUZUMIYA\n0 19979 YASUZUMI\n4 2\n150 150 150 150\n4\n0 1344 HOGEHOGE\n1 1466 HOGEHOGE\n2 1789 HOGEHOGE\n3 19100 GEHO\n2\n2 1200 SETTEN\n3 700 SETTEN\n0 0" ], "output": [ "177 57\n19 58\n19 57\n19 62\n\n253 70\n13 58\n13...
{ "input": [ "3 2\n1 2 10\n3\n0 3420 o\n1 4589 o\n2 4638 x\n3\n1 6577 SUZUMIYA\n2 7644 SUZUMIYA\n0 19979 YASUZUMI\n4 2\n150 138 150 150\n4\n0 1344 HOGEHOGE\n1 1466 HOGEHOGE\n2 1789 HOGEHOGE\n3 19100 GEHO\n2\n2 1200 SETTEN\n3 700 SETTEN\n0 0", "3 2\n1 2 10\n3\n0 3420 o\n1 4589 o\n2 4638 x\n3\n1 6577 SUZUMIYA\n...
p01296 Futon
The sales department of Japanese Ancient Giant Corp. is visiting a hot spring resort for their recreational trip. For deepening their friendships, they are staying in one large room of a Japanese-style hotel called a ryokan. In the ryokan, people sleep in Japanese-style beds called futons. They all have put their futo...
{ "input": [], "output": [] }
{ "input": [ "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n2 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0" ], "output": [ "Yes\nNo\nYes" ] }
{ "input": [ "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n2 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n1 1 y\n1 2 x\n0", "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 w\n0 1 x\n2 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0", "4\n0 0 x\n2 0 x\n0 1 x\n2 1 x\n4\n1 0 x\n0 1 x\n3 1 x\n1 2 x\n4\n0 0 x\n2 0 y\n0 1 y\n1 2 x\n0",...
p01465 Testing Circuits
A Boolean expression is given. In the expression, each variable appears exactly once. Calculate the number of variable assignments that make the expression evaluate to true. Input A data set consists of only one line. The Boolean expression is given by a string which consists of digits, x, (, ), |, &, and ~. Other ...
{ "input": [], "output": [] }
{ "input": [ "(x1&x2)", "(x1&x2)|(x3&x4)|(~(x5|x6)&(x7&x8))" ], "output": [ "1", "121" ] }
{ "input": [ "(x1&x3)|(x2&x4)|(~(x5|x6)&(x7&x8))", "(x1&x3)", "(x1|x2)&(x3&x4)|(~(x5|x6)&(x6&x8))", "(x2&x35|(x2&x4)|(~(x)|x8)&(x6&x6))", "(x1&x3)|(x2&x4)|(~(x)|x65&(x6&x8))", "(x2&x3)|(x2&x4)|(~(x5|x86&(x)&x6))", "(x1&x3)|(x2&x4)|(~(x5|x6)&(x6&x8))", "(x1&x2)|(x3&x4)|(~(x4|x6)&(x7&x8)...
p01625 Princess Tetra's Puzzle
Princess Tetra of the Kingdom of Palace is known as an unrivaled puzzle lover, and has recently been enthusiastic about her own "Tetra puzzle". This is a puzzle that uses a board with equilateral triangle squares and a regular tetrapod block consisting of four equilateral triangle panels called a tetrapod. The purpose ...
{ "input": [], "output": [] }
{ "input": [ "3\n2 3 2 2 2 1\n2 0 1 -1 2 -1\n-2 -1 -1 -1 -2 0\n6\n-1 0 1 0 0 -1\n-2 -1 -3 -2 -4 -2\n2 -1 2 0 1 -1\n4 -2 3 -2 3 -1\n1 1 0 1 -1 1\n-3 -1 -1 -1 -2 0\n5\n-1 2 0 2 1 2\n-3 1 -2 1 -2 2\n-2 0 -2 -1 -3 0\n1 -1 0 -1 -1 -1\n1 0 2 0 2 -1\n4\n-2 0 -2 -1 -3 -1\n-1 -1 0 -1 1 -1\n2 -1 2 0 3 -1\n-1 0 0 0 1 0\n5\n...
{ "input": [ "3\n2 3 2 2 2 1\n2 0 1 -1 2 -1\n-2 -2 -1 -1 -2 0\n6\n-1 0 1 0 0 -1\n-2 -1 -3 -2 -4 -2\n2 -1 2 0 1 -1\n4 -2 3 -2 3 -1\n1 1 0 1 -1 1\n-3 -1 -1 -1 -2 0\n5\n-1 2 0 2 1 2\n-3 1 -2 1 -2 2\n-2 0 -2 -1 -3 0\n1 -1 0 -1 -1 -1\n1 0 2 0 2 -1\n4\n-2 0 -2 -1 -3 -1\n-1 -1 0 -1 1 -1\n2 -1 2 0 3 -1\n-1 0 0 0 1 0\n5\n...
p01777 Disordered Data Detection
F: Disordered Data Detection / Anomaly detection story Akane Miyamori is an engineer working for Musashino Software. Today, I'm worried about the bug report I received from the customer. "Weird story, the behavior of the software you made last time is plump, can you check it there? Isn't it your job to maintain it?" ...
{ "input": [], "output": [] }
{ "input": [ "7\n4 1 10 5 7 7 3\n5\n2 5 0\n3 6 1\n3 6 2\n1 7 2\n1 7 5" ], "output": [ "1\n1\n0\n3\n1" ] }
{ "input": [ "7\n4 1 10 5 7 7 3\n5\n1 5 0\n3 6 1\n3 6 2\n1 7 2\n1 7 5", "7\n3 1 10 5 7 1 3\n5\n1 5 0\n3 6 1\n3 6 2\n1 7 2\n1 7 5", "7\n3 1 10 5 7 1 3\n5\n2 5 0\n3 6 1\n3 6 2\n1 7 2\n1 7 5", "7\n3 1 10 5 7 1 3\n5\n2 5 0\n4 6 1\n3 6 2\n1 7 2\n1 7 5", "7\n4 1 10 5 7 7 3\n5\n2 5 0\n3 6 1\n3 6 2\n1 7 3...
p01911 Rainy Bus Stops
problem AOR Ika is at the $ S $ th bus stop at time $ 0 $ and wants to go from there to the $ G $ th bus stop. The number of bus stops $ N $ and $ M $ routes (*) connecting different bus stops are given. The bus stops are numbered $ 1, \ dots, and N $, respectively. Each route consists of $ 4 $ values: origin $ u $, d...
{ "input": [], "output": [] }
{ "input": [ "2 2 1 2\n1 2 10 100\n1 2 5 500" ], "output": [ "5" ] }
{ "input": [ "2 1 1 2\n1 2 10 100\n1 2 5 500", "2 2 1 2\n1 2 10 101\n1 2 5 500", "2 1 1 2\n1 2 13 011\n2 2 5 500", "2 1 1 2\n1 2 19 011\n2 2 5 500", "2 2 1 2\n1 2 10 100\n1 2 7 893", "2 1 1 2\n1 2 34 011\n2 2 5 500", "2 1 1 2\n1 2 9 011\n2 2 5 500", "3 2 1 2\n1 2 11 110\n1 2 6 893", ...
p02050 K is Key of Takakkey
K is a polygonal Kay "Do I have to be No. 1? Is it not No. K?" This is Mr. Kay's inscription. Recently, Mr. Kay seems to be exclusively interested in polygons, seeing N points placed on a vast two-dimensional plane spreading in front of him, and thinking about how to form polygons from them. There is. Apparently, Kay...
{ "input": [], "output": [] }
{ "input": [ "5 2\n1 1\n1 4\n2 2\n3 1\n3 5\n3 1\n0 2\n1 0\n-1 0\n3 2\n0 2\n1 0\n-1 0\n9 10\n8 1\n9 19\n2 10\n1 1\n4 17\n7 13\n3 4\n6 13\n9 21\n0 0" ], "output": [ "11.812559200041266\n6.472135954999580\n-1\n52.202878812480016" ] }
{ "input": [ "5 2\n1 1\n1 4\n2 2\n3 1\n3 5\n3 1\n0 2\n1 0\n-1 0\n3 2\n0 2\n1 0\n-1 0\n9 7\n8 1\n9 19\n2 10\n1 1\n4 17\n7 13\n3 4\n6 13\n9 21\n0 0", "5 2\n1 1\n1 4\n2 2\n3 1\n3 5\n3 1\n0 2\n1 0\n-1 0\n3 3\n0 2\n1 0\n-1 0\n9 7\n5 1\n9 19\n2 10\n1 1\n4 17\n7 13\n3 4\n6 13\n9 21\n0 0", "5 2\n1 1\n1 4\n2 2\n3 ...
p02192 K Average Ranges
K Average Ranges Given the sequence a_1, a_2, .., a_N. How many intervals in this sequence have an average value of K or more and a length of 1 or more? input N K a_1 a_2 ... a_N output Output the answer. Constraint * 1 \ leq N \ leq 10 ^ 5 * 1 \ leq K \ leq 10 ^ 9 * 1 \ leq a_i \ leq 10 ^ 9 Input example ...
{ "input": [], "output": [] }
{ "input": [ "6 6\n8 6 9 1 2 1" ], "output": [ "7" ] }
{ "input": [ "6 5\n8 6 9 1 2 1", "6 5\n8 6 9 1 4 1", "6 5\n8 6 9 1 4 2", "6 5\n8 6 9 1 7 2", "6 5\n8 6 3 1 7 2", "6 5\n5 6 3 1 7 2", "6 5\n5 2 3 2 7 2", "6 5\n3 2 8 -1 5 2", "6 5\n3 2 15 -2 5 0", "6 5\n3 2 37 -3 7 0", "6 5\n8 6 4 1 4 1", "6 5\n5 6 5 2 7 2", "6 5\n5 ...
p02346 Range Sum Query (RSQ)
Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations: * add(i, x): add x to ai. * getSum(s, t): print the sum of as, as+1,...,at. Note that the initial values of ai (i = 1, 2, . . . , n) are 0. Constraints * 1 ≤ n ≤ 100000 * 1 ≤ q ≤ 100000 * If comi is 0, then 1 ≤ xi...
{ "input": [], "output": [] }
{ "input": [ "3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2" ], "output": [ "3\n2" ] }
{ "input": [ "4 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2", "4 5\n0 1 1\n0 2 2\n0 1 5\n1 1 2\n1 2 2", "4 5\n0 1 0\n0 2 2\n0 1 5\n1 1 2\n1 2 2", "4 5\n0 1 1\n0 2 4\n0 3 3\n1 1 2\n1 2 2", "4 5\n0 1 1\n0 4 4\n0 3 3\n1 1 2\n1 2 2", "4 5\n0 1 1\n0 2 2\n0 3 9\n1 1 2\n0 2 2", "4 5\n0 1 0\n0 2 2\n0 1 5...
chcube
One day, Chef found a cube which has each of its sides painted in some color out of black, blue, red, green, yellow and orange. Now he asks you to check if he can choose three sides such that they are pairwise adjacent and painted in the same color. Input The first line of the input contains an integer T denoting the...
{ "input": [], "output": [] }
{ "input": [ "2\nblue yellow green orange black green\ngreen yellow green orange black green" ], "output": [ "NO\nYES\n" ] }
{ "input": [], "output": [] }