time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For example, a 3 × 4 cake may
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The
time limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard outputThe winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only
time limit per test1 secondmemory limit per test256 megabytesinputinput.txtoutputoutput.txtThere are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA country has n cities. Initially, there is no road in the country. One day, the king decides to construct some roads connecting pairs of cities.
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPermutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputLinear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram's movement. At the i-th stop aipassengers exit
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.Petr decided to start reading it
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEverybody knows that the Berland citizens are keen on health, especially students. Berland students are so tough that all they drink is orange
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputEverybody knows that opposites attract. That is the key principle of the "Perfect Matching" dating agency. The "Perfect Matching" matchmakers have
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputSimon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputMr. Scrooge, a very busy man, decided to count the time he wastes on all sorts of useless stuff to evaluate the lost profit. He has already counted
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.The
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputPetya started to attend programming lessons. On the first lesson his task was to write a simple program. The program was supposed to do the
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputwHAT DO WE NEED cAPS LOCK FOR?Caps lock is a computer keyboard key. Pressing it sets an input mode in which typed letters are capital by default.
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn'
time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputValera had two bags of potatoes, the first of these bags contains x (x ≥ 1) potatoes, and the second — y (y ≥ 1) potatoes. Valera — very scattered
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputWhen 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
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1squares. You are
time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe Little Girl loves problems on games very much. Here's one of them.Two players have got a string s, consisting of lowercase English letters.