question
large_stringlengths
265
13.2k
Solve the programming task below in a Python markdown code block. A calculator scholar has discovered a strange life form called an electronic fly that lives in electronic space. While observing the behavior of the electronic flies, the electronic flies at the (x, y, z) point in this space then move to (x', y', z') in...
Solve the programming task below in a Python markdown code block. King Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom. Amazingly, there are no roads in the kingdom now. Recently, he planned to construct roads between the capital and the cities, but it turned out that the constr...
Solve the programming task below in a Python markdown code block. Consider a sequence generation that follows the following steps. We will store removed values in variable `res`. Assume `n = 25`: ```Haskell -> [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25] Let's remove the first number => res = [1...
Solve the programming task below in a Python markdown code block. Let's call a non-empty sequence of positive integers a_1, a_2... a_{k} coprime if the greatest common divisor of all elements of this sequence is equal to 1. Given an array a consisting of n positive integers, find the number of its coprime subsequence...
Solve the programming task below in a Python markdown code block. The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you c...
Solve the programming task below in a Python markdown code block. Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a_1, a_2, ..., a_{n} are good. Now she is interested in good sequences. A sequence x_1, x_2, ..., x_{k} is called good if it satisfies the following t...
Solve the programming task below in a Python markdown code block. You are given an array $a_1, a_2, \dots , a_n$, which is sorted in non-decreasing order ($a_i \le a_{i + 1})$. Find three indices $i$, $j$, $k$ such that $1 \le i < j < k \le n$ and it is impossible to construct a non-degenerate triangle (a triangle w...
Solve the programming task below in a Python markdown code block. This is the harder version of the problem. In this version, $1 \le n, m \le 2\cdot10^5$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems. You are given a sequence of integers $a=[a_1,a_...
Solve the programming task below in a Python markdown code block. The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string. A Bitlandish string is a string made only of characters "0" and "1". BitHaval (the mayor of Bitlan...
Solve the programming task below in a Python markdown code block. There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N. On this sequence, Snuke can perform the following operation: - Choose K consecutive elements in the sequence. Then, replace the value of eac...
Solve the programming task below in a Python markdown code block. The customer telephone support center of the computer sales company called JAG is now in- credibly confused. There are too many customers who request the support, and they call the support center all the time. So, the company wants to figure out how man...
Solve the programming task below in a Python markdown code block. Given a sorted array of numbers, return the summary of its ranges. ## Examples ```python summary_ranges([1, 2, 3, 4]) == ["1->4"] summary_ranges([1, 1, 1, 1, 1]) == ["1"] summary_ranges([0, 1, 2, 5, 6, 9]) == ["0->2", "5->6", "9"] summary_ranges([0, 1,...
Solve the programming task below in a Python markdown code block. You are given two integers $n$ and $m$. You have to construct the array $a$ of length $n$ consisting of non-negative integers (i.e. integers greater than or equal to zero) such that the sum of elements of this array is exactly $m$ and the value $\sum\li...
Solve the programming task below in a Python markdown code block. The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are mult...
Solve the programming task below in a Python markdown code block. # Feynman's squares Richard Phillips Feynman was a well-known American physicist and a recipient of the Nobel Prize in Physics. He worked in theoretical physics and pioneered the field of quantum computing. Recently, an old farmer found some papers and...
Solve the programming task below in a Python markdown code block. There are N cells arranged in a row, numbered 1, 2, \ldots, N from left to right. Tak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below. You are given an integer K that is less than or e...
Solve the programming task below in a Python markdown code block. Final kata of the series (highly recommended to compute [layers](https://www.codewars.com/kata/progressive-spiral-number-position/) and [branch](https://www.codewars.com/kata/progressive-spiral-number-branch/) first to get a good idea), this is a blatan...
Solve the programming task below in a Python markdown code block. You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). In how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content? Here...
Solve the programming task below in a Python markdown code block. There are N+1 towns. The i-th town is being attacked by A_i monsters. We have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters. What is the maximum total number of monsters the heroes c...
Solve the programming task below in a Python markdown code block. An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9. Determine whether N is a multiple of 9. -----Constraints----- - 0 \leq N < 10^{200000} - N is an integer. -----Input----- Inp...
Solve the programming task below in a Python markdown code block. There are N non-negative integers written on a blackboard. The i-th integer is A_i. Takahashi can perform the following two kinds of operations any number of times in any order: - Select one integer written on the board (let this integer be X). Write 2...
Solve the programming task below in a Python markdown code block. Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color c_{i}. The goal of the game is to destroy all the gemstones in the line as quickly as possible. In one second, Genos is able to...
Solve the programming task below in a Python markdown code block. The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includes it in...
Solve the programming task below in a Python markdown code block. Think of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are going to celebrate birthday of ...
Solve the programming task below in a Python markdown code block. In this Kata, you will be given a number and your task will be to return the nearest prime number. ```Haskell solve(4) = 3. The nearest primes are 3 and 5. If difference is equal, pick the lower one. solve(125) = 127 ``` We'll be testing for numbers...
Solve the programming task below in a Python markdown code block. On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. On each square lay f...
Solve the programming task below in a Python markdown code block. There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met. *...
Solve the programming task below in a Python markdown code block. A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≤ l ≤ r ≤ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive element...
Solve the programming task below in a Python markdown code block. Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches. The current state of the wall can be respresented by a ...
Solve the programming task below in a Python markdown code block. There are $n$ programmers that you want to split into several non-empty teams. The skill of the $i$-th programmer is $a_i$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in th...
Solve the programming task below in a Python markdown code block. There are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree. You have a map of that network, so for each railway section you know whi...
Solve the programming task below in a Python markdown code block. Find the edit distance between given two words s1 and s2. The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations: * insertion: Insert a character at a parti...
Solve the programming task below in a Python markdown code block. Problem There are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called "U & U". "U & U" has a common score for $ 2 $ teams, and the goal is to work...
Solve the programming task below in a Python markdown code block. AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i. Because he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or g...
Solve the programming task below in a Python markdown code block. You have two strings A = A_1 A_2 ... A_n and B = B_1 B_2 ... B_n of the same length consisting of 0 and 1. You can transform A using the following operations in any order and as many times as you want: * Shift A by one character to the left (i.e., if ...
Solve the programming task below in a Python markdown code block. Simply find the closest value to zero from the list. Notice that there are negatives in the list. List is always not empty and contains only integers. Return ```None``` if it is not possible to define only one of such values. And of course, we are expe...
Solve the programming task below in a Python markdown code block. Problem In 1333, the greatest scientist in human history, Dr. Ushishi, developed an artificial intelligence with an ID of ai1333 in order to pass on his wisdom to posterity. For the next 100 years, ai1333 brought great benefits to humankind, but on the...
Solve the programming task below in a Python markdown code block. You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the s...
Solve the programming task below in a Python markdown code block. It is the hard version of the problem. The only difference is that in this version $1 \le n \le 300$. In the cinema seats can be represented as the table with $n$ rows and $m$ columns. The rows are numbered with integers from $1$ to $n$. The seats in e...
Solve the programming task below in a Python markdown code block. Your task is to define a function that understands basic mathematical expressions and solves them. For example: ```python calculate("1 + 1") # => 2 calculate("18 + 4*6") # => 42 calculate("245 - 826") # => -581 calculate("09 + 000482") #...
Solve the programming task below in a Python markdown code block. On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M. For CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet. The i-th (1≦i≦N) participant can speak K_i languages numbered ...
Solve the programming task below in a Python markdown code block. In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you c...
Solve the programming task below in a Python markdown code block. We need a function ```prime_bef_aft()``` that gives the largest prime below a certain given value ```n```, ```befPrime or bef_prime``` (depending on the language), and the smallest prime larger than this value, ```aftPrime/aft_prime``` (depending ...
Solve the programming task below in a Python markdown code block. A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap. Overall the shop sells n clothing ...
Solve the programming task below in a Python markdown code block. Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th ...
Solve the programming task below in a Python markdown code block. The reciprocal of all non-zero real numbers is real, but the reciprocal of an integer is not necessarily an integer. This is the reason why 3/2 * 2 = 2 even though 3.0 / 2.0 * 2.0 = 3.0 in C language. However, if you consider integers with the same rema...
Solve the programming task below in a Python markdown code block. There are N turkeys. We number them from 1 through N. M men will visit here one by one. The i-th man to visit will take the following action: * If both turkeys x_i and y_i are alive: selects one of them with equal probability, then eats it. * If eithe...
Solve the programming task below in a Python markdown code block. An IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons — 8 blocks in total, each block has four hexadecimal digits. Here is an example of the correct r...
Solve the programming task below in a Python markdown code block. Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has n buses and m trolleys, the buses are numbered by integers from 1 to n, the trolleys are numbered by integers from 1 to m. Public transport i...
Solve the programming task below in a Python markdown code block. Write a function that takes a number or a string and gives back the number of **permutations without repetitions** that can generated using all of its element.; more on permutations [here](https://en.wikipedia.org/wiki/Permutation). For example, starti...
Solve the programming task below in a Python markdown code block. You have got a shelf and want to put some books on it. You are given $q$ queries of three types: L $id$ — put a book having index $id$ on the shelf to the left from the leftmost existing book; R $id$ — put a book having index $id$ on the shelf to the...
Solve the programming task below in a Python markdown code block. Two players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game. The game works as follows: there is a tree of size n,...
Solve the programming task below in a Python markdown code block. A card pyramid of height $1$ is constructed by resting two cards against each other. For $h>1$, a card pyramid of height $h$ is constructed by placing a card pyramid of height $h-1$ onto a base. A base consists of $h$ pyramids of height $1$, and $h-1$ c...
Solve the programming task below in a Python markdown code block. William arrived at a conference dedicated to cryptocurrencies. Networking, meeting new people, and using friends' connections are essential to stay up to date with the latest news from the world of cryptocurrencies. The conference has $n$ participants,...
Solve the programming task below in a Python markdown code block. # Task You are given two string `a` an `s`. Starting with an empty string we can do the following two operations: ``` append the given string a to the end of the current string. erase one symbol of the current string.``` Your task is to find the least ...
Solve the programming task below in a Python markdown code block. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write...
Solve the programming task below in a Python markdown code block. You are given array $a_1, a_2, \dots, a_n$. Find the subsegment $a_l, a_{l+1}, \dots, a_r$ ($1 \le l \le r \le n$) with maximum arithmetic mean $\frac{1}{r - l + 1}\sum\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding). If t...
Solve the programming task below in a Python markdown code block. Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has a_{i} coins. Polycarpus and Vasily move in turns. Polycarpus moves first. During a mov...
Solve the programming task below in a Python markdown code block. After lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not manage to fi...
Solve the programming task below in a Python markdown code block. As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi. <image> Someday Arpa shouted Owf loudly from the top of ...
Solve the programming task below in a Python markdown code block. The electrical resistance is the opposition to the passage of electric current. If two resistors with resistance R1 and R2 are connected to each other, the resultant resistance R depends on how their ends are connected. If they are connected in Series, ...
Solve the programming task below in a Python markdown code block. At the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing any homework today. It is obviou...
Solve the programming task below in a Python markdown code block. Sasha and Dima want to buy two $n$-tier cakes. Each cake should consist of $n$ different tiers: from the size of $1$ to the size of $n$. Tiers should go in order from the smallest to the biggest (from top to bottom). They live on the same street, there...
Solve the programming task below in a Python markdown code block. Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right. Ilya is really keep on helping his city. So, he wants...
Solve the programming task below in a Python markdown code block. Example Input 2 2 2 0 0 0 5 Output 1 3 3 1 0 Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within ```python delimiters.
Solve the programming task below in a Python markdown code block. Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees. Fafa finds doing this every time...
Solve the programming task below in a Python markdown code block. A Madhav array has the following property: ```a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...``` Complete the function/method that returns `true` if the given array is a Madhav array, otherwise it returns `false`. *Edge case...
Solve the programming task below in a Python markdown code block. We have N integers A_1, A_2, ..., A_N. There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list? -----Cons...
Solve the programming task below in a Python markdown code block. This is the easy version of the problem. The only difference is that in this version k = 0. There is an array a_1, a_2, …, a_n of n positive integers. You should divide it into a minimal number of continuous segments, such that in each segment there ar...
Solve the programming task below in a Python markdown code block. After a long journey, the super-space-time immigrant ship carrying you finally discovered a planet that seems to be habitable. The planet, named JOI, is a harsh planet with three types of terrain, "Jungle," "Ocean," and "Ice," as the name implies. A sim...
Solve the programming task below in a Python markdown code block. ## Check Digits Some numbers are more important to get right during data entry than others: a common example is product codes. To reduce the possibility of mistakes, product codes can be crafted in such a way that simple errors are detected. This is d...
Solve the programming task below in a Python markdown code block. Given an integer x, find 2 integers a and b such that: * 1 ≤ a,b ≤ x * b divides a (a is divisible by b). * a ⋅ b>x. * a/b<x. Input The only line contains the integer x (1 ≤ x ≤ 100). Output You should output two integers a and b, sati...
Solve the programming task below in a Python markdown code block. You have three tasks, all of which need to be completed. First, you can complete any one task at cost 0. Then, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|. Here, |x| denotes the absolute value of x. Find the m...
Solve the programming task below in a Python markdown code block. 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 (inclu...
Solve the programming task below in a Python markdown code block. `late_clock` function receive an array with 4 digits and should return the latest time that can be built with those digits. The time should be in `HH:MM` format. Examples: ``` [1, 9, 8, 3] => 19:38 [9, 1, 2, 5] => 21:59 ``` You can suppose the input i...
Solve the programming task below in a Python markdown code block. There is a beautiful garden of stones in Innopolis. Its most beautiful place is the $n$ piles with stones numbered from $1$ to $n$. EJOI participants have visited this place twice. When they first visited it, the number of stones in piles was $x_1, ...
Solve the programming task below in a Python markdown code block. There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i. Snuke will perform the following operation zero or more times: * Choose two stones painted in the same color. Repaint all the stones between them, with the...
Solve the programming task below in a Python markdown code block. Eugeny has array a = a_1, a_2, ..., a_{n}, consisting of n integers. Each integer a_{i} equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The response to the query will b...
Solve the programming task below in a Python markdown code block. After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks. An intersection point is any point on the grid which is formed by the intersection of...
Solve the programming task below in a Python markdown code block. Read problems statements in Russian also. Chef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the ...
Solve the programming task below in a Python markdown code block. Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1. You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes o...
Solve the programming task below in a Python markdown code block. The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness". The test consists of n questions; the questions are to be answered...
Solve the programming task below in a Python markdown code block. You are given $n$ strings $s_1, s_2, \ldots, s_n$ consisting of lowercase Latin letters. In one operation you can remove a character from a string $s_i$ and insert it to an arbitrary position in a string $s_j$ ($j$ may be equal to $i$). You may perform...
Solve the programming task below in a Python markdown code block. Naman has two binary strings $s$ and $t$ of length $n$ (a binary string is a string which only consists of the characters "0" and "1"). He wants to convert $s$ into $t$ using the following operation as few times as possible. In one operation, he can ch...
Solve the programming task below in a Python markdown code block. Leha is planning his journey from Moscow to Saratov. He hates trains, so he has decided to get from one city to another by car. The path from Moscow to Saratov can be represented as a straight line (well, it's not that straight in reality, but in this ...
Solve the programming task below in a Python markdown code block. Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x_1 = a, another one is in the point x_2 = b. Each of the friends can move by one along the line in any direction unlimited number of times. When...
Solve the programming task below in a Python markdown code block. Given are integer sequence of length N, A = (A_1, A_2, \cdots, A_N), and an integer K. For each X such that 1 \le X \le K, find the following value: \left(\displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} (A_L+A_R)^X\right) \bmod 998244353 -----Constrain...
Solve the programming task below in a Python markdown code block. The problem statement looms below, filling you with determination. Consider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through...
Solve the programming task below in a Python markdown code block. There are $n$ beautiful skyscrapers in New York, the height of the $i$-th one is $h_i$. Today some villains have set on fire first $n - 1$ of them, and now the only safety building is $n$-th skyscraper. Let's call a jump from $i$-th skyscraper to $j$-t...
Solve the programming task below in a Python markdown code block. Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game. Rules of ...
Solve the programming task below in a Python markdown code block. Kuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen $n$ distinct positive integers and put all of them in a set $S$. Now he defines a magical permutation to be: A permutation of integers from...
Solve the programming task below in a Python markdown code block. The Kingdom of Kremland is a tree (a connected undirected graph without cycles) consisting of $n$ vertices. Each vertex $i$ has its own value $a_i$. All vertices are connected in series by edges. Formally, for every $1 \leq i < n$ there is an edge betwe...
Solve the programming task below in a Python markdown code block. In 40XX, the Earth was invaded by aliens! Already most of the Earth has been dominated by aliens, leaving Tsuruga Castle Fortress as the only remaining defense base. Suppression units are approaching the Tsuruga Castle Fortress one after another. <imag...
Solve the programming task below in a Python markdown code block. There are n points on a straight line, and the i-th point among them is located at x_{i}. All these coordinates are distinct. Determine the number m — the smallest number of points you should add on the line to make the distances between all neighborin...
Solve the programming task below in a Python markdown code block. Your task is to return the number of visible dots on a die after it has been rolled(that means the total count of dots that would not be touching the table when rolled) 6, 8, 10, 12, 20 sided dice are the possible inputs for "numOfSides" topNum is eq...
Solve the programming task below in a Python markdown code block. There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i. Takahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at m...
Solve the programming task below in a Python markdown code block. Write a program that, given a word, computes the scrabble score for that word. ## Letter Values You'll need these: ``` Letter Value A, E, I, O, U, L, N, R, S, T 1 D, G 2 B, C, M, P ...
Solve the programming task below in a Python markdown code block. There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. Han Solo has the newest duplex lazer gun to fight these stormtroo...
Solve the programming task below in a Python markdown code block. Hanh lives in a shared apartment. There are $n$ people (including Hanh) living there, each has a private fridge. $n$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The o...
Solve the programming task below in a Python markdown code block. While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 201...