Conditional operator


Plus
Pin


Problem description Progress
ID 33615. We share a chocolate bar
Темы: Conditional operator   

Chocolate is one of the most beloved treats on the planet.  Willy claims that chocolate facilitates concentration, increases the speed of information processing and improves memory. Willy always takes a chocolate bar to the party. Willy always has a rectangular shaped chocolate bar divided into \(n \cdot m\) slices. He wants to leave for the next batch part of the chocolate bar, consisting of k lobes. Moreover, he wants to break the chocolate bar once in a straight line into two parts. Determine if Willy can break off exactly k slices from the chocolate in this way.

Input
The program receives three numbers as input: n, m, k.

Imprint
The program should output one of two words: YES or NO.
 

 

Examples
# Input Output
1 4
2
6
YES
2 2
10
7
NO

ID 33614. King move
Темы: Conditional operator   

King – this is a special piece in chess. Its value is incomparable with the value of other pieces – with his loss, the game ends immediately.

That Chess King is priceless! But he also has the right to fight. The king can close the path to three pawns. And when paired with a pawn, he can cause trouble for the strongest pieces. The chess king moves horizontally, vertically and diagonally, but only 1 square.
Let's help Willie program the move of the chess king. 

Given two different cells of a chessboard, determine if the king can get from the first cell to the second in one move.

Input 
The program receives as input four numbers from 1 to 8 each, specifying the column number and row number, first for the first cell, then for the second cell. Each number is given on a separate line.

Imprint 
The program should output YES if it is possible to get from the first cell to the second by the king's move, or NO  otherwise.
 

 

Examples
# Input Output
1 4
4
5
5
YES

ID 22003. Rule calculations - 1
Темы: Conditional operator   

Integers X and Y are given. Calculate the number Z, according to the following rule:
Z = X + Y,  if X <= Y;
Z = 1 - X + Y otherwise.

Input:
2 integers X and Y are entered from the keyboard.

Imprint 
It is necessary to display the value of the variable Z.
 

Example
test number Input Output
1 5 6 11
2 6 5 0

ID 22005. Rule calculations - 2
Темы: Conditional operator   

Given an integer. If the number is positive, then print it; if negative - output the number multiplied by –1.

Input: a single number is entered from the keyboard
Output: display the number itself if it is positive, or the number multiplied by -1 otherwise

Input and output example

test number Input Output
1 3 3
2 -3 3

ID 22001. Rule calculations - 3
Темы: Conditional operator   

You are given four integers. Square those of them whose values ​​are non-negative, and to the fourth power - negative

Input: four integers are entered from the keyboard

Output: display converted numbers (output numbers in the same sequence as input)

Input and output example

test number Input Output
1 3 5 -2 -4 9 25 16 256

ID 32988. sum or product
Темы: Conditional operator    Whole numbers   

An integer X (\(100<=X<=9999\)) is entered from the keyboard. If the number is four-digit, then find the sum its digits, and if three-digit, then the product of the digits of the given number.

Input
The input is an integer X (\(100<=X<=9999\))..

Imprint
Display the answer to the problem.
 

 

Examples
# Input Output
1 125 10
2 1253 11

ID 21960. Comparing the digits of a number
Темы: Whole numbers    Conditional operator   

Given a two-digit number. Display the word YES if the digits of this number are the same and the word NO if the digits are different.

Input 
One number is entered from the keyboard.

Imprint 
Display the word YES if the digits of the given number are the same, or the word NO if the digits are different.
 

 

Examples
# Input Output
1 65 NO
2 55 YES

ID 21959. First or second
Темы: Whole numbers    Conditional operator   

You are given a two-digit number whose digits are different.  Print the word first if the first digit is greater than the second, and the word second if the second digit is greater than the first.

Input 
A positive two-digit number is entered from the keyboard.

Imprint 
Print the word first if the first digit is greater than the second, and the word second if the second digit is greater than the first.
 

 

Examples
# Input Output
1 65 first
2 56 second

ID 3992. The amount is a multiple of 5
Темы: Whole numbers    Conditional operator   

Given a three digit number. Determine if the sum of its digits is a multiple of 5. Display the word YES or NO.

Input
The input is a positive three-digit number.

Imprint
Print the answer word YES if the sum of the digits of the original number is a multiple of 5, otherwise print the word NO.
 

 

Examples
# Input Output
1 473 NO
2 451 YES

ID 3991. Lucky number
Темы: Whole numbers    Conditional operator   

Given a six digit number. Determine whether it is lucky (the sum of the first three digits is equal to the sum of the last three). If the number is happy, display the word HAPPY, otherwise, display the word NO.

Input
The input is a positive six-digit number.

Imprint
Display the answer to the problem.
 

 

Examples
# Input Output
1 111111 HAPPY
2 134211 NO

ID 3990. Maximum digit of a number
Темы: Whole numbers    Conditional operator   

Given a four-digit number. Determine the maximum digit of the number.

Input
The input is a positive four-digit number.

Imprint
Display the answer to the problem.
 

 

Example
# Input Output
1 4731 7

ID 3989. How many fours are there
Темы: Conditional operator    Whole numbers   

Given a three digit number. Determine how many times the number 4 appears in it.

Input
The input is a positive three-digit number.

Imprint
Display the answer to the problem.
 

 

Example
# Input Output
1 473 1

ID 3986. Various digits of a number
Темы: Conditional operator    Whole numbers   

Given a three digit number. Print the word YES if all digits of the number are different and the word NO otherwise.


Input
The input is a positive three-digit number.

Imprint
Display the answer to the problem.
 

 

Examples
# Input Output
1 123 YES
2 112 NO

ID 33631. triangle type
Темы: Conditional operator   

Three sides of a triangle a, b, c are given. Determine the type of triangle with given sides. Print one of four words: rectangular for a right triangle, acute for an acute triangle, obtuse  for an obtuse triangle, or impossible if no triangle with such sides exists.

Input data: Three natural numbers are entered.
Output: Print the answer to the problem.

Examples
# Input Output
1 3
4
5
rectangular
2 1
2
3
impossible

ID 33633. Laptop warehouse
Темы: Conditional operator   

Notebooks packed in boxes were brought to the warehouse, which has the shape of a rectangular parallelepiped. Each box also has the shape of a rectangular parallelepiped. According to the storage rules, boxes with laptops must be placed in a warehouse with the following two conditions:
1. The sides of the boxes must be parallel to the sides of the warehouse.
2. When placing a box in a warehouse, it is allowed to place it anywhere (with the fulfillment of the previous condition), including on another box, but all boxes must be oriented in the same way (i.e. you cannot place one box “standing” and the other &mdash ;“lying”)

Write a program that will determine the maximum number of laptops that can be placed in the warehouse, given the size of the warehouse and the size of the box with a laptop.

Input: The program receives six natural numbers as input. The first three define the length, height and width of the warehouse. The next three sets the length, height, and width of the laptop box, respectively.
Output: The program should output a single number — the maximum number of laptops that can be placed in the warehouse.

Examples
# Input Output
1 100
200
300
1
2
3
1000000
2 100
200
300
3
2
1
1000000
3 100
100
1
2
2
2
0
4 7
7
7
3
3
3
8

ID 33634. Subway tickets - 2
Темы: Conditional operator   

A long time ago, ticket prices were:
1 trip — 15 rubles,
5 trips — 70 rubles,
10 trips — 125 rubles,
20 trips — 230 rubles,
60 trips — 440 rubles.
The passenger plans to make n trips. Determine how many tickets of each type he must purchase so that the total number of paid trips is not less than n, and the total cost of purchased tickets — minimal.

Input: The program receives one number n as input.

Output: The program should output five integers: the number of tickets for 1, 5, 10, 20, 60 trips to be purchased. If for some given n there are several ways to purchase tickets of the same total cost, you need to print the combination of tickets that gives more trips.

Examples
# Input Output
1 1 1 0 0 0 0
2 7 2 1 0 0 0

ID 32989. The sum of the digits of a number
Темы: Whole numbers    Conditional operator   

Given a two-digit number. Determine if the sum of its digits is a two-digit number. If not, then after how many numbers to meet the first two-digit number that satisfies this condition.

Input 
A single number is entered from the keyboard N (\(10 <= N <= 99\)).

Imprint 
Display the word YES if the sum of the digits of the number N is a two-digit number, otherwise display a number that shows how many numbers from the original N > meet the first number whose sum of digits will be a two-digit number.
 

 

Examples
# Input Output
1 65 YES
2 25 3

ID 33635. Are the numbers included?
Темы: Conditional operator   

Given a three digit number. Determine if it contains numbers 3, 6 or 9.

Input 
The input to the program is a single number N \(( 100 <= N <= 999 )\).

Imprint 
Print YES if digits 3, 6 or 9 are included in the number, otherwise print NO.
 

 

Examples
# Input Output
1 359 YES
2 125 NO

ID 33630. Chess board
Темы: Conditional operator   

Two squares of a chessboard are given. If they are colored in the same color, then output the word YES, and if they are in different colors – then NO.

Input data: 4 numbers are entered - the coordinates of the cells.

Output: Print the answer to the problem.
 
Examples
# Input Output
1 1
1
2
2
YES
2 1
1
2
3
NO

ID 33628. Крещенские купания
Темы: Conditional operator   

Во время Крещенских купаний Вилли любит окунуться в прорубь, которая представляет собой прямоугольник размером \( N х M\) метров. Для большей смелости Вилли опускает на воду деревянную шахматную доску и идёт переодеваться. После этого он возвращается, и видит, что доска находится на расстоянии \(x\) метров от одной из длинных сторон (не обязательно от ближайшей) и \(y\) метров от одной из коротких сторон. Плыть за доской он просто обязан. Какое минимальное расстояние необходимо преодолеть Вилли, чтобы доплыть до своей шахматной доски (размерами доски можно пренебречь)?

Входные данные: Программа получает на вход числа N, M, x, y.
Выходные данные: Программа должна вывести число метров, которое нужно преодолеть Вилли до доски.

 
Примеры
Входные данные Выходные данные
1 23
52
8
43
8

ID 33629. Шахматный набор
Темы: Conditional operator   

Вилли ездит на соревнования всегда с двумя наборами шахмат. Набор шахмат представляет из себя складную шахматную доску, внутрь которой можно положить фигуры. Для экономии места в багаже, Вилли всегда складывает все фигуры в одну коробку, и эту коробку кладет внутрь другой коробки. 
Перед очередными соревнованиями он пошел в магазин за новыми шахматными наборами. Он выбрал два набора шахмат. Первый набор имеет размер доски в сложенном виде A1×B1×C1, второй - размером A2×B2×C2.
Вилли хочет узнать, поместится ли один шахматный набор внутрь другого, при условии, что поворачивать доски можно только на 90 градусов вокруг ребер.

Входные данные: Программа получает на вход числа A1, B1, C1, A2, B2, C2.
Выходные данные: Программа должна вывести одну из следующих строчек:

Boxes are equal, если оба набора одинаковые,
The first box is smaller than the second one, если первый набор может быть положен во второй,
The first box is larger than the second one, если второй набор может быть положен в первый,
Boxes are incomparable, во всех остальных случаях.

Примеры

Входные данные Выходные данные
1 1
2
3
3
2
1
Boxes are equal
2 3
4
5
2
4
6
Boxes are incomparable

ID 33651. Olympic Games
Темы: Conditional operator   

Everyone knows that the 2012 Summer Olympics took place in London, but not everyone is familiar with the history of major sports competitions. The tradition of games originated in Ancient Greece, but was forgotten at the end of the ancient era and reappeared only at the end of the 19th century thanks to the French public figure Pierre de Coubertin.

Since 1896, the Summer Olympic Games have been held again, and since 1924 — winter, and both types of competitions are held every four years. At first, the winter and summer Olympics were held in the same year, but at the end of the 20th century, the International Olympic Committee decided to establish a two-year break between different types of Games. Thus, 1992 was last marked by the holding of both summer and winter Olympic Games, in 1994 only winter ones were held, in 1996 — summer, and since then they continue to alternate.

It is also known that in 1916, 1940 and 1944 the Olympic Games were canceled due to the First and Second World Wars, and in 1906 an extraordinary Olympics was held.

It is required to write a program that, for a given year, will determine whether the Olympic Games were held this year and whether they were summer or winter.

Input: The program receives one natural number as input N (1800 ≤ N  ≤ 2014) — year number.

Output: Print "winter" if only the Winter Olympics were held this year, "summer" if only the Summer Olympics were held, "winter summer" if both Olympiads were held , and "nothing" if there were no Olympic Games that year.

Examples
# Input Output
1 1896 summer
2 1924 winter summer

ID 33652. Air conditioner
Темы: Conditional operator   

A new type of air conditioner has been installed in the office where the programmer Petr works. This conditioner differs in special simplicity in management. The air conditioner has only two controllable parameters: the desired temperature and operating mode.

The air conditioner can operate in the following four modes:

  • "freeze" — cooling. In this mode, the air conditioner can only reduce the temperature. If the temperature in the room is already not higher than desired, then it turns off.
  • "heat" — heat. In this mode, the air conditioner can only increase the temperature. If the temperature in the room is already not less than desired, then it turns off.
  • "auto" — auto mode. In this mode, the air conditioner can either increase or decrease the temperature in the room to the desired one.
  • "fan" — ventilation. In this mode, the air conditioner only ventilates the air and does not change the temperature in the room.

