Plus
Pin


Problem description Progress
ID 18683. Smallest number
Темы: for loop   

Given a sequence of numbers. Find the smallest number in it.
 
Input
First given number N (number of numbers in sequence) and then N numbers on one line, separated by one space.
 
Output
Print the smallest number.
 
Examples
# Input Output
1
7
4 2 5 -1 4 6 2
-1

ID 33681. Wonderful Numbers 3
Темы: for loop   

The square of a three-digit number ends with three digits equal to that number. Find and print all such numbers.

Input data: The program does not require input from the keyboard, it simply displays a list of the numbers you are looking for
Output: Output the answer to the problem. Output numbers one per line

ID 33683. Wonderful Numbers 5
Темы: for loop   

You are given two four-digit numbers A and B. Print in ascending order all four-digit numbers in the range from A to B, which record contains exactly three identical digits.

Input
Two integers A and B are entered.

Imprint
Print the answer to the problem.
 
Examples
# Input Output
1 1900
2100
1911
1999 2000
2022

ID 28407. Function tab 1
Темы: for loop   

Write a program that evaluates the function z(t) when x changes from 4 to 28 in increments of 1.
\(z = 2t^2 - 5.5t - 2\), when \(t = x+2\ ).

Input
You don't need to enter anything from the keyboard.

Imprint 
You need to output z(t)  values ​​for all x values. One pair (x, z) per line. See the example for output format.
 

Examples
# Input Output
1  
x=4 z=37.0
x=5 z=57.5
...
x=27 z=1520.5
x=28 z=1633.0

ID 28406. Function tab 2
Темы: for loop   

Write a program that calculates the function z(t) when a changes from 2 to 17  >with step 1.
\(z = 3.5t^2 - 7t +16\), when \(t = 4a\)< /span>.

Input
You don't need to enter anything from the keyboard.

Imprint 
You need to output z(t)  values ​​for all a values. One pair (a, z) per line. See the example for output format.
 

Examples
# Input Output
1  
a=2 z=184.0
a=3 z=436.0
a=4 z=800.0
...
a=16 z=13904.0
a=17 z=15724.0

ID 33684. Wonderful Numbers 6
Темы: for loop   

Given non-negative integers a, b, c, d, with (0 <= c <= d)  ;. Print in ascending order all the numbers from a to inclusive, which give a remainder c when divided by  ;d.

Input
Four integers  a, b, c, d are entered. Each number on a new line.

Imprint 
Output the answer to the problem. Output the numbers on one line, separated by one space. If there are no such numbers in the specified range, then nothing should be displayed.
 
Examples
# Input Output
1 2
5
0
2
2 4

ID 7135. From a to b. Task 4
Темы: for loop   

Given three integers a, b and c
Write a program that finds the number of all integers from a to b that are multiples of c

Input: 
The first line contains three integers a, b and c (a<=b,  a,b,c modulo no more than 100)

Output:
The program should output a single number -  the number of all integers from a to b that are multiples of c

Example

Enter

Output

1 10 3
3

ID 7136. From a to b. Task 3
Темы: for loop   

You are given three integers a, b and c.
Write a program that finds the count of all integers from a to b that end in c

Input: 
The first line contains three integers a, b and c (a<=b,  a,b modulo no more than 100, 0<=c<=9)

Output:
The program should output a single number -  the number of all integers from a to b that end in c

Example

Enter

Output

1 10 8
1

ID 7132. From a to b. Task 6
Темы: for loop   

Given a natural number a.
Write a program that finds the sum of all integers from 1 to a that end in 3 

Input: 
The first line contains a natural number a (a,  a modulo no more than 100)

Output:
The program should print a single number - the sum of all integers from 1 to a ending in 3
 

Example

Enter

Output

25
39

ID 7131. From a to b. Task 7
Темы: for loop   

You are given two integers a and b.
Write a program that finds the arithmetic mean of the squares of all integers from a to b

Input: 
The first line contains two integers a and b (a<=b,  a,b modulo no more than 100)

Output:
The program should output one number - the arithmetic mean of the squares of all integers from a to b (with 2 decimal places)

Example

Enter

Output

1  5
11.00

ID 7129. From a to b. Task 8
Темы: for loop   

You are given two integers a and b.
Write a program that finds the sum of all triple integers from a to b

Input: 
The first line contains two integers a and b (a<=b,  a,b modulo no more than 100)

Output:
The program should output one number The sum of all tripled numbers from a to b
 

Example

Enter

Output

10 20 495

ID 2965. Processing of entered numbers - 3
Темы: for loop   

Given a sequence of numbers. Find out how many times it contains the maximum number
 
Input data: First enter the number N - the number of members of the sequence, and then N numbers - the members of the sequence
Output: Print a single number - the number of times the maximum number occurs in the sequence.

Examples:
Input
7
1
4
2
5
2
5
3
 
Output
2

ID 27045. End row of numbers - 3
Темы: for loop   

Given a real number X (X<10). Calculate



Input: the first line contains a single number X

Output: Print the sum of the given series
(In the checking program, the accuracy is set to 3 decimal places)

ID 23576. End row of numbers - 1
Темы: for loop   

Given a natural number N. Write a program that calculates the first N factors of the following expression:

\(P = {2 \over 3}\cdot{4 \over 5}\cdot{6 \over 7}\ cdot ... \cdot {{2 \cdot N} \over {2\cdot N +1}}\)

Input
The input is a natural number N.

Imprint
Output the answer to the problem
 

 

Examples
# Input Output
1 42 0.135542

ID 23577. End row of numbers - 2
Темы: for loop   

The number N is given (1<=N<=15). Calculate:


Example.
Input
12

Imprint
0.451016

ID 34787. Transfiguration
Темы: for loop   

Transfiguration  (English Transfiguration; literally «transfiguration», «transfiguration») — a discipline that studies the magical ways transformation of some objects into others, inanimate objects into living ones and vice versa, as well as one living objects into others. A special case of transfiguration is the creation of objects from nothing or their disappearance. The subject is extremely complex and requires certain magical powers and strict concentration. Transfiguration requires a magic wand and knowledge of the appropriate formula.

Known Number  \(n >= 2\)  transfigure to sum \(1 \cdot 2+2 \cdot 3+...+(n-1) \cdot n\).
Print your answer as a calculated expression and its value exactly as shown in the example.

Input 
Enter a natural number.

Imprint 
Print the answer to the problem.
 

 

Examples
# Input Output
1 4 1*2+2*3+3*4=20
2 2 1*2=2

ID 34789. Wonderful Numbers 8
Темы: for loop   

Among all three-digit numbers, find those whose sum of digits is a multiple of 7 and the number itself is also divisible by 7. Print all such numbers.

Input data: The program does not require input from the keyboard, it simply displays a list of the numbers you are looking for
Output: Output the answer to the problem. Output numbers one per line
 

ID 15832. Processing of entered numbers - 3
Темы: for loop   

