Codeforces Round 579 (Div. 3)


A. Circle of Students
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
1 2 3 4
3
1 3 2
5
1 2 3 5 4
1
1
5
3 2 1 5 4
Output
YES
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
B. Equal Rectangles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
1 1 10 10
2
10 5 2 10 1 1 2 5
2
10 5 1 10 5 1 1 1
2
1 1 1 1 1 1 1 1
1
10000 10000 10000 10000
Output
YES
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
C. Common Divisors
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
1
Input
6
6 90 12 18 30 18
Output
4
----------------------------------------------------------------------------------------------------
D1. Remove the Substring (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
bbaba
bb
Output
3
Input
baaba
ab
Output
2
Input
abcde
abcde
Output
0
Input
asdfasdf
fasd
Output
3
----------------------------------------------------------------------------------------------------
D2. Remove the Substring (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
bbaba
bb
Output
3
Input
baaba
ab
Output
2
Input
abcde
abcde
Output
0
Input
asdfasdf
fasd
Output
3
----------------------------------------------------------------------------------------------------
E. Boxers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2 4 1
Output
4
Input
6
1 1 1 4 4 4
Output
5
----------------------------------------------------------------------------------------------------
F1. Complete the Projects (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
4 6
10 -2
8 -1
Output
YES
Input
3 5
4 -5
4 -2
1 3
Output
YES
Input
4 4
5 2
5 -3
2 1
4 -2
Output
YES
Input
3 10
10 0
10 -10
30 0
Output
NO
----------------------------------------------------------------------------------------------------
F2. Complete the Projects (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
4 6
10 -2
8 -1
Output
3
Input
5 20
45 -6
34 -15
10 34
1 27
40 -45
Output
5
Input
3 2
300 -300
1 299
1 123
Output
3
----------------------------------------------------------------------------------------------------
