Harbour.Space Scholarship Contest 2021-2022 (open for everyone, rated, Div. 1 + Div. 2)


A. Digits Sum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
9
10
34
880055535
Output
0
1
1
3
88005553
----------------------------------------------------------------------------------------------------
B. Reverse String
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
abcdef
cdedcb
aaa
aaaaa
aab
baaa
ab
b
abcdef
abcdef
ba
baa
Output
YES
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
C. Penalty
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1?0???1001
1111111111
??????????
0100000000
Output
7
10
6
9
----------------------------------------------------------------------------------------------------
D. Backspace
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
ababa
ba
ababa
bb
aaa
aaaa
aababa
ababa
Output
YES
NO
NO
YES
----------------------------------------------------------------------------------------------------
E. Permutation Shift
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4 1
2 3 1 4
3 1
1 2 3
3 1
3 2 1
6 0
1 2 3 4 6 5
Output
1 3
1 0
3 0 1 2
0
----------------------------------------------------------------------------------------------------
F. Pairwise Modulo
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6 2 7 3
Output
0 2 12 22
Input
3
3 2 1
Output
0 3 5
----------------------------------------------------------------------------------------------------
G. Common Divisor Graph
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
2 10 3
1 2
1 3
2 3
Output
0
1
1
Input
5 12
3 8 7 6 25
1 2
1 3
1 4
1 5
2 1
2 3
2 4
2 5
3 1
3 2
3 4
3 5
Output
0
1
0
1
0
1
0
1
1
1
1
2
----------------------------------------------------------------------------------------------------
H. XOR and Distance
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3
6 0 3
Output
3 1 1 2 2 1 1 3 
Input
3 4
13 4 2
Output
2 2 6 6 3 1 2 2 2 2 1 3 6 6 2 2 
----------------------------------------------------------------------------------------------------
I. Stairs
time limit per test: 10 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
6
3 3 3 1 1 1
Output
6
Input
7
4 4 4 4 3 3 3
Output
6
Input
1
1
Output
1
Input
8
2 2 2 2 2 2 1 1
Output
370
Input
4
3 2 3 1
Output
0
----------------------------------------------------------------------------------------------------