Enter 8 positive integers from the keyboard. Determine how many of them are divisible by 3 and end in 4. The program should output one number: the number of numbers that are multiples of 3 and end in 4.
 

 
Input
12
14
24
54
44
33
84
114
Output
4

ID 15831. Processing of entered numbers - 4
Темы: for loop   

Enter 5 positive integers from the keyboard. Calculate the sum of those numbers that are divisible by 4 and end with 6. The program should output one number: the sum of numbers entered from the keyboard that are multiples of 4 and end with 6
 

Input
12
16
36
26
20
Output
52

ID 34790. Processing of entered numbers - 6
Темы: for loop   

The statement shows the salary paid to each of the employees of the company for the month. Determine the number of employees with a salary of less than 5000.

Input data: in the first line enter the number N (25 <= N <= 100) - the number of employees of the company, in the following lines enter N numbers (one number per line) - the salary of each employee .
Output: inoutput the answer to the problem

Examples

# Input Output
1 5
10000
2000
4000
5000
6000
2
 

ID 34792. Processing of entered numbers - 8
Темы: for loop   

Given a sequence of integers. Find the maximum odd number in it. There is at least one odd number in the sequence

Input data: In the first line enter the number N - the number of numbers in the sequence, and then N integers, one per line.
Output: Output the answer to the problem

Examples

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

ID 34793. Processing of entered numbers - 9
Темы: for loop   

Given a sequence of integers. Find the maximum even number in it. There is at least one even number in the sequence

Input data: In the first line enter the number N - the number of numbers in the sequence, and then N integers, one per line.
Output: Output the answer to the problem

Examples

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

ID 7138. From a to b. Task 1
Темы: for loop   

Given three integers \(a\), \(b\) and \(c\)
Write a program that counts all integers from \(a \)  to \(b\) which, when divided by integer \(c\) , will give a remainder greater than 4

Input: 
The first line contains three integers \(a\), \(b\) and \(c\) (\(a <= b\),  a,b no greater than 100 by modulo, 0<=c<=9)

Output:
The program should print a single number -  the number of all integers from a to b, which, when divided by integer by c, will give a remainder greater than 4

Examples

# Input Output
1 1 10 9 4

ID 7130. From a to b. Task 7
Темы: for loop   

You are given two integers a and b.
Write a program that finds the product of all double integers from a to b that when multiplied by 3 get an even number

Input: 
The first line contains two integers a and b (a<=b,  a,b modulo no more than 10)

Output:
The program should print one number the product of all doubled numbers from a to b

Example

Enter

Output

1 5 32

ID 7137. From a to b. Task 2
Темы: for loop   

You are given three integers a, b and c.
Write a program that finds the number of all integers from a to b that, when multiplied by a number c , are even numbers

Input: 
The first line contains three integers a, b and c (a<=b,  a,b modulo no more than 100, 0<=c<=9)

Output:
The program should print a single number -   the number of all integers from a to b, which, when multiplied by the number c , will be even numbers

Example

Enter

Output

1 10 8
10

ID 34808. Maximum number - 1
Темы: for loop   

Given a natural number n and integers a1, a2, ..., an. Find the number of the maximum number divisible by 3. If there are several numbers with the maximum value divisible by 3, then the number of the last of them must be found (it is guaranteed that there is at least one number divisible by 3).

Input: in the first line enter the number N - the number of numbers in the sequence (0<N<100), and then N integers.
Output: print the answer to the problem

Examples

# Input Output
1 7
4
9
6
-3
-4
9
-2
6
 
 

ID 34809. Maximum number - 2
Темы: for loop   

Given a natural number n and integers a1, a2, ..., an. Find the number of the maximum number that is not a multiple of 3. If there are several numbers with a maximum value that is not a multiple of 3, then the number of the last of them must be found (it is guaranteed that there is at least one number that is not a multiple of 3).

Input: in the first line enter the number N - the number of numbers in the sequence (0<N<100), and then N integers.
Output: print the answer to the problem

Examples

# Input Output
1 7
4
9
6
-3
-4
9
-2
1
 
 

ID 34810. Maximum number - 3
Темы: for loop   

Given a natural number n and integers a1, a2, ..., an. Find the number of the minimum multiple of a1 (a1>0) among all numbers a1..an. If there are several numbers with a minimum value that is a multiple of a1, then the number of the first of them must be found. 

Input: in the first line enter the number N - the number of numbers in the sequence (0<N<100), and then N integers.
Output: print the answer to the problem

Examples

# Input Output
1 7
4
9
6
-3
-4
8
-2
5
 
 

ID 34813. Processing of entered numbers - 14
Темы: for loop   

Data on air temperature during the month are known. Determine how many days in a month there was the lowest positive temperature (it is guaranteed that there was at least one day with a temperature above zero). 

Input data: in the first line enter the number N - the number of days in a month (N<=31), and then N integers.
Output: print the answer to the problem

Examples

# Input Output
1 7
3
3
6
3
-4
3
-2
4
 
 

ID 34814. Processing of entered numbers - 15
Темы: for loop   

Data on air temperature during the month are known. Determine how many days in a month there was the highest negative temperature (it is guaranteed that there was at least one day with a temperature below zero). 

Input data: in the first line enter the number N - the number of days in a month (N<=31), and then N integers.
Output: print the answer to the problem

Examples

# Input Output
1 7
3
3
6
3
-4
3
-4
2
 
 

ID 34815. Multiple highs (lows) - 1
Темы: for loop   

The sum of points scored by each of the N teams participating in the football championship is known. Determine the sum of points scored by the teams that took the first three places in the championship (teams could score the same number of points).

Input data: in the first line enter the number N - the number of teams (4 < N<= 100), and then N integers - the number of points scored.
Output: print the answer to the problem

Examples

# Input Output
1 7
3
3
6
3
4
3
4
14
 
 

ID 24630. Processing of entered numbers - 1
Темы: for loop   

The mass of each of N objects is known. Determine the total mass of the entire set of items.

Input:
The first line contains a natural number N - the number of items
The next N lines contain numbers (one number per line) - the mass of each object

Imprint
Display one number on the screen - the total mass of a set of items

Example:
Input
3
3
5
4

Imprint
12

ID 2962. Processing of entered numbers - 5
Темы: for loop   

Given a sequence of integers. Find the smallest even number in it. Sequence contains at least one even number
 
Input data: In the first line enter the number N - the number of numbers in the sequence, and then N integers, one per line.
Output: Output the answer to the problem

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

ID 34802. Processing of entered numbers - 11
Темы: for loop   

Given a sequence of integers. Find in it the maximum number that is not a multiple of 3. There is at least one number in the sequence that is not a multiple of 3

Input data: In the first line enter the number N - the number of numbers in the sequence, and then N integers, one per line.
Output: Output the answer to the problem

Examples

# Input Output
1 7
4
6
8
-3
-4
3
-2
8
 
 

ID 34816. Multiple highs (lows) - 2
Темы: for loop   

The results of each of the N teams participating in the running championship are known. Determine the time of the teams in the top three (teams could finish the distance at the same time).

