question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. Luba has to do n chores today. i-th chore takes a_{i} units of time to complete. It is guaranteed that for every $i \in [ 2 . . n ]$ the condition a_{i} ≥ a_{i} - 1 is met, so the sequence is sorted. Also Luba can work really hard on some chores. She c...
Solve the programming task below in a Python markdown code block. We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a p...
Solve the programming task below in a Python markdown code block. Polycarp urgently needs a shovel! He comes to the shop and chooses an appropriate one. The shovel that Policarp chooses is sold for k burles. Assume that there is an unlimited number of such shovels in the shop. In his pocket Polycarp has an unlimited ...
Solve the programming task below in a Python markdown code block. A schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in science and engineering. Vasya liked t...
Solve the programming task below in a Python markdown code block. Chef has learned a new technique for comparing two recipes. A recipe contains a list of ingredients in increasing order of the times they will be processed. An ingredient is represented by a letter 'a'-'z'. The i-th letter in a recipe denotes the i-th i...
Solve the programming task below in a Python markdown code block. You are given a keyboard that consists of $26$ keys. The keys are arranged sequentially in one row in a certain order. Each key corresponds to a unique lowercase Latin letter. You have to type the word $s$ on this keyboard. It also consists only of low...
Solve the programming task below in a Python markdown code block. This is the hard version of the problem. The difference between versions is the constraints on $n$ and $a_i$. You can make hacks only if all versions of the problem are solved. First, Aoi came up with the following idea for the competitive programming ...
Solve the programming task below in a Python markdown code block. Given is a string S consisting of lowercase English letters. Find the maximum positive integer K that satisfies the following condition: * There exists a partition of S into K non-empty strings S=S_1S_2...S_K such that S_i \neq S_{i+1} (1 \leq i \leq K...
Solve the programming task below in a Python markdown code block. n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not alwa...
Solve the programming task below in a Python markdown code block. problem JOI decided to make a signboard for the store. There are N old signboards with letters written at equal intervals. JOI makes a sign by erasing some letters from the old sign. I want the remaining characters to be the name of the store, and the...
Solve the programming task below in a Python markdown code block. A wise king declared a new calendar. "Tomorrow shall be the first day of the calendar, that is, the day 1 of the month 1 of the year 1. Each year consists of 10 months, from month 1 through month 10, and starts from a big month. A common year shall star...
Solve the programming task below in a Python markdown code block. problem A city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction. The w roads in the north-south direction are numbered 1, ...
Solve the programming task below in a Python markdown code block. Alexey, a merry Berland entrant, got sick of the gray reality and he zealously wants to go to university. There are a lot of universities nowadays, so Alexey is getting lost in the diversity — he has not yet decided what profession he wants to get. At s...
Solve the programming task below in a Python markdown code block. problem AOR Ika is studying to pass the test. AOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure. 1. Check the correctness of the answer. 2. If the answer is correct, write a circle mark,...
Solve the programming task below in a Python markdown code block. A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters «+» and «1» into this sequence. For example, sequences «(())()», «()» and «(()(()))» are regular, while «)(», «(()» and «(()))(» are n...
Solve the programming task below in a Python markdown code block. Tomya is a girl. She loves Chef Ciel very much. Tomya like a positive integer p, and now she wants to get a receipt of Ciel's restaurant whose total price is exactly p. The current menus of Ciel's restaurant are shown the following table. Name of Menup...
Solve the programming task below in a Python markdown code block. Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange algorithm on a graph — something that will definitely never be useful in real life. He asked a girl sitting next to him to lend him some ...
Solve the programming task below in a Python markdown code block. Fox Ciel is playing a card game with her friend Jiro. Jiro has n cards, each one has two attributes: position (Attack or Defense) and strength. Fox Ciel has m cards, each one has these two attributes too. It's known that position of all Ciel's cards is...
Solve the programming task below in a Python markdown code block. Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resistance value. However, all Mike has is lots of identical resistors with unit resistance R0 = 1. Elements with other resistance c...
Solve the programming task below in a Python markdown code block. There is a frog staying to the left of the string $s = s_1 s_2 \ldots s_n$ consisting of $n$ characters (to be more precise, the frog initially stays at the cell $0$). Each character of $s$ is either 'L' or 'R'. It means that if the frog is staying at t...
Solve the programming task below in a Python markdown code block. Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. - Operation 1: Pour 100A grams of water into t...
Solve the programming task below in a Python markdown code block. The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a litt...
Solve the programming task below in a Python markdown code block. Как известно, в теплую погоду многие жители крупных городов пользуются сервисами городского велопроката. Вот и Аркадий сегодня будет добираться от школы до дома, используя городские велосипеды. Школа и дом находятся на одной прямой улице, кроме того, н...
Solve the programming task below in a Python markdown code block. Given are strings s and t of length N each, both consisting of lowercase English letters. Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second cha...
Solve the programming task below in a Python markdown code block. Read problems statements in Mandarin Chinese and Russian as well. Given n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the...
Solve the programming task below in a Python markdown code block. This is the hard version of the problem. The difference is the constraint on the sum of lengths of strings and the number of test cases. You can make hacks only if you solve all versions of this task. You are given a string $s$, consisting of lowercase...
Solve the programming task below in a Python markdown code block. For a dynamic array $A = \\{a_0, a_1, ...\\}$ of integers, perform a sequence of the following operations: * push($d$, $x$): Add element $x$ at the begining of $A$, if $d = 0$. Add element $x$ at the end of $A$, if $d = 1$. * randomAccess($p$): Print e...
Solve the programming task below in a Python markdown code block. There is a sequence of length N: a = (a_1, a_2, ..., a_N). Here, each a_i is a non-negative integer. Snuke can repeatedly perform the following operation: * Let the XOR of all the elements in a be x. Select an integer i (1 ≤ i ≤ N) and replace a_i wit...
Solve the programming task below in a Python markdown code block. Implement a function/class, which should return an integer if the input string is in one of the formats specified below, or `null/nil/None` otherwise. Format: * Optional `-` or `+` * Base prefix `0b` (binary), `0x` (hexadecimal), `0o` (octal), or in ca...
Solve the programming task below in a Python markdown code block. In this kata, you'll be given an integer of range `0 <= x <= 99` and have to return that number spelt out in English. A few examples: ```python name_that_number(4) # returns "four" name_that_number(19) # returns "nineteen" name_that_number(99) # re...
Solve the programming task below in a Python markdown code block. It's your Birthday. Your colleagues buy you a cake. The numbers of candles on the cake is provided (x). Please note this is not reality, and your age can be anywhere up to 1,000. Yes, you would look a mess. As a surprise, your colleagues have arranged ...
Solve the programming task below in a Python markdown code block. There is a matrix A of size x × y filled with integers. For every $i \in [ 1 . . x ]$, $j \in [ 1 . . y ]$ A_{i}, j = y(i - 1) + j. Obviously, every integer from [1..xy] occurs exactly once in this matrix. You have traversed some path in this matrix. ...
Solve the programming task below in a Python markdown code block. You are given N real values A_1, A_2, \ldots, A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i \cdot A_j is integer. Constraints * 2 \leq N \leq 200\,000 * 0 < A_i < 10^4 * A_i is given with at most 9 digits after...
Solve the programming task below in a Python markdown code block. You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. -----Constraints----- - 1≦a≦100 - 1≦b≦100 - 1≦h≦100 - All input values are in...
Solve the programming task below in a Python markdown code block. 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 inform...
Solve the programming task below in a Python markdown code block. You have a string S consisting of N uppercase English letters. You are allowed to perform at most one operation of following kind: Choose any position in the string, remove the character at that position and insert it back to any other place in the stri...
Solve the programming task below in a Python markdown code block. International Women's Day is coming soon! Polycarp is preparing for the holiday. There are $n$ candy boxes in the shop for sale. The $i$-th box contains $d_i$ candies. Polycarp wants to prepare the maximum number of gifts for $k$ girls. Each gift will...
Solve the programming task below in a Python markdown code block. Problem Given the strings $ s $, $ t $. First, let the string set $ A = $ {$ s $}, $ B = \ phi $. At this time, I want to perform the following operations as much as possible. operation step1 Perform the following processing for all $ u ∊ A $. 1. F...
Solve the programming task below in a Python markdown code block. You've gotten an n × m sheet of squared paper. Some of its squares are painted. Let's mark the set of all painted squares as A. Set A is connected. Your task is to find the minimum number of squares that we can delete from set A to make it not connected...
Solve the programming task below in a Python markdown code block. There are $n$ persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends. We want to plan a trip for every evening of $m$ days. On each trip, you have to select a group of people that will go ...
Solve the programming task below in a Python markdown code block. Two people are playing a game with a string $s$, consisting of lowercase latin letters. On a player's turn, he should choose two consecutive equal letters in the string and delete them. For example, if the string is equal to "xaax" than there is onl...
Solve the programming task below in a Python markdown code block. When Valera has got some free time, he goes to the library to read some books. Today he's got t free minutes to read. That's why Valera took n books in the library and for each book he estimated the time he is going to need to read it. Let's number the ...
Solve the programming task below in a Python markdown code block. Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [...
Solve the programming task below in a Python markdown code block. Vlad enjoys listening to music. He lives in Sam's Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants! Vlad built up his own p...
Solve the programming task below in a Python markdown code block. One day n cells of some array decided to play the following game. Initially each cell contains a number which is equal to it's ordinal number (starting from 1). Also each cell determined it's favourite number. On it's move i-th cell can exchange it's va...
Solve the programming task below in a Python markdown code block. You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at mos...
Solve the programming task below in a Python markdown code block. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. -----Constraints----- - s_1, s_2 and s_3 are composed of lowerca...
Solve the programming task below in a Python markdown code block. The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem: You've go...
Solve the programming task below in a Python markdown code block. How to make a cake you'll never eat. Ingredients. * 2 carrots * 0 calories * 100 g chocolate spread * 1 pack of flour * 1 egg Method. 1. Put calories into the mixing bowl. 2. Take carrots from refrigerator. 3. Chop carrots. 4. ...
Solve the programming task below in a Python markdown code block. Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you? You are given a set o...
Solve the programming task below in a Python markdown code block. ## Description Your job is to create a simple password validation function, as seen on many websites. The rules for a valid password are as follows: - There needs to be at least 1 uppercase letter. - There needs to be at least 1 lowercase letter. - Th...
Solve the programming task below in a Python markdown code block. Sereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and n water mugs on it. Then all players take turns to move. During a move, a player takes a non-empty mug of water and pours all wa...
Solve the programming task below in a Python markdown code block. There are N squares arranged in a row, numbered 1, 2, ..., N from left to right. You are given a string S of length N consisting of `.` and `#`. If the i-th character of S is `#`, Square i contains a rock; if the i-th character of S is `.`, Square i is ...
Solve the programming task below in a Python markdown code block. You are given a chessboard of size $n \times n$. It is filled with numbers from $1$ to $n^2$ in the following way: the first $\lceil \frac{n^2}{2} \rceil$ numbers from $1$ to $\lceil \frac{n^2}{2} \rceil$ are written in the cells with even sum of coordi...
Solve the programming task below in a Python markdown code block. There is an integer sequence of length 2^N: A_0, A_1, ..., A_{2^N-1}. (Note that the sequence is 0-indexed.) For every integer K satisfying 1 \leq K \leq 2^N-1, solve the following problem: - Let i and j be integers. Find the maximum value of A_i + A_j...
Solve the programming task below in a Python markdown code block. You are given $n$ segments on a coordinate axis $OX$. The $i$-th segment has borders $[l_i; r_i]$. All points $x$, for which $l_i \le x \le r_i$ holds, belong to the $i$-th segment. Your task is to choose the maximum by size (the number of segments) su...
Solve the programming task below in a Python markdown code block. There is a string $s$ of length $3$, consisting of uppercase and lowercase English letters. Check if it is equal to "YES" (without quotes), where each letter can be in any case. For example, "yES", "Yes", "yes" are all allowable. -----Input----- The ...
Solve the programming task below in a Python markdown code block. You have $n$ chains, the $i$-th chain consists of $c_i$ vertices. Vertices in each chain are numbered independently from $1$ to $c_i$ along the chain. In other words, the $i$-th chain is the undirected graph with $c_i$ vertices and $(c_i - 1)$ edges con...
Solve the programming task below in a Python markdown code block. As behooves any intelligent schoolboy, Kevin Sun is studying psycowlogy, cowculus, and cryptcowgraphy at the Bovinia State University (BGU) under Farmer Ivan. During his Mathematics of Olympiads (MoO) class, Kevin was confronted with a weird functional ...
Solve the programming task below in a Python markdown code block. Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squ...
Solve the programming task below in a Python markdown code block. Paw the Spider is making a web. Web-making is a real art, Paw has been learning to do it his whole life. Let's consider the structure of the web. <image> There are n main threads going from the center of the web. All main threads are located in one pl...
Solve the programming task below in a Python markdown code block. A tree is a graph with n vertices and exactly n - 1 edges; this graph should meet the following condition: there exists exactly one shortest (by number of edges) path between any pair of its vertices. A subtree of a tree T is a tree with both vertices ...
Solve the programming task below in a Python markdown code block. The polar bears are going fishing. They plan to sail from (s_{x}, s_{y}) to (e_{x}, e_{y}). However, the boat can only sail by wind. At each second, the wind blows in one of these directions: east, south, west or north. Assume the boat is currently at (...
Solve the programming task below in a Python markdown code block. The time is 2020. There is data that saves the qualifying results of PC Koshien 2020. This data stores the reference number and the number of correct answers assigned to each team. Here, the ranking is determined by the number of correct answers, and th...
Solve the programming task below in a Python markdown code block. Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants. The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has $n$...
Solve the programming task below in a Python markdown code block. Let S be the concatenation of 10^{10} copies of the string 110. (For reference, the concatenation of 3 copies of 110 is 110110110.) We have a string T of length N. Find the number of times T occurs in S as a contiguous substring. -----Constraints----- ...
Solve the programming task below in a Python markdown code block. "Fukusekiken" is a popular ramen shop where you can line up. But recently, I've heard some customers say, "I can't afford to have vacant seats when I enter the store, even though I have a long waiting time." I'd like to find out why such dissatisfaction...
Solve the programming task below in a Python markdown code block. Recently, the Fair Nut has written $k$ strings of length $n$, consisting of letters "a" and "b". He calculated $c$ — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time. Then, he lost h...
Solve the programming task below in a Python markdown code block. It's a walking tour day in SIS.Winter, so $t$ groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another. Initially, some students are angry. Let's describe a group of students by a str...
Solve the programming task below in a Python markdown code block. On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23. After finishing the document, she noticed that sh...
Solve the programming task below in a Python markdown code block. Elections in Berland are coming. There are only two candidates — Alice and Bob. The main Berland TV channel plans to show political debates. There are $n$ people who want to take part in the debate as a spectator. Each person is described by their infl...
Solve the programming task below in a Python markdown code block. ## The Riddle The King of a small country invites 1000 senators to his annual party. As a tradition, each senator brings the King a bottle of wine. Soon after, the Queen discovers that one of the senators is trying to assassinate the King by giving him...
Solve the programming task below in a Python markdown code block. You are given an n × m rectangular table consisting of lower case English letters. In one operation you can completely remove one column from the table. The remaining parts are combined forming a new table. For example, after removing the second column ...
Solve the programming task below in a Python markdown code block. Assume that you have $k$ one-dimensional segments $s_1, s_2, \dots s_k$ (each segment is denoted by two integers — its endpoints). Then you can build the following graph on these segments. The graph consists of $k$ vertexes, and there is an edge between...
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is on constraints. In this version constraints are lower. You can make hacks only if all versions of the problem are solved. Koa the Koala is at the beach! The beach consists (from left to right) of a...
Solve the programming task below in a Python markdown code block. After the mysterious disappearance of Ashish, his two favourite disciples Ishika and Hriday, were each left with one half of a secret message. These messages can each be represented by a permutation of size $n$. Let's call them $a$ and $b$. Note that a...
Solve the programming task below in a Python markdown code block. The Little Elephant likes permutations. This time he has a permutation A[1], A[2], ..., A[N] of numbers 1, 2, ..., N. He calls a permutation A good, if the number of its inversions is equal to the number of its local inversions. The number of inversion...
Solve the programming task below in a Python markdown code block. Shinya watched a program on TV called "Maya's Great Prophecy! Will the World End in 2012?" After all, I wasn't sure if the world would end, but I was interested in Maya's "long-term calendar," which was introduced in the program. The program explained a...
Solve the programming task below in a Python markdown code block. Cirno_9baka has a tree with $n$ nodes. He is willing to share it with you, which means you can operate on it. Initially, there are two chess pieces on the node $1$ of the tree. In one step, you can choose any piece, and move it to the neighboring node....
Solve the programming task below in a Python markdown code block. It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$). You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful. A number is ...
Solve the programming task below in a Python markdown code block. There is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$. Let's define operation slice on some height $H$ as following: for each towe...
Solve the programming task below in a Python markdown code block. Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons: Tetrahedron. Tetrahedron has 4 triangular faces. Cube. Cube has 6 square faces. Octahedron. Octahedron has 8 triangular faces. Dod...
Solve the programming task below in a Python markdown code block. The problem was inspired by Pied Piper story. After a challenge from Hooli's compression competitor Nucleus, Richard pulled an all-nighter to invent a new approach to compression: middle-out. You are given two strings $s$ and $t$ of the same length $n$...
Solve the programming task below in a Python markdown code block. The Beroil corporation structure is hierarchical, that is it can be represented as a tree. Let's examine the presentation of this structure as follows: * employee ::= name. | name:employee1,employee2, ... ,employeek. * name ::= name of an employee ...
Solve the programming task below in a Python markdown code block. You were lucky enough to get a map just before entering the legendary magical mystery world. The map shows the whole area of your planned exploration, including several countries with complicated borders. The map is clearly drawn, but in sepia ink only;...
Solve the programming task below in a Python markdown code block. Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation: The track is the circle with length L, in distinct points of which there are n barriers...
Solve the programming task below in a Python markdown code block. coastline Waves rush to the beach every second. There is data that observes and records how many meters the wave rushed beyond the reference point P every second for only T seconds. The data consists of T integers x1, ..., xT, and for each i (1 ≤ i ≤ T...
Solve the programming task below in a Python markdown code block. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: They are equal. If we split string a into two halves of the same size a_1 and a...
Solve the programming task below in a Python markdown code block. [Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13 Read the inputs from stdin solve the problem and write the answer to stdout (do ...
Solve the programming task below in a Python markdown code block. ###Lucky number Write a function to find if a number is lucky or not. If the sum of all digits is 0 or multiple of 9 then the number is lucky. `1892376 => 1+8+9+2+3+7+6 = 36`. 36 is divisble by 9, hence number is lucky. Function will return `true` f...
Solve the programming task below in a Python markdown code block. Create a function finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects. This function should take two arguments: exam - grade for exam (from 0 to 100); projects -...
Solve the programming task below in a Python markdown code block. Smart Beaver recently got interested in a new word game. The point is as follows: count the number of distinct good substrings of some string s. To determine if a string is good or not the game uses rules. Overall there are n rules. Each rule is describ...
Solve the programming task below in a Python markdown code block. Skier rides on a snowy field. Its movements can be described by a string of characters 'S', 'N', 'W', 'E' (which correspond to $1$ meter movement in the south, north, west or east direction respectively). It is known that if he moves along a previously...
Solve the programming task below in a Python markdown code block. Balph is learning to play a game called Buma. In this game, he is given a row of colored balls. He has to choose the color of one new ball and the place to insert it (between two balls, or to the left of all the balls, or to the right of all the balls)....
Solve the programming task below in a Python markdown code block. Every day, N passengers arrive at Takahashi Airport. The i-th passenger arrives at time T_i. Every passenger arrived at Takahashi airport travels to the city by bus. Each bus can accommodate up to C passengers. Naturally, a passenger cannot take a bus ...
Solve the programming task below in a Python markdown code block. One day, at the "Russian Code Cup" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once. The appointed Jud...
Solve the programming task below in a Python markdown code block. $n$ robots have escaped from your laboratory! You have to find them as soon as possible, because these robots are experimental, and their behavior is not tested yet, so they may be really dangerous! Fortunately, even though your robots have escaped, yo...
Solve the programming task below in a Python markdown code block. Given a square table sized NxN (3 ≤ N ≤ 5,000; rows and columns are indexed from 1) with a robot on it. The robot has a mission of moving from cell (1, 1) to cell (N, N) using only the directions "right" or "down". You are requested to find the number o...
Solve the programming task below in a Python markdown code block. Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that t...
Solve the programming task below in a Python markdown code block. William really likes the cellular automaton called "Game of Life" so he decided to make his own version. For simplicity, William decided to define his cellular automaton on an array containing $n$ cells, with each cell either being alive or dead. Evolu...