Codeforces Round 654 (Div. 2)


A. Magical Sticks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
2
3
4
Output
1
1
2
2
----------------------------------------------------------------------------------------------------
B. Magical Calendar
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3 4
3 2
3 1
13 7
1010000 9999999
Output
4
3
1
28
510049495001
----------------------------------------------------------------------------------------------------
C. A Cookie for You
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 2 1 2
0 100 0 1
12 13 25 1
27 83 14 25
0 0 1 0
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
Output
Yes
No
No
Yes
No
Yes
----------------------------------------------------------------------------------------------------
D. Grid-00100
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 2
3 8
1 0
4 16
Output
0
10
01
2
111
111
101
0
0
0
1111
1111
1111
1111
----------------------------------------------------------------------------------------------------
E1. Asterism (Easy Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
3 4 5
Output
1
3
Input
4 3
2 3 5 6
Output
2
3 4
Input
4 3
9 1 1 1
Output
0
----------------------------------------------------------------------------------------------------
E2. Asterism (Hard Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
3 4 5
Output
1
3
Input
4 3
2 3 5 6
Output
2
3 4
Input
4 3
9 1 1 1
Output
0
Input
3 2
1000000000 1 999999999
Output
1
999999998
----------------------------------------------------------------------------------------------------
F. Raging Thunder
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 6
><>><
2 4
3 5
1 5
1 3
2 4
1 5
Output
3
3
5
3
2
3
----------------------------------------------------------------------------------------------------