Input data: in the first line enter the number N - the number of teams (3< N<= 100), and then N integers - the finish time of each team
Output: print three numbers separated by a space - the answer to the problem in order of increasing time

Examples

# Input Output
1 7
3
1
6
2
4
5
4
1 2 3
 
 

ID 34788. Wonderful Numbers 7
Темы: for loop   

Among all four-digit numbers, display those that are equal to the fourth power of the sum of their digits.

Input data: The program does not require input from the keyboard, it simply displays a list of the numbers you are looking for
Output: Output the answer to the problem. Output numbers one per line

ID 34812. Maximum number - 5
Темы: for loop   

Given a natural number n and integers a1, a2, ..., an. Find  number of the minimum odd number. If there are several numbers with a minimum odd value, then the number of the first of them must be found. It is guaranteed that there is at least one odd number

Input: in the first line enter the number N - the number of numbers in the sequence (0<N<100), and then N integers.
Output: print the answer to the problem

Examples

# Input Output
1 7
4
-3
6
-3
-4
8
-2
2
 
 

ID 2966. Processing of entered numbers - 2
Темы: for loop   

You are given a sequence of N numbers. Count the number of even numbers in even places in it.
 
Input data: in the first line enters the number N, in the following lines you enter N numbers (one number per line) - the members of the sequence.
 
Output.
Print the number of even numbers in even places (numbered from 0 ) in the sequence.

Examples
# Input Output
1 5
1
2
4
5
6
2
 
Explanation: the numbers 4 and 6 are suitable, as they are, respectively, in the 2nd and 4th places.

ID 34785. Winter at Hogwarts
Темы: for loop   

Tired of an unusually warm winter, the people of Hogwarts decided to find out if this was really the longest thaw on record. They turned to weather forecasters, who, in turn, began to study the statistics for the past years. They are interested in how many days the longest thaw lasted.

They call a thaw a period in which the average daily temperature exceeded 0 degrees Celsius every day.
Write a program to help weather forecasters in their work.

Input 
The first line is a number N – total number of days to consider (\(1 <= N <= 100\)).
The following N lines specify one integer each. Each number – average daily temperature on the corresponding day. Temperatures – integers belonging to the range from –50 to 50.

Imprint
It is required to display one number – the length of the longest thaw, that is, the largest number of consecutive days during which the average daily temperature exceeded 0 degrees. If the temperature on each day was non-positive, print 0.
 

Examples
# Input Output Explanations
1 6
-20
30
-40
50
10
-10
 
2 We are considering 6 days. The longest thaw was on the 4th and 5th days (50 and 10 degrees respectively)
2 8
10
20
30
1
-10
1
2
3
 
4 The longest thaw was in the first 4 days
3 5
-10
0
-10
0
-10
0 There were no days with a positive temperature

ID 34786. Numerology Hogwarts
Темы: for loop   

What is different (if different) from traditional numerology from numerology taught at Hogwarts — unknown. Numerology is one of the disciplines that third-year students can choose for additional study. Homework is known to include essay writing and charting. It is known that Hermione Granger really liked this subject, and the numerology teacher Professor Vector was one of her favorite teachers.

When building charts, you first need to fill in a table with data. Often the data is an arithmetic progression. 

Input 
First, two natural numbers are entered, modulo not exceeding 100, and then the number N (natural, \(2 <= N <= 100\)< /span>) – the total number of numbers in an arithmetic progression (including the first two numbers). Numbers are entered separated by spaces.

Imprint 
Print the N members of the arithmetic progression, separating them with a space.
 

 

Examples
# Input Output
1 2 5 8 2 5 8 11 14 17 20 23

ID 34784. Ночной рыцарь
Темы: for loop   

"Night Knight" – a bus for witches and wizards in trouble. 
"Night Knight" impresses with its size. Small in length, it is significant in height. Giant wheels, three floors. Car color – bright purple.
The bus has several magical properties. First, it arises right there, on demand, anywhere and at any time. The Wizard doesn't even have to wait. Equipped stops «Night Knight» Not needed.


Harry Potter fans decided to organize a city tour on a Night Knight-themed bus. The bus was 437 centimeters high. On the excursion route there are N bridges. The organizers were worried that a tall bus might not pass under one of them. They know the height of each of the bridges. The bus can pass under the bridge if and only if the height of the bridge exceeds the height of the bus. Help the organizers find out if the tour will end safely, and if not, determine where the accident will occur.
 
Input data 
The first line of input is the number N (\(1<=N<=1000\)). Then there are N natural numbers (one number per line) not exceeding 10000 - the height of the bridges in centimeters in the order in which they occur on the bus path.
 
Output 
You need to display the phrase "No crash" if the tour ends successfully. If an accident occurs, then you need to display the message "Crash k", where k  is the number of the bridge where the accident will occur. Print phrases without quotes with exactly one space inside.
 

 

Examples
# Input Output
1 1
927
No crash
2 3
763
545
113
Crash 3

ID 23082. For loop statement. Multiplication table
Темы: for loop   

You need to write a program that, according to the number N given from the keyboard, prints a multiplication table by a given number, for example, for N = 2, the program should output the following information:

2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20

ID 33563. Aunt Owl Family
Темы: for loop   

When studying the course “Output Text on the Screen”, we wrote a program that outputs Aunt Owl on the screen.
Now you need to write a program that outputs the corresponding number of owls by the number entered from the keyboard.
We remind you that the picture of Aunt Owl consists of characters. Size 5 by 11 characters.