The air conditioner is powerful enough, so when set to the correct operating mode, it brings the temperature in the room to the desired one in an hour.

It is required to write a program that, according to the set temperature in the room troom, installed on the air conditioner, the desired temperature tcond and operating mode determines the temperature that will be established in the room in an hour.

Input: The first line contains two integers troom, and tcond separated by exactly one space (–50 ≤ troom< /sub> ≤ 50, –50 ≤ tcond ≤ 50) .

The second line contains a single word written in lowercase Latin letters — air conditioner operation mode.

Output: You need to output the bottom integer — the temperature that will be established in the room in an hour.

Note: 
In the first example, the air conditioner is in heating mode. In an hour, he will heat the room to the desired temperature of 20 degrees.

In the second example, the air conditioner is in cooling mode. Since the temperature in the room is lower than the desired temperature, the air conditioner turns off by itself and the temperature in the room does not change.
Examples

# Input Output
1 10 20
heat
20
2 10 20
freeze
10

ID 33653. Full house!
Темы: Conditional operator   

In one of the popular cinemas, all sessions are sold out, so all seats in the hall are always occupied. Unfortunately, the distance between the rows in the cinema hall is small, and the audience, making their way to their seats before the start of the film, is forced to stumble over the legs of those already seated. Entering the hall, the viewer thinks from which side of the row he will make his way to his place (from the left or from the right), and chooses the side so as to stumble over a smaller number of people. In case of equality, the viewer chooses the side to which his place is closer.

Vasya, an ardent lover of cinema and an equally ardent hater of mathematics, was the first to buy a ticket for the next premiere. When Vasya entered the hall and sat down in his place, he saw that all the other chairs in his row were still empty. Vasya knew for sure that by the beginning of the screening the hall would be filled to capacity, which meant that any minute other film lovers would start stumbling over his feet, making their way to their seats. Despite all his dislike for mathematics, Vasya instantly estimated what the maximum number of people could trip over his feet before all the spectators took their places. Can you?

Input: The program takes as input two integers (one per line) n and k — the number of seats in the row where Vasya is sitting, and the number of his seat, respectively (1≤k≤n≤50, n — even). Seats in a row are numbered from one.

Output: The program should print the maximum number of people who can trip over Vasya's feet.
Examples
# Input Output
1 4
1
1

ID 33654. electric train
Темы: Conditional operator   

The cars in the train are numbered with natural numbers, starting from 1 (at the same time, sometimes the cars are numbered from the "head" of the train, and sometimes - from the "tail"; it depends on which direction the train is going). Each car has its number.

Vitya got into the ith car from the head of the train and discovered that his car has the number j. He wants to determine how many cars are in the train. Write a program that will do this or tell you that it can't be done without more information.

Input: The input of the program is two numbers i and j (1 ≤ i  ≤ 1000, 1 ≤ j ≤ 1000) separated by a space.
Output: Print a single number — the number of wagons in the train. If it is impossible to uniquely determine the number of wagons, print  number  0
Examples
# Input Output
1 3 4 6

ID 33655. Olympics at Hogwarts
Темы: Conditional operator   

Hogwarts hosts the traditional annual Olympiad in the theory of magic among junior students. School manager Argus Filch was assigned to distribute students to classrooms.

Each faculty put up their best students for the Olympiad. From Gryffindor G students, from Slytherin S students, Hufflepuff represents H students and Ravenclaw —  R students. Filch has M audiences at his disposal. The classrooms have been given a special expansion spell, so they can accommodate any number of students if needed. When seating, it is necessary to take into account that students of the same faculty, who are in the same audience, can take advantage of the opportunity to start cheating, exchanging ideas for solving problems. Therefore, in any classroom, the number of students from one faculty who fall into it should be minimized. Let's call a seating arrangement that satisfies this requirement optimal.

Help me calculate what is the minimum number of students from the same faculty who still have to be seated in the same classroom, even with optimal seating.

Input: The first line contains four integers GSH< /em> and R (1 ≤ G, S, H , R ≤ 1000) — the number of students representing each of the faculties of the school.

The second line contains an integer M (1 ≤ M ≤ 1000) — the number of classes Filch has at his disposal.

Output: Print the minimum number of students from the same department that Filch will have to seat in the same room even with optimal seating.
Examples

# Input Output
1 4 3 4 4
2
2
2 15 14 13 14
3
5

ID 33636. Point on the coordinate plane - 1
Темы: Conditional operator   

Write a program that determines if a point with given coordinates is in a shaded area.

Input: The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate).
Output: The program should output the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

Examples
# Input Output
1 1.5 0.25 YES
2 1.5 -0.25 NO

ID 32946. Conditioning - 1
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


given natural number a is a multiple of b, but not a multiple of c

EXAMPLE: (the input is three numbers a, b, c separated by a space)
input:
24 12 3
output:
0

EXAMPLE:
input:
50 25 3
output:
1

ID 32945. Conditioning - 2
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


the product of natural numbers a and b is a multiple of c

EXAMPLE: (the input is three numbers separated by a space)
entry: 12 24 3
output: 1

EXAMPLE:
entry: 27 24 5
output: 0

ID 32944. Conditioning - 4
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


the sum of two natural numbers is a multiple of 2

EXAMPLE: (two numbers separated by a space)
entrance: 12 24
output: 1

EXAMPLE:
entrance: 27 24
output: 0

ID 32943. Conditioning - 5
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


this four-digit number reads the same from left to right and right to left

EXAMPLE:
input: 1221
output: 1

EXAMPLE:
input: 2727
output: 0

ID 32942. Conditioning - 6
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


the integer N is an even two-digit number

EXAMPLE:
entry: 12
output: 1

EXAMPLE:
entry: 27
output: 0

ID 32941. Conditioning - 7
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


the square of a given two-digit number is equal to the cube of the sum of its digits

EXAMPLE:
entry: 12
output: 0

EXAMPLE:
entry: 27
output: 1

ID 32940. Conditioning - 3
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


the sum of the digits of the given three-digit number is an even number

EXAMPLE:
input: 123
output: 1

EXAMPLE:
input: 122
output: 0

ID 32939. Conditioning - 8
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


The sum of the first two digits of a given four-digit number is equal to the sum of its last two digits

EXAMPLE:
input: 1234
output: 0

EXAMPLE:
input: 1221
output: 1

ID 24900. Conditioning - 9
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


digits of the original four-digit number N form a strictly increasing sequence
 
input
the input is the number N (1000<=N<=9999)

output
1 - if all digits of the number form a strictly increasing sequence
0 - otherwise

EXAMPLE:
input: 1234
output: 1

EXAMPLE:
input: 1224
output: 0

ID 24899. Conditioning - 10
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


the given numbers x and y are the coordinates of the point lying in the first coordinate quadrant
 
input
the input is two integers x and y (-10^5<x,y<10^5)

output
1 - given numbers x and y are the coordinates of a point lying in the first coordinate quarter
0 - otherwise

ID 24898. Conditioning - 11
Темы: Conditional operator   

Write a program that prints 1 if the given statement is true and 0 otherwise.


all digits of the original four-digit number are distinct
 
input
the input is the number N (1000<=N<=9999)

output
1 - if all digits of the number are different
0 - otherwise

ID 33041. Number of even digits
Темы: Whole numbers    Conditional operator   

Given a four-digit number. Determine how many even digits are in it.

Input
The input is a four-digit positive number.

Imprint
Display the answer to the problem.
 

 

Example
# Input Output
1 4732 2

ID 33042. Number of odd digits
Темы: Conditional operator    Whole numbers   

Given a four-digit number. Determine how many odd digits are in it.

Input
The input is a four-digit positive number.

Imprint
Display the answer to the problem.
 

 

Example
# Input Output
1 4732 2

ID 31924. Elevator
Темы: Formula derivation    Conditional operator   

Peter needs to get from floor A to floor B. To call the elevator on all floors of the office building, except for the first and last, there are two buttons – to move down and move up. At the moment when Peter pressed the desired call button, the elevator was on floor C and carried one passenger to floor D. If the elevator passes the floor on which the call button is pressed, and the elevator moves in the appropriate direction, then the elevator stops to put an additional passenger. The elevator moves between adjacent floors in one unit of time, and it also takes one unit of time for the elevator to stop on the floor for disembarking or boarding passengers.
Write a program to calculate how long it will take Peter to reach floor B, assuming no one else calls the elevator.
The first line of input contains four integers A, B, C, and D separated by a single space (1 ≤ A, B, C, D ≤ 20, A≠B, C≠D, A≠C).< /div>
Output one integer – the number of time units from the moment the elevator is called to the moment when Peter exits the elevator on floor B.
 
Input Output
3 9 2 5 10
3 9 5 2 13
Note:
Explanation for example 1
The elevator will reach the 3rd floor in 1 unit of time, stop for 1 unit of time for Peter to get into the elevator, then after 2 units of time it will reach the 5th floor and stop for 1 unit of time to disembark the previous passenger, after In 4 time units, the elevator will take Peter to the 9th floor, and after 1 time unit, Peter will exit the elevator.

ID 33527. Reliable fastening
Темы: Conditional operator   

The outdoor billboard is attached to the pole with three fasteners. The first  mount can withstand the wind, the speed of which does not exceed A m / s, the second – B m / s, third – C m/s. The shield itself will be securely fastened if at least two of the three fastenings can withstand the wind of a given speed. Determine the maximum speed
wind that this shield can withstand.
The program receives as input three positive integers A, B, C, not exceeding 2×109, – allowable wind speeds that can withstand three fastenings & nbsp; of the shield. The program should output a single number – the maximum wind speed the shield can withstand.
 

Input Output
28
15
10
15

ID 33632. Prisoner of the Chateau d'If
Темы: Conditional operator   

During many years of confinement, a prisoner of If Castle made a rectangular hole in the wall measuring D×E. Chateau d'If is made of bricks, A×B×C. Determine if the prisoner will be able to throw bricks into the sea through this hole, if the sides of the brick should be parallel to the sides of the hole.

Input
The program receives numbers A, B, C, D, E as input.

Imprint
The program should output the word YES or NO.

Examples
# Input Output
1 1
1
1
1
1
YES
2 2
2
2
1
1
NO

ID 22004. Number output
Темы: Conditional operator   

Given two integer numbers. Output the first one if it is greater than the second and both numbers if it is not.

Input format 
The program receives as input two different integers written on the same line, separated by a space.

Output format
Output the first number if it is greater than the second, or output both numbers if the first number is not greater than the second.
 

Examples
Input Output
1 5 3 5
2 3 5 3 5

ID 33616. So different speeds
Темы: Conditional operator   

Several facts about speeds.

  1. The windiest place on Earth is Victoria Land in Antarctica. The wind speed there can reach up to 215 km/h.
  2. The highest speed of a toy train is 10 km/h.
  3. The slowest speed in sports was recorded on August 12, 1889 - 1350 m/h in rope pulling.
  4. The average speed of snails is approximately 1.5 mm per second.

There are different types of speeds: reading speed, information transmission speed, bird flight speed, and so on.
Given two speeds (the first one in kilometers per hour, and the second one in meters per second), which speed is greater. The speeds are not equal. Output the higher speed.
 

Input format
The input consists of two integers, each on a separate line:

  • Speed in kilometers per hour (k).
  • Speed in meters per second (m).

Output format
Output the highest speed, following the output format described in the examples.

 
Examples
Входные данные Выходные данные
1 10
1
10 kph
2 18
6
6 mps

ID 37497. Ход короля
Темы: Conditional operator   

Король – это особая в шахматах фигура. Его ценность несравнима с ценностью остальных фигур – с его потерей партия сразу заканчивается.

Поэтому шахматный король бесценен! Но он тоже имеет право вести бой. Король может закрыть путь трём пешкам. А в паре с пешкой он может доставить неприятности самым сильным фигурам. Шахматный король ходит по горизонтали, вертикали и диагонали, но только на 1 клетку.
Поможем Вилли запрограммировать ход шахматного короля. 

Даны две различные клетки шахматной доски, определите, может ли король попасть с первой клетки на вторую одним ходом.

Входные данные: Программа получает на вход четыре числа от 1 до 8 каждое, задающие номер столбца и номер строки сначала для первой клетки, потом для второй клетки.
Выходные данные: Программа должна вывести YES, если из первой клетки ходом короля можно попасть во вторую или NO в противном случае.
Примеры
Входные данные Выходные данные
1 4
4
5
5
YES

ID 37538. Saint Francis Xavier's Day
Темы: Conditional operator   

Today, the Indian town of Old Goa celebrates St. Francis Xavier's Day. Saint Francis Xavier – missionary, member of the Jesuit order, considered the greatest Catholic missionary of modern times.
Relics of Saint Francis Xavier – spiritual patron of Indian Christians – rest in Old Goa in the famous Catholic church – Basilica of Bom Jesus. Since the construction of the temple in 1605, once every ten years, the relics of the saint are exhibited for public viewing.
Indian peasant Virmaram  – a very pious man, he did not miss the opportunity to touch the holy relics. Knowing the years of his life, determine how many times he could touch the holy relics (it is believed that in the year of his birth he could not do this, but in the year of his death – he could).

