## 努力过

1981317307@qq.com 期待成为朋友~

# Educational Codeforces Round 39 (Rated for Div. 2)

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

You are given a sequence a consisting of n integers. You may partition this sequence into two sequences b and c in such a way that every element belongs exactly to one of these sequences.

Let B be the sum of elements belonging to b, and C be the sum of elements belonging to c (if some of these sequences is empty, then its sum is 0). What is the maximum possible value of B - C?

Input

The first line contains one integer n (1 ≤ n ≤ 100) — the number of elements in a.

The second line contains n integers a1, a2, ..., an ( - 100 ≤ ai ≤ 100) — the elements of sequence a.

Output

Print the maximum possible value of B - C, where B is the sum of elements of sequence b, and C is the sum of elements of sequence c.

Examples
Input
Copy
3
1 -2 0

Output
Copy
3

Input
Copy
6
16 23 16 15 42 8

Output
Copy
120

Note

In the first example we may choose b = {1, 0}, c = { - 2}. Then B = 1, C =  - 2, B - C = 3.

In the second example we choose b = {16, 23, 16, 15, 42, 8}, c = {} (an empty sequence). Then B = 120, C = 0, B - C = 120.

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int maxn = 110;
int vis[maxn];

int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i = 1; i <= n; i ++)
scanf("%d",&vis[i]);
sort(vis+1,vis+1+n);
int sum1 = 0;
int sum2 = 0;
for(int i = 1; i <= n;i ++)
{
if(vis[i] <= 0)
sum1 += vis[i];
else
sum2 += vis[i];
}
printf("%d\n",sum2-sum1);
}
return 0;
}

B. Weird Subtraction Process
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have two variables a and b. Consider the following sequence of actions performed with these variables:

1. If a = 0 or b = 0, end the process. Otherwise, go to step 2;
2. If a ≥ 2·b, then set the value of a to a - 2·b, and repeat step 1. Otherwise, go to step 3;
3. If b ≥ 2·a, then set the value of b to b - 2·a, and repeat step 1. Otherwise, end the process.

Initially the values of a and b are positive integers, and so the process will be finite.

You have to determine the values of a and b after the process ends.

Input

The only line of the input contains two integers n and m (1 ≤ n, m ≤ 1018). n is the initial value of variable a, and m is the initial value of variable b.

Output

Print two integers — the values of a and b after the end of the process.

Examples
Input
Copy
12 5

Output
Copy
0 1

Input
Copy
31 12

Output
Copy
7 12

Note

Explanations to the samples:

1. a = 12, b = 5 a = 2, b = 5 a = 2, b = 1 a = 0, b = 1;
2. a = 31, b = 12 a = 7, b = 12.

#include<stdio.h>

int main()
{
long long a,b;
while(scanf("%lld%lld",&a,&b)!=EOF)
{
int flag = 1;
while(a&&b)
{
if(a>=2*b)
a = a%(2*b);
else if( b >= 2*a)
b = b%(2*a);
else
break;
}
printf("%lld %lld\n",a,b);
}
return 0;
}

C. String Transformation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a string s consisting of |s| small english letters.

In one move you can replace any character of this string to the next character in alphabetical order (a will be replaced with b, s will be replaced with t, etc.). You cannot replace letter z with any other letter.

Your target is to make some number of moves (not necessary minimal) to get string abcdefghijklmnopqrstuvwxyz (english alphabet) as a subsequence. Subsequence of the string is the string that is obtained by deleting characters at some positions. You need to print the string that will be obtained from the given string and will be contain english alphabet as a subsequence or say that it is impossible.

Input

The only one line of the input consisting of the string s consisting of |s| (1 ≤ |s| ≤ 105) small english letters.

Output

If you can get a string that can be obtained from the given string and will contain english alphabet as a subsequence, print it. Otherwise print «-1» (without quotes).

Examples
Input
Copy
aacceeggiikkmmooqqssuuwwyy

Output
Copy
abcdefghijklmnopqrstuvwxyz

Input
Copy
thereisnoanswer

Output
Copy
-1


#include<stdio.h>
#include<string.h>
const int maxn = 100010;
char vis[maxn];
char str[26] ;
int main()
{
while(scanf("%s",vis)!=EOF)
{
char ch = 'a';
for(int i = 0;vis[i]!='\0';i++)
{
if(ch == 'z'+1)
break;
if(vis[i] <= ch)
vis[i] = ch ++;
}

if(ch == 'z'+1)
printf("%s\n",vis);
else
printf("-1\n");
}
return 0;
}

01-13 583

06-28 99

04-05 194

06-28 45

05-22 120

06-21 21

07-15 71

04-12 104

05-22 16

05-22 101