task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
A-Mazing Puzzle Description: The Severely Challenging Archaeological Exploration Division (SCArED) specializes in the investigation of archaeological sites that are too difficult, dangerous or downright terrifying for humans to examine firsthand. Instead they send in one or more mobile robots to invest...
26,100
A1 Paper Description: Björn likes the square root of two, $\sqrt {2} = 1.41421356\dots $ very much. He likes it so much that he has decided to write down the first $10\, 000$ digits of it on a single paper. He started doing this on an A4 paper, but ran out of space after writing down only $1250$ digits...
26,101
ABC Description: You will be given three integers $A$, $B$ and $C$. The numbers will not be given in that exact order, but we do know that $A$ is less than $B$ and $B$ less than $C$. In order to make for a more pleasant viewing, we want to rearrange them in a given order. ## Input The first line contains...
26,102
ABC String Description: You’re given a string consisting of the characters A, B, and C. The string contains the same count of A, B, and C characters. A string is beautiful if * Its length is divisible by $3$. * The string can be split evenly into contiguous substrings of size $3$, where each substri...
26,103
ACKME Company Picnic Description: At ACKME Corporation, the annual company picnic has one very important rule: nobody should have to spend their day off with their boss. As the data science intern, your job is to help draw up the invitation list for the best possible company picnic. Luckily, ACKME has ...
26,104
ACM Contest Scoring Description: Our new contest submission system keeps a chronological log of all submissions made by each team during the contest. With each entry, it records the number of minutes into the competition at which the submission was received, the letter that identifies the relevant cont...
26,105
AI Jeopardy Description: Nowadays, more and more of Jeopardy’s viewers are AIs themselves and as such the show is considering having categories on topics that are more popular with this new number-crunching viewer base. Focus group testing has revealed that AIs are particularly fond of the “Binomial Co...
26,106
AND Permutation Description: You are given a sequence of $n$ distinct nonnegative integers $a_1, a_2, \ldots , a_ n$. For the given sequence, it is guaranteed that for all nonnegative numbers $x$, if there is some $i$ such that $a_ i \ \& \ x = x$, then there is a $j$ such that $a_ j = x$. Her...
26,107
ARMPIT Computations Description: The popular ARMPIT processor has a simple architecture that is built around a single register that is $12$ bits long. The most significant bit is viewed as being at the left end, and the least significant bit at the right end. The contents of the register are often repr...
26,108
ASCII Addition Description: Nowadays, there are smartphone applications that instantly translate text and even solve math problems if you just point your phone’s camera at them. Your job is to implement a much simpler functionality reminiscent of the past – add two integers written down as ASCII art. ...
26,109
ASCII Figure Rotation Description: Consider an ASCII art figure like the one on the left. If the figure contains only spaces and the +, - and | symbols, then its possible to produce rotated versions of the figure using ASCII art. For example, the figure on the right is a 90 degree clockwise rotation of...
26,110
ASCII Kassi 2 Description: Last year we looked back in time and made contestants draw ASCII boxes as a challenge. This year we want to look at things from a new perspective! Therefore the challenge this year is to draw an ASCII box, but diagonally! Last time the symbols +, - and | were used to dra...
26,111
ASCII kassi Description: Today the High School Programming Contest of Iceland is hosted on Kattis, which reviews the solutions from contestants upon their submission. Most of the process has been automated, but it wasn’t always this way. Some years ago, judges walked from contestant to contestant, to ...
26,112
AVL++ Description: An AVL tree, named after its two inventors, Adelson-Velskii and Landis, is a binary search tree with an additional constraint that keeps the tree balanced. The balance factor of a node $x$, denoted $\mathit{bf}(x)$, is defined to be $H(x_ R) - H(x_ L)$, where $H(\, )$ is ...
26,113
Aa Description: The letter Å is a relatively new invention in the Danish alphabet, being introduced only in 1948. Before that, the digraph Aa was used instead – this survives in town names like Aabenraa and Aarhus. When sorting Danish words, Å is treated as the last letter of the alphabet. Interesting...
26,114
Aaah! Description: Jon Marius shouted too much at the recent Justin Bieber concert, and now needs to go to the doctor because of his sore throat. The doctor’s instructions are to say “aaah”. Unfortunately, the doctors sometimes need Jon Marius to say “aaah” for a while, which Jon Marius has never been ...
26,115
Ab Initio Description: “A journey of a thousand miles begins with a single step.” ­–Lao Tzu. When someone is studying competitive programming from the beginning, he or she is said to be a student of competitive programming ab initio. Students should be given relatively easy problems to begin their jou...
26,116
Abandoned Animal Description: You know that your sister will hold on to her beloved Fluffynose whenever possible, so the only time she could’ve lost it is when she grabbed an item on her shopping list. So, all you have to do is figure out at what store she bought what, and then you’ll reunite her with ...
26,117
Above Average Description: ## Input The first line of standard input contains an integer $1 \le C \le 50$, the number of test cases. $C$ data sets follow. Each data set begins with an integer, $N$, the number of people in the class ($1 \le N \le 1000$). $N$ integers follow, separated by sp...
26,118
Abridged Reading Description: Miss Othmar is a grade school teacher who uses a very interesting textbook in her science class. All of the chapters in the book have material that depends on at most one previous chapter’s material, while several chapters are labeled “Culminating Concept” chapters that ha...
26,119
Absolutely Symmetric Description: SoCCat deemed a matrix $T$ of size $n \times n$ consisting of integers to be absolutely symmetric if and only if $|T_{i,j}| = |T_{j,i}|$ for all $1 \leq i, j \leq n$. In other words, the absolute value of the entry in the $i$-th row and $j$-th column is equal t...
26,120
Abstract Art Description: Arty has been an abstract artist since childhood, and his works have taken on many forms. His latest (and most pricey) creations are lovingly referred to as Abstract Art within the abstract art community (they’re not the most original bunch when it comes to loving nicknames). ...
26,121
Abstract Painting Description: Gon is currently training to become a modern artist. Everyday, Gon practices his painting skill on a rectangular canvas, divided into $R \cdot C$ unit squares, with $R$ rows and $C$ columns. Gon wants to paint all the edges of all unit squares. Contrary to popular belief, c...
26,122
Absurdistan Roads II Description: The people of Absurdistan discovered how to build roads only last year. After the discovery, each city decided to build its own road, connecting the city with some other city. Each newly built road can be used in both directions. Absurdistan is full of absurd coincidences...
26,123
Absurdistan Roads III Description: The people of Absurdistan discovered how to build roads only last year. After the discovery, each city decided to build its own road, connecting the city to some other city. Each newly built road can be used in both directions. You bought a tourist guide which has a map ...
26,124
Acceptable Seating Arrangements Description: Charlie is managing a classroom. The seats in the classroom are arranged in a grid with rows and columns. Each student has a distinct height. A configuration of students to seats is acceptable if the following conditions are met: * Each student is assigned to ...
26,125
Access Denied Description: In a timing attack, we exploit that we can deduce a computation path from the time it takes to do the computation. In CTSS the password check was done using a simple string matching algorithm, similar to this: ``` bool CheckPassword(string pwd1, string pwd2) { if (pwd1.Lengt...
26,126
Access Points Description: A well-known programming contest is considering a new way to position its teams. For the contest all $n$ teams have to be assigned some position $(x,y)$ in an infinitely-large gym hall. To keep a good overview of the teams the following strategy is chosen: All teams have bee...
26,127
Accounting Description: Erika the economist studies economic inequality. Her model starts in a situation where everybody has the same amount of money. After that, people’s wealth changes in various complicated ways. Erika needs to run a simulation a large number of times to check if her model works. T...
26,128
Ace Arbiter Description: Alice and Bob are playing a friendly game of ping pong. The game consists of several rounds. At the end of each round, exactly one player gets one point. The first player to 11 points wins. When that happens, the game immediately ends. Alice start serving the first round, then ...
26,129
Ada Loveslaces Description: A shoe has a lacing geometry: $N$, the number of eyelets (on a side), $d$, the distance between eyelets, $s$, the separation between the columns of eyelets when the shoe is laced, and $t$, the thickness of an eyelet. In Figure 1 below, $N = 3$, with eyelets numbered from...
26,130
Add 'Em Up! Description: Simon is a contestant on the new exciting game show, Add ’Em Up! In this show, contestants are given a set of cards with multi-digit numbers on them, and need to select two cards that add up to a given sum. However, to make things more interesting, the font that the cards are p...
26,131
Add Two Numbers Description: In this problem, your program should read two whole numbers (also called integers) from the input, and print out their sum. As a refresher, here are some ways to read two numbers from standard input in a few different languages: ``` # Python 3 line = input() a, b = line.split...
26,132
Add or Multiply Description: Your younger sister is playing with a wooden math toy consisting of number and operator blocks. Each number block is printed with a single digit from $1$ to $9$, and operator blocks are double-sided; $+$ and $\times $ are printed on each side. She has just built a m...
26,133
Adding Trouble Description: Your friend Bob is really bad at adding numbers, and he’d like some help to make sure he’s doing it correctly! Can you help Bob make sure he is adding correctly? Given 3 integers $A$, $B$, $C$, make sure that $A + B = C$, and that Bob indeed added $A$ and $B$ correctly. ## ...
26,134
Adding Up the Votes Description: That last point is of particular interest, because computer science researchers at KTH Royal Institute of Technology, the host of the SCC 2021-2022 finals, have been studying how to count votes as quickly as possible. Given a series of votes, it’s easy to determine if a...
26,135
Adding Words Description: Psychologists at Wassamatta University believe that humans are able to more easily deal with words than with numbers. So they have devised experiments to find out if this is true. In an interesting twist, one of their experiments deals with using words which represent numbers....
26,136
Adjoin the Networks Description: One day your boss explains to you that he has a bunch of computer networks that are currently unreachable from each other, and he asks you, the cable expert’s assistant, to adjoin the networks to each other using new cables. Existing cables in the network cannot be touc...
26,137
Administrative Difficulties Description: It is difficult for a spy to do his job without a decent car. The Bureau of Administrative Personnel for Cars (BAPC) spy-car rental company has a large collection of cars that spies can use and handles the resulting administration. Using cars obviously costs mon...
26,138
Adolescent Architecture Description: Little Peter is building a stack out of his toy blocks. He is using two kinds of blocks – cubes and cylinders – and wants to stack all of them into a single tower, where each block other than the topmost block has a single block standing on it. In order for the to...
26,139
Ads Description: Web pages are littered with ads (advertisements) these days. You wrote a simple program to detect images which are ads and remove them. Characters that are any of the following are allowed in images: * alphanumeric characters * question mark ‘?’ * exclamation mark ‘!’ * comma ‘,’ * f...
26,140
Advanced Causal Measurements Description: Causality is a very important concept in theoretical physics. The basic elements in a discussion of causality are events. An event $e$ is described by its time of occurrence $t$, and its location, $x$, and we write $e = (t,x)$. For our concerns, all eve...
26,141
Adventure Begins Description: The game Pokenom Go has just been released. Pokenom trainers can now travel the world, capture Pokenom in the wild and battle each other! Bash — the Pokenom trainer — has decided to drop out of his university to pursue his childhood dream of becoming the best Pokenom train...
26,142
Adventures in Moving -- Part IV Description: To help you move from Waterloo to the big city, you are considering renting a moving truck. Gas prices being so high these days, you want to know how much the gas for such a beast will set you back. The truck consumes a full litre of gas for each kilometre it ...
26,143
Advertising ICPC Description: You’re making a flag to try to advertise ICPC! The flag takes the form of a grid that is already filled with some “C”, “I”, and “P” letters. A flag is advertising ICPC if there exists at least one $2 \times 2$ subgrid that looks exactly like the following: ``` IC P...
26,144
Afjörmun Description: ## Input The first line will contain the integer $n$ ($1 \leq n \leq 10^4$), the number of sentences in the memed text. The following $n$ lines will include one memed sentence each. Each sentence is at most $300$ characters. Note that a sentence always ends with a full stop and ...
26,145
Aflmælingar Description: Hrolleifur has just gotten his hands on $300$ power generators and one measuring device. He can set each power generator to a value between $0\% $ and $100\% $ and then turn them all on to get a measurement of their power. The power generators can only be set to integer per...
26,146
Agamemnon's Odyssey Description: Agamemnon, the great king of Mycenae, was assembling his troops in Aulis to sail to the shores of Troy, when he had a vision of goddess Artemis. In this vision, Agamemnon found out that he had accidentally slain a deer that was sacred to Artemis, and now the goddess swo...
26,147
Agar.IO Description: There are $n$ players in an agar-io game. The $i^{th}$ player has an initial size of $a_ i$. There are $m$ pairs of players, where the $i^{th}$ pair represents that players $u_ i$ and $v_ i$ adjacent to each other. Note that unlike the 2d game, our agar-io game is o...
26,148
Air Conditioned Minions Description: You are the boss of ACM (Air Conditioned Minions), an upstanding company with a single goal of world domination. The company has $N$ minions. Each minion works evilly from early morning until evening inside a super secret bunker in Helsinki. After much deliberation...
26,149
Air Rally Description: Baxter and Forthington are playing badminton the only correct way—ten thousand feet in the air! They intend to rally the shuttlecock back and forth while cruising side-by-side at a constant speed. For simplicity, assume that they cruise at one distance unit per second. Forthington ...
26,150
Airfare Grants Description: Congratulations! Your team has advanced to the next round of the International Cupcake Production Competition (ICPC)! To participate in the competition, you are going to fly to Cupcake City from your hometown. The competition organizers have just shared good news: generous s...
26,151
Airline Hub Description: World Wide Flyer (WWF) has landing rights at several airports throughout the world. They wish to place their central hub at the airport that minimizes the maximum direct flying distance from the hub to any other airport in the world. ## Input Input file contains several sets of i...
26,152
Airport Coffee Description: As it happens, Jonna just landed at Copenhagen Airport, trying to make her connection to Heathrow Airport. Since her flight from Helsinki was delayed, she must walk very quickly from her arrival gate to the new departure gate. Normally, Jonna walks at a speed of $a$ centimet...
26,153
Airport Construction Description: The tropical island nation of Piconesia is famous for its beautiful beaches, lush vegetation, cocoa and coffee plantations, and wonderful weather all year round. This paradise is being considered as a future location for the World Finals of the ACM International Colleg...
26,154
Airport Logistics Description: Many airports have moving conveyor belts in the corridors between halls and terminals. Instead of walking on the floor, passengers can choose to stand on a conveyor or, even better, walk on a conveyor to get to the end of the corridor much faster. The brand new Delft Cit...
26,155
Airports Description: An airline company offers flights out of $n$ airports. The flight time between any given pair of airports is known, but may differ on direction due to things like wind or geography. Upon landing at a given airport, a plane must be inspected before it can be flown again. This inspe...
26,156
Akcija Description: There is a promotional offer in a bookstore “Take 3, pay for the 2 more expensive ones”. So, each customer who picks $3$ books gets the cheapest one for free. Of course, the customer can take even more books and, depending on the way the books are arranged into groups of three, ...
26,157
Akureyri Description: The year 2016 is an important year for Forritunarkeppni Framhaldsskólanna. For the first time ever the contest will be held in two locations! But now it is the year 3016 and the contest is held all over the country, not just in Reykjavík or Akureyri. The contestants no longer go t...
26,158
Aladin Description: Aladin was walking down the path one day when he found the strangest thing: $N$ empty boxes right next to a weird alien machine. After a bit of fumbling around he got the machine to do something. The machine now accepts 4 integers $L$, $R$, $A$ and $B$. After that hitting the big re...
26,159
Alchemy Description: Since the days of yore, alchemy has been studied and practiced. The practice makes alchemists able to transmute materials into other forms. Transmuting materials requires drawing a transmutation circle on the ground. A little known fact about transmutation circles is they can be dr...
26,160
Alchemy Description: You just finished day one of your alchemy class! For your alchemy homework, you have been given a string of lowercase letters and wish to make it a palindrome. You’re only a beginner at alchemy though, so your powers are limited. In a single operation, you may choose exactly two ad...
26,161
Alchemy 101 Description: As a student at Hogwarts School of Witchcraft and Wizardry, Harry must learn Alchemy  — the study of magical properties of elements and transmutation of substances. In today’s Alchemy lab session, Harry is experimenting with transmuting substances. In the magical world, there a...
26,162
Alcohol Description: An organic chemical compound is a molecule consisting of atoms that are pairwise connected by bonds. Atom are of different types, such as oxygen, carbon, and hydrogen. A hydroxy group is a hydrogen–oxygen bond. A compound is an alcohol if it contains a hydroxy group bound to a ...
26,163
Alcohol-Free Alternative Description: In Sweden, across the Øresund Bridge, the alcohol laws are considerably harsher than in Denmark. Aside from the higher age limit, there are also a number of restrictions on how alcohol may be served. One of these restrictions concerns alcohol-free alternatives: a r...
26,164
Aldur Description: ## Input The first line consists of a single integer $n$, the number of friends Tómas has. Then there are $n$ lines. In the $i$-th line there is a single integer $a_i$, the age of his $i$-th friend. ## Output Print a single integer, the age of Tómas’ youngest friend. ...
26,165
Aldursröðun Description: ## Input The first line of the input contains an integer $3 \leq n \leq 8$. The next line of the input contains $n$ integers, $1 \leq c_ i \leq 10^9$. The integer $c_ i$ describes the age of your $i$-th child. ## Output The first line of the output should contain the ages of...
26,166
Alea Iacta Est Description: You play a game with multiple fair six-sided dice. Each die’s face displays a single symbol. The objective of the game is to roll the dice and create a valid word from the symbols on top of each die. If you cannot form a word, you may reroll the dice for another attempt. Su...
26,167
Alea iacta est Description: Isaac B. Manfred always dreamed about being a terribly rich man. Recently, he started to study dice games. He found several of them similar to a trademarked game called Yahtzee! The rules sometimes vary but basic principles are the same. To give you an idea, we will describe...
26,168
Alehouse Description: Making friends can seem impossible, but going to the alehouse makes it easy — it is actually the only way to make friendships. Luckily, the alehouse is extremely good at its task: if two people are inside simultaneously, they instantly become friends. People even become friends if...
26,169
Alex and Barb Description: Alex and Barb are waiting for their two cousins to visit for dinner. Since their cousins tend to get involved in all sorts of shenanigans, Alex and Barb decide to pass the time with a little card game. The game is as follows: there is a stack of $k$ cards on the table. Alex and ...
26,170
Alice in the Digital World Description: After returning from Wonderland, Alice needs to improve her scientific skills in the current digital world. Alice decides to participate the ACM - ICPC Asia Nha Trang Regional Contest 2016 to evaluate her actual performance. Her favorite problem in the contest is...
26,171
Alien Attack 2 Description: In order to keep a low profile in the future, the Galactic Committee for Person Captures (GCPC) has established rules for abductions. Besides a lot of boring paperwork, the aliens have to prepare the abduction carefully. While they can make multiple trips (in fact, alien tra...
26,172
Alien Codebreaking Description: You’ve intercepted encrypted communications between Martian diplomats. Since Martian diplomats are often spies, you decide to decrypt the messages. While the Martians have skilled rocket tech, they lag behind in number theory considerably, which compromises their encrypt...
26,173
Alien Integers Description: Exploratory robots are essential to expanding our understanding of the moon, Mars, and other celestial bodies. When there are two or more robots in the same vicinity, they need to be marked by humanly readable integers for purposes of visual tracking. To reduce the possibili...
26,174
Alien Math Description: Humans are exploring the stars, and we have encountered aliens! In an exchange of scientific knowledge, we’ve learned that not only do they use entirely different symbols to do math, they don’t even use base ten! It would be nice to have a program to convert the alien numbers to...
26,175
Alien Microwave Description: A standard microwave is operated by entering the cooking time as a string in the form of hhmmss, where hh, mm, and ss are two-digit integers less than $24$, $60$, and $60$, respectively. Leading zeros in the string hhmmss are omitted. For example, the cooking time o...
26,176
Alien Numbers Description: The decimal numeral system is composed of ten digits, which we represent as "0123456789" (the digits in a system are written from lowest to highest). Imagine you have discovered an alien numeral system composed of some number of digits, which may or may not be the same as tho...
26,177
Aligning Bottles Description: It was a great evening. However, your friends helped themselves to bottles from the crate of Harboe pilsner without any attention to aesthetics, leaving an unorderly mess of holes and disconnected clusters. Before you go to bed, you want to restore some semblance of order....
26,178
All Colourings Description: Given an undirected graph $G = (V,E)$, a proper colouring of $G$ with $K$ colours is an assignment of values from $1$ through $K$ to each vertex so that each edge receives a different value/colour. That is, a proper $K$-colouring is a mapping $\sigma : V \rightarrow ...
26,179
All Different Directions Description: If you walk through a big city and try to find your way around, you might try asking people for directions. However, asking $n$ people for directions might result in $n$ different sets of directions. But you believe in the law of averages: if you consider everyone’...
26,180
All Fax No Printer Description: You have $k$ fax machines. Throughout the day, $n$ jobs arrive in order, each taking a certain amount of time. Each job gets run on a machine if one is available, else must be canceled if none are available at that time. Being a regretful person, you want to know how wel...
26,181
All Friends Description: Sociologists are interested in the phenomenon of “friendship”. To study this property, they analyze various groups of people. For each two persons in such a group they determine whether they are friends (it is assumed that this relation is symmetric). The sociologists are mostl...
26,182
All Just A Dream Description: When the All Just A Dream trick is taken too far and gets used too often, it can get difficult to keep track of what has actually happened. This is where you enter the picture. You will be given a list of events, dreams, and scenarios. Each scenario specifies some events t...
26,183
All Kill Description: You just finished participating in a programming contest with your friend. Unfortunately, you were unable to All Kill the contest (i.e., solve all of the problems), but you are now wondering if there might be some strategy that would have solved all of the problems. Solving a pro...
26,184
All Modulo Pythagorean Description: You are given a value $n$ and should investigate Pythagorean triples modulo $n$. This means we are considering triples $(a, b, c)$ where $0 < a, b, c < n$ that satisfy $a^2 + b^2 = c^2 \pmod{n}$ and $a \leq b$. For example in the first sample the solutions are $...
26,185
All Pair Sums Description: You are given two multisets of integers, $A$ and $B$. Then you are given queries containing a number $x$ and are asked to find the number of ways to write $x$ as a sum of two numbers $a \in A$ and $b \in B$. ## Input The first line of input contains two positive integers $n...
26,186
All Pairs Shortest Path Description: ## Input The input consists of several test cases. Each test case starts with a line with three non-negative integers, $1 \le n \le 150$, $0 \le m \le 5000$ and $1 \le q \le 1000$, separated by single single spaces, where $n$ is the numbers of nodes in the ...
26,187
All Square Sums Description: You are given a non-negative integer $n$ and should print all ways to write $n$ as the sum of two integer squares. ## Input The first and only line of input contain a non-negative integer $n \leq 10^{18}$. ## Output First print the number of ways $n$ can be written as t...
26,188
All about that base Description: The base (or radix) of a positional numeral system is the number of symbols that can be used to represent a number in that system. The base $10$ system (also known as decimal) uses $10$ distinct symbols: $0, 1, \ldots , 9$. For example, we interpret the number $7234...
26,189
All in the Family Description: The scientists working at the Family Genetics Institute are tracing the spread of a hereditary disease through family trees. They have started by listing the family members that have the disease, and the parent who passed the disease on to each child (we will assume that ...
26,190
All is Well Description: “All is well!” cries the watchman as he makes his way through the city. Each night he patrols the city, following a route that ensures that the people of the town hear him. You feel safe and secure each night as you start to fall asleep and hear the familiar call from the stree...
26,191
Allergen Testing Description: You are in a chemistry class, and you are working with some compounds, exactly one of which you are allergic to. You have a fixed number of days to figure out which compound it is. You set up a number of sites on your arm for testing. On each day, you do the following exac...
26,192
Allergy Test Description: A test for allergy is conducted over the course of several days, and consists of exposing you to different substances (so called allergens). The goal is to decide exactly which of the allergens you are allergic to. Each allergen has a live duration $D$ measured in whole da...
26,193
Alloys Description: Pelle is building a new advanced underground drill. He wants to build the drill out of a new titanium-aluminium-magnesium alloy. Such an alloy can be mixed in many ways. If an alloy is made with the ratios $x, y, z$ ($x + y + z = 1$) of titanium, aluminium and magnesium, the all...
26,194
Almennir Borgarar Description: Benni, an ardent competitive programmer (and hamburger enthusiast), is waiting in line with $m$ other contestants in front of him. How long will Benni have to wait if the chefs utilize the grills optimally? ## Input The first line of the input contains two integers $n$ ...
26,195
Almost Balanced Description: Consider making a string $s$ of $\textbf{even}$ length $n$ consisting of $0$ and $1$, where $s$ must satisfy $m$ conditions. The $i^{th}$ condition is represented by integers $T_ i, L_ i, R_ i (1 \leq L_ i<R_ i \leq n), V_ i (0 \leq V_ i)$. Note that $L_ i \not\equiv R_ i \text...
26,196
Almost Perfect Description: A positive integer $p$ is called a perfect number if all the proper divisors of $p$ sum to $p$ exactly. Integer $d$ is a proper divisor of $p$ if $1 \le d \le p-1$ and $p$ is evenly divisible by $d$. For example, the number $28$ is a perfect number, since its...
26,197
Almost Pythagorean Description: You are given a non-negative integer $n$ and should print the number of integer triples $(a, b, c)$ that satisfy $0 \leq a \leq b \leq c \leq n$ and $a^2 + b^2 = c^2 + c$. ## Input The first and only line of input contains a non-negative integer $n \leq 10^{5}$. #...
26,198
Almost Sorted Description: You are given an array of of $n$ integers $a_1, a_2, \ldots , a_ n$. An array is almost sorted if it is possible to reverse a continuous subarray to obtain an ascending sorted array. In other words, an array is almost sorted if there exists $1\leq i\leq j\leq n$ such that $a_...
26,199