Codeforces Round 639 (Div. 2)


A. Puzzle Pieces
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 3
100000 100000
2 2
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Card Constructions
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
3
14
15
24
1
Output
1
2
1
3
0
----------------------------------------------------------------------------------------------------
C. Hilbert's Hotel
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
1
14
2
1 -1
4
5 5 5 1
3
3 2 1
2
0 1
5
-239 -2 -100 -3 -11
Output
YES
YES
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
D. Monopole Magnets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
.#.
###
##.
Output
1
Input
4 2
##
.#
.#
##
Output
-1
Input
4 5
....#
####.
.###.
.#...
Output
2
Input
2 1
.
#
Output
-1
Input
3 5
.....
.....
.....
Output
0
----------------------------------------------------------------------------------------------------
E. Quantifier Question
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
1 2
Output
1
AE
Input
4 3
1 2
2 3
3 1
Output
-1
Input
3 2
1 3
2 3
Output
2
AAE
----------------------------------------------------------------------------------------------------
F. Résumé Review
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 32
1 2 3 4 5 5 5 5 5 5
Output
1 2 3 3 3 4 4 4 4 4 
Input
5 8
4 4 8 2 1
Output
2 2 2 1 1 
----------------------------------------------------------------------------------------------------
