Educational Codeforces Round 51 (Rated for Div. 2)


A. Vasya And Password
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
abcDCE
htQw27
Output
abcD4E
htQw27
----------------------------------------------------------------------------------------------------
B. Relatively Prime Pairs
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 8
Output
YES
2 7
4 1
3 8
6 5
----------------------------------------------------------------------------------------------------
C. Vasya and Multisets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 5 7 1
Output
YES
BABA
Input
3
3 5 1
Output
NO
----------------------------------------------------------------------------------------------------
D. Bicolorings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
Output
12
Input
4 1
Output
2
Input
1 2
Output
2
----------------------------------------------------------------------------------------------------
E. Vasya and Big Integers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
135
1
15
Output
2
Input
10000
0
9
Output
1
----------------------------------------------------------------------------------------------------
F. The Shortest Statement
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 2 3
2 3 1
3 1 5
3
1 2
1 3
2 3
Output
3
4
1
Input
8 13
1 2 4
2 3 6
3 4 1
4 5 12
5 6 3
6 7 8
7 8 7
1 4 1
1 8 3
2 6 9
2 7 1
4 6 3
6 8 2
8
1 5
1 7
2 3
2 8
3 7
3 4
6 8
7 8
Output
7
5
6
7
7
1
2
7
----------------------------------------------------------------------------------------------------
G. Distinctification
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1
3 3
5 5
4 2
2 4
Output
0
0
0
-5
-16
Input
4
2 4
2 3
2 2
1 1
Output
0
3
7
1
----------------------------------------------------------------------------------------------------