:)\_____/(:
 {(@)v(@)}
 {|~- -~|}
 {/^'^'^\}
 ===m-m===
Between two neighboring Owls there is an empty (consisting of spaces) column

Examples
Input Output
1 1
:)\_____/(:
 {(@)v(@)}
 {|~- -~|}
 {/^'^'^\}
 ===m-m===
2 2
:)\_____/(: :)\_____/(:
 {(@)v(@)}   {(@)v(@)}
 {|~- -~|}   {|~- -~|}
 {/^'^'^\}   {/^'^'^\}
 ===m-m===   ===m-m===

ID 33565. All odd numbers on the segment
Темы: for loop   

Given two integers A and B. It is necessary to print all the odd numbers on the segment from A to B
Input: Two integers A and B are input to the program. (\(A \leq B\)), one per line
Output: output all the odd numbers on a given interval with a space

Example

Input Output
1 1
10
1 3 5 7 9

Please note: you cannot use the conditional if statement in this task.

ID 33657. Row of numbers
Темы: for loop   

Given two integers A and B. Print all numbers from A to B inclusive, in ascending order, if A < B, or in decreasing order otherwise.

Input: Two integer.
Output: Output the answer to the problem. Numbers must be outputed in one line with a space

Examples
Input Output
1 1
10
1 2 3 4 5 6 7 8 9 10

ID 33658. Decreasing odd row
Темы: for loop   

Given a natural number n. Type all n-digit odd positive integers in descending order.

Input: A natural number is entered.
Output: Output the answer to the problem.

Example
Input Output
1 1 9 7 5 3 1

ID 33659. Wonderful numbers - 1
Темы: for loop   

Find and print all two-digit numbers that are equal to twice the product of their numbers.

Input: The program does not require data input from the keyboard, it simply displays a list of the required numbers.

Output: Output the answer to the problem (output the numbers in one line with a space).

ID 33660. Wonderful numbers - 2
Темы: for loop   

Given two four-digit numbers A and B. Output all four-digit numbers on the segment from A to B, the record of which is a palindrome.

Input: Enter two integers A and B

Output: Output the answer to the problem.


Examples
Input Output
1 1600
2100
1661
1771
1881
1991
2002

ID 23241. Sum of Sequence Numbers - Task 2
Темы: for loop   

Now try to write a program yourself that finds the sum of integers from a to b. Where a and b are entered from the keyboard (numbers are input on the same line).

ID 23242. Sum of Sequence Numbers - Task 3
Темы: for loop   

Write a program that finds not just the sum, but the sum of the squares of integers from a to b (a and b are entered from the keyboard)

Example:
Input:
1 5
Output
55

Clarification of the answer:
(1*1+2*2+3*3+4*4+5*5=55)

ID 7134. Multiplication of Integers
Темы: for loop   

Two integers a and b are given.
Write a program that iterates over all integers from a to b and finds the product of those that, when multiplied by the number 6, give a result ending in the number 2.

Input: 
The first line contains two integers a and b (a <= b, a, b no more than 100 modulo)
Output:
The program should output one number - the multiplication of integers from a to b, the multiplication of which is 6 ends with 2. If there are no such numbers, output 0
 
Example

Input Output
1 1 10 14

ID 33690. Multiplication sum
Темы: for loop   

For a given positive integer n≥2, calculate the sum 1 × 2 + 2 × 3 + ... + (n-1) × n. Output the answer in the form of a calculated expression and its value exactly as shown in the example.

Input: A natural number is entered.
Output: Output the answer to the problem.

Example
Input Output
1 4 1*2+2*3+3*4=20

ID 33564. The number of combinations from N to K
Темы: for loop   

Non-negative integers n and k are given. It is necessary to output the number of combinations of n by k.
The formula for the number of combinations (you must remember that 0! = 1):
\(C^k_n=\frac{n!}{k!(n-k)!}\)

Input: integers n and k, each from a new line (each number is not more than 10, \(n >= k\))
Output: need to print one number in response

Example

Input Output
1 3
2
3
2 4
4
1

ID 2964. Nested Loops - 1
Темы: for loop    while loop    Cycles   

Two numbers N and K are entered. Print the number of numbers from 1 to N (inclusive) such that their sum of digits is divisible by K.
 
Examples
# Input Output
1 100 3 33
2 22 4 5

ID 37499. Ночной рыцарь
Темы: for loop   

"Night Knight" – a bus for witches and wizards in trouble. 
"Night Knight" impresses with its size. Small in length, it is significant in height. Giant wheels, three floors. Car color – bright purple.
The bus has several magical properties. First, it arises right there, on demand, anywhere and at any time. The Wizard doesn't even have to wait. Equipped stops «Night Knight» Not needed.


Harry Potter fans decided to organize a city tour on a Night Knight-themed bus. The bus was 437 centimeters high. On the excursion route there are N bridges. The organizers were worried that a tall bus might not pass under one of them. They know the height of each of the bridges. The bus can pass under the bridge if and only if the height of the bridge exceeds the height of the bus. Help the organizers find out if the tour will end safely, and if not, determine where the accident will occur.
 
Input: N (1<=N<=1000) is given in the first line of input. Then there are N natural numbers (one number per line) not exceeding 10000 - the height of the bridges in centimeters in the order in which they occur on the bus path.
Output: Output the phrase "No crash" if the tour ends successfully. If an accident occurs, then you need to display the message "Crash k", where  k  is the number of the bridge where the accident will occur. Print phrases without quotes with exactly one space inside.
 
Examples
# Input Output
1 1
927
No crash
2 3
763
545
113
Crash 3

ID 37500. Winter at Hogwarts
Темы: for loop   

JK Rowling, Harry Potter and actor Daniel Radcliffe were all born on the same day – July 31st. One of my favorite seasons is winter

Tired of an unusually warm winter, the people of Hogwarts decided to find out if this was really the longest thaw on record. They turned to weather forecasters, who, in turn, began to study the statistics for the past years. They are interested in how many days the longest thaw lasted.

They call a thaw a period in which the average daily temperature exceeded 0 degrees Celsius every day.
Write a program to help weather forecasters in their work.

Input data: Start with a number N – total number of days considered (1 <= N <= 100).
The next N lines contain one integer each. Each number – average daily temperature on the corresponding day. Temperatures – integers belonging to the range from –50 to 50.

Output: You need to output a single number – the length of the longest thaw, that is, the largest number of consecutive days during which the average daily temperature exceeded 0 degrees. If the temperature on each day was non-positive, print 0.

Explanations for examples:

1) 6 days are considered. The longest thaw was on the 4th and 5th days (50 and 10 degrees respectively)
2) The longest thaw was in the first 4 days
3) There were no days with a positive temperature

Examples

# Input Output
1 6
-20
30
-40
50
10
-10
 
2
2 8
10
20
30
1
-10
1
2
3
 
4
3 5
-10
0
-10
0
-10
0

ID 32972. Switching windows
Темы: for loop   

Dima – a programmer, so there are always a lot of windows open on his computer. Since Dima does not have a very large monitor, only one window can be displayed on it. At each point in time, the window manager keeps a list of open windows, the first window of the list is displayed on the monitor. Dima uses the keyboard shortcut Alt + Tab to switch windows. If you keep this button pressed for T seconds, then. T + the first window in the current numbering will move to the first position, and the relative order of the remaining windows will not change. 

For example, the figure below shows what happens to the window order if you press Alt + Tab for 3 seconds. If you hold Alt + Tab N – 1 second, the last window in the list will be the first one. The list of open windows is "looped", the last window is followed by the first window from the list, i.e. if you hold down Alt + Tab for N seconds, then the window that was the first in the list will remain in first place.

If you hold down Alt + Tab N + 1 for a second, the second window will move to the first position, and so on.

At the beginning of the working day, Dima's favorite development environment had the number M in the list of open windows. During the day, Dima K once used the keyboard shortcut Alt + Tab. Determine where his favorite development environment is at the end of the day.

Input:
The first line of the input contains an integer N, \(1 <= N <= 10^5\) – the number of windows on the screen.
The second line contains an integer M, \(1 <= M <= N \)– the number that Dima's favorite development environment had at the beginning of the day.
The third line contains an integer K, \(1 <= K <= 10^5\) – number of times Dima pressed Alt + Tab. The following K lines contain positive integers not exceeding 105  – the duration of each press in seconds.
Output:
The program should output a single integer – the position of Dima's favorite environment at the end of the working day.
 