Input: Two natural numbers – year of birth and year of death. Numbers are separated by spaces. Both numbers do not exceed 2000.
Output: The program must  determine how many times the peasant could touch the holy relics  and display the answer - one number.

Examples
# Input Output
1 1610 1640 3
2 1615 1645 3

 

ID 33637. Point on the coordinate plane - 2
Темы: Conditional operator   

Write a program that which determines whether the point with the given coordinates is in the shaded area. 

Input: 

The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate).

Output:

The program should output the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

 

Examples
# Input Output
1 0. 1. YES
2 0. -1. NO

ID 33695. Point on the coordinate plane - 11
Темы: Conditional operator   

Point coordinates (x, y) given . Print the word YES on the screen if the point falls within the shaded area, otherwise print NO. A point located on the border with a shaded area is considered not to fall into it.

Input data: The program receives two real numbers as input - the coordinates of the point (x, y)
Output: Output the answer to the problem

 

Examples
# Input Output
1 0.0 -0.5 NO
2 1.0 1.5 YES

ID 33694. Point on the coordinate plane - 10
Темы: Conditional operator   

Point coordinates (x, y) given . Print the word YES on the screen if the point falls within the shaded area, otherwise print NO. A point located on the border with a shaded area is considered not to fall into it.

Input data: The program receives two real numbers as input - the coordinates of the point (x, y)
Output: Output the answer to the problem

 

Examples
# Input Output
1 0.0 0.0 NO
2 1.0 1.5 YES

ID 33693. Point on the coordinate plane - 9
Темы: Conditional operator   

Point coordinates (x, y) are given. Print the word YES on the screen if the point falls within the shaded area, otherwise print NO. A point located on the border with a shaded area is considered not to fall into it.

Input data: The program receives two real numbers as input - the coordinates of the point (x, y)
Output: Output the answer to the problem

 

Examples
# Input Output
1 0.0 1.0 NO
2 1.0 0.5 YES

ID 33643. Point on the coordinate plane - 8
Темы: Conditional operator   

Write a program that which determines whether the point with the given coordinates is in the shaded area.

Input: The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate)

Output: The program should output the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

 

Examples
# Input Output
1 -0..5 -0.5 YES
2 -1. 1.5  NO

ID 33642. Point on the coordinate plane - 7
Темы: Conditional operator   

Write a program that which determines whether the point with the given coordinates is in the shaded area.

Input: The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate).

Output: The program should output the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

 

Examples
# Input Output
1 0.5 0.5  YES
2 -0.5 -0.5  NO

ID 33641. Point on the coordinate plane - 6
Темы: Conditional operator   

Write a program that which determines whether the point with the given coordinates is in the shaded area.

Input: The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate).

Output: The program should output the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

 

Examples
# Input Output
1 0. 0. NO

ID 33640. Point on the coordinate plane - 5
Темы: Conditional operator   

Write a program that which determines whether the point with the given coordinates is in the shaded area.

Input: The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate).

Output: The program should print the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

 

Examples
# Input Output
1 -0.5 0. NO
2 0. 0.5 YES

ID 33639. Point on the coordinate plane - 4
Темы: Conditional operator   

Write a program that which determines whether the point with the given coordinates is in the shaded area.

Input: The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate).

Output: The program should output the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

 

Examples
# Input Output
1 -0.5 0.5 YES
2 0.5 -0.5 NO

ID 33638. Point on the coordinate plane - 3
Темы: Conditional operator   

Write a program that which determines whether the point with the given coordinates is in the shaded area.

Input: The input string contains two real numbers – coordinates of a point on the plane (first -coordinate, then – -coordinate).

Output: The program should print the word 'YES' if the point is in the shaded area, and the word 'NO' if it is not.

 

Examples
# Input Output
1 0. 1. NO
2 0. -1. YES

ID 33626. Donuts
Темы: Conditional operator   

Dedicated to donut lovers! 

Donuts — These are dough products fried in oil. Prepare  donuts with or without filling. You can put p donuts into the oil pot at the same time. Each donut needs to be fried on both sides for m minutes continuously. 
Write a program that will determine the minimum number of minutes in which n donuts will be ready.

Input 
The program receives three natural numbers as input: pm and n, one per line.

Imprint
Output the answer to the problem.

 

Examples
# Input Output
1 1
5
1
10
2 2
3
7
21

ID 33624. travel card
Темы: Conditional operator   

