Codeforces Round 276 (Div. 1)


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

Examples
Input
3
1 2
2 4
1 10
Output
1
3
7
----------------------------------------------------------------------------------------------------
B. Maximum Value
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 4 5
Output
2
----------------------------------------------------------------------------------------------------
C. Strange Sorting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
qwerty
3
4 2
6 3
5 2
Output
qertwy
qtewry
qetyrw
----------------------------------------------------------------------------------------------------
D. Kindergarten
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 1 2
Output
3
Input
3
3 3 3
Output
0
----------------------------------------------------------------------------------------------------
E. Sign on Fence
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 2 3 3
3
2 5 3
2 5 2
1 5 5
Output
2
3
1
----------------------------------------------------------------------------------------------------