Examples
# Input Output Note
1
3
2
3
1
5
2
3
There are three windows on the screen. Let's number the windows from 1 to 3 in the same order as
which they were located at the beginning of the day. Dima's development environment
was number 2. Dima pressed Alt + Tab three times,
The
press duration was 1, 5 and 2 seconds. Then
windows layout after each click will be like this:
Press for 1s, the second window moves to the beginning of – 2 1 3.
Pressed for 5 seconds, the third window moves to the top of – 3 2 1
Pressed for 2s, the third window moves to the top of – 1 3 2
As a result, Dima's development environment was in place 3 in the list

ID 34817. Multiple highs (lows) - 3
Темы: for loop   

The air temperature is known for each day of a month. Determine the three warmest days (display the numbers of these days).

Input data: in the first line enter the number N - the number of days in a month (0 < N <= 31), and then N integers - the air temperature.
Output: print the answer to the problem - three numbers separated by a space in order of increasing air temperature (if air temperature is equal, output in decreasing order of day numbers - only for days with the same air temperature)

Examples

# Input Output
1 7
3
3
6
3
4
3
4
7 5 3
 
 

ID 28325. The maximum number in the sequence
Темы: for loop   

Enter the number N and then N numbers, one per line
It is necessary to outpur the maximum number among all the numbers entered.

Input: 
in the first line the number N is entered - the number of numbers (N <= 100)
then one by one in the line there are N numbers (all numbers are integers not exceeding 10,000 in absolute value)

Output: 
output the maximum number of all N numbers.

Examples

Input Output
1 5
0
1
2
3
4
4

ID 28326. Minimum not all
Темы: for loop   

Given the integer N.
Next, N numbers are fed to the program input.
It is necessary to print the minimum even number among all N numbers.

Input:
in the first line the number N is entered - the integer (N <= 100)
then there are N numbers, one per line (all numbers are integers not exceeding 10,000 in absolute value)
Among N numbers, there is at least one even number

Output:
output the minimum even number among all N numbers

Примеры

Входные данные Выходные данные
1 5
-2
1
2
3
0
-2

ID 28327. Max and Min Number
Темы: for loop   

Given the number N.
N numbers are input.
It is necessary to display the position of the minimum and maximum numbers among all numbers.

Input:
in the first line the number N is entered - the number of numbers (N <= 100)
then there are N numbers, one per line (all numbers are integers not exceeding 10,000 in absolute value)

Output:
output two numbers with a space, first the position number of the minimum number, then after 1 space, the position number of the maximum number.

Example:
Input: 
5
-2
1
2
3
0
Output: 
1 4

With difficulties:
The theoretical card contains a hint.

ID 38193. Thaw
Темы: for loop   

Tired of an unusually warm winter, Muscovites decided to find out if this is indeed the longest thaw on record. They turned to weather forecasters, who, in turn, began to study the statistics for the past years. They are interested in how many days the longest thaw lasted.

They call a thaw a period in which the average daily temperature exceeds 0 degrees Celsius every day. Write a program to help weather forecasters in their work.

Input
First enter the number N – the total number of days considered (1 ≤ N ≤ 100). The next line contains N integers separated by spaces. Each number – average daily temperature on the corresponding day. Temperatures – integers belonging to the range from –50 to 50.

Imprint
It is required to display one number – the length of the longest thaw, that is, the largest number of consecutive days during which the average daily temperature exceeded 0 degrees. If the temperature on each day was non-positive, print 0.

Examples
# Input Output Explanation
1 6
-20 30 -40 50 10 -10
2 We are considering 6 days. The longest thaw was on the 4th and 5th days (50 and 10 degrees respectively)
2 8
10 20 30 1 -10 1 2 3
4 The longest thaw was in the first 4 days
3 5
-10 0 -10 0 -10
0 There were no days with a positive temperature

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 38217. Division with remainder
Темы: for loop   

Vasya is learning to divide with the remainder. He took some number, divided it by 2 and discarded the remainder. What happened, divided by 3 and again discarded the remainder. He divided the resulting number by 4, discarded the remainder and got the number K. What number could Vasya choose initially?

Input
Enter a natural number K not exceeding 1000 .

Imprint
Print all possible numbers that Vasya could have chosen initially, in ascending order, separating them with spaces.

Examples
# Input Output
1 1 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

ID 38247. The task of the Zen master
Темы: for loop   

After many years of meditation, one Zen monk realized that he was not really enlightened yet. Coming to the master, he asked how to achieve enlightenment. The master answered him, "Even the masters do not know this." When the monk questioned him in bewilderment, the master told him that there are people who seem enlightened, but in fact are stupid and do not understand anything about Zen. As an illustration of his words, he offered him the following problem.

A person can be represented as a table of size N × M filled with some integers. The sum of the numbers in the row of the table symbolizes how people see a person (the larger the sum, the more enlightened a person is considered in this area of ​​Zen). The sum of the numbers in the column symbolizes the person's real knowledge (the smaller it is, the less the person knows, and if the sum of the numbers is negative, then the person's ideas are false). It is necessary to fill the table with any integers so that the sum of the numbers in each row of the table is positive (that is, the person externally seemed to be absolutely enlightened), and the sum of the numbers in as many columns as possible was negative (that is, the person’s ideas about Zen were actually mostly false).

Help the Zen monk get closer to enlightenment and solve the problem proposed by the master.

Input
Enter the numbers N (1 ≤ N ≤ 100) and M (1 ≤ M ≤ 100) — the number of rows and columns in the table. Numbers are separated by spaces.

Imprint
First, print the maximum number of columns for the given table sizes, the sum of numbers in which is negative, and then print the table itself, filled accordingly. If there are several ways to fill in the table, print any of them. The numbers in the answer must not exceed 1000.

Examples
# Input Output
1 3 4 3
8 13 -40 21
-17 -4 18 12
6-10 13-5
2 3 5 4
1 2 3 4 5
5 4 3 2 1
-7 -8 -7 -8 40

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 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 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 38317. euphonious word
Темы: for loop    Strings   

All letters of the Latin alphabet are divided into vowels and consonants. The vowels are: a, e, i, o, u, y. The remaining letters are consonants.

A word is called euphonious if this word does not contain more than two consonants in a row and no more than two vowels in a row. For example, the words abba, mama, program — harmonious, and the words aaa, school, search — dissonant.

The word is entered. If this word is dissonant, then it is allowed to add any letters to any place in this word. Determine the minimum number of letters that can be added to this word to make it euphonious.

Input
A word is entered, consisting only of small Latin letters. The word length does not exceed 30 characters.

Imprint
Print the minimum number of letters that need to be added to this word to make it euphonious.
 

Examples
# Input Output Explanation
1 program 0 The word is already euphonious.
2 school 1 It is enough to add one vowel, for example, between the letters s   and c

ID 38327. Cheating
Темы: for loop   

On a test, N students sit in a row. For each student, it is known what grade he would have received if he had written this control independently (the grade — is a number from 2 to 5). However, students can write the control not only on their own, but also copy from their neighbor, but only if the neighbor writes the control on their own. In this case, the cheater will receive the same grade as the one from whom he cheated.