In a certain city of Che, tickets for public transport (let's call such tickets in one word - travel) can be bought at different rates:
- a ticket for one trip costs 15 rubles,
- a ticket for 10 trips costs 125 rubles,
- A ticket for 60 trips costs 440 rubles.
You are planning to make n trips. 
Determine how many passes of each type you need to buy in order to spend as little money as possible, and the total number of paid trips was not less than n.

Input
The program receives a single number n.

Imprint 
The program should output three integers equal to the required number of tickets for 1, 10, 60 trips.

 

Examples
# Input Output
1 36 0 0 1
2 64 4 0 1

ID 33623. Linear Equation
Темы: Conditional operator   

Numbers a and b are given. Solve in integers the \(ax+b=0\) equation. Print all solutions of this equation, if their number is finite, print the word NO, if there are no solutions, print the word INF, if there are infinitely many solutions.

Input
Two numbers are entered, one per line.

Imprint 
Output the answer to the problem.

 

Examples
# Input Output
1 1
-7
7
2 6
-2
NO

ID 33621. Point area
Темы: Conditional operator   

Given the coordinates of the point (x, y). Outpur the word YES, if the point falls into the shaded area, otherwise print NO. A point located on the border with the shaded area is considered not to fall into it.

Input: Two real numbers are fed to the input of the program - the coordinates of the point (x, y)
Output: Print the answer to the problem

Examples

Input ​​​​​​​Output
1 1.0 1.0 NO
2 1.9 1.8 YES

ID 33613. Knight's move
Темы: Conditional operator   

Knight is the most mysterious figure in a chess game. The main distinguishing feature — change the color of the field with each move. 
It is required to determine whether a knight standing on a cell with the specified coordinates (row number and column number) can beat a piece standing on another specified cell.

Input
Four numbers are entered: the coordinates of the knight and the coordinates of another figure. Coordinates are integers between 1 and 8.

Imprint
It is required to output the word YES if the knight can capture the piece in 1 move, otherwise output the word NO.

 

Examples
# Input Output
1 1
1
2
3
YES
2 3
2
8
3
NO

ID 33612. Programming the Queen
Темы: Conditional operator   

No one has yet made statistics on how many programmers can play chess well (at least at the level of the first rank). But we can definitely say that any programmer at least once tried to write a program related to chess in one way or another. Let's try it too.
It is required to determine whether the queen standing on a cell with the specified coordinates (row number and column number) can beat a piece standing on another specified cell.
 

Input
Four numbers are entered: the coordinates of the queen and the coordinates of the other piece. Coordinates are integers between 1 and 8.

Imprint 
It is required to output the word YES if the queen can capture a piece in 1 move, otherwise output the word NO.

 

Examples
# Input Output
1 1
1
8
1
YES
2 3
2
8
3
NO

ID 33611. Verification of solutions
Темы: Conditional operator   

Chess, having originated 15 centuries ago, continues to live and develop, using all modern technical means. However, despite this, no one, not excluding the world champion, has yet learned to play flawlessly. Alas, the mental capabilities of man are not unlimited. Chess engines can check for errors in your game in a matter of seconds and suggest how you should play.
We have not yet learned how to write a computer engine, but we will try to write a program that checks the answers.

There is such a task: “A four-digit number is given as input to the program. If it is symmetric, print 1, otherwise print any other integer”.
As you already know, all tasks are checked on pre-prepared examples and the correct answers to them.

It seems to a novice programmer that he has solved this problem, but for some reason the system does not accept his solution. A novice programmer thinks that this is due to the fact that he displays not the any other number that is written in the correct answers.

Help the programmer. Write a program that, based on the answer recorded in the testing system and the programmer's answer, determines whether the problem is solved correctly.
 

Input
The program receives two numbers as input: the answer recorded in the testing system and the student's answer.

Imprint
The program should output YES if the student gave the correct answer and NO otherwise.

 

Examples
# Input Output
1 11
-1
YES
2 3
1
NO

ID 37539. Endless table
Темы: Conditional operator   

Natural numbers are written in an (infinite) table, as shown.

It is required to display all its neighbors for a given number (the numbers written in the cells above, on the right, on the left and below, if any).
 

Input data: Enter one natural number not exceeding 109.
Output: The program should output all the numbers written in adjacent data cells in ascending order. Numbers must be separated by spaces.

Examples
# Input Output
1 1 3
2 7 3 6 8 13

ID 37540. Arrows of Ivan
Темы: Conditional operator   

Ivan the Fool (Ivan the Fool) — one of the most popular heroes of Russian, as well as Belarusian and Ukrainian fairy tales. Ivan the Fool is not really stupid, but just the last child in the family. Since he is the third son, he is not entitled to a share in the inheritance. Ivan loved archery in his free time. Launching the arrows once again, Ivan decided to see what shape they form if we connect the points of falling arrows. Although Ivan is not stupid, he still needs your help.
The coordinates of three points on the plane where Ivan's arrows fell are known. Determine the relative position of the arrows.

Input data: The program receives 6 numbers as input: x1, y1, x2, y2, x3, y3. All numbers are integers, modulo does not exceed 100. They define 3 points of the plane: a(x1, y1), b(x2, y2), c(x3, y3).
Output: It is necessary to determine the relative position of the points and display the situation code on the screen:

0 — 3 dots match;
1 — exactly 2 points out of 3 match;
2 — the points do not coincide, they lie on the same line;
3 — the points form an acute triangle;
4 — the points form a right triangle;
5 — the points form an obtuse triangle.

 
Examples
# Input Output
1 1 1 1 1 1 1 0
2 0 0 3 0 0 4 4

ID 32947. Watch
Темы: Case Study    Conditional operator    Simulation tasks   

An electronic ink wristwatch can display the current time in several different forms. One of the forms is an imitation of a mechanical watch with arrows. The watch dial is divided into 12 large hour divisions, and each of them - into 5 small divisions. The angle between the small divisions on the dial is 6. To save energy, the image is redrawn once a minute when you need to move the minute hand. The hour hand also moves discretely, moving every 12 minutes by one small division. Thus at 12:35 the hour hand will point to the 2nd small division to the right of 12 o'clock, and the minute hand will point to 7 o'clock. The angle between the arrows at this moment is 162°. At 12:36 the hour hand will move to the 3rd small division after 12 o'clock and the minute — to the next minor division after 7 o'clock. The angle between the hands of the clock will not change.

Write a program that calculates the value of the "internal" the (smaller) angle between the hour hand and the minute hand at a given time.
The first line of input contains two integers separated by a single space — clock time, hours H and minutes M (\(1 <= H <= 12, 0 <= M <= 59\)).< /div>
Print a single integer between 0 and 180 — the angle between the arrows in degrees.
 
Examples
# Input Output
1 12 35 162

ID 38192. Metro
Темы: Conditional operator   

Vitya works near one of the stations of the Moscow metro circle line, but lives next to another station on the same line. It is required to find out what is the least number of intermediate stations that Vitya needs to pass along the ring in order to get home from work.

Input
The stations are numbered in a row with natural numbers 1, 2, 3, …, N (the 1st station – is adjacent to the Nth), N does not exceed 100.

Three numbers are entered: first N – the total number of stations on the circle line, and then i and j – the numbers of the station at which Vitya gets off, and the station at which he must get off. Numbers i and j do not match. All numbers are separated by a space.

Imprint
It is required to give the minimum number of intermediate stations (not counting the pick-up and drop-off stations) that Vitya needs to pass.

Examples

# Input Output Explanations
1 100 5 6 0 There are 100 stations on the circle line; Vitya can go from the 5th to the 6th station directly, without intermediate stations
2 10 1 9 1 There are 10 stations on the circle line; Vitya can go from the 1st to the 9th station through one intermediate station, its number is 10

ID 38197. Saint Francis Xavier's Day
Темы: Conditional operator   

Today in the Indian town of Old Goa celebrate the Day of St. Francis Xavier. Saint Francis Xavier – missionary, member of the Jesuit order, considered the greatest Catholic missionary of modern times.

Relics of Saint Francis Xavier – spiritual patron of Indian Christians – rest in Old Goa in the famous Catholic church – Basilica of Bom Jesus. Since the construction of the temple in 1605, once every ten years, the relics of the saint are exhibited for public viewing.

Indian peasant Virmaram  – a very pious man, he did not miss the opportunity to touch the holy relics. Knowing the years of his life, determine how many times he could touch the holy relics (it is believed that in the year of his birth he could not do this, but in the year of his death – he could).

Input
Enter two natural numbers – year of birth and year of death. Numbers are separated by spaces. Both numbers do not exceed 2000.
Imprint
The program should  determine how many times the peasant could touch the holy relics,  and output the answer - a single number.
 

Examples
# Input Output
1 1610 1640 3
2 1615 1645 3

ID 38198. The equation
Темы: Whole numbers    Conditional operator   

Solve the equation in integers:

\( { \sqrt{ax +b}} = c\)

a, b, c – given integers: find all solutions or report that there are no solutions in integers.

Input
Enter three numbers a, b and c separated by spaces.

Imprint
The program should display all solutions of the equation in ascending order, or NO SOLUTION (in capital letters) if there are no solutions. If there are infinitely many solutions, output MANY SOLUTIONS. 

Examples
# Input Output
1 1 0 0 0
2 1 2 -3 NO SOLUTION

ID 38199. Endless table
Темы: Whole numbers    Conditional operator   

The natural numbers are written in an (infinite) table, as shown.


It is required to display all its neighbors for a given number (the numbers written in the cells above, on the right, on the left and below, if any)

Input
One natural number not exceeding 109.

Imprint
The program should display all the numbers written in adjacent cells with the data, in ascending order. Numbers must be separated by a space.

Examples
# Input Output
1 1 3
2 7 3 6 8 13

ID 38205. Cards
Темы: Conditional operator   

Vasya laid out 100 cards in a row from left to right, on which the numbers 1, 2, 3, …, 100 are written, respectively (numbers down). After that, he swapped the cards on which the numbers i and j are written. Petya opens the cards in turn from left to right. What is the minimum number of cards he will have to open in order to find out exactly which cards Vasya swapped?

Input
Two numbers i (1 ≤ i ≤ 100) and j (1 ≤ j ≤ 100) are entered. Numbers are written with a space.

Imprint
It is required to display one number – the minimum number of cards Petya needs to open.
 
Examples

# Input Output
1 10 20 10

ID 38208. Apartments
Темы: Conditional operator   

The house has several entrances. Each block has the same number of apartments. Apartments are numbered consecutively, starting from one. Can the first apartment in some entrance have the number x, and the last – number y?

Input
Enter two natural numbers x and y (x ≤ y) not exceeding 10,000.

Imprint
Print the word YES (in capital Latin letters) if it is possible, and NO otherwise.

Examples

# Input Output
1 11 15 YES
2 2 10 NO

ID 38207. Number
Темы: for loop    Conditional operator    Strings   

Enter a natural number. It is required to separate the triples of its digits with commas (counting from the right).

Input
One natural number is entered, not exceeding 10100.

Imprint
Output the same number, separating triples of digits with commas.

Examples

# Input Output
1 1000 1,000
2 12345678 12,345,678
3 999 999

ID 38209. Horse
Темы: Conditional operator   

On a board of size KxN cells (K rows, N columns), there is a chess knight in the j-th row and i-th column. Can he get into the cell in the m-th row and s-th column in one or more moves?

Input
6 natural numbers are entered: K, N, j, i, m, s (1 ≤ K ≤ N ≤ 100). Cells (i, j) and (s, m) do not match.

Imprint
Print the word YES if it is possible, and NO otherwise.

Examples

# Input Output
1 8 8 1 2 7 8 YES

ID 38210. alarm clocks
Темы: Conditional operator    One-Dimensional Arrays    date and time    Bust   

The alarm clock on a cell phone can be set to ring at the same time every day, or at a specified time on a specific day of the week. Multiple alarms can be set independently.

Use the information about alarms and the current time and day of the week to determine when the next alarm will sound.

Input
The first line contains three numbers that specify the current time: the day of the week (from 1 to 7), hours and minutes.

The second line contains one natural number N, not exceeding 100 – number of alarms.

The next N lines contain descriptions of N alarm clocks. The description of each alarm consists of three numbers: day of the week (a number from 1 to 7 for Monday,  …, Sunday, respectively, 0 – if the alarm should ring every day), hours (from 0 to 23), minutes (from 0 to 59).


Imprint
Print  separated by a space, three numbers specifying the day of the week, hours and minutes when the next alarm clock rings.
 

Examples
# Input Output Explanation
1 2 10 20
2
1 23 15
0 10 10
3 10 10  
2 7 1 1
3
7059
7 23 59
7 1 1
7 1 1 In the second example, the third alarm will ring at the start time.

ID 38211. Tournament
Темы: Conditional operator   

N teams participated in a one-round tournament without draws (each played one match with each). The winners are all teams that have won at least games than the rest. What is the maximum number of winners in such a tournament?

Input
One natural number is entered, not exceeding 1000 – number of commands.

Imprint
Print one number – the largest possible number of winners in such a tournament.

Examples
# Input Output
1 2 1

ID 38212. Sum of digits
Темы: Conditional operator   

Count the number of natural numbers on the segment from a to b, the sum of whose digits is even.

Input
Enter two natural numbers a and b, not exceeding a billion (a ≤ b).
Imprint
Print one number – the number of numbers greater than or equal to a and less than or equal to b that have an even sum of digits.

Examples
# Input Output
1 1 5 2
2 10 10 0

ID 38213. Tennis
Темы: Conditional operator   

Vasya, Petya and Kolya played tennis right through (the loser skipped the next game, giving up his place to the third). Vasya claims to have played x games, Petya – that played y parties, Kolya – z games.

Determine if it could be.

Input
Enter three non-negative integers x, y, z not exceeding 1000.

Imprint
Print YES (in capital letters) if it could be, and NO otherwise.

Examples
# Input Output
1 3 1 2 YES
2 1 1 1 NO

ID 38214. Difficult task from the exam
Темы: Conditional operator   

Petya has been preparing for the exam in computer science for a long time. He learned to solve all the problems, and he failed to learn how to solve only problem A12. But he hopes to smuggle a laptop into the exam, and he asks you to write a program that will help him. Here's what this difficult task looks like in the 2010 USE demo version:
"A12. Vitya invited his friend Sergei to visit, but did not tell him the code for the digital lock of his entrance, but sent the following 5M5 message:
"In the sequence of numbers 3182, divide all numbers greater than 5 by 2 (discarding the remainder if necessary), and then remove all even numbers from the resulting sequence."
What code did Sergey get by following the steps in the message?"

Input
4 digits are entered in one line without spaces – the sequence contained in the SMS message in the real version of the exam instead of 3182 in the demo version.

Imprint
Print the digital lock code without spaces.

Examples
# Input Output
1 0586 53

ID 38221. ski jumping
Темы: One-Dimensional Arrays    Conditional operator   

In ski jumping competitions, jumping technique is judged by five judges. Each judge gives a score from 1 to 20, after which one lowest and one highest score is discarded. You need to write a program that will display the results of the jump for a TV broadcast.

It should display the five scores given by the judges without changing their order, and then their sum, and at the same time take into brackets those marks that are not taken into account when calculating the sum

Input
The input is 5 natural numbers from 1 to 20, separated by a space.

Imprint
Print the same numbers in the same order, putting in brackets the minimum (and if there are several – the leftmost of them) and the maximum (and if there are several – the rightmost of them) number, as well as the sum of all numbers not taken in brackets. All numbers (including the sum) must be printed on one line and separated by one space (there must be no spaces inside the brackets). The amount must be preceded by an equals sign, separated on the left and right by a single space. The order of the scores must be the same as in the input.

Examples
# Input Output
1 1 2 3 4 5 (1) 2 3 4 (5) = 9
2 10 11 10 11 10 (10) 11 10 (11) 10 = 31

ID 38243. simple game
Темы: Conditional operator   

How difficult it is to be a schoolboy! It is these thoughts that most often visit Petya after mathematics lessons. Today the teacher told me what prime numbers are. Petya heard about them for the first time. It turns out that the prime number — This is a natural number that has exactly two different natural divisors, that is, it is divisible without remainder only by one and by itself. After the lesson, Petya and his friend Seryozha came up with the following game: one calls two numbers A and B, and the other says how many zeros are at the end of the product of all primes between A and B inclusive. Petya noticed that Seryozha answers the question much faster than he does, and asks you to help him. Write a program for Petya that will answer Serezha's questions.

Input
The input is two numbers A, B (1 ≤ A ≤ B ≤ 109), separated by a space. It is guaranteed that there is at least one prime number between A and B.

Imprint
Print the number of zeros that ends the product of all prime numbers on the interval from A to B.

Examples
# Input Output
1 1 7 1
2 3 3 0

ID 38249. Glory and trains
Темы: for loop    Conditional operator   

Slava has a lot of friends, and he really likes to meet with them. But, unfortunately, all of Slava's friends live in different cities (each in his own), to which Slava from his Big City can only get by train. Every time Slava decides to visit one of his friends, he faces a difficult choice — who exactly to go to this time. Slava loves all her friends very much and does not want to offend anyone. Therefore, he acts as follows: at some point in time, Slava leaves the house and goes to the station. After arriving at the station, Slava boards the nearest train, which goes to one of his friends. According to the known time of Slava's arrival at the station, help him find out which friend he will go to today.

Input
The first line of the input contains numbers M (1 ≤ M ≤ 105) — the number of electric trains that depart from the station, and the time T at which Slava arrives at the station (0 ≤ T ≤ 109). M lines follow, each containing two integers ti (0 ≤ ti ≤ 109, all ti are distinct) and fi (1 ≤ fi ≤ 109), where ti — the departure time of the i-th train (all ti are different), and fi corresponds to the number of the friend the i-th train goes to. It is guaranteed that there is at least one electric train that leaves later than time T.

Imprint
Print one number — the number of the friend that Slava will visit today.

Examples
# Input Output Explanation
1 5 74
28 3
85 2
6 1
5 3
72 1
2 It is believed that Slava catches the i-th train only if he arrives before the moment of its departure, i.e. T < ti.

ID 38251. Metro
Темы: One-Dimensional Arrays    Conditional operator   

Vanya does not really like people, but, unfortunately, he sometimes still has to take the subway. In such cases, two things help him: headphones with his favorite "Scoprions"; and the right place. Since Vanya wants to be as far away from all people as possible, the right place is considered to be the place from which the distance from the nearest neighbor will be the maximum possible in the car. There are N seats in the car, and they are all located along one wall, and the entrance to the car is at seat number 1. The seats go in a row, without gaps. Vanya understands that sometimes there can be several correct seats, and wants to sit in the correct seat closest to the entrance (that is, the correct seat with the minimum number).

Guess what place Vanya will take in the car.

Input
The first line contains the number N (1 ≤ N ≤ 105). The next line contains N numbers separated by spaces — 0 or 1. The number 0 indicates free space, 1 — busy; places are numbered from left to right. It is guaranteed that at least one place is free.

Imprint
Print the number of the seat where Vanya will sit.

Examples
# Input Output
1 8
1 0 1 0 0 1 0 1
2
2 7
0 1 0 0 0 1 0
4
3 4
0 0 0 1
1

ID 38254. Cork
Темы: One-Dimensional Arrays    Conditional operator   

One summer day, Arkady and his parents went on a road trip. He really hoped that outside the city they would be able to avoid the hated traffic jams. But, alas, after an hour they got into a traffic jam. Arkady felt sad and thought about how fast they could go if there were no traffic jams ... The section of the road they are on now, — single-lane. And this means that it is not possible to overtake the cars in front. That is, no matter how powerful the car is, it still cannot go faster than the car in front of it. Arkady is well versed in cars and therefore knows the maximum speeds of those cars that are ahead. Now he wants to figure out what the maximum speed each car could be in this area would be.

Input
The first line contains the number N (1 ≤ N ≤ 200) — the number of cars in traffic. The next N lines contain one integer each, and the i-th line contains the speed of the i-th car. The speed of each of the cars does not exceed 300. It is assumed that the (i + 1)-th car goes behind the i-th car, and the first car can go at its maximum speed.

Imprint
Print N numbers — the speed of cars with which they could drive on this section.

Examples
# Input Output
1 2
80
100
80 80

ID 38256. Domino Chess
Темы: Conditional operator   

Vasya is very fond of various games: checkers, chess, dominoes, tic-tac-toe, etc. Since he has been playing them for quite a long time, he managed to learn these games quite well, and they became boring. Therefore, he now invents new games based on those he has already played enough. He recently invented the game Domino Chess.

It consists of the following: Vasya takes a large piece of plywood from his grandfather and paints it in such a way that he gets a chessboard of size N × M cells. Then he takes domino bones and tries to cover the resulting board with them so that all the cells are closed, there are no overlaps and no dominoes stick out over the edges of the board (each domino covers two adjacent cells).

Since Vasya does not ask grandfather's permission before taking a board, he sometimes takes boards that are not needed, and sometimes those that grandfather wanted to use in the construction of a new dacha. Just today, Vasya took the "necessary" board, so grandfather was forced to cut two squares of one cell from Vasya's board.

At first, Vasya was upset that he would not be able to play his game. And then I decided to try to pave the board with the cells already cut out, and in such a way that the cut cells were not covered with dominoes.

Help Vasya understand if this can be done.

Input
The first line of the input contains numbers N and M — board dimensions (1 ≤ N ≤ 200, 1 ≤ M ≤ 200, N·M > 2).

The second line contains two space-separated integers — x1 and y1 coordinates of the first cut cell (1 ≤ x1 ≤ N, 1 ≤ y1 ≤ M).

The third line contains two space-separated integers — x2 and y2 coordinates of the second cut cell (1 ≤ x2 ≤ N, 1 ≤ y2 ≤ M).

The first and second cells do not match.

Imprint
Print "YES" if the board with cut out cells can be covered with dominoes, and "NO" otherwise. (Vasya's supply of dominoes is endless.)
 

Examples
# Input Output
1 2 2
1 1
2 2
NO
2 2 2
1 1
1 2
YES

ID 38260. paver
Темы: Real numbers    Conditional operator   

The holidays began, and Maxim came to visit his grandparents, but not at all to the village, as you probably thought. Maxim's grandparents live in a very cultured city with legendary bad weather — it often rains here.

And now, as soon as Maxim left the station building, a downpour began. The umbrella, according to all the laws of meanness, lies at the bottom of his suitcase, and he does not want to climb after it at all. Yes, and here — There is a bus stop very close, under which you can hide from the rain. You just need to cross the street, and that's it! "It's not all that simple," — came to Maxim's mind. And indeed — does not happen.

The fact is that on the street that separates Maxim from the stop, the asphalt is being changed. The old layer of asphalt has already been removed (there are now pits, so it’s impossible to pass there), and now an asphalt paver is courageously crawling along the street, approaching Maxim, at a speed of v2 m / min, leaving behind a new, neatly laid asphalt. True, before the new asphalt can be walked on, it must cool down for T minutes. The paver has just started work, so all the asphalt behind it was poured yesterday and has already cooled down.

Of course, Maxim does not want to get wet, so he tries to get to the other side of the street as quickly as possible. He runs at a speed of v1 m/min. He also knows the width of the street — L m. Maxim can walk along the street along the sidewalk as much as he wants. He wants to be on the road as little as possible, so he only crosses the street perpendicularly.

Input
Given integers L, D, T, v1, v2 — street width, distance to the paver, time that the asphalt cools down (in minutes), Maxim's speed and the speed of the paver. (1 ≤ L ≤ 100, 1 ≤ D ≤ 100, 1 ≤ T ≤ 100, 1&thinsp ;≤ v1 ≤ 100, 1 ≤ v2 ≤ 100).

Imprint
Print one number — the time in minutes it takes Maxim to get to the other side of the street.

Examples
# Input Output
1 4 9 3 2 1 6.0
2 1 1 1 3 1 0.666666666667

ID 38262. waterfalls
Темы: One-Dimensional Arrays    Conditional operator   

Recently, Uncle Fyodor read in the Murzilka magazine that the highest waterfall in the world — This is the Angel Falls, whose height is 1054 meters. “It would be great to see such a waterfall!”, — he dreamed.

But Venezuela is far away, so for now Uncle Fyodor decided to start by exploring the Smetanka River, which flows next to Prostokvashino. It starts in the hills and gradually descends towards the village. Uncle Fyodor, together with Sharik, walked along the entire course of Smetanka from its source. Sometimes along the way they met waterfalls. As Uncle Fyodor learned from that article in Murzilka, a section of a river with a constant slope angle exceeding 45 degrees, that is, a section whose height is greater than its length, is considered a waterfall.

Already after the trip, over and over again redrawing the map of Smetanka on paper, Uncle Fyodor noticed that if you draw a side view of Smetanka (that is, the higher the point — is drawn, the higher it is above sea level, and the more to the right — the farther it is from the source and closer to Prostokvashino), then we get a non-increasing broken line, which is very easy to analyze. Each segment of this broken line — this is just a section of the river with a constant angle of inclination, which may turn out to be a waterfall!

After spending several evenings studying the Smetanka map, Uncle Fyodor remembered that in addition to waterfalls, there are also cascades of waterfalls. A waterfall cascade is one or more successive waterfalls. Cascade height — is the difference between the heights of the highest and lowest points belonging to this cascade.

Now Uncle Fedor was wondering, what is the height of the highest cascade of waterfalls on Smetanka? Help him: according to the description of the river made by Sharik and Uncle Fyodor, find this number.

Input
The first line contains the number n (2<=n<=105 ) — the number of vertices of the broken line describing the Smetanka river. The next n lines contain the coordinates of these points, the i-th line contains numbers xi and yi — horizontal distance from the point to the source and the height of the point above sea level (0xi<=109, yi<=10< sup>9 ). The points are listed starting from the source of the river, that is, starting from a point whose x-coordinate is zero and whose y-coordinate is — maximum among all points. It is guaranteed that the river flows from top to bottom and from left to right, that is, each next point is neither higher nor to the left of the previous one.

Imprint
Print one integer: the height of the highest cascade of waterfalls on this river. If the river doesn't actually have waterfalls, print 0.

Examples
# Input Output
1 3
0 15
1 10
5 5
10

ID 38265. Renumber
Темы: for loop    Conditional operator   

In the village of Prostokvashino, part of the houses stopped using paper mail services, switching to electronic mail. In total, there are N houses in the village, of which M have not yet switched to using only e-mail. The postman Pechkin decided to renumber the houses that still use paper mail so that they have numbers from 1 to M. At the same time, Pechkin does not care that houses with neighboring numbers will not stand next to each other. Since the postman does not really want to remember the new numbers for all the houses to which he still carries letters and telegrams, he wants to renumber only some of them. What is the minimum number of houses that would need to be renumbered to be in order

Input
The first line contains two numbers N and M (1<=M<=N<=1000) – the number of houses in Prostokvashino and the number of those houses that still use the services of the postman Pechkin, respectively. The second line contains M numbers ai , (1<=ai<=N) in ascending order – house numbers that still use paper mail.

Imprint
In response, print one number – the minimum number of houses to be renumbered.

Examples
# Input Output Explanations
1 8 5
1 2 4 5 8
1 In the example above, the house that had the number 8 should be given the number 3. Then the 5 houses that still use paper mail will just have numbers from 1 to 5.

ID 38266. counting crows
Темы: Conditional operator    for loop   

In the attic of a house in Prostokvashino, Sharik found a strange device. Uncle Fyodor quickly realized that it was — a manual mechanical counter, and according to his favorite encyclopedia, it is "a manual mechanism for counting repeated events by pressing a button on the counter, so as not to use pen and paper to write them down or not to keep these numbers in mind."

Inside, such a counter is arranged as follows: it has three disks with numbers from 0 to 9 inscribed on the edge. The disks are put on the axis to which the button is connected. Initially, the number 0 is written on each of the three disks. When the button is pressed, one or more disks are rotated so that the number currently recorded on the counter increases by 1. Each disk, when the button is pressed, rotates only one number forward. If several discs are rotated at the same time, the discs corresponding to the lower digits of the number are rotated first, and then — older.

For example, let's say the number 18 is written on the counter now. This means that the number 0 is set on the first disk, on the second — 1, on the third — 8. The next number after 18 — 19, so when the button is pressed, the third disk will rotate one number so that it is set to the number 9, and the rest will remain stationary. Now the counter will read 19. After pressing it again, the counter should show the number 20. This means that the third disk must be rotated by one number so that the number 0 is set on it, and that the second disk must also be rotated in order to 2 was installed on it.

In order to try his find in action, Sharik did not come up with anything better than to count the crows flying past the window. Since the counter that Ball found is very old, each of the dials will click when it is turned. Uncle Fyodor, who was sitting nearby, counted all the clicks that he heard. Now he wants to understand how many crows flew past their window, i.e. what number is written on the counter.

Input
One integer n is entered: how many clicks Uncle Fyodor counted (0<=n<=1107).

Imprint
Print one integer: the number of crows flying past the window. If Uncle Fyodor made a mistake and such a number of clicks couldn't have been made, print −1.

Examples
# Input Output
1 9 9
2 10 -1

ID 38269. Dad, I'm a physicist!
Темы: Conditional operator   

Theory of Relativity — thing is complicated. This is Maxim, the seven-year-old son of a famous physicist, he has known for a long time. From his father's explanations, Maxim realized that the light — it's the fastest thing in the world. And if it seems that something is still faster than light, then in fact it is moving at a speed equal to the speed of light — 299 792 458 m/s.

So on the way to the sea, running away on the Moscow-Adler train from something very dissatisfied with dad, Maxim did not think at all about what exactly he would receive now and whether it could have been somehow prevented. He was worried about one thing: how fast is his dad running relative to the Earth, given the theory of relativity? The train travels from Moscow to Adler at a speed of v m/s, and dad runs after Maxim towards the head of the train at a speed of u m/s relative to the train.

Input
Given two numbers v and u — the speed of the train relative to the Earth and the speed of Pope Maxim relative to the train, respectively. Both speeds are non-negative and do not exceed the speed of light (299 792 458 m/s).

Imprint
Print one number — the speed of Pope Maxim relative to the Earth, found taking into account Maxim's ideas about the theory of relativity.

Examples
# Input Output
1 120 35 155
2 149896229 149896230 299792458

ID 38270. Kindergarten
Темы: Conditional operator    Cycles   

In the younger group of the kindergarten "Teletubbies" there are n children in total. Each of them, like any four-year-old, can easily start crying simply because his classmates also cry. So what if he doesn't know what's wrong? Comrades can't be wrong.

The teacher has been working in the kindergarten for many years, and is well versed in the children's mood. It is enough for her to look at the child to understand how tearful he is today: will he cry himself today because the compote is tasteless, will he burst into tears because Katya and Vanya are already crying, but he is not yet, or will he play with cubes with concentration, not paying attention to the tears and snot of comrades.

Knowing today's tearfulness of each of the children, determine whether today the whole group will sob at the same time, or will do without a mass hysteria.

Input
The first line contains an integer n (1n1000) — the number of children in the group. The next line contains n numbers separated by a space, and the i-th number qi (0qin−1  ) denotes the crying of the i-th child. The number qi indicates the number of children that must cry for this child to cry too. If qi = 0, then this child will definitely cry today just like that, regardless of his comrades. It is believed that a child cannot start crying if the right number of children do not cry around him. If a child starts crying, he will not calm down until the evening.

Imprint
Print "YES" if the whole group will cry at the same time, or "NO" otherwise.

Examples
# Input Output
1 4
1 0 1 2
YES
2 3
1 1 1
NO

ID 38276. Jackets
Темы: Conditional operator    for loop   

Charitable organizations each year raise money for warm clothing for the poor. The protagonist of this task has two jackets, but this does not stop him from suffering. One of his jackets — winter, and the second — demi-season (it's nice to walk in it in autumn or spring). Jackets are matched perfectly: in a winter jacket it is comfortable at a temperature of x degrees or lower, and in a demi-season – at temperatures above x degrees. In general, he would live and be happy. But where would the task come from then?

The problem of our hero is that, putting on the wrong jacket today, which he wore yesterday, he constantly forgets to shift the travel card, keys and other useful things into the pocket of a new jacket. After a little thought, he decided that the jacket, not quite suitable for today's temperature, — it's not as bad as forgotten things. Therefore, if today is slightly warmer than the boundary temperature, he will still go in a winter jacket, similarly for a demi-season one. A little more formally, it sounds like this: he changes his jacket from winter to demi-season only if today there are at least x + d   degrees outside the window, and from demi-season to winter — if outside the window x − d   degrees or colder. Sometimes, of course, he is not very comfortable on the street, but all things are definitely with him.

Based on the weather forecast archive for the last n days, determine how many days the protagonist of this problem was uncomfortable. It is believed that on the first day he went out in the jacket that is comfortable for that day.

Input
The first line contains two real numbers x and d — temperature boundary between jackets and temperature deviation, which the hero of the task considers insignificant (−89≤x≤55, 1≤d≤6 ).

The second line contains an integer n, 1≤n≤105 — number of days in the weather archive.

The third line contains n real numbers ti — temperature on the i-th day (−89≤ti≤55 ).

Imprint
Print a single number: the number of days when the hero of the problem felt uncomfortable in the jacket he wore on that day
 

Examples
# Input Output
1 5 1
7
6 7 4 4 2 3 7
0
2 0 2
4
-1 1 -1 1
2

ID 38278. Alyona, remember Viti's age!
Темы: Whole numbers    Conditional operator   

Victor is madly in love with statistics. Still — their birthdays fall on the same day of the year with their older brother! Now every year on his birthday, he writes down how old he and his brother are, and tries to find something interesting in these records.

Today is Viti's birthday, and he showed his notes to Alena. Vitya knows that she also likes to explore all sorts of sets of numbers and find patterns in them. Alena immediately noticed an interesting moment: when Vitya was n years old on one of his previous birthdays, his brother was m years old, and today Vitya is exactly k times younger than his brother!

Returning home in the evening, Alena became interested in the question: is this data enough to calculate how old Vitya turned today? Alena quickly coped, but can you solve this difficult task and find out by the numbers n, m and k, how old is Vita?

Input
The input consists of three lines, each containing one natural number: n , m and k — the age of Vitya and his brother in the old days, as well as how many times Vitya is younger than his brother today ( 1 ≤ n < m ≤ 10 000 , 2 ≤ k ≤ 10 000 ).

Imprint
If the situation described in the condition could happen, print a single number t — how old is Vita today.

If Vitya and Alena made a mistake and the described situation could not have happened, print the number - 1 .
 

# Input Output
1 4
15
2
11
2 4
15
3
-1
3 4
8
2
-1

ID 38288. Cutting the cake
Темы: Conditional operator   

Today is Krosh's birthday! On this occasion, he baked a huge cake. The cake is a rectangle n × m , divided into nm unit squares by horizontal and vertical cream lines.

Sovunya and Nyusha came to visit Krosh for the holiday. According to the laws of hospitality, Krosh must share his cake with him. To do this, he wants to cut two pieces of the cake in turn and distribute them to the guests.

Krosh can cut a piece of cake like this: divide the cake into two rectangles with one cut passing along one of the horizontal or vertical lines (thus, after the cut, both rectangles have integer side lengths). Next, Krosh chooses one of these rectangles and gives it to the next guest.

After Krosh cuts a piece from his cake twice, he eats the rest himself. Today the cake turned out to be very tasty, and therefore Krosh wants him to get a piece of the largest possible area. Help him determine the maximum area of ​​the cake he can keep.

Input
The first line of the input contains a single integer n ( 1 ≤ n ≤ 4·104 ) — cake length. The second line of the input contains a single integer m ( 1 ≤ m ≤ 4·104 ) — cake width.

It is guaranteed that two pieces can be cut off from the Krosh cake, leaving a rectangle of non-zero area.

Imprint
Print one number — the maximum area of ​​a piece of cake that Krosh can keep.

Examples
# Input Output
1 4
3
6


Note
Illustration for the test from the example: Krosh makes cuts along the dotted lines, giving the guests pieces with gray borders. At the end, he gets a piece of size 2 × 3 .

 

ID 38305. Buses
Темы: Whole numbers    Conditional operator   

The organizers decided to order buses to visit the health camp. It is known that N children and M adults are going to the camp. Each bus can carry K people. There must be at least two adults on each bus that children travel on.

Determine whether it will be possible to send all children and adults to the camp, and if so, what is the minimum number of buses required to order.

Input
The input of the program is 3 natural numbers written with a space - N, M and K, each of them does not exceed 10 000.

Imprint
Print the number of buses to order. If it's impossible to send everyone to the camp, print 0 (zero).
 

Examples
# Input Output
1 10 4 7 2
2 10 4 5 0

ID 38306. benches
Темы: One-Dimensional Arrays    Conditional operator   

The benches in the park are arranged as follows. Several identical cubic granite blocks are placed in a row, and a granite slab is placed on them (see figure). The modernist architect decided that it would be more interesting if all the shops had different (and not necessarily symmetrical) arrangements of granite foot blocks. At the same time, they are arranged so that the slab does not fall: for this it is enough that there is at least one granite block or part of it both to the left and to the right of the center of the slab (in particular, if the center of the slab falls in the middle of a block, then to the left and to the right of the center of the slab is part of the block, and the slab does not fall).

The thieves discovered that they could pull out the granite blocks one at a time, located on the edge (both on the left and on the right). They want to pull out as many blocks as possible from under the bench without it falling down (you can't move the remaining blocks). Determine which blocks they should leave.


Input
The first line of the input contains two numbers: L - the length of the bench and K - the number of granite blocks-legs. Both numbers are natural and do not exceed 10,000.

The second line is followed by K different non-negative integers, specifying the position of each leg. The leg position is determined by the distance from the left edge of the slab to the left edge of the leg (the leg is a 1x1x1 cube). The legs are listed from left to right (that is, starting with the leg with the smallest distance to the left edge).

Imprint
It is required to list the legs that the robbers need to leave. For each leg, you need to give out its position, as it is specified in the input data. The legs should be listed from left to right, in the order in which  they appear in the input.
 

Examples
# Input Output
1 5 2
0 2
2
2 13 4
1 4 8 11
4 8
3 14 6
1 6 8 11 12 13
6 8

ID 38307. Elections
Темы: Symbols    Conditional operator    Whole numbers   

In the elections to the State Duma, N parties were included in the ballots. An electronic scanner for reading information from ballots transmits information about each ballot in the following format: if there is a mark in the corresponding box of the ballot, then the scanner transmits + (plus), otherwise it transmits - (minus). Thus, it sends a sequence of N characters - pluses and minuses.

The ballot is considered valid if the mark is in exactly one cell. Invalid ballots are not included in the calculation of election results.

A party enters the State Duma only if it receives at least 7% of the total number of valid ballots.

It is required to display the numbers (in the order they are listed in the ballot) of all parties that are going to the State Duma.

Input
The first line of the input contains two numbers separated by a space: N - the number of parties and M - the number of ballots. Both numbers are natural, N ≤ 200, M≤ 100 000.

The next M lines contain the information obtained from the ballots. Each line is a sequence of N characters + or - (no spaces).

It is guaranteed that there is at least one valid ballot.

Imprint
Output the numbers of the parties that entered the Duma, separated by a space, in ascending order. If none of the parties makes it to the Duma,  nothing needs to be displayed.
 

Examples
# Input Output
1 3 4
+--
+--
-+-
+-+
1 2
2 1 5
+
-
-
-
-
1

ID 38314. Internet payment
Темы: Whole numbers    Conditional operator   

Vitya is connected to the Internet according to the following tariff plan. The monthly subscription fee is A rubles, and this subscription fee includes B megabytes of traffic. Unused megabytes "burn out" at the end of the month. If the traffic exceeds B megabytes, then each megabyte of traffic in excess of prepaid costs C rubles.

It is known that last month Vitya spent D megabytes of traffic. How much did Internet access cost him last month (including the monthly fee)?

Input
Four natural numbers A, B, C, D are entered. All numbers do not exceed 100.

Imprint
Print one number — the amount (in rubles) that Vitya has to pay for the Internet.

Examples
# Input Output
1 100 10 12 15 160
2 100 10 12 1 100

ID 38316. Calculator
Темы: Conditional operator   

The new OpenCalculator program has a new feature – you can customize which buttons are shown and which – No. If the button is not displayed on the screen, then you cannot enter the corresponding number from the keyboard or by copying from another program. Petya set up the calculator in such a way that it only displays buttons with numbers x, y, z. Write a program that determines whether Petya can enter the number N, and if not, what is the minimum number of buttons that must be additionally displayed on the screen to enter it.

Input
First, three different numbers from 0 to 9 are entered: x, y, and z (the numbers are separated by spaces). Next, enter a non-negative integer N, which Petya wants to enter into the calculator. The number N does not exceed 10000.

Imprint
Print the minimum number of buttons that must be added so that the number N can be entered (if the number can be entered using existing buttons, print 0)
 

Examples
# Input Output Explanation
1 1 2 3
1123
0 The number can be entered using the available buttons.
2 1 2 3
1001
1 Need to add button 0.
3 5 7 3
123
2 We need to add buttons 1 and 2.

ID 38321. Placement of laptops
Темы: Simulation tasks    Conditional operator   

The school decided to put two rectangular laptops on one rectangular table. Laptops should be placed so that their sides are parallel to the sides of the table. Determine what dimensions the table should have so that both laptops fit on it and the table area is minimal.

Input
Four natural numbers are entered, the first two specify the dimensions of one laptop, and the next two — the dimensions of the second. Numbers do not exceed 1000.

Imprint
Print two numbers — table dimensions. If multiple answers are possible, print any of them (but only one).

Note
The examples show all kinds of answers to the given problem. Your program should output one of them.

Examples
# Input Output
1 10 2 2 10 20 2
2 20
4 10
104
2 5 7 3 2 9 5
5 9

ID 38329. Comparisons
Темы: Conditional operator   

About three numbers (denoted a, b, c) all the results of comparing them with each other are known. It is required to arrange these numbers in ascending order.

Input
Three lines are entered. The first contains the result of comparing the numbers a and b with each other in the following format. The first character — always a, the third character — b (corresponding to small Latin letters), and between them is written one of the characters >, < or =. The second line contains the result of comparing a and c in the same format (the first character is always a, the third — c), and the third line — the result of comparing b and c (the first character is always b, the third — c). It is guaranteed that the input data is not inconsistent.

Imprint
Print the characters a, b, c in the order of their corresponding numbers — each next number must be greater than or equal to the previous one. If two numbers are equal, the corresponding variables can be output in any order. Characters must be displayed in one line without spaces or other separators.

Note
In the second example, cba's answer is also correct. Please note that if there are several answers — you don't need to print them all, your program should print exactly one answer.
 

Examples
# Input Output
1 a>b
a>c
b>c
cba
2 a=b
a>c
b>c
cab
cba

ID 38341. Check if the situation is correct
Темы: Conditional operator   

Write a program that, according to the image of the field for playing Tic-Tac-Toe will determine whether such a situation could have arisen as a result of playing with all the rules.

Recall that the game of "Tic-tac-toe" is conducted on the field 3×3. The two players take turns. The first puts a cross, and the second – zero. Putting a cross and a zero is allowed in any cell of the field that has not yet been occupied. When one of the players puts three of his signs in one horizontal, vertical or diagonal line, or when all the cells of the field are occupied, the game ends.

Input
Enter three lines of three numbers each, describing the playing field. The number 0 denotes an empty cell, 1 – cross, 2 – zero. Numbers in a string are separated by spaces.

Imprint
It is required to output the word YES if the indicated situation could have occurred during the game, and NO otherwise.

Examples
# Input Output
1 1 1 1
1 1 1
1 1 1
NO
2 2 1 1
1 1 2
2 2 1
YES
3 1 1 1
2 0 2
0 0 0
YES
4 0 0 0
0 1 0
0 0 0
YES
5 1 1 1
2 2 2
0 0 0
NO

ID 38378. Chunga-Changa
Темы: Conditional operator    Whole numbers   

Our happiness is constant — Chew coconuts, eat bananas, Chew coconuts, eat bananas, Chunga-changa!
m/f «Katerok»
After the discovery of the island "Chunga-Changa" civilization gradually began to make its way there and even a market economy began to develop. There is also a new currency — chizhik. Now, in order to happily chew coconuts, you must first buy them under a palm tree.

Sasha and Masha passed by a palm tree, under which coconuts are sold at the price of z chizhiks apiece. Sasha has x siskins, and Masha has y. Each of the girls is going to buy the maximum number of coconuts she has enough money to buy. While discussing their plans to buy coconuts, the girls noticed that if one of them gave a certain number of siskins to another, then the total number of coconuts they would buy could increase (or decrease) because of this. Coconuts are not sold in parts, that is, each of the girls can only buy a non-negative integer number of coconuts. Chizhiks also cannot be divided into parts, that is, one of the girls can only send a non-negative integer number of chizhiks to the other.

For example, suppose that Sasha had 5 chizhiks, Masha 4, and one coconut costs 3 siskins. Then, if the girls do not exchange siskins, they will buy 1+1=2 coconuts. If Masha gives Sasha one chizhik, then Sasha will have 6 of them, and Masha will have 3, and the girls will buy 2+1=3 coconuts.

Life on the island is no longer so easy and simple, so Sasha and Masha want to distribute the money so that in total they can buy as many coconuts as possible. At the same time, no one likes to lend chizhiks, so among all the ways that lead to the maximum number of purchased coconuts, find the one that minimizes the number of chizhiks transferred between Sasha and Masha (no matter in which direction).

Input
The first line contains three integers x, y and z (0 ≤ x, y ≤ 1018 , 1 ≤ z ≤ 1018) — the number of chizhiks Sasha has, the number of chizhiks Masha has and the price of one coconut.

Imprint
Print two integers — the maximum total number of coconuts that can be bought, and the minimum number of siskins that one of the girls will have to share for this.
Note
The first example is analyzed in the problem statement. In the second example, it is optimal not to exchange siskins, in this case 3+4=7 coconuts will be bought.

Examples
# Input Output
1 5 4 3 3 1
2 6 8 2 7 0

ID 38462. Cake sets
Темы: Conditional operator   

In the warehouse of the confectionery factory, two types of cakes are stored - croissants and eclairs. Croissants are A pieces and eclairs are B pieces. There is an unlimited supply of gift boxes, each box can only contain three cakes. This requires that the box contains both types of cakes, that is, one box can contain two croissants and one eclair or one croissant and two eclairs.
Determine if it is possible to pack all available cakes into boxes and output a suitable way for placing cakes in boxes.


Input
The program receives as input two integers A and B written on separate lines. 1 <= A <= 109, 1 <= B <= 109.

Imprint
If it is possible to arrange all the cakes into boxes in accordance with the condition of the problem, the program should output two integers. The first number is equal to the number of boxes that contain two croissants and one eclair. The second number is equal to the number of boxes that contain one croissant and two eclairs. 
If it is impossible to put all the cakes into boxes in the right way, the program should output a single number -1.
 

Examples
# Input Output
1 4
5
1 2
2 5
3
-1

ID 38480. Iroha loves haiku
Темы: Conditional operator   

Iroha loves Haiku. Haiku is genre < /a>traditional Japanese lyrical poetry waka, known since 14th century. A haiku consists of three phrases with 5, 7 and 5 syllables, in that order ( 5-7-5 scheme). code>). To create Haiku, Iroha came up with three different phrases. These phrases have a, b and с syllables, respectively. Determine if Iroha can build a Haiku by using each of the phrases once in a certain order. 


Input
The input is three natural numbers a, b and с (\(1 < ;= a, b, c <= 10\)) .

Imprint
If it is possible to construct a Haiku using each of the phrases once, print YES  (case sensitive). Otherwise, print NO.
 

 

Examples
# Input Output
1 5 5 7 YES
2 5 7 7 NO

ID 38486. Hotel fee
Темы: Conditional operator   

Some hotel has set the following room rate:

  • X rubles per night, for the first K nights;
  • Y rubles per night, for (K+1)-th and subsequent nights.

Gromozek decided to stay at this hotel for N consecutive nights. Calculate the total cost of staying Gromozeka at this hotel.



Input
The input is 4 positive integers: NKX (\(1<=N,K<=10000\)\(1<=Y<X< =10000\)). One number per line.

Imprint
Display the total cost of accommodation in this hotel.
 

 

Examples
# Input Output Explanation
1 5
3
10000
9000
48000 Accommodation cost:

10000 rub. for the 1st night;
10000 rub. for the 2nd night;
10000 rub. for the 3rd night;
9000 rub. for the 4th night;;
9000 rub. for the 5th night;
Total: 48,000 rubles.
 
2 2
3
10000
9000
20000  

 

ID 38498. Gromozeka and paint
Темы: Conditional operator   

Gromozeka recently bought three cans of paint. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. The color of each can of paint is conventionally represented by an integer from 1 to 100 inclusive. Since Gromozeka is forgetful, he could buy several cans of paint of the same color. Count the number of different colors of these paint cans and tell him.

Input
One line contains three integers a, b and c (\(1 <= a,b,c<=100\)).

Imprint
Display the answer to the problem.
 

 

Examples
# Input Output
1 3 1 4 3
2 3 3 33 2

 

ID 38502. Candy battle
Темы: Conditional operator   

There are three packages of sweets, each of which contains candies in the amount of a, b and c pieces, respectively. they fight over these sweets. The teacher Anna Nikolaevna tries to distribute the packs between two pupils in such a way that everyone gets the same number of sweets. Determine if it's possible.
Please note that Anna Nikolaevna cannot take the candies out of the package, and the entire contents of each package must be given to one of the students.

Input
The input string contains three numbers a, b and c (\(1<=a ,b,c<=100\)).

Imprint
If it is possible to distribute the packages so that each pupil gets the same number of sweets, print Yes. Otherwise, print No.
 

 

Examples
# Input Output Explanation
1 10 30 20 Yes Hand out a pack of 30 sweets to one person and two packs of 10 and 20 candies to another. Everyone gets 30 sweets.
2 30 30 100 No In this case, the pupil who receives the package of 100 sweets always has more candies than the other.
Please note that each package must be given to one of them.
3 56 25 31 Yes  

 

ID 38525. Tasks for Gromozeka
Темы: Conditional operator   

Gromozeka solves chess problems from the beginners' collection (ABC) if his current rating is less than 1200, and problems from the club players' collection (ARC) otherwise. You are given Gromozeka's current rating, x. Print ABC if Gromozeka will solve problems for beginners, and print ARC  otherwise.

Input
The input is a positive integer x.

Imprint
Display the answer to the problem.
 

 

Examples
# Input Output
1 1000 ABC
2 2000 ARC

 

ID 38546. Sale
Темы: Conditional operator    Greedy Algorithm   

Stores for promotional purposes often arrange sales. For example, one of the major chains of stationery stores announced two promotional offers: "Buy N identical products and get one more product for free" and "Buy K products for the price of K&minus 1 product".

To hold the Olympiad, the organizers need to print out the conditions for the participants, which takes a lot of paper. Each pack costs B rubles. What is the maximum number of packs of paper that can be purchased for A rubles, using promotional offers correctly?

Input
The input file contains integers N, K, A and B (1 ≤ N ≤ 100, 2 ≤ K ≤ 100, 1 ≤ A ≤ 109, 1 ≤ B ≤ 109), separated by spaces.

Imprint
Print a single integer - the maximum number of packs of paper that the organizers of the Olympiad can buy.

Note
In the first example, using the second promotional offer twice, you can buy 8 packs of paper, paying for 6.

In the second example, promotional offers cannot be used.

In the third example, you can use each of the two promotional offers once and buy another pack of paper with the remaining ruble.

Examples
# Input Output
1 4 4 13 2 8
2 3 4 8 3 2
3 3 4 7 1 9

ID 38591. SilverTests Beginner rounds
Темы: Conditional operator   

All SilverTests Beginner Coder (STBCoder) contests are tagged as STBC001, STBC002, ...  from Round 1 to Round 999. After the STBC999  round, a problem arises: how should the next rounds be marked? In the end, it was decided for rounds from 1000 to 1999 to be marked as STBD000, STBD001, ..., STBD999. Rounds 2000 to 2999 are marked as STBE000, STBE001, ..., STBE999 etc., each time the last letter is changed (STBC, STBD,  STBE, ..., STBL). Rounds from 1 to 9999 are thus marked. 
You are given an integer N between 1 and 9999 (inclusive). Print the first four characters of the label for the Nth round of the SilverTests Begginer Coder.

Input
Input N integer (\(1<=N<=9999\)).

Imprint
Print the first three characters of the label for the Nth round of the SilverTests Beginner Coder Contest.

 

Examples
# Input Output
1 999 STBC
2 1000 STBD
3 6345 STBI

 

ID 38617. Happy birthday!
Темы: Conditional operator    Whole numbers    Whole numbers   

Pupsen and Vupsen will soon celebrate their 16th birthday. Baba Kapa baked them a round cake and cut it into 16 equal fan-shaped pieces. Puppy and Puppy were just about to eat A and B of these slices, respectively, when they found a note attached to the cake that said "the same caterpillar cannot eat two adjacent pieces of cake." Can they both follow the instructions on the note and take the desired number of cake pieces?

Input
The input string contains two space-separated numbers A and B.

Imprint
Print the word Hooray! on the screen if Pupsen and Vupsen can follow the instructions in the note and take the desired number of cake pieces, otherwise print the sad emoticon :(.

 

Examples
# Input Output
1 5 4 Hooray!
2 8 8  Hooray!

 

ID 38626. Arithmetic cookies. Very easy task
Темы: Conditional operator    Strings    Symbols   

There is always an integer in Gromozeka's mind. Initially, in Gromozeka's mind, the integer is 0. Now Gromozeka is going to eat four cookies, each of which has either + or - written on it. When he eats a cookie with the symbol +, the integer in his mind increases by 1; when he eats a cookie with a - character, the integer in his mind decreases by 1. The cookies that Gromozeka is about to eat are given to you as a string S, i th character in S is i is the cookie he eats. Find the integer in Gromozeka's mind after he has eaten all the cookies.

Input
The input is a string of 4 characters, each of which is equal to or -.

Imprint
Print an integer in Gromozeka's mind after he has eaten all the cookies.
 

 

Examples
# Input Output
1
+-++
2
2
-+--
-2
3
----
-4

 

ID 38627. Number Cookies
Темы: Whole numbers    while loop    Conditional operator   

Gromozeka loves number cookies. Among all the numerical cookies, Gromozek eats only those on which the sum of the digits of the written number in the decimal number system is a divisor of the number itself. You are given a number written on a cookie. Determine whether Gromozeka will eat it or not.

Input
The input is an integer N (1<=N<=109).

Imprint
Print Yes if Gromozeka will eat such a cookie, No  if not.
 

 

Examples
# Input Output
1 12 Yes
2 101 No

 

ID 38641. Little Red Riding Hood
Темы: Conditional operator   

Little Red Riding Hood often visits her grandmother. But she is very afraid that sooner or later the wolf will visit her grandmother again. Therefore, she decided to negotiate with the Forester about the protection of her grandmother. The forester agreed to guard the grandmother for 10 pies.

Upon learning of this, the wolf told Little Red Riding Hood that she absolutely did not need to spend pies on the Forester. For half of those pies that Little Red Riding Hood brings to her grandmother, the Wolf promised not to touch her.

Today (November 26) is Mother's Day in Russia. Mom baked some pies and asked Little Red Riding Hood to take them to Grandma. It is required to determine how many pies Little Red Riding Hood can bring to her grandmother.

Input
One even number is entered - the number of pies that mom baked.

Imprint
The program should print  one number - the number of pies that Little Red Riding Hood can bring to her grandmother.

Examples
# Input Output
1 12 6
2 100 90

ID 38643. Under the control of the rook
Темы: Conditional operator   

It is required to determine whether a rook located on a cell with the specified coordinates (row number and column number) controls a piece located on another specified cell.

Input
Four numbers are entered: the coordinates of the rook (two numbers) and the coordinates of the other piece (two numbers), each number is entered on a separate line. Coordinates are integers in the range from 1 to 8.

Imprint
It is required to print the word YES if the rook can capture the piece in 1 move and NO otherwise.
 

Examples
# Input Output
1 1
1
2
2
NO
2 1
1
2
1
YES

ID 20378. Elephant
Темы: Conditional operator   

It is required to determine whether the bishop, standing on a cell with the specified coordinates (row number and column number), beats a piece, standing on another specified cell.

Input

Four numbers are entered: the coordinates of the elephant and the coordinates of another figure. Coordinates are integers between 1 and 8.

Output

It is required to print the word YES if the bishop is able to capture the piece in 1 move, otherwise print the word NO

Examples
input
1
1
5
5
output
YES

input
3
2
2
2
output
NO

ID 38644. Queen
Темы: Conditional operator   

It is required to determine whether the queen on the cell with the specified coordinates (row number and column number) captures the piece on another specified cell.

Input
Four numbers are entered: the coordinates of the queen and the coordinates of the other piece. Coordinates are integers in the range from 1 to 8.

Imprint
It is required to print the word YES if the queen can capture a piece in 1 move, otherwise print the word NO
 

Examples
# Input Output
1 1
1
8
1
YES
2 3
2
8
3
NO

ID 38648. Chips
Темы: Whole numbers    Conditional operator   

A chip was placed in each extreme cell of the square board. Could it turn out that exactly k chips are placed? (For example, if the board is 22, then 4 chips are exposed, and if 66, then 20).

Input
One natural number k is entered, not exceeding 30000

Imprint
The program should print the word YES if there is such a size of the board that exactly (no more and no less) k chips will be put on, otherwise it should print the word NO.

Examples
# Input Output
1 20 YES
2 13 NO

ID 38649. cutlets
Темы: Conditional operator    Whole numbers   

You can put k cutlets in the pan at the same time. Each cutlet needs to be fried on each side for m minutes continuously. What is the shortest time it takes to fry n cutlets on both sides?

Input
3 numbers are entered: k, m and n. All numbers do not exceed 32000.

Imprint
Print the time it takes for all cutlets to be fried.


Examples
# Input Output
1 1
5
1
10

ID 38650. Coordinate quarters
Темы: Conditional operator   

Given the coordinates of two points on the plane, it is required to determine whether they lie in the same coordinate quarter or not (all coordinates are nonzero).

Input
4 numbers are entered: the coordinates of the first point (x1, y1) and the coordinates of the second point (x2, y2).

Imprint
The program should print the word YES if the points are in the same coordinate quadrant, otherwise print the word NO.

Examples
# Input Output
1 3
3
5
1
YES

ID 38651. We share a chocolate bar
Темы: Conditional operator   

It is required to determine whether it is possible from a chocolate bar of size n × m slices break off k slices, if it is allowed to make one break in a straight line between the slices (that is, break the chocolate bar into two rectangles).

Input
3 numbers are entered: n, m and k; k is not equal to n x times; m. It is guaranteed that the number of slices in a chocolate bar does not exceed 30000.

Imprint
The program should print the word YES if it is possible to break off the specified number of slices, otherwise print the word NO.

Examples
# Input Output
1 3
2
4
YES
2 3
2
1
NO

ID 38677. King
Темы: Conditional operator   

The field of the chessboard is defined by a pair of numbers (a, b), each from 1 to 8, the first number specifies the column number, the second – line number. Two cells are given. Determine if the chess king can get from the first cell to the second in one move.

Input
Given 4 integers from 1 to 8 each, the first two define the starting cell, the second two define the final cell. The start and end cells do not match. Numbers are written on separate lines.

Imprint
The program should print YES if it is possible to get to the second one from the first cell by the king's move, or NO otherwise.
 

Examples
# Input Output
1 4
4
5
5
YES

ID 38684. Subway tickets
Темы: Conditional operator   

A ticket for one trip in the metro costs 15 rubles, a ticket for 10 trips costs 125 rubles, a ticket for 60 trips costs 440 rubles. The passenger plans to make n trips. Determine how many tickets of each type he must purchase so that the total number of paid trips is not less than n, and the total cost of purchased tickets – minimal.

Input
Given one number n - the number of trips.

Imprint
Print three integers equal to the required number of tickets for 1, 10, 60 trips.
 

Examples
# Input Output
1 129 0 1 2

ID 38685. Subway tickets - 2
Темы: Conditional operator   

A ticket for one trip in the metro costs 15 rubles, a ticket for 5 trips costs 70 rubles, a ticket for 10 trips costs 125 rubles, a ticket for 20 trips costs 230 rubles, a ticket for 60 trips costs 440 rubles. The passenger plans to make n trips. Determine how many tickets of each type he must purchase so that the total number of paid trips is not less than n, and the total cost of purchased tickets – minimal.

Input
Given one number n - the number of trips.

Imprint
Print five integers equal to the required number of tickets for 1, 5, 10, 20, 60 trips. If for some given n there are several ways to purchase tickets of the same cost, you need to print the combination of tickets that gives the most number of trips.


Examples
# Input Output
1 1 1 0 0 0 0 

ID 38710. Minimum discount
Темы: Whole numbers    Conditional operator   

Mr. Duncan, the manager of Duncan's Toy Chest, donates a certain amount of money to children's funds each year around Christmas.  The amount that goes to charity is always equal to the minimum number, which is divided by 2 and the number of toys sold in a year. Given the number of toys sold per year (N), determine the amount that Mr. Duncan will donate. 

Input
The input is a positive integer N (1<=N<=109).

Imprint
Print a single number - the amount that Mr. Duncan will donate.
 

Examples
# Input Output
1 3 6
2 10 10
3 999999999 1999999998

ID 38732. Number Divisors
Темы: for loop    Prime numbers and factorization    Conditional operator   

Print all natural divisors of x in ascending order (including 1 and the number itself).

Input
Enter a natural number x

Imprint
Print all divisors of x

 

Examples
# Input Output
1 32 1 2 4 8 16 32 

ID 38921. Until until the New Year!
Темы: Conditional operator   

In some other world today is the Dth of December. Write a program that displays "Happy New Year!" if D = 31, "Before Happy New Year!" if D = 30, "Before before Happy New Year!" if D = 29 and  ;"Before before before Happy New Year!" if D = 28.

Input
The input is an integer D (28 <= D <= 31). 

Imprint
Print the answer to the appropriate line.
 

Examples
# Input Output
1 31 Happy New Year!
2 28 Before before before Happy New Year!

ID 38925. Happy New Year!
Темы: Conditional operator   

Today is December 31 in some other world. Grandfather Kokovani has A tangerines, and Darena has B tangerines. Grandfather Kokovanya performs the following action K times:

  • If grandfather Kokovani has one or several tangerines, he gives one of his tangerines to Darena and she eats it.
  • Otherwise, if Darena has one or several tangerines, she gives one to her grandfather and he eats it.
  • If they don't both have a single tangerine, then neither of them eats anything.
How many tangerines will Kokovani and Daryona's grandfather have at the end of the game?

Input
The program receives three space-separated integers as input: A, B and (0 <= A, B, K <= 1012).

Imprint
Print 2 numbers on the screen - the number of tangerines that Kokovani and Darena's grandfather will have at the end of the game. 
 
Examples
# Input Output Explanation
1 2 3 3 0 2 Grandfather Kokovanya will do the following:
1) He has two tangerines, so he gives one to Darena and she eats it.
2) Now he has one tangerine left, and he will give it back to Daryon, who will eat it.
3) Now he has no tangerines left, but Darena has three of them, so grandfather Kokovanya eats one of them.
Thus, in the end, grandfather Kokovani will have 0 tangerines, and Darena will have 2.
2 500000000000 500000000000 1000000000000 0 0 Watch out for overflow!

ID 39056. economic literacy
Темы: Conditional operator   

Many banks, when paying for purchases with their bank cards, offer a refund system for part of the money spent, called cashback .

Alena's mother has three similar cards with different conditions for returning part of the amount spent. The bank card RR receives 5 rubles from each full 100 rubles of the cost of one purchase. For example, 5 rubles is returned for a purchase worth 100 rubles and 199 rubles. Bank BB returns 2 rubles from every 50 rubles of purchase, and for a purchase worth 199 rubles it will return 6 rubles. And the MM bank returns 3% of the total cost of any purchase (note that if the price is an integer number of rubles, 3% will always be an integer number of kopecks), so 5 rubles will be returned for a purchase of 199 rubles. 97 kopecks

Alena loves to go shopping with her mother. Mom suggested that Alena decide which purchase to pay with which card so that the refund amount is the maximum possible. Consider that payment for any purchase is possible with any card. If any two or all three cards give the best return amount accurate to kopecks, then Alyona chooses the one of the cards that she likes best in terms of design. Most of all, Alena likes the MM bank card, then comes the BB bank card, and Alena likes the RR bank card the least.


Input

Enter a single integer ( 1 <= S <= 10 000 ) — purchase price in rubles.


Output

Print the name of the bank RR BB or MM depending on which bank card is more profitable to pay this purchase. And if the return amount is equal - the name of the bank specified in the task condition.

 

Note

In the first example, only the bank MM  will refund part of the purchase amount. The second example is analyzed in the problem statement.

 
Examples
# Input Output
1 10 MM
2 199 BB
3 101 RR

ID 39390. Social distancing I
Темы: Case Study    Conditional operator    Simple puzzles   

A terrible disease afflicts the cows. Farmer John wants to protect them.
The FD Barn is a narrow long building containing N stalls in a row (2≤N≤105). Some of these stalls are already occupied by cows, some are free. After reading about the need for social distancing, the FD wants to maximize D, where D is the distance between the two closest occupied stalls. For example, if stalls 3 and 8 are the closest that are occupied, then D=5.

Two new cows have been added to FD's herd, and he must decide which unoccupied stall to place each of them in. Determine how k he should place these cows so that the result D, becomes the maximum possible. The FD cannot move any existing cows, he can only assign stalls to new cows.

Input
The first line of input contains N. The next line contains a string of length N, consisting of 0 and 1, describing the sequence of stalls in the barn. 0 means an empty stall, 1 means an occupied stall. There are at least two zeros in the string, which is enough to accommodate two cows.
Imprint
Output the largest value of D (the smallest distance between two occupied stalls) that the FD can obtain by adding two new cows in an optimal way.

Examples
# Input Output  
1 14
10001001000010
2 In this example, the FD can add cows like this: 10x010010x0010 where x represents new cows. In this case D=2. It is not possible to mark cows in such a way as to get more D.

ID 39535. hungry pawn
Темы: Strings    Conditional operator    Formula derivation   

Gromozeka respects chessboard games. Gromozeka has a hungry pawn on a regular 8x8 board. A hungry pawn eats some opponent’s piece every move (i.e. it can move diagonally forward 1 square to the right or left, it cannot move back). Gromozeka, without looking at the board, learned to determine whether a hungry pawn can move from one square of the board to another. It is impossible to turn into a queen to a hungry pawn.
Write a program with which you could also easily check Gromozeka.

Input
The program receives as input two cells of the chessboard in chess notation. First, the cell where the hungry pawn stands, and then, after a gap, the cell where the hungry pawn must go.

Imprint
Print the word YES (in capital letters) if a hungry pawn can move from the first cell to the second, and NO otherwise.
The board has a size of 8x8, the verticals are numbered in small Latin letters from a to h, the horizontals are numbered from 1 to 8. The starting and ending cells do not match.
 

Examples
# Input Output
1 a1 b2 YES
2 b2 a1 NO
3 a1 h7 NO

ID 42231. Neighboring squares
Темы: Conditional operator   

There is a grid with H horizontal rows and W vertical columns. Let (ij) denote the square in the i-th row from the top and in the j-th column on the left.
Find the number of squares that have a common side with the square (RC).

Square (ab) and square (cd) have one common side if and only if |a-c|+|b-d|=1 (where |x| denotes the absolute value of < code>x).

Input
The program receives two lines as input. The first line contains two integers H and W (1 <= H, W <= 10). The second line contains two integers R< /code> and C (1 <= H, W <= 10).

Imprint
Print the answer to the problem.
 

Examples
# Input Output
1 3 4
2 2
4
2 3 4
1 3
3

Grid image, for the examples described above

ID 42451. What kind of ice cream do you like?
Темы: Conditional operator   

An alien research expedition led by Dick Solomon is trying to lead the life of an ordinary human family. More recently, they have learned that  milk powder consists of milkfat and skimmed milk powder. The most favorite product made from powdered milk is an ice cream type product. Having tried a fairly large number of samples, the members of the expedition identified 4 main categories:

  • an ice cream-type product with at least 15 percent milk powder and at least 8 percent milkfat is called ice cream (1);
  • An ice cream-type product with at least 10 percent milk powder and at least 3 percent milkfat that is not ice cream is called iced ice cream (2 );
  • A type of ice cream product with a milk powder content of at least 3 percent that is not ice cream or iced milk is calledlacto ice (3);
  • An ice cream type product that is not ice cream, ice milk or lacto ice is called flavoured ice (4).
Dick Solomon, returning from work, bought an ice cream that contains A% skimmed milk powder and B% milk fat . And he again forgot what category this ice cream belongs to. Can you help him identify the category of ice cream?
Print your answer as an integer.

Input
The single input line contains two space-separated integers A and B (0 <= A, B <= 100, A+B <= 100).

Imprint
Screenshot an integer:
1 - if it's ice cream;
2 - if it is ice milk;
3 - if it's lacto ice;
4 is flavored ice.


Use nested conditions (elif for Python and else if for other languages).
 
Examples
# Input Output Note
1 10 8 1 This product contains 10 percent skimmed milk powder and 8 percent milk fat, for a total of 18 percent milk powder.
Since it contains at least 15 percent milk powder and at least 8 percent milk fat, it is ice cream; the correct answer is 1.
2 1 2 3  

ID 42452. When is Saturday
Темы: Strings    Conditional operator   

One day, tired from going to school, Tommy wanted to know how many days were left until Saturday. We know that this day was a weekday, and the name of the day of the week was S (in English). How many days remained until the first Saturday after this day (counting the Saturday itself, but not counting the day S)?

Input
The input is the string S (S can be  MondayTuesdayWednesdayThursday or Friday).

Imprint
Display the answer to the problem

Use nested conditions (elif for Python and else if for other languages).
 

Examples
# Input Output
1
Wednesday
3

ID 43033. Rectangle Tommy
Темы: Conditional operator   

Tommy is very fond of rectangular shapes. In geometry class, Tommy was given four strips of paper to draw his favorite shape. Unfortunately, Tommy lost one strip and he still had & nbsp; three strips of paper l1, l2, l3 . Now Tommy wondered if he could make a rectangle out of these strips if he cut any one strip once in such a way that the length of each part was non-zero, and the sum of the lengths of the resulting parts would be equal to the original length of the strip.
Tommy thinks a square is a rectangle. 

Help Tommy see if he can make a rectangle.

Input
The program receives three integers l1, l2, l3  ;(1 <= l1, l2, l3 <= 108).

Imprint
If Tommy succeeds in constructing a rectangle, then display the word YES. If the rectangle cannot be constructed, the word NO.

 

Examples
# Input Output
1
2 5 2
NO
2
2 4 2
YES

ID 43934. Little Red Riding Hood
Темы: Conditional operator   

Little Red Riding Hood often visits her grandmother. But she is very afraid that sooner or later the wolf will visit her grandmother again. Therefore, she decided to negotiate with the Forester about the protection of her grandmother. The forester agreed to guard the grandmother for 10 pies.
Upon learning of this, the wolf told Little Red Riding Hood that she absolutely did not need to spend pies on the Forester. For half of those pies that Little Red Riding Hood brings to her grandmother, the Wolf promised not to touch her.
Today (November 26) is Mother's Day in Russia. Mom baked some pies and asked Little Red Riding Hood to take them to Grandma. It is required to determine how many pies Little Red Riding Hood can bring to her grandmother.

Input
One even number is entered - the number of pies that mom baked.
 
Output
The program should output  one number - the number of pies that Little Red Riding Hood will be able to bring to grandma.
 
Examples
# Input Output
1 12 6
2 100 90

ID 44032. When is the New Year?
Темы: Strings    Conditional operator   

Tommy loves Christmas very much! December 31 this year falls on a Saturday. Tommy wanted to know how many days until December 31st. We know that today is a weekday S (in English) and December 31st is already this week on Saturday. Help Tommy determine how many days until December 31 after today (counting December 31, but not counting today S)?

Input
The input is the string S (S can be  Monday(Monday), Tuesday(Tuesday ), Wednesday(Wednesday), Thursday(Thursday) or Friday(Friday)).

Imprint
Display the answer to the problem

Use nested conditions (elif for Python and else if for other languages).
 

Examples
# Input Output
1
Wednesday
3

ID 44034. Get to the toys
Темы: Conditional operator    Simple puzzles   

Santa Claus decided to check the toy factory to see if all the gifts for children are ready. To get to the toy storage area, he needs to go through a narrow secret corridor. In the corridor, for each meter of the path, the number of meters from the door is indicated. At the door, near which Santa Claus is standing, the number 0 is written. You can move along the corridor both to the left and to the right. When moving to the left, the numbers are negative, when moving to the right, they are positive.

Because the location is classified, the factory is constantly changing the entrance to the toy store. 

Santa Claus knows that today the entrance to the factory is located at the door with the number X. It is also known that in the corridor, next to the number Y there is a door blocking the passage along the corridor. To open it, you need to take the key, which is located on the wall on the shelf in the corridor next to the number Z.

Determine if Santa Claus himself can get to the door to the toys. If possible, determine the minimum distance that Santa Claus will need to walk. If it fails, then print -1.



Input
The program receives as input a string containing 3 different non-zero numbers: X, Y, Z (-103 <= X, Y, Z <= 103).

Imprint
Print the minimum distance that Santa Claus needs to walk from the door where he is standing to the door behind which there is a place to store toys. If Santa Claus can't get to this door, print -1.
 
 
Examples
# Input Output
1 10 -10 1 10
2 20 10 -10 40
3 100 1 1000 -1