Hello 2018


A. Modular Exponentiation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
42
Output
10
Input
1
58
Output
0
Input
98765432
23456789
Output
23456789
----------------------------------------------------------------------------------------------------
B. Christmas Spruce
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
1
1
Output
Yes
Input
7
1
1
1
2
2
2
Output
No
Input
8
1
1
1
1
3
3
3
Output
Yes
----------------------------------------------------------------------------------------------------
C. Party Lemonade
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 12
20 30 70 90
Output
150
Input
4 3
10000 1000 100 10
Output
10
Input
4 3
10 100 1000 10000
Output
30
Input
5 787787787
123456789 234567890 345678901 456789012 987654321
Output
44981600785557577
----------------------------------------------------------------------------------------------------
D. Too Easy Problems
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 300
3 100
4 150
4 80
2 90
2 300
Output
2
3
3 1 4
Input
2 100
1 787
2 788
Output
0
0
Input
2 100
2 42
2 58
Output
2
2
1 2
----------------------------------------------------------------------------------------------------
E. Logical Expression
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
00110011
00000111
11110000
00011111
Output
y
(y|z)&x
!x
x|y&z
----------------------------------------------------------------------------------------------------
F. Strongly Connected Tournament
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2
Output
4
Input
3
4 6
Output
142606340
Input
4
1 2
Output
598946623
----------------------------------------------------------------------------------------------------
G. Power Substring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
8
2
Output
3
1
Input
2
3
4857
Output
5
20
----------------------------------------------------------------------------------------------------
H. Don't Exceed
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1.00
2
3.000000
4.0
Output
1
Input
1
0.50216
Output
342677322
Input
2
0.5
1.0
Output
623902721
Input
6
0.77
1.234567
2.1
1.890
2.9999
3.77
Output
859831967
----------------------------------------------------------------------------------------------------