Namely (rules are applied strictly in the specified order):

  • Students who know the material at 5 will write the test on their own.
  • A student who knows the material at 4, if he sits next to someone who knows at 5, will copy from him, otherwise he will write on his own.
  • A student who knows 3, if he sits next to someone who knows 5, will cheat from him. If among his neighbors there is no one who knows for 5, but there is one who knows for 4, and at the same time writes on his own, then the C student will write off from him. Otherwise it will write itself.
  • Similarly, a schoolboy who knows 2 — from the neighbors who write on their own, he will choose the one who knows best, and write off from him. And if there are none (or both of his neighbors also know 2), then he will write on his own.
Decide who gets what grade.

Input
The number N (1<=N<=10) is entered - the number of students, and then a sequence of N numbers describing who can write a test for what grade if they write on their own.

Imprint
Output N numbers - grades that students will get for the test.
 
Examples
# Input Output Explanation
1 5
5
2
3
4
5
5
5
3
5
5
The first and fifth students will write on their own. The second will write off the first, and the fourth — at the fifth (as a result, they will also receive fives). The third person has no one to write off from, since his neighbors will not write the work on their own.
2 6
2
2
3
2
2
4
2
3
3
3
4
4
The second and fourth will be written off from the third, the fifth — at the sixth.

ID 38362. Fibonacci sequence
Темы: for loop   

A sequence of numbers a1, a2, …, ai,… is called Fibonacci if for all  ;i >= 3 true that a= ai– 1 + ai–2, that is, each member of the sequence (starting from the third) is equal to the sum of the two previous ones. It is clear that by setting different numbers a 1 and a2 we can get various such sequences, and any Fibonacci sequence is uniquely given by its two first terms.

Let's solve the reverse problem. You will be given a number N and two members of the sequence: aN and aN+1. You need to write a program that, given their values, will find a1 and a2.


Input
The number N and the values ​​of the two members of the sequence are entered: aN and aN+1 (1 <= <= 30, sequence members are integers, modulo not exceeding 100).
If you write in the Python programming language, then reading aN and aN+1 elements should be organized like this : 
x, y = map(int, input().split()).

Imprint
Print two numbers — the values ​​of the first and second members of this sequence.

Examples
# Input Output
1 4
3 5
1 1

ID 38490. We are packing our bags!
Темы: for loop   

Alena packs things for vacation. She can take hand luggage and luggage with her on the plane. For hand luggage, Alena has a backpack, and for luggage – huge suitcase.
According to the rules of transportation, the weight of hand luggage should not exceed S kg, and luggage can be of any weight (Alena is ready to pay extra for excess luggage). Of course,
the most valuable things – laptop, camera, documents, etc. – Alena wants to put in hand luggage.
Alena has arranged all her belongings in order of decreasing value and begins to put the most valuable things in her backpack. She acts as follows – takes
the most valuable item, and if its mass does not exceed S, then puts it in a backpack, otherwise puts it in a suitcase. She then takes the next highest value item, if possible
put in a backpack, that is, if its mass, together with the mass of things already put in a backpack, does not exceed S, then puts it in a backpack, otherwise in a suitcase, and in the same way the process
continues for all items in descending order of their value.
Determine the weight of the backpack and suitcase after Alyona folds everything.

The first line of the input contains the number S – the maximum allowed weight of the backpack. The second line of the input contains the number N – number of items.
The next N lines give the masses of the items, the items themselves are listed in descending order of value (the mass of the most valuable item is indicated first, then the mass of the second in
the value of the subject, etc.). All numbers are natural, the number S does not exceed 2x109, the sum of the weights of all objects also does not exceed 2x109. The value of N does not exceed 105.

The program should output two numbers – the weight of the backpack and the weight of the suitcase (the weight of an empty backpack and suitcase is not taken into account).

Examples
# Input Output Explanation
1 20
5
6
10
5
2
3
18 8 The maximum possible weight of the backpack is 20 kg. Given 5 items weighing 6, 10, 5, 2, 3.
First, an item with a weight of 6 is placed in the backpack, then an item with a weight of 10 is also placed in the backpack. Item
weighing 5 cannot be put in a backpack, because then the weight of the backpack will become 21 kg, so an item weighing 5
put in a suitcase. Then an item weighing 2 is placed in the backpack, and an item weighing 3 – in a suitcase. Weight
backpack 6 + 10 + 2 = 18, suitcase weight 5 + 3 = 8.

ID 38505. Candies and boxes
Темы: for loop    One-Dimensional Arrays    Bust   

N boxes are arranged in a row. Initially, the ith box on the left contains ai candies.  Gromozeka chooses a box containing at least one candy, and eats one of the candies in the selected box. He can perform this action any number of times. His goal is to ensure that any two adjacent boxes contain no more than x candies.
Find the minimum number of operations required to achieve Gromozeka's goal.

Input
The first line contains two numbers N (\(2<=N<=10^5\)) and x  ;(\(0<=x<=10^9\)).  The second line contains N integers a(\(0<=a_i<= 10^9\)).

Imprint
Output the answer to the problem.

 

Examples
# Input Output Explanations
1 3 3
2 2 2
1 You must eat one candy in the second box. Then the number of candies in each box will be (2,1,2).
2 6 1
1 6 1 2 0 4
11 For example, you can eat six candies in the second box, two in the fourth, and three in the sixth. Then the number of candies in each box will be (1,0,1,0,0,1).
3 5 9
3 1 4 1 5
0 Goal already reached
4 2 0
5 5
10 All candies must be eaten.

 

ID 38587. Diamond Turtles
Темы: Simple puzzles    for loop   

Funny Wu likes to give diamond turtles as gifts. He has turtles in his bag in either three colors: pink, white and green, or four colors: pink, white, green and yellow. He gave the turtles one by one from the bag, the color of the ith turtle was Si. The colors are presented as follows: -pink, W- white, G -green, < code>Y - yellow. If there were three colors of turtles in the bag, print Three; if there were four colors, print Four

Input
The first line contains the number N (\(1<=N<=100\)) - the number of Turtles that Veselchak U. Vo took out the second line contains N characters Si - the colors of the turtles taken out. Each character Si is equal to P, W, G  or Y. There are always i, j and k such that Si = &# 39;P', Sj = 'W' and Sk = 'G'.

Imprint
If there were three colors of turtles in the bag, print Three; if there were four colors, print Four

 

Examples
# Input Output
1 6
G W Y P Y W
Four
2 9
G W W G P W P G G
Three
3 8
P Y W G Y W Y Y
Four

ID 38592. Snow cover
Темы: for loop    Cycles   

In some village there are 999 towers 1, (1 + 2), (1 + 2 + 3), ..., (1 + 2 + 3 + ... + 999) meters high from west to east. The distance between two adjacent towers is 1 meter. It snowed for a while before it finally stopped. For two neighboring towers located 1 meter apart, we measured the lengths of the parts of these towers that are not covered with snow and got a meters for the west tower and b meters for the east tower. Assuming that the thickness of the snow cover and the height above sea level are the same in the entire settlement, find the total depth of the snow cover. Let's also assume that the depth of the snow cover is always at least 1 meter.

Input
The input string contains two integers a and b (\(1\leq a<b<499500=1+2+3+...+999\)) . All input data satisfies the condition of the problem.

Imprint
Print the depth of the snow cover.
 

 

Examples
# Input Output Explanation
1 8 13 2 The two towers are 10 meters and 15 meters respectively. Thus, we see that the depth of the snow cover is 2 meters.
2 54 65 1  

 

ID 38687. Sum of squares
Темы: for loop   

Given a positive integer n, compute the sum \(1^2+2^2+...+n^2\).

Input
A single natural number n is entered, not exceeding 100.

Imprint
You need to display  the calculated amount.


Examples
# Input Output
1 2 5

ID 38711. Running to Steklyashkin
Темы: while loop    for loop   

After the beetle flew into Dunno and hit him on the head, Dunno gathered N of the Flower City shorties around him and said, "And now, brothers, the sun broke a piece and flies straight to us. Soon it will fall and crush us all. Horror what will happen! Go ask Steklyashkin." All the little ones knew that Dunno was a talker, but nevertheless they decided to run faster to Steklyashkin and find out the truth. Steklyashkin lives on the same street, so the shorties had to run in one straight line. After 10 seconds, each shorty ran away from Dunno at a distance of a. Determine the maximum  the distance between any two shorts who ran to Steklyashkin. 

Input
The first line contains an integer N (1<=N<=100). The second line contains N numbers ai (1<=ai<=109 ) - the distance that the i-th shorty ran away from Dunno.

Imprint
Print the maximum  the distance between any two shorts who ran towards Steklyashkin.
 

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

ID 38714. The difference in the number of candies
Темы: while loop    for loop   

You have N bags of candy. There are some candies in each bag of . Determine the maximum difference between the number of candies of any two bags.

Input
The first line contains an integer N (1<=N<=100). The second line contains N numbers ai (1<=ai<=109 ) - number of candies in  i-th bag.

Imprint
Print the maximum difference between the number of candies of any two bags.
 

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

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 38733. Number of divisors
Темы: Prime numbers and factorization    for loop   

Count the number of natural divisors of x (including 1 and the number itself; x2109).

Input
A natural number x is entered.

Imprint
Print a single number - the number of divisors of x.
 

Examples
# Input Output
1 32 6

ID 38738. counting numbers
Темы: for loop   

Count how many of the given N numbers are zeros, positive numbers, negative numbers.

Input
The number N is entered, followed by N integers.

Imprint
You must print the number of zeros first, then the number of positive and negative numbers.

 

Examples
# Input Output
1 5
28
0
0
0
0
4 1 0

ID 38929. Snezhik Sugrobovich - 1
Темы: for loop   

In some world, it's December 31st. N Christmas trees are growing in Father Frost's garden. Snezhik Sugrobovich decided to decorate the Christmas trees with a garland. To make the light from the garland visible as far as possible, he fixed the garland on top of the three tallest Christmas trees. Determine the total height to which Snezhik Sugrobovich will rise, hanging a garland.

Input
The first line contains the number N - the number of trees (4 < N <= 100), and then N integers - the height of each tree.

Imprint
Output the answer to the problem.


Examples
# Input Output
1 7
3
3
6
3
4
3
4
14
 
 

ID 38932. Increasing sequence
Темы: for loop   

Given a natural number N - the number of numbers that are input. Determine if the input numbers form an ascending sequence.

Input
The first line contains a natural number N (N<105). The following N lines contain numbers, one per line. Each number does not exceed 109.

Imprint
Print YES if the numbers form an ascending sequence, otherwise print NO.
 

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

ID 38931. How many numbers are greater than the previous
Темы: for loop   

Given a natural number N - the number of numbers that are input. Determine how many numbers are greater than the previous entered number.

Input
The first line contains a natural number N (N<105). The following N lines contain numbers, one per line. Each number does not exceed 109.

Imprint
Display the answer to the problem.
 

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

ID 38933. Alternating sequence
Темы: for loop   

Given a natural number N - the number of numbers that are input. Determine if the input numbers form an alternating sequence.

Input
The first line contains a natural number N (N<105). The following N lines contain non-zero numbers, one per line. Each number does not exceed 109.

Imprint
Print YES if the numbers form an alternating sequence, otherwise print NO.
 

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

ID 38934. Pairs of numbers with a sum divisible by 3
Темы: for loop   

Given a natural number N - the number of numbers that are input. A pair is any 2 numbers that are entered  successively one after another. Determine the number of pairs of numbers whose sum is a multiple of 3.

Input
The first line contains a natural number N (N<105). The following N lines contain numbers, one per line. Each number does not exceed 109.

Imprint
Display one number on the screen - the answer to the problem. 
 

Examples
# Input Output
1 5
4
2
6
5
4
2

ID 38935. Triplets of numbers - 1
Темы: for loop   

Given a natural number N - the number of numbers that are input. A triple is any 3 numbers that are entered  successively one after another. Determine the number of triples of numbers for which the sum of the first two numbers from the given triple is equal to the third number in the given triple.

Input
The first line contains a natural number N (N<105). The following N lines contain numbers, one per line. Each number does not exceed 109.

Imprint
Display one number on the screen - the answer to the problem. 
 

Examples
# Input Output
1 5
1
2
3
5
8
3
 
 

ID 38936. Triplets of numbers - 2
Темы: for loop   

Given a natural number N - the number of numbers that are input. A triple is any 3 numbers that are entered  successively one after another. Determine the number of triples of numbers in which the second number from the triple is greater than the first and third numbers from the given triple.

Input
The first line contains a natural number N (N<105). The following N lines contain numbers, one per line. Each number does not exceed 109.

Imprint
Display one number on the screen - the answer to the problem. 
 

Examples
# Input Output
1 5
1
2
1
9
8
2
 
 

ID 38937. Pair with the highest amount
Темы: for loop   

Given a natural number N - the number of numbers that are input. A pair is any 2 numbers that are entered  successively one after another. Find a pair of numbers with a maximum sum. 

Input
The first line contains a natural number N (N<105). The following N lines contain numbers, one per line. Each number does not exceed 109.

Imprint
Print two space-separated numbers on the screen in one line - a pair of numbers with the maximum sum. The numbers must be output in the same order they were entered. 

Examples
# Input Output
1 5
12
13
20
-12
-1
13 20
 
 

ID 39017. Algorithm Analysis - 01
Темы: for loop   

At what minimum natural number n, the program will display two numbers on the screen, such that the first is even, the second is odd.
 

Python
s = 0
k = 0
for j in range(14, n):
    k += j // 10% 10
    s += j % 10
print(k, s)

ID 39018. Algorithm Analysis - 02
Темы: for loop   

At what minimum natural number n, the program will display the string 6 13.
 

Python
s = 0
k = 0
for j in range(125, n):
    k += j // 100% 10
    s += j // 10% 10
print(k, s)

ID 39019. Algorithm Analysis - 03
Темы: for loop   

At what minimum natural number n, the program will display the string 16 23.
 

Python
s = 0
k = 0
for j in range(1111, n):
    k += j // 100% 10
    s += j // 10% 10
print(k, s)

ID 39020. Algorithm analysis - 04
Темы: for loop   

At what minimum natural number n, the program will display the string 10 90.
 

Python
s = 0
k = 0
for j in range(1000, n):
    k += j % 1000 // 10
    s += j % 10
print(k, s)

ID 39021. Algorithm analysis - 05
Темы: for loop   

At what minimum natural number n, the program will display the string 34 26.
 

Python
s = 0
k = 0
for j in range(2225, n):
    k += j % 100 // 10
    s += j // 1000% 10
print(k, s)

ID 39061. Processing of entered numbers - 7
Темы: for loop   

Given some numbers. Count how many of them are equal to zero and output this number.


Input 
The number N is entered first, then exactly N integers are entered.

Imprint
Print the answer to the problem.
 
Examples
# Input Output
1 5
0
7
0
2
2
2

ID 39166. Algorithm analysis - 06
Темы: for loop   

At what minimum natural odd number n, the program will display the number 17
 

Python
s = 0
k = 0
for i in range(2000, n):
    if i // 10% 10 < i % 10:
        k += 1
print(k) 

ID 39167. Algorithm analysis - 07
Темы: for loop   

What is the minimum natural odd number n for which the program will display the number 3
 

Python
s = 0
k = 0
for i in range (2461, n, 10):
    if i % 100 // 10 > i // 100% 10:
        k += 1
print(k) 

ID 39168. Algorithm analysis - 08
Темы: for loop   

What is the minimum natural odd number n for which the program will display the number 3?
 

Python
s = 0
k = 0
for i in range (5600, n, 10):
    if i % 10 <= i // 100 % 10:
        k += 1
print(k) 

ID 39516. Mad scientist
Темы: One-Dimensional Arrays    for loop   

Farmer John ordered N of his cows (1 & le; N & le; 1000), each of which has one of two breeds Holsteins or Guernseys. He fixed this order as a string of N characters, each of which is either H or G respectively. Unfortunately, when the cows arrived at the farm and he lined them up again, they formed a different line from the original.

Let's call these two strings A and B, where A is the original string he wanted to see, B is the string that came out when the cows arrived. FD asked Cousin Ben for help.

After several months of work, Ben has created an amazing MCBF-3000 machine that can take any substring and change all Gs to Hs and all Hs to Gs. A. Help FD.

Input
The first line contains N, and the next two lines contain strings A and B. Each of the strings consists only of characters H and G.
Imprint
Print the minimum number of times the MCBF-3000 machine is used to transform string B into string A.

Examples
# Input Output
1
7
GHHHGHH
HHGGGHH
2

ID 38688. Number of combinations
Темы: Dynamic Table Programming    for loop   

Given natural n and k compute the value of \(C^k_n = {n! \over k!(n-k)!} \) (number of combinations of n elements by k).

Input
2 numbers are entered - n and k (n, k ≤ 30 ).

Imprint
You need to output  value \(C^k_n\) (integer).
 

Examples
# Input Output
1 2
1
2

ID 42967. Vasina arithmetic
Темы: for loop   

Vasya writes an integer n on the board. Next, with the number written on the board, he performs the following operation:

  • if the last digit of the number is not equal to zero, then Vasya divides the number by this last digit and discards the fractional part (in this case, Vasya erases the old number from the board and writes a new one on the board);
  • if the last digit of the number is zero, then it erases it.
What number will be written on the board after performing this operation k times?


Input
The first line of the input contains two integers n and k (2 <= n <= 109, 1 <= k <= 50) - the number that Vasya initially wrote on the board and the number of execution of the described operation.

Imprint
It is necessary to output one number - the answer to the problem.
 
 
Examples
# Input Output
1 512 4 21
2 10000 5  1

ID 42968. Vasina arithmetic - 2
Темы: for loop   

Vasya writes an integer n on the board. Next, with the number written on the board, he performs the following operation:

  • if the last digit of the number is not equal to zero, then Vasya erases the old number and writes on the board a new number equal to the minimum integer nbsp;nbsp;which is not less than the quotient of dividing the old number by the last digit of this number;< /li>
  • if the last digit of the number is zero, then it erases it.
What number will be written on the board after performing this operation k times?


Input
The first line of the input contains two integers n and k (2 <= n <= 109, 1 <= k <= 50) - the number that Vasya initially wrote on the board and the number of execution of the described operation.

Imprint
It is necessary to output one number - the answer to the problem.
 
 
Examples
# Input Output
1 512 4 3
2 10000 5  1

ID 43474. Gromozeka and valerian
Темы: for loop    Cycles    Simple puzzles    Implementation task   

Gromozeka loves valerian very much. On his home planet Chumaroza you can buy for k chumriks (local currency) the first package of valerian, for 2·k chumriks -  the second and so on (in other words, ith packing you have to pay i·k chumrikov). Gromozek wants to buy  w packages of valerian.  He has n chumriks. How many chumriks will he have to take on credit from the chumaroz bank in order to buy w packages of valerian?


Input

The first line contains three positive integers k, n, w (1  <=  k, w< /code>  <=  1000, 0 <= n <= 109) , the cost of the first package, Gromozeka's initial number of chumaroziki and the number of packages of valerian he wants to buy.


Output

Print a single integer - the number of chumaroziks that Gromozeka needs to borrow from the bank. If you don't need to take a loan, print 0.

 
Examples
# Input Output
1 3 17 4 13

ID 43658. Output the sequence
Темы: for loop   

Given two numbers n and m (n <= m). Write a program that prints all numbers between n and m inclusive, prefixing each number with the word number.

Input
The program receives as input two numbers n and m (n <= m), each number in on a separate line.

Imprint
Print all numbers from n to m, one number per line, prefixing each number with the word number
 
 

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

ID 43660. Output sequence - 2
Темы: for loop   

Given two numbers n and m (n >= m). Write a program that prints all numbers from n to m inclusive, in increments of -3.

Input
The program receives as input two numbers n and m (n >= m), each number in on a separate line.

Imprint
Output all numbers from the range from n to m. Print each number on a separate line.
 
 

Examples
# Input Output
1
10
1
10
7
4
1

ID 43661. wonderful numbers 9
Темы: for loop   

Two natural numbers n and (n <= m) are given. Write a program that prints all numbers from n to m inclusive, satisfying at least one of the following conditions:

  • number is a multiple of 19;
  • number ends in 10;
  • the number is a multiple of 2 and 3 at the same time;
  • two-digit number.

Input
Two natural numbers n and (n <= m) are entered. Each number is written on a separate line.

Imprint
Print the answer to the problem.
 
Examples
# Input Output
1 95
110
95
96
97
98
99
102
108
110