var
  n,i,j:longint;
  a:array[0..200001] of int64;
  s:int64;
begin
  readln(n);
  for i:=1 to n do read(a[i]);
  for i:=1 to n-1 do
    for j:=i+1 to n do
      s:=(s+a[i]*a[j]) mod 1000000007;
  writeln(s mod 1000000007);
end.

Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.

Score : 300 points

Problem Statement

Given are N integers A_1,\ldots,A_N.

Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).

Constraints

2 \leq N \leq 2\times 10^5

0 \leq A_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

Print \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j, modulo (10^9+7).

Sample Input 1

3
1 2 3

Sample Output 1

11

We have 1 \times 2 + 1 \times 3 + 2 \times 3 = 11.

Sample Input 2

4
141421356 17320508 22360679 244949

Sample Output 2

437235829

Submitted source-code file size, in bytes.

Execution CPU time reported by official Project CodeNet metadata, in milliseconds.

Peak memory usage reported by official Project CodeNet metadata, in kilobytes.


var
    N, A, i: Integer;
    cnt: array[1..1000000] of Integer;
begin
    read(N);
    for i := 1 to N do
    begin
        read(A);
        inc(cnt[A]);
    end;
end.

Score : 500 points

Problem Statement

We have N integers. The i-th number is A_i.

\{A_i\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N.

\{A_i\} is said to be setwise coprime when \{A_i\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1.

Determine if \{A_i\} is pairwise coprime, setwise coprime, or neither.

Here, GCD(\ldots) denotes greatest common divisor.

Constraints

2 \leq N \leq 10^6

1 \leq A_i\leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

If \{A_i\} is pairwise coprime, print pairwise coprime; if \{A_i\} is setwise coprime, print setwise coprime; if neither, print not coprime.

Sample Input 1

3
3 4 5

Sample Output 1

pairwise coprime

GCD(3,4)=GCD(3,5)=GCD(4,5)=1, so they are pairwise coprime.

Sample Input 2

3
6 10 15

Sample Output 2

setwise coprime

Since GCD(6,10)=2, they are not pairwise coprime. However, since GCD(6,10,15)=1, they are setwise coprime.

Sample Input 3

3
6 10 16

Sample Output 3

not coprime

GCD(6,10,16)=2, so they are neither pairwise coprime nor setwise coprime.


program main;
var n,a : integer;
begin
	readln(n);
    a := 1000;
    while (a < n) do begin
    	a := a + 1000;
    end;
    writeln(a - n);
end.

Score : 100 points

Problem Statement

We will buy a product for N yen (the currency of Japan) at a shop.

If we use only 1000-yen bills to pay the price, how much change will we receive?

Assume we use the minimum number of bills required.

Constraints

1 \leq N \leq 10000

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the amount of change as an integer.

Sample Input 1

1900

Sample Output 1

100

We will use two 1000-yen bills to pay the price and receive 100 yen in change.

Sample Input 2

3000

Sample Output 2

0

We can pay the exact price.


program main;
var n,a : integer;
begin
	readln(n);
    a := 1000;
    if(a < n) then begin
    	a := a + 1000;
    end;
    writeln(a - n);
end.


program main;
var n,a : integer;
begin
	readln(n);
    a := 1000;
    if(a < n) then begin
    	a := a + 1000;
    end;
    writeln(a mod n);
end.


program main;
var n : integer;
begin
	readln(n);
    writeln(n mod 1000);
end.


program main;
var a: integer;

begin
    readln(a);
    writeln((1000 - a mod 1000) mod 1000);
end.


program payment;
var
    n : longint;
begin
    readln(n);
    if n < 1000 then
        writeln(1000 - n)
    else if n mod 1000 <> 0 then
        writeln(1000 - n mod 1000)
            else writeln(0);
end.


program payment;
var
    n : longint;
begin
    readln(n);
    if n < 1000 then
        writeln(1000 - n)
    else
        writeln(1000 - n mod 1000);
end.


var n:integer;begin readln(n);writeln((1000-(n mod 1000)) mod 1000);end.


program main;
var n,m : integer;
begin
  readln(n);
  m := n mod 1000;
  if (m = 0) then writeln(m)
    else writeln(1000-m);
end.


program main;
var
   a : integer;
begin
    readln(a);
    if a < 1000 then
        writeln(1000-a)
    else
        begin
            while ( a > 1000 ) do
                dec(a,1000);
            if a = 0 then
                writeln('0')
            else
                writeln(1000-a);
        end;
end.


program main;
var
   a : integer;
begin
    readln(a);
    while ( a > 1000 ) do
        dec(a,1000);
    if a = 0 then
        writeln('0')
    else
        if a > 1000 then
            writeln(1000 - a)
        else if a < 1000 then
            writeln(a);
end.


program main;
var
   a : integer;
begin
    readln(a);
    repeat
        dec(a,1000);
    until (a < 1000);
    if a = 0 then
        writeln('0')
    else
        writeln(1000 - a);
end.


program main;
var N,i,x,y:integer;
begin
    readln(N);
    i:=0; x:=1000; y:=1;
    if N mod 1000 = 0 then writeln('0')
    else begin
    while x<N do begin
    y:=y+1; x:=x+1000;
    end;
    writeln(y*1000-N);
end;
end.


program main;
var N , a , b ,c , final , initial , k ,amount:integer;
  begin
   readln(N);
if N=1000 then writeln(0);

if N<>1000 then begin

final:=N mod 1000 ;
   writeln(1000-final);

   end;

     end.


program main;
var N , a , b ,c , final , initial , k ,amount:integer;
  begin
     readln(N);
     initial:=1000;
     k:=1;
     while initial<N do
     begin
     k:=k+1;
     initial:=initial*k;
     end;

     final:=initial-N;
     writeln(final);
     end.


program main;
var N , a , b ,c , final , initial , k ,amount:integer;
  begin
     readln(N);
     amount:=N;
     initial:=1000;
     k:=1;
     while initial<amount do
     begin
     k:=k+1;
     initial:=initial*k;
     end;

     final:=initial-amount;
     writeln(final);
     end.


program main;
var N , a , b ,c , final , initial , k ,amount:integer;
  begin
     readln(N);
     N:=amount;
     initial:=1000;
     k:=1;
     while initial<amount do
     begin
     k:=k+1;
     initial:=initial*k;
     end;

     final:=initial-amount;
     writeln(final);
     end.


program hi;
var n: integer;

begin
    readln(n);
    writeln((1000 - n mod 1000) mod 1000);
end.


program hi;
var n: integer;

begin
    readln(n);
    writeln((1000 - n div 1000) div 1000);
end.


program main;
var n : integer;

begin
  readln(n);
  if n mod 1000 = 0 then
     writeln(n mod 1000)
  else
     writeln((n div 1000 + 1) * 1000 - n);
end.


program main;
var
    target : integer;
begin
    readln(target);
    target := target mod 1000;
    if target = 0
        then writeln(0)
        else writeln(1000-target);
end.


program main;
var
    n : integer;

begin
    readln(n);

    writeln((1000 - (n mod 1000)) mod 1000);
end.


program main;
var input : integer;
begin
	readln(input);
	while(input > 0) do
             input  := input - 1000;
    writeln(abs(input));
    readln;
end.


program main;
var input : integer;
begin
	readln(input);
	writeln(input mod 1000);
end.


var n : longint;

begin
    readln(n);
    writeln((1000 - n mod 1000) mod 1000);
end.


var
	n:Smallint;
begin
    read(n);
    while n>1000 do
        n:=n-1000;
    write(1000-n);
end.


var
	n:Smallint;
begin
    read(n);
    if n=0 then begin
        write(0)
    end
    else if n<=1000 then begin
        write(1000-n)
    end
    else if n<=2000 then begin
        write(2000-n)
    end
    else if n<=3000 then begin
        write(3000-n)
    end
    else if n<=4000 then begin
        write(4000-n)
    end
    else if n<=5000 then begin
        write(5000-n)
    end
    else if n<=6000 then begin
        write(6000-n)
    end
    else if n<=7000 then begin
        write(7000-n)
    end
    else if n<=8000 then begin
        write(8000-n)
    end
    else if n<=9000 then begin
        write(9000-n)
    end
    else begin
        write(10000-n)
    end;
end.


var
	n:Smallint;
begin
    read(n);
    n:=10000-n;
    while n>=1000 do
        n:=n-1000;
    write(n);
end.


var
	n:Smallint;
begin
    read(n);
    n:=10000-n;
    while n>999 do
        n:=n-1000;
    write(n);
end.


var
	n:Smallint;
begin
    read(n);
    n:=n mod 1000;
    write((1000-n) mod 1000)
end.


var
	n:Smallint;
begin
    read(n);
    n:=n mod 1000;
    writeln((1000-n) mod 1000)
end.


var
	n:Smallint;
begin
    read(n);
    writeln((1000-(n mod 1000)) mod 1000)
end.


var
	n:Smallint;
begin
    read(n);
    n:=n mod 1000;
    if n=0 then begin
        writeln(0);
    end
    else begin
	    writeln(1000-n);
    end;
end.


var
	n:Smallint;
begin
    if (n mod 1000)=0 then begin
        writeln(0);
    end
    else begin
	    writeln(0);
    end;
end.


var
	i:Smallint;
begin
	for i:=1 to 365 do writeln(1);
end.

Problem Statement

AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows.

The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative.

Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}.

If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)).

Please schedule contests on behalf of AtCoder.
If the satisfaction at the end of day D is S, you will get a score of \max(10^6 + S, 0).
There are 50 test cases, and the score of a submission is the total scores for each test case.
You can make submissions multiple times, and the highest score among your submissions will be your score.

Constraints

D = 365

Each c_i is an integer satisfying 0\leq c_i \leq 100.

Each s_{d,i} is an integer satisfying 0\leq s_{d,i} \leq 20000.

Input

Input is given from Standard Input in the following format:

D
c_1 c_2 \cdots c_{26}
s_{1,1} s_{1,2} \cdots s_{1,26}
\vdots
s_{D,1} s_{D,2} \cdots s_{D,26}

Output

Let t_d (1\leq t_d \leq 26) be the type of the contest that will be held at day d.
Print D integers t_d to Standard Output in the following format:

t_1
t_2
\vdots
t_D

Any output that does not follow the above format may result in 0 pointsWA for that test case.

Input Generation

Each integer c_i and s_{d,i} is generated independently and uniformly at random from the integers in the range described in the problem statement.

Sample Input 1

5
86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82
19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424
6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570
6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256
8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452
19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192

Sample Output 1

1
17
13
14
13

Note that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case. The final satisfaction with this output is 79325, so the score is 1079325.

Input generator, score calculator, and visualizer

Beginner's Guide

If you don't know what to do, proceed to problem B or C.


var
	i:Smallint;
begin
    i:=0;
	while i<365 do begin
        i:=i+1;
    	writeln(1);
    end;
end.


var
	i:Smallint;
begin
	for i:=1 to 365 do write('1 ');
end.


var
    i:Smallint;
begin
	for i:=1 to 365 do writeln(1);
end.


var
	x:ShortString;
    i:Smallint;
begin
	read(x);
	for i:=1 to 366 do readln(x);
	for i:=1 to 365 do writeln(1);
end.


var
	x:Array[1..10000]of Smallint;
    i,d:Smallint;
begin
	read(d);
	for i:=1 to 26*(d+1) do read(x[i]);
	for i:=1 to d do writeln(1);
end.


var
	N,i,j:Longint;
	ans:int64;
begin
	read(N);
	j:=round(sqrt(N));
	if j*j>N then dec(j);
	for i:=1 to j do inc(ans,(N div i)*(N div i+1)*i-i*i*i);
	writeln(ans);
end.

Score : 400 points

Problem Statement

For a positive integer X, let f(X) be the number of positive divisors of X.

Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Constraints

1 \leq N \leq 10^7

Input

Input is given from Standard Input in the following format:

N

Output

Print the value \sum_{K=1}^N K\times f(K).

Sample Input 1

4

Sample Output 1

23

We have f(1)=1, f(2)=2, f(3)=2, and f(4)=3, so the answer is 1\times 1 + 2\times 2 + 3\times 2 + 4\times 3 =23.

Sample Input 2

100

Sample Output 2

26879

Sample Input 3

10000000

Sample Output 3

838627288460105

Watch out for overflows.


uses math;
var
	N,i,j:Longint;
	ans:int64;
begin
	read(N);
	j:=floor(sqrt(N));
	if j*j>N then dec(j);
	for i:=1 to j do inc(ans,(N div i)*(N div i+1)*i-i*i*i);
	writeln(ans);
end.


var
	N,i,j,ans:int64;
begin
	read(N);
	i:=1;
	while i<=N do begin
		j:=N div(N div i)+1;
		inc(ans,(j-i)*(i+j-1)*(N div i)*(N div i+1)div 4);
		i:=j;
	end;
	writeln(ans);
end.


program multi2;
var
    total, current : qword;
    exploded : boolean;
    i, n : longint;
begin
    exploded := false;
    readln(n);
    total := 1;
    for i := 1 to n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if 1000000000000000000 div current < total then begin
            exploded := true;
        end;
        total := total * current;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.

Score : 200 points

Problem Statement

Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N.

However, if the result exceeds 10^{18}, print -1 instead.

Constraints

2 \leq N \leq 10^5

0 \leq A_i \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 ... A_N

Output

Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have 1000000000 \times 1000000000 = 1000000000000000000.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have 101 \times 9901 \times 999999000001 = 1000000000000000001, which exceeds 10^{18}, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0


program multi2;
var
    total, current : qword;
    exploded : boolean;
    i, n : longint;
begin
    exploded := false;
    readln(n);
    total := 1;
    for i := 1 to n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if 1000000000000000000 / current < total then begin
            exploded := true;
        end;
        total := total * current;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    total, current : qword;
    exploded : boolean;
    i, n : longint;
begin
    exploded := false;
    readln(n);
    total := 1;
    for i := 1 to n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if 1000000000000000000 / current < total then begin
            exploded := true;
        end;
        total *= current;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    total, current : qword;
    exploded : boolean;
    i, n : longint;
begin
    exploded := false;
    readln(n);
    read(total);
    for i := 2 to n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if 1000000000000000000 / current < total then begin
            exploded := true;
        end;
        total *= current;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    total, current : qword;
    exploded : boolean;
    i, n : longint;
begin
    exploded := false;
    readln(n);
    read(total);
    for i := 1 to n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if 1000000000000000000 / current < total then begin
            exploded := true;
        end;
        total *= current;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    n, i, total, current : qword;
    exploded : boolean;
begin
    i := 2;
    exploded := false;
    readln(n);
    read(total);
    while i <= n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if 1000000000000000000 / current < total then begin
            exploded := true;
        end;
        total *= current;
        i += 1;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    n, i, total, current : qword;
    exploded : boolean;
begin
    i := 2;
    exploded := false;
    readln(n);
    read(total);
    while i <= n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if 1000000000000000000 / current > total then begin
            exploded := true;
        end;
        total *= current;
        i += 1;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    n, i, total, current : qword;
    exploded : boolean;
begin
    i := 2;
    exploded := false;
    readln(n);
    read(total);
    while i <= n do begin
        read(current);
        if current = 0 then begin
            writeln(0);
            exit;
        end;
        if total * current > 1000000000000000000 then begin
            exploded := true;
        end;
        total *= current;
        i += 1;
    end;
    if exploded then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    n, i, total, current : qword;
begin
    i := 2;
    readln(n);
    read(total);
    while i <= n do begin
        read(current);
        total *= current;
        i += 1;
    end;
    if total > 1000000000000000000 then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    n, i, total, current : int64;
begin
    i := 2;
    readln(n);
    read(total);
    while i <= n do begin
        read(current);
        total *= current;
        i += 1;
    end;
    if total > 1000000000000000000 then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    n, i : longint;
    total, current : int64;
begin
    readln(n);
    read(total);
    for i := 2 to n do begin
        read(current);
        total *= current;
    end;
    if total > 1000000000000000000 then
        writeln(-1)
    else
        writeln(total);
end.


program multi2;
var
    n, i : longint;
    total, current : int64;
begin
    readln(n);
    read(total);
    for i := 2 to n do begin
        read(current);
        if (total * current) > 1000000000000000000 then begin
            writeln(-1);
            exit;
        end
        else
            total *= current;
    end;
    writeln(total);
end.


program main;
var
    ans : QWord;
    a, i : integer;
    ar : array[1..100000] of QWord;
begin
    readln(a);
    ans := 1;
    for i := 1 to a do
        begin
            read(ar[i]);
            if ( ar[i] = 0 ) then
                begin
                    writeln('0');
                    exit;
                end;
        end;
    for i := 1 to a do
        begin
            if ans > 1000000000000000000 div ar[i] then
                    begin
                        writeln('-1');
                        exit;
                    end;
            ans := ans * ar[i];
        end;

    writeln(ans);
end.


program main;
var
    ans : QWord;
    a, i : integer;
    ar : array[1..100000] of integer;
begin
    readln(a);
    ans := 1;
    for i := 1 to a do
        begin
            read(ar[i]);
            if ( ar[i] = 0 ) then
                begin
                    writeln('0');
                    exit;
                end;
            if ans > 1000000000000000000 div ar[i] then
                begin
                    writeln('-1');
                    exit;
                end;
        end;
    for i := 1 to a do
        ans := ans * ar[i];
    writeln(ans);
end.


program main;
var
    ans : QWord;
    a, i : integer;
    ar : array[1..100000] of QWord;
begin
    readln(a);
    ans := 1;
    for i := 1 to a do
        read(ar[i]);
    for i := 1 to a do
        ans := ans * ar[i];
    if ( ans = 0 ) then
        writeln('0')
    else
        if ( ans > 1000000000000000000 ) then
            writeln('-1')
        else
            writeln(ans);
end.


program main;
uses math;
var i, n : longint;
    m : array [1..100000] of qword;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if p > 1e18 / m[i] then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
uses math;
var i, n : longint;
    m : array [1..100000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if log10(p*m[i]) > 18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
uses math;
var i, n : int64;
    m : array [1..100000] of qword;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if log10(p*m[i]) > 18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
uses math;
var i, n : int64;
    m : array [1..100000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if log10(p*m[i]) > 18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
uses math;
var i, n : int64;
    m : array [1..100000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if (trunc(log10(p))+trunc(log10(m[i]))-1) > 1e18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
var i, n : int64;
    m : array [1..100000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if p*m[i] > 1e18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
uses math;
var i, n : int64;
    m : array [1..10000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if p*m[i] > 1e18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(1-1)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
var i, n : int64;
    m : array [1..10000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if p*m[i] > 1e18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln(p-p)
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
var i, n : int64;
    m : array [1..10000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if p*m[i] > 1e18 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln('0')
  else if c then
    writeln('-1')
  else writeln(p);
end.


program main;
uses math;
var i, n : int64;
    m : array [1..10000] of longint;
    p : qword = 1;
    c : boolean = false;
    z : boolean = false;

begin
  readln(n);
  for i := 1 to n do
    read(m[i]);
  readln;
  for i := 1 to n do
    if (m[i] = 0) then begin
      z := true;
      break;
    end;
  if not(z) then
    for i := 1 to n do
      if (trunc(log10(p))+trunc(log10(m[i]))-1) > 19 then begin
        c := true;
        break;
      end
      else p := p * m[i];
  if z then
    writeln('0')
  else if c then
    writeln('-1')
  else writeln(p);
end.


program hi;
var
    a, ans: QWord;
    n, i: integer;
    ex: boolean = false;

begin
    readln(n);
    ans := 1;
    for i := 1 to n do begin
        read(a);
        if a = 0 then begin
            writeln(0);
            exit;
        end;
        if ans > 1000000000000000000 div a then
            ex := true;
        ans := ans * a;
    end;
    if ex then
        writeln(-1)
    else
        writeln(ans);
end.


program hi;
var
    ans: QWord;
    a: array[1..10010] of QWord;
    n, i: integer;

procedure mergesort(l, r : integer);
var
    tmp : array [1..100] of QWord;
    mid, p1, p2, pt, i : integer;
begin
    if l < r then begin
        mid := (l + r) div 2;
        mergesort(l, mid);
        mergesort(mid + 1, r);
        p1 := l; p2 := mid + 1; pt := l;
        while (p1 <= mid) and (p2 <= r) do begin
            if a[p1] < a[p2] then begin
                tmp[pt] := a[p1];
                inc(p1);
            end else begin
                tmp[pt] := a[p2];
                inc(p2);
            end;
            inc(pt);
        end;
        while p1 <= mid do begin
            tmp[pt] := a[p1];
            inc(pt); inc(p1);
        end;
        while p2 <= r do begin
            tmp[pt] := a[p2];
            inc(pt); inc(p2);
        end;
        for i := l to r do
            a[i] := tmp[i];
    end;
end;

begin
    readln(n);
    ans := 1;
    for i := 1 to n do
        read(a[i]);
    mergesort(1, n);
    for i := 1 to n do begin
        if a[i] = 0 then begin
            writeln(0);
            exit;
        end;
        if ans <= 1000000000000000000 div a[i] then
            ans := ans * a[i]
        else begin
            writeln(-1);
            exit;
        end;
    end;
    writeln(ans);
end.


program hi;
var
    ans: QWord;
    a: array[1..10010] of QWord;
    n, i, j: integer;

procedure swap(var x: QWord; var y: QWord);
var tmp: QWord;
begin
    tmp := x;
    x := y;
    y := tmp;
end;

begin
    readln(n);
    ans := 1;
    for i := 1 to n do
        read(a[i]);
    for i := 1 to n - 1 do
        for j := 1 to n - 1 do
            if a[j] > a[j + 1] then
                swap(a[j], a[j + 1]);
    for i := 1 to n do begin
        if a[i] = 0 then begin
            writeln(0);
            exit;
        end;
        if ans <= 1000000000000000000 div a[i] then
            ans := ans * a[i]
        else begin
            writeln(-1);
            exit;
        end;
    end;
    writeln(ans);
end.


program hi;
var
    a, ans: QWord;
    n, i: integer;
    ex: boolean = false;

begin
    readln(n);
    ans := 1;
    for i := 1 to n do begin
        read(a);
        if (ans > 1000000000000000000) then
            ex := true;
        if (a = 0) then begin
            writeln(0);
            exit;
        end else if (a > 1000000000000000000) then
            ex := true
        else
            ans := ans * a;
    end;
    if (ex) or (ans > 1000000000000000000) then
        writeln(-1)
    else
        writeln(ans)
end.


program hi;
var
    a, ans: int64;
    n, i: integer;
    ex: boolean = false;

begin
    readln(n);
    ans := 1;
    for i := 1 to n do begin
        read(a);
        if (ans > 1000000000000000000) then
            ex := true;
        if (a = 0) then begin
            writeln(0);
            exit;
        end else if (a > 1000000000000000000) then
            ex := true
        else
            ans := ans * a;
    end;
    if (ex) or (ans > 1000000000000000000) then
        writeln(-1)
    else
        writeln(ans)
end.


program main;
var i, n, t : int64;
    p : qword;

begin
  readln(n);
  p := 1;
  for i := 1 to n do begin
    read(t);
    p := p * t;
  end;
  readln;
  if p > 1000000000000000000 then
    writeln('-1')
  else writeln(p);
end.


program main;
var i, n, p, t : int64;

begin
  readln(n);
  p := 1;
  for i := 1 to n do begin
    read(t);
    p := p * t;
  end;
  readln;
  if p > 1000000000000000000 then writeln('-1') else writeln(p);
end.


program main;
var i, n, p, t : int64;

begin
  readln(n);
  p := 1;
  for i := 1 to n do begin
    read(t);
    p := p * t;
  end;
  readln;
  if p > 1000000000000000000 then writeln(-1) else writeln(p);
end.


program main;
var
	count, sum, i, num : longint;

begin
	readln(count);
 	sum := 1;
    for i := 1 to count do begin
    	read(num);
        sum := sum*num;
    end;
    if sum <= 1000000000000000000
    	then writeln(sum)
        	else writeln('-1');
end.


program main;
var
	count, sum, i, num : int64;

begin
	readln(count);
 	sum := 1;
    for i := 1 to count do begin
    	read(num);
        sum := sum*num;
    end;
    if sum <= 1000000000000000000
    	then writeln(sum)
        	else writeln('-1');
end.


program main;
var
	count, sum, i, num : int64;

begin
	readln(count);
 	sum := 1;
    for i := 1 to count do begin
    	read(num);
        sum := sum*num;
    end;
    if sum < 1000000000000000000
    	then writeln(sum)
        	else writeln('-1');
end.


program main;
var
    x, i, j : integer;
    total : real;
    A : array[1..1000] of int64;
begin
    total := 1;
    readln(x);
    for i := 1 to x do
        read(A[i]);
    for j := 1 to x do begin
        if A[i] = 0
            then begin
                writeln('0');
                halt;
            end
            else begin
                total := total * A[i];
                if (ln(total)/ln(10)) >= 18
                    then begin
                        writeln('-1');
                        halt;
                    end;
            end;
    end;
    if (ln(total)/ln(10)) < 18
        then writeln(trunc(total));
end.


var
	N,i:Longint;
	A:Array[1..100000]of int64;
	ret:int64;
begin
	read(N);
	for i:=1 to N do begin
		read(A[i]);
		if A[i]=0 then begin
			writeln(0);
			exit;
		end;
	end;
	ret:=1;
	for i:=1 to N do begin
		if A[i]>1000000000000000000 div ret then begin
			writeln(-1);
			exit;
		end;
		ret:=ret*A[i];
	end;
	writeln(ret);
end.


var n,i : longint;
    ans,a: int64;
    zero : boolean;
begin
    read(n);
    ans := 1;
    zero := false;
    for i := 1 to n do begin
        read(a);
        if (ans <> -1) and (a <= 1000000000000000000 div ans) then
            ans := ans * a
        else
            ans := -1;
        if a = 0 then
            zero := true;
    end;
    if not zero then writeln(ans) else writeln(0);
end.


program times3;
var
    a, b2 : int64;
    b : real;
begin
    read(a, b);
    readln;
    b2 := trunc(b * 100);
    writeln(trunc(a * b2 / 100));
end.

Score : 300 points

Problem Statement

Compute A \times B, truncate its fractional part, and print the result as an integer.

Constraints

0 \leq A \leq 10^{15}

0 \leq B < 10

A is an integer.

B is a number with two digits after the decimal point.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the answer as an integer.

Sample Input 1

198 1.10

Sample Output 1

217

We have 198 \times 1.10 = 217.8. After truncating the fractional part, we have the answer: 217.

Sample Input 2

1 0.01

Sample Output 2

0

Sample Input 3

1000000000000000 9.99

Sample Output 3

9990000000000000


program main;
var
n, k : real;
product : int64;

begin
    read(n, k);
    product := trunc(n*k);
    writeln(product);
end.


program main;
var
n, k : real;
product : integer;

begin
    read(n, k);
    product := trunc(n*k);
    writeln(product);
end.


var a,b2: int64;
    b: string;

function todigit(c : char) : integer;
begin
    todigit := ord(c) - ord('0');
end;

begin
    read(a,b);
    b2 := todigit(b[2]) * 100 + todigit(b[4]) * 10 + todigit(b[5]);
    writeln((a * b2) div 100);
end.


var
	N,i,T:Longint;
	K:int64;
	A,B:Array[1..200000]of Longint;
begin
	read(N,K);
	for i:=1 to N do read(A[i]);
	T:=1;
	while K>0 do begin
		if K mod 2=1 then T:=A[T];
		K:=K div 2;
		for i:=1 to N do B[i]:=A[i];
		for i:=1 to N do A[i]:=B[B[i]];
	end;
	writeln(T);
end.

Score: 400 points

Problem Statement

The Kingdom of Takahashi has N towns, numbered 1 through N.

There is one teleporter in each town. The teleporter in Town i (1 \leq i \leq N) sends you to Town A_i.

Takahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and uses a teleporter exactly K times from there.

Help the king by writing a program that answers this question.

Constraints

2 \leq N \leq 2 \times 10^5

1 \leq A_i \leq N

1 \leq K \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the integer representing the town the king will be in if he starts at Town 1 and uses a teleporter exactly K times from there.

Sample Input 1

4 5
3 2 4 1

Sample Output 1

4

If we start at Town 1 and use the teleporter 5 times, our travel will be as follows: 1 \to 3 \to 4 \to 1 \to 3 \to 4.

Sample Input 2

6 727202214173249351
6 5 2 5 3 2

Sample Output 2

2


var
	N,i,T:Longint;
	K:int64;
	A,B:Array[1..100000]of Longint;
begin
	read(N,K);
	for i:=1 to N do read(A[i]);
	T:=1;
	while K>0 do begin
		if K mod 2=1 then T:=A[T];
		K:=K div 2;
		for i:=1 to N do B[i]:=A[i];
		for i:=1 to N do A[i]:=B[B[i]];
	end;
	writeln(T);
end.


program hihi;
var a, b, c, d : integer;
begin
	readln(a, b, c, d);
    while (a>0) and (c>0) do begin
    	c:= c - b;
        if c>0 then a:= a - d;
    end;
    if c<=0 then writeln('Yes')
    else writeln('No');
end.

Score : 200 points

Problem Statement

Takahashi and Aoki will have a battle using their monsters.

The health and strength of Takahashi's monster are A and B, respectively, and those of Aoki's monster are C and D, respectively.

The two monsters will take turns attacking, in the order Takahashi's, Aoki's, Takahashi's, Aoki's, ...
Here, an attack decreases the opponent's health by the value equal to the attacker's strength.
The monsters keep attacking until the health of one monster becomes 0 or below. The person with the monster whose health becomes 0 or below loses, and the other person wins.

If Takahashi will win, print Yes; if he will lose, print No.

Constraints

1 \leq A,B,C,D \leq 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C D

Output

If Takahashi will win, print Yes; if he will lose, print No.

Sample Input 1

10 9 10 10

Sample Output 1

No

First, Takahashi's monster attacks Aoki's monster, whose health is now 10-9=1.

Next, Aoki's monster attacks Takahashi's monster, whose health is now 10-10=0.

Takahashi's monster is the first to have 0 or less health, so Takahashi loses.

Sample Input 2

46 4 40 5

Sample Output 2

Yes


program Battle;
var
	A, B, C, D : integer;
begin
	readln(A, B, C, D);
	repeat
		A := A - D;
		C := C - B;
	until (A <= 0) or (C <=0);
	if C <= 0
		then writeln('Yes')
		else writeln('No');
end.


program train;
var
    a, b, c, d : longint;
begin
    read(a, b, c, d);
    while (a > 0) and (c > 0) do begin
        c := c - b;
       if c > 0
            then a := a - d;
        end;
    if a <= 0
        then write('No')
        else write('Yes');
end.


program main;
var a, b, c, d : integer;
begin
    readln(a, b, c, d);

    while(a > 0) and (c > 0) do begin
    c := c - b;
    if c > 0 then
    a:= a - d;
end;

if c <= 0 then
    writeln('Yes')
else
    writeln('No');
end.


program main;
var
	a,b,c,d : longint;
begin
	readln(a,b,c,d);
    if a mod d > 0 then a := a div d + 1 else a := 1;
    if c mod b > 0 then c := c div b + 1 else c := 1;
    if a >= c
    	then writeln('Yes')
        else writeln('No');
end.


program main;
var
	a,b,c,d : longint;
begin
	readln(a,b,c,d);
    if a mod d > 0 then a := a div d + 1;
    if c mod b > 0 then c := c div b + 1;
    if a >= c
    	then writeln('Yes')
        else writeln('No');
end.


program main;
var
	a,b,c,d : longint;
begin
	readln(a,b,c,d);
    if a mod d > 0 then a := a div d + 1;
    if c mod b > 0 then c := c div b + 1;
    if a <= c
    	then writeln('Yes')
        else writeln('No');
end.


program main;
var
	a,b,c,d : longint;
begin
	readln(a,b,c,d);
    if a mod d > 0 then a := a div d + 1;
    if c mod b > 0 then c := c div b + 1;
    if a < c
    	then writeln('No')
        else writeln('Yes');
end.


program main;
var
	a,b,c,d : longint;
begin
	readln(a,b,c,d);
    if a mod d > 0 then a := a div d + 1;
    if c mod b > 0 then c := c div b + 1;
    if a < c
    	then writeln('Yes')
        else writeln('No');
end.


program main;
var a, b, c, d : integer;
begin
	readln(a, b, c, d);

    repeat
        if (a > 0) and (c > 0)
            then c := c - b;
            if (c > 0)
                then a := a - d;
    until ((a <= 0) or (c <= 0)) ;

    if a <= 0
        then writeln('No')
        else writeln('Yes');
end.


program battle;
var
    a, b, c, d : longint;

function dothejob(x : longint; y : longint) : longint;
begin
    if (x mod y) <> 0 then dothejob := trunc(x / y) + 1
        else dothejob := (x div y);
end;

begin
    readln(a, b, c, d);
    if (dothejob(a, d)) < (dothejob(c, b)) then writeln('No')
        else writeln('Yes');
end.


program main;
var a, b, c, d : integer;
begin
  readln(a, b, c, d);

  while (a > 0) and (c > 0) do begin
    c := c - b;
    if c > 0 then
      a := a - d;
  end;

  if c <= 0 then
    writeln('Yes')
  else
    writeln('No');

end.


program main;
var a,b,c,d : integer;
begin
    readln(a,b,c,d);
    repeat
    c:=c-b;
    if c > 0
    then a:=a-d;
    until (a <= 0) or (c <= 0);
    if a <= 0
    then writeln('No')
    else writeln('Yes');
end.


program main;
var a,b,c,d : integer;
begin
    readln(a,b,c,d);
    repeat
    c:=c-b;
    if c > 0
    then a:=a-d;
    until (a <= 0) or (c <= 0);
    writeln(a,c);
    if a <= 0
    then writeln('No')
    else writeln('Yes');
end.


program main;
var
    h1, s1, h2, s2 : integer;
begin
    readln(h1, s1, h2, s2);
    while (h1 > 0) and (h2 > 0) do begin
        h1 := h1 - s2;
        h2 := h2 - s1;
        if h2 <= 0
            then writeln('Yes')
            else if h1 <= 0
                then writeln('No');
    end;
end.


program main;
var
    thp, tatk, ahp, aatk : integer;
begin
    readln(thp, tatk, ahp, aatk);

    if ((((ahp - 1) div tatk) - 0.5) < ((thp - 1) div aatk)) then
        writeln('Yes')
    else
        writeln('No');
end.


program main;
var
	a1, a2, t1, t2 : integer;

begin
	read( t1, t2, a1, a2 );

    if ((a1-t2) <= 0)
        	then writeln('Yes')
    else begin
    repeat
    	a1 := a1 - t2;
        t2 := t1 - a2;
    until (a1 <= 0) or (t2 <= 0);
    if a1 <= 0
    	then writeln('Yes')
        	else writeln('No');
    end;
end.


program main;
var
	a1, a2, t1, t2 : integer;

begin
	read( t1, t2, a1, a2 );

    repeat
    	a1 := a1 - t2;
        t2 := t1 - a2;
    until (a1 <= 0) or (t2 <= 0);
    if (a1 <= 0) or (a1 < t2)
    	then writeln('Yes')
        	else writeln('No');
end.


program main;
var
	a1, a2, t1, t2 : integer;

begin
	read( t1, t2, a1, a2 );

    repeat
    	a1 := a1 - t2;
        t2 := t1 - a2;
    until (a1 <= 0) or (t2 <= 0);
    if (a1 <= 0) or (a1 <= t2)
    	then writeln('Yes')
        	else writeln('No');
end.


program main;
var
	a1, a2, t1, t2 : integer;

begin
	read( t1, t2, a1, a2 );

    repeat
    	a1 := a1 - t2;
        t2 := t1 - a2;
    until (a1 <= 0) or (t2 <= 0);
    if a1 > t2
    	then writeln('No')
        	else writeln('Yes');
end.


program main;
var
	a1, a2, t1, t2 : integer;

begin
	read( t1, t2, a1, a2 );

    repeat
    	a1 := a1 - t2;
        t2 := t1 - a2;
    until (a1 <= 0) or (t2 <= 0);
    if t2 > a1
    	then writeln('Yes')
        	else writeln('No');
end.


program main;
var
	a1, a2, t1, t2 : integer;

begin
	read( t1, t2, a1, a2 );

    repeat
    	a1 := a1 - t2;
        t2 := t1 - a2;
    until (a1 <= 0) or (t2 <= 0);
    if a1 <= 0
    	then writeln('Yes')
        	else writeln('No');
end.


program main;
var
	a,b,c,d:integer;
	k:boolean;
begin
	k:=false;
	readln(a,b,c,d);
    while (a>0) and (c>0) do begin
    	if k then a:=a-d else c:=c-b;
    	k:=k xor true;
    end;
    if k then writeln('Yes') else writeln('No');
end.


program main;
var
	a,b,c,d:integer;
begin
	readln(a,b,c,d);
    if (a/d>=c/b) then writeln('Yes') else writeln('No');
end.


var a,b,c,d:longint;
begin
  readln(a,b,c,d);
  if (c+b-1)div b<=(a+d-1)div d then
    writeln('Yes')
  else
    writeln('No');
end.


var a,b,c,d:Longint;
begin
read(a,b,c,d);
if(c-1)div b>(a-1)div d then writeln('No')else writeln('Yes');
end.


var
	S:String;
	cnt:Array[0..2018]of Longint;
	a,p,i:Longint;
	ans:int64;
begin
	readln(S);
	cnt[0]:=1;
	p:=1;
	for i:=length(S)downto 1 do begin
		a:=(a+p*(ord(S[i])-48))mod 2019;
		p:=p*10 mod 2019;
		inc(ans,cnt[a]);
		inc(cnt[a]);
	end;
	writeln(ans);
end.

Score : 400 points

Problem Statement

Given is a string S consisting of digits from 1 through 9.

Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:

Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Constraints

1 ≤ |S| ≤ 200000

S is a string consisting of digits from 1 through 9.

Input

Input is given from Standard Input in the following format:

S

Output

Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition.

Sample Input 1

1817181712114

Sample Output 1

3

Three pairs - (1,5), (5,9), and (9,13) - satisfy the condition.

Sample Input 2

14282668646

Sample Output 2

2

Sample Input 3

2119

Sample Output 3

0

No pairs satisfy the condition.


program circlepond;
var
    r, pi : real;
begin
    readln(r);
    pi := 3.14159265359;
    writeln(r * pi * 2:0:2);
end.

Score : 100 points

Problem Statement

Print the circumference of a circle of radius R.

Constraints

1 \leq R \leq 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

R

Output

Print the circumference of the circle.
Your output is considered correct if and only if its absolute or relative error from our answer is at most 10^{-2}.

Sample Input 1

1

Sample Output 1

6.28318530717958623200

Since we accept an absolute or relative error of at most 10^{-2}, 6.28 is also an acceptable output, but 6 is not.

Sample Input 2

73

Sample Output 2

458.67252742410977361942


program train;
var
    r : integer;
begin
    read(r);
    write(2*pi*r);
end.


program main;
var
	r : real;
begin
	readln(r);
	r:= r*2*pi;
    writeln(r:0:2);
end.


program hihi;
var R : integer;
begin
	readln(R);
    writeln(2*pi*r:0:6);
end.


program main;
var r : integer;
begin
    readln(r);
    writeln(2*pi*r:0:6);
end.


program Circlepond;
var
	R : integer;
begin
	readln(R);
	writeln(2*pi*R :0:2);
end.


var
	x : integer;

begin
	readln(x);
	writeln((x * 2 * pi) : 0 : 4)
end.


program main;
var R : integer;
begin
	read(R);
    writeln((2 * pi * R):0:2);
end.


program main;
var r : integer;
begin
  readln(r);
  writeln(2*pi*r:0:6);
end.


program main;
var r:integer;
    n:real;
begin
    readln(r);
    n:=(2*pi*r);
    writeln(n:10);
end.


program HelloWorld;
var
    n : integer;
begin
    readln(n);
    writeln(2*n*pi:0:2)
end.


program main;
var
    n, i : integer;
begin
    readln(n);
    writeln((pi * n * 2) : 0 : 2);
end.


program main;
var
	r : integer;
    cir : real;

begin
	read(r);
    cir := 2*pi*r;
    writeln(cir :0:20);
end.


program main;
var r:integer;
    n:real;
begin
    readln(r);
    n:=(2*pi*r);
    writeln(n:2);
end.


program main;
var
    r:integer;
begin
	readln(r);
    writeln(2*r*pi:0:10);
end.


var r:real;
begin
read(r);
writeln(r*6.3:0:9);
end.


uses crt,math;
const   fi='';
        nmax=1999;
        vc=1000*1000*1000;
type    data=int64;
var
        f:text;
        A:array[0..nmax+1,0..nmax+1] of data;
        Fx,Fy,MatchX,MatchY,tr:array[0..nmax+1] of data;
        Q:array[0..nmax*nmax] of data;
        ddx,ddy:array[0..nmax+1] of boolean;
        dau,cuoi,start,finish:data;
        n:longint;
        mm :data;

procedure docfile;
var     u,v,c:data;
        i,j:longint;
begin
        clrscr;
        readln(n);
        for i:=1 to n do
        begin
                read(u);
                for j:=1 to n do begin a[i,j] := u*abs(i-j); mm := max(mm,a[i,j]); end;
        end;
        for i:=1 to n do
        begin
                for j:=1 to n do a[i,j] := mm - a[i,j];
        end;
end;

procedure init;
var     i,j:longint;
begin
        fillchar(MatchX,sizeof(matchx),0);
        MatchY:=MatchX;

        for i:=1 to n do
                begin
                        fx[i]:=vc;
                        for j:=1 to n do
                                if fx[i]>a[i,j] then
                                        fx[i]:=a[i,j];
                end;
        for i:=1 to n do
                begin
                        fy[i]:=vc;
                        for j:=1 to n do
                                if a[i,j]-fx[i]<fy[i] then
                                        fy[i]:=a[i,j]-fx[i];
                end;
end;

function get(i,j:longint):data;
begin
        get:=a[i,j]-fx[i]-fy[j];
end;

procedure themvao(x:data);
begin
        inc(cuoi);
        q[cuoi]:=x;
end;

function layra:data;
begin
        layra:=q[dau];
        inc(dau);
end;

procedure bfs;
var     u,v,j,i:longint;
begin
        fillchar(tr,sizeof(tr),0);
        dau:=1;
        cuoi:=0;
        themvao(start);
        while dau<=cuoi do
                begin
                        u:=layra;
                        for v:=1 to n do
                                if (tr[v]=0) and (get(u,v)=0) then
                                        begin
                                                tr[v]:=u;
                                                if matchy[v]=0 then
                                                        begin
                                                                finish:=v;
                                                                exit;
                                                        end;
                                                themvao(matchy[v]);
                                        end;
                end;
end;

procedure enlager(u:longint);
var     v,next:longint;
begin
        repeat
                v:=tr[u];
                next:=MatchX[v];
                MatchX[v]:=u;
                MatchY[u]:=v;
                u:=next;
        until   u=0;
end;

procedure subX_addY;
var    delta:data;
        i,j:longint;
begin
        fillchar(ddx,sizeof(ddx),false);
        ddy:=ddx;
        ddx[start]:=true;
        for i:=1 to n do
                if tr[i]<>0 then
                        begin
                                ddx[MatchY[i]]:=true;
                                ddy[i]:=true;
                        end;
        delta:=vc;
        for i:=1 to n do
                if ddx[i] then
                        for j:=1 to n do
                                if (not ddy[j]) and (delta>get(i,j)) then
                                        delta:=get(i,j);
        for i:=1 to n do
                begin
                        if ddx[i] then fx[i]:=fx[i]+delta;
                        if ddy[i] then fy[i]:=fy[i]-delta;
                end;
end;

procedure xuli;
var     res:data;
        i,j:longint;
begin
        for i:=1 to n do
                begin
                        start:=i;
                        finish:=0;
                        repeat
                                bfs;
                                if finish=0 then subx_addy;
                        until finish<>0;
                        enlager(finish);
                end;
        res:=0;
        for i:=1 to n do
                if MatchX[i]<>0 then
                        inc(res,a[i,Matchx[i]]);
        writeln(mm*n - res);
        {for i:=1 to n do
                if MatchX[i]<>0 then
                        writeln(i, ' ',MatchX[i]);   }

end;

begin
        docfile;
        init;
        xuli;
end.


var r:Longint;
begin
read(r);
writeln(r*6.283:0:9);
end.


var r : integer;

begin
    readln(r);
    writeln(2 * 3.14 * r);
end.


var r:real;
begin
  readln(r);
  writeln(r*2*3.141592)
end.


var r:real;
begin
  readln(r);
  writeln(r*3.141592)
end.


Uses math;
Var n,m,i,a,sum:Longint;
Begin
    Readln(n,m);
    For i:=1 to m do begin
        Read(a);
        sum:=sum+a;
    End;
    Writeln(max(n-sum,-1));
End.


Var r:Longint;
Begin
    Readln(r);
    Writeln(r*2*3.14);
End.


Var r:Double;
Begin
    Readln(r);
    Writeln(r*2*3,14);
End.


program main;
var a : integer;
begin
read(a);
if (a >= 100) and (a <= 999)  and (frac((a-7)/10) = 0) then write('Yes')
	else if (a > 99) and (a < 1000)  and ((frac(trunc((a-70)/10)/10)) = 0) then write('Yes')
    	else if (a > 99) and (a < 1000)  and ((a-700) >= 0) and ((a-700) <= 99) then write('Yes')
        	else write('No');
end.

Score : 100 points

Problem Statement

Given is a three-digit integer N. Does N contain the digit 7?

If so, print Yes; otherwise, print No.

Constraints

100 \leq N \leq 999

Input

Input is given from Standard Input in the following format:

N

Output

If N contains the digit 7, print Yes; otherwise, print No.

Sample Input 1

117

Sample Output 1

Yes

117 contains 7 as its last digit.

Sample Input 2

123

Sample Output 2

No

123 does not contain the digit 7.

Sample Input 3

777

Sample Output 3

Yes


program main;
var a : integer;
begin
read(a);
if (a > 99) and (a < 1000)  and (frac((a-7)/10) = 0) then write('Yes')
	else if (a > 99) and (a < 1000)  and ((frac(trunc((a-70)/10))/10) = 0) then write('Yes')
    	else if (a > 99) and (a < 1000)  and ((a-700) >= 0) and ((a-700) <= 99) then write('Yes')
        	else write('No')
end.


program main;
var n, u, t, h : integer;

begin
  readln(n);
  u:= n mod 10;
  t:= (n div 10) mod 10;
  h:= h div 100;
  if (u = 7) or (t = 7) or (h = 7) then
    writeln('Yes')
  else
    writeln('No');
end.


program main;
var n, u, t, h : integer;

begin
  readln(n);
  u:= n mod 10;
  t:= (n div 10) mod 10;
  h:= n div 100;
  if (u = 7) or (t = 7) or (h = 7) then
    writeln('Yes')
  else
    writeln('No');
end.


program main;

var
	s : string;
    i : integer;
    ok : boolean;

begin
	ok := false;
	readln(s);
    for i := 1 to length(s) do
    	if s[i] = '7'
        	then ok := true;
    if (ok)
    	then writeln('Yes')
    	else writeln('No');
end.


program main;
var n, u, t, h : integer;
begin
    readln(n);

    u := n mod 10;
    t := (n div 10) mod 10;
    h := n div 100;

    if (u = 7)or (t = 7) or (h = 7) then
        writeln('Yes')
    else
        writeln('No');
end.


program train;
var
    n : integer;
    s : string;

begin
    read(n);
    str(n, s);
    if pos('7', s) > 0
        then write('Yes')
        else write('No');
end.


program hihi;
var n : string;
begin
	readln(n);
    if (n[1]='7') or (n[2]='7') or (n[3]='7')
    then writeln('Yes')
    else writeln('No');
end.


program Lucky7;
var
	n : integer;
	contain : boolean;
begin
	readln(n);
	if ( n div 100 = 7 )
		then contain := true
		else if ( ((n div 10) mod 10) = 7 )
				then contain := true
				else if ( (n mod 10) = 7 )
						then contain := true
						else contain := false;
	if contain
		then writeln('Yes')
		else writeln('No');
end.


program main;
var N, a, b : integer;
    x : real;
begin
	read(N);
    x := N / 100;
    a := trunc(x) * 100;
    b := trunc((N - a) / 10) * 10;
    if trunc(x) = 7
    then writeln('Yes')
    else if trunc((N - a) / 10) = 7
        then writeln('Yes')
        else if (N - a - b) = 7
            then writeln('Yes')
            else writeln('No');
end.


program main;
var
    i : integer;
    ans : boolean;
    s : string;
begin
    readln(s);

    ans := false;
    for i := 1 to 3 do
        if (s[i] = '7') then
            ans := true;

    if (ans) then
        writeln('Yes')
    else
        writeln('No');
end.


program main;
var
    i : integer;
    ans : boolean;
    s : string;
begin
    readln(s);

    ans := true;
    for i := 1 to length(s) do
        if (s[i] <> '7') then
            ans := false;

    if (ans) then
        writeln('Yes')
    else
        writeln('No');
end.


program main;
var n, u, t, h : integer;
begin
  readln(n);

  // get digits
  u := n mod 10;
  t := (n div 10) mod 10;
  h := n div 100;

  if (u = 7) or (t = 7) or (h = 7) then
    writeln('Yes')
  else
    writeln('No');
end.


program main;
var
	num : string;
    position : integer;
begin
	read(num);
    position := pos('7',num);
    if position <> 0
    	then writeln('Yes')
        	else writeln('No');
end.


program main;
var x:integer;
begin
    readln(x);
    if trunc(x/100) = 7
    then writeln('Yes')
        else if trunc((x-(trunc(x/100)*100))/10) = 7
        then writeln('Yes')
            else if x-(trunc(x/100)*100)-((trunc((x-(trunc(x/100)*100))/10))*10) = 7
            then writeln('Yes')
            else writeln('No');
end.


program main;
var
    x, first, second, third : integer;
begin
    readln(x);
    first := x div 100;
    second := (x mod 100) div 10;
    third := (x mod 100) mod 10;
    if (first = 7) or (second = 7) or (third = 7)
        then writeln('Yes')
        else writeln('No');
end.


program main;
var
    i,j,k:integer;
    s:string;
begin
    readln(s);
    if (pos('7',s)<>0) then writeln('Yes') else writeln('No');
end.


program Lucky7;
var
    num : string;
    digit : char;

begin
    readln(num);
    for digit in num do begin
        if digit = '7' then begin
            writeln('Yes');
            Halt;
        end;
    end;
    writeln('No');
end.


var
  i:longint;
  s:ansistring;
begin
  readln(s);
  for i:=1 to length(s) do
    if s[i]='7' then begin writeln('Yes');exit;end;
  writeln('No');
end.


Uses crt;
Var n:integer;
begin
clrscr;
readln(n);
if ((n mod 10 = 7) or (n div 100=7) or(n-((n div 100)*100)-(n mod 10)=70)) then write('Yes')
else write('No');
readln;
end.


Uses crt;
Var n:integer;
begin
clrscr;
readln(n);
if ((n mod 10 = 7) or (n div 100=7) or(n-(n div 100)-(n mod 10)=70)) then write('Yes')
else write('No');
readln;
end.


Uses crt;
Var n:integer;
begin
clrscr;
readln(n);
if n mod 10 = 7 then write('Yes')
else write('No');
readln;
end.


program contest;
  var n: integer;
    r: boolean;
begin
  readln(n);
  while n>0 do begin
    if n mod 10 = 7 then r:= true;
    n:=n div 10;
  end;
  if r then writeln('Yes') else writeln('No');
end.


var n,a,b,c:integer;

begin
  readln(n);
  a:=n div 100;n:=n - a*100;
  b:=n div 10; n:=n-b*10;
  c:=n ;
  if ((a=7)or(b=7)or(c=7))
  then write('Yes')
  else write('No');
end.


var s:string;
begin
  readln(s);
  if pos('7',s)<>0 then
    writeln('Yes')
    else writeln('No');
end.


var S:String;
begin
readln(S);
if(S[1]='7')or(S[2]='7')or(S[3]='7')then writeln('Yes')else writeln('No');
end.


program main;
var
    i, j, k, n, a, b, t : integer;
    sum : longint;
begin
    readln(n);

    sum := 0;
    for i := 1 to n do
        for j := 1 to n do
            for k := 1 to n do begin
                a := i; b := j;
                while (a <> 0) do begin
                    t := a;
                    a := b mod a;
                    b := t;
                end;

                a := k;
                while (a <> 0) do begin
                    t := a;
                    a := b mod a;
                    b := t;
                end;

                sum := sum + b;
            end;

    writeln(sum);
end.

Score : 300 points

Problem Statement

Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}.

Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.

Constraints

1 \leq K \leq 200

K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

Print the value of \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}.

Sample Input 1

2

Sample Output 1

9

\gcd(1,1,1)+\gcd(1,1,2)+\gcd(1,2,1)+\gcd(1,2,2)
+\gcd(2,1,1)+\gcd(2,1,2)+\gcd(2,2,1)+\gcd(2,2,2)
=1+1+1+1+1+1+1+2=9

Thus, the answer is 9.

Sample Input 2

200

Sample Output 2

10813692


program main;
var s,a,b,c,n : longint;
function gcd(a,b :longint):longint;
var temp : longint;
begin
    repeat
    temp := b;
    b := a mod b;
    a := temp;
    until b = 0;
    gcd := a;
end;
begin
    s := 0;
    readln(n);
    for a := 1 to n do
        for b := 1 to n do
            for c := 1 to n do
                s := s + gcd(gcd(a,b),c);
    writeln(s);
end.


program SumofGCD;
var
    k, mid, fin, h, i, j  : Longint;

function findgcd(x : longint; y : longint):longint;
begin
    if (y = 0) then findgcd := x
        else findgcd := findgcd(y, x mod y);
end;

begin
    readln(k);
    fin := 0;
    for h := 1 to k do begin
        for i := 1 to k do begin
            for j := 1 to k do begin
                mid := findgcd(i, j);
                fin += findgcd(h, mid)
            end;
        end;
    end;
    writeln(fin);
end.


program hi;
var
    a, b, c, k, i, ans: longint;
    r: array[1..200] of longint;

function gcd(x: longint; y: longint): longint;
begin
    if y = 0 then
        gcd := x
    else
        gcd := gcd(y, x mod y);
end;

begin
    readln(k);
    for i := 1 to k do
        r[i] := i;
    ans := 0;
    for c := 1 to k do
        for b := 1 to k do
            for a := 1 to k do
                ans := ans + gcd(gcd(r[a], r[b]), r[c]);
    writeln(ans);
end.


program hi;
var
    a, b, c, k, i, ans: longint;
    r: array[1..200] of longint;

procedure aswap(var x: longint; var y: longint);
var tmp: longint;
begin
    if x > y then begin
        tmp := x;
        x := y;
        y := tmp;
    end;
end;

function gcd(x: longint; y: longint): longint;
var i: longint;
begin
    aswap(x, y);
    for i := 1 to y do
        if (x mod i = 0) and (y mod i = 0) then
            gcd := i;
end;

begin
    readln(k);
    for i := 1 to k do
        r[i] := i;
    ans := 0;
    for c := 1 to k do
        for b := 1 to k do
            for a := 1 to k do
                ans := ans + gcd(gcd(r[a], r[b]), r[c]);
    writeln(ans);
end.


Program main;
var
    i, j, k, n : integer;
    sum : int64;

function gcd(a, b, c : integer) : int64;
var
    i : integer;
begin
    for i := 1 to n do
        if (a mod i = 0) and (b mod i = 0) and (c mod i = 0)
            then gcd := i;
end;

begin
    sum := 0;
    readln(n);
    for i := 1 to n do
        for j := 1 to n do
            for k := 1 to n do
                sum := sum + gcd(i,j,k);
    writeln(sum);
end.


program main;
var
	n, sum : integer;
    i, j, k : integer;

function gcd(x, y : integer) : integer;
begin
	while true do
    begin
   		x := x mod y;
        if x = 0 then break;
        y := y mod x;
        if y = 0 then break;
    end;
    gcd := x + y;
end;

begin
	sum := 0;
	readln(n);
    for i := 1 to n do
    	for j := 1 to n do
        	for k := 1 to n do
            	sum := sum + gcd(gcd(i, j), k);
    writeln(sum);
end.


program main;
var
	n, sum : integer;
    i, j, k : integer;

function gcd(x, y : integer) : integer;
begin
	if y = 0 then gcd := x
	else gcd := gcd(y, x mod y);
end;

begin
	sum := 0;
	readln(n);
    for i := 1 to n do
    	for j := 1 to n do
        	for k := 1 to n do
            	sum := sum + gcd(gcd(i, j), k);
    writeln(sum);
end.


var
    i,j,k : integer;
    n : integer;
    sum : longint;
    dp : array [1..200,1..200] of integer;
function gcd(a,b : integer):integer;
var cur,wth:integer;
begin
    wth:=1;
    for cur:=2 to 200 do begin
        while ((a mod cur) = 0) and ((b mod cur) = 0) do begin
            a:=(a div cur);
            b:=(b div cur);
            wth:=wth*cur;
        end;
    end;
    gcd:=wth;
end;
begin
    for i:=1 to 200 do
        for j:=1 to 200 do
            dp[i][j]:=gcd(i,j);
    readln(n);
    sum:=0;
    for i:=1 to n do
        for j:=1 to n do
            for k:=1 to n do sum:=sum+dp[dp[i][j]][k];
    writeln(sum);
end.


function gcd(a,b:Longint):Longint;
begin
if b=0 then gcd:=a else gcd:=gcd(b,a mod b);
end;
var K,a,b,c,ans:Longint;
begin
read(K);
for a:=1 to K do for b:=1 to K do for c:=1 to K do inc(ans,gcd(a,gcd(b,c)));
writeln(ans);
end.


var k,ans,a,b,c,d :integer;

function gcd(p,q:integer):integer;
begin
  if (p mod q =0)then gcd:=q
  else gcd(q,p mod q)
end;

begin
  readln(k);
  ans:=0;
  for a:=1 to k do
  begin
    for b:=1 to k do
    begin
      d:=gcd(a,b);
      for c:=1 to k do
      begin
        inc(ans,gcd(d,c));
      end;
    end;
  end;
  writeln(ans);
end.


var
i,j,k,N:Longint;
S:String;
R,G,B,ans:int64;
begin
readln(N);
readln(S);
for i:=1 to N do if S[i]='R'then inc(R)else if S[i]='B'then inc(B)else inc(G);
ans:=R*G*B;
for i:=1 to N do for j:=i+2 to N do if(j-i)mod 2=0 then begin
if(S[i]<>S[j])and(S[i]<>S[(i+j)div 2])and(S[j]<>S[(i+j)div 2])then dec(ans);
end;
writeln(ans);
end.

Score : 400 points

Problem Statement

We have a string S of length N consisting of R, G, and B.

Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions:

S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k.

j - i \neq k - j.

Constraints

1 \leq N \leq 4000

S is a string of length N consisting of R, G, and B.

Input

Input is given from Standard Input in the following format:

N
S

Output

Print the number of triplets in question.

Sample Input 1

4
RRGB

Sample Output 1

1

Only the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4) satisfies the first condition but not the second, so it does not count.

Sample Input 2

39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB

Sample Output 2

1800


var n,i,j,r,g,b,cnt  :int64;
    s:string;

begin
  readln(n);
  readln(s);
  r:=0; g:=0; b:=0; cnt:=0;
  for i:=1 to n do begin
    if s[i]='R' then inc(r,1);
    if s[i]='G' then inc(g,1);
    if s[i]='B' then inc(b,1);
  end;
  for i:=1 to n-1 do
    for j:=i to n do begin
      if ((j-i)mod 2=0)and(s[i]<>s[j])and(s[j]<>s[(i+j)div 2])and(s[i]<>s[(i+j)div 2])
      then inc(cnt,1)
    end;
  writeln(r*g*b-cnt)
end.


var s:string;
    n,ans,i,j,k:int64;

begin
  readln(n);
  readln(s);
  ans:=0;
  for i:=1 to n-2 do begin
    for k:=i+2 to n do begin
      for j:=i+1 to k-1 do begin
        if((j-i)<>(k-j))
        or((s[i]<>s[j])and(s[j]<>s[k])and(s[k]<>s[i]))
        then inc(ans,1);
      end;
    end;
  end;
  writeln(ans);
end.


var s:string;
    n,ans,i,j,k:int64;

begin
  readln(n);
  readln(s);
  ans:=0;
  for i:=1 to n-2 do begin
    for k:=i+2 to n do begin
      for j:=i+1 to k-1 do begin
        if((j-i)<>(k-j))
        or((s[i]<>s[j])and(s[j]<>s[k])and(s[k]<>s[i]))
        then inc(ans,1);
      end;
    end;
  end;
end.


var s:string;
    n,ans,i,j,k:int64;

begin
  readln(n);
  readln(s);
  ans:=0;
  for j:=2 to n-1 do begin
    for i:=j-1 downto 1 do begin
      for k:=j+1 to n do begin
        if((j-i)<>(k-j))
        or((s[i]<>s[j])and(s[j]<>s[k])and(s[k]<>s[i]))
        then inc(ans,1);
      end;
    end;
  end;
end.


var s:ansistring;
r,c,g:array [1..4000] of longint;
i,j,k,ans,n:longint;
begin
  readln(n);
  readln(s);
  for i:=1 to n do
    for j:=i+1 to n do
      if (s[i]<>s[j]) then
        for k:=j+1 to n do
          if  (s[k]<>s[j]) and (s[i]<>s[k]) and (j-i<>k-j) then
            inc(ans);
  writeln(ans);
end.


var s:ansistring;
i,j,k,ans,n:longint;
begin
  readln(n);
  readln(s);
  for i:=1 to n do
    for j:=i+1 to n do
      for k:=j+1 to n do
        if (s[i]<>s[j]) and (s[k]<>s[j]) and (s[i]<>s[k]) and (j-i<>k-j) then
          inc(ans);
  writeln(ans);
end.


var s:ansistring;
i,j,k,ans,n:longint;
begin
  readln(n);
  readln(s);
  for i:=1 to n do
    for j:=i to n do
      for k:=j to n do
        if (s[i]<>s[j]) and (s[k]<>s[j]) and (s[i]<>s[k]) and (j-i<>k-j) then
          inc(ans);
  writeln(ans);
end.


const max=5000;
var
  r,b,g:array[0..max] of longint;
  n,i,j:longint;
  ans:int64;
  s:ansistring;
begin
  readln(n);
  readln(s);
  for i:=n downto 1 do
  begin
    r[i]:=r[i+1];
    g[i]:=g[i+1];
    b[i]:=b[i+1];
    if (s[i]='R') then inc(r[i]);
    if (s[i]='G') then inc(g[i]);
    if (s[i]='B') then inc(b[i]);
  end;
  for i:=2 to n-1 do
   begin
     for j:=i-1 downto 1 do
     if (s[i]<>s[j]) then
     begin
       if (s[i]='R') and (s[j]='G') or (s[i]='G') and (s[j]='R') then
       begin
         ans:=ans+b[i+1];
         if (i-j+i<=n) then if (s[i-j+i]='B') then dec(ans);
       end;
       if (s[i]='R') and (s[j]='B') or (s[i]='B') and (s[j]='R') then
       begin
         ans:=ans+g[i+1];
         if (i-j+i<=n) then if (s[i-j+i]='G') then dec(ans);
       end;
       if (s[i]='G') and (s[j]='B') or (s[i]='B') and (s[j]='G') then
       begin
         ans:=ans+r[i+1];
         if (i-j+i<=n) then if (s[i-j+i]='R') then dec(ans);
       end;
     end;
   end;
   writeln(ans);
end.


program main;
var x ,y ,z : integer;
begin
read(x, y ,z);
write(z,' ',x,' ',y);
end.

Score : 100 points

Problem Statement

We have three boxes A, B, and C, each of which contains an integer.

Currently, the boxes A, B, and C contain the integers X, Y, and Z, respectively.

We will now do the operations below in order. Find the content of each box afterward.

Swap the contents of the boxes A and B

Swap the contents of the boxes A and C

Constraints

1 \leq X,Y,Z \leq 100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y Z

Output

Print the integers contained in the boxes A, B, and C, in this order, with space in between.

Sample Input 1

1 2 3

Sample Output 1

3 1 2

After the contents of the boxes A and B are swapped, A, B, and C contain 2, 1, and 3, respectively.

Then, after the contents of A and C are swapped, A, B, and C contain 3, 1, and 2, respectively.

Sample Input 2

100 100 100

Sample Output 2

100 100 100

Sample Input 3

41 59 31

Sample Output 3

31 41 59


program main;
var x ,y ,z : integer;
begin
read(x, y ,z);
write(z ,x ,y);
end.


program main;
var x, y, z, t : integer;
begin
    readln(x, y, z);
    writeln(z, ' ', x, ' ', y);
end.


program train;
var
    i, temp : integer;
    a : array[1..3] of integer;

begin
    for i := 1 to 3 do
        read(a[i]);

    temp := a[1];
    a[1] := a[2];
    a[2] := temp;

    temp := a[1];
    a[1] := a[3];
    a[3] := temp;

    for i := 1 to 3 do
        write(a[i],' ');

end.


program main;
var a,b,c : integer;
begin
	readln(a,b,c);
    writeln(c,' ',a,' ',b);
end.


program ABCSwap;
var
	A, B, C, temp : integer;
begin
	readln(A, B, C);

	temp:= A;
	A := B;
	B:= temp;

	temp:= A;
	A := C;
	C:= temp;

	writeln(A, ' ', B, ' ', C);
end.


program main;
var
x, y, z, a, b, c : integer;

begin
    read(x, y, z);
    a := z;
    b := x;
    c := y;
    write(a:0,b :4, c :4);
end.


program main;
var
x, y, z, a, b, c : integer;

begin
    read(x, y, z);
    a := z;
    b := x;
    c := y;
    write(a:0,b :3, c :3);
end.


program main;
var

x, y, z, a, b, c : integer;

begin
	read(x, y, z);
    a := z;
    b := x;
    c := y;
    write(a, b, c);
end.


program main;
var a,b,c,temp : integer;
begin
    temp:=0;
    readln(a,b,c);
    temp:=a;
    a:=b;
    b:=temp;
    temp:=a;
    a:=c;
    c:=temp;
    writeln(a,' ',b,' ',c);
end.


program hihi;
var a, b, c : integer;
begin
	readln(a, b, c);
    writeln(c, ' ', a, ' ', b);
end.


program main;
var
	a,b,c : integer;
begin
	read(a);
    read(b);
    read(c);
    writeln(c,' ',a,' ',b);

end.


program main;
var
	a,b,c : integer;
begin
	read(a);
    read(b);
    read(c);
    writeln(c,a,b);

end.


program main;
var
    a, b, c : integer;
begin
    readln(a, b, c);
    writeln(c,' ', a,' ', b)
end.


program hi;
var x, y, z: integer;
begin
	readln(x, y, z);
    writeln(z, ' ', x, ' ', y)
end.


program ABCSwap;
var
    x, y, z : int64;
begin
    readln(x, y, z);
    writeln(z,' ',x ,' ',y);
end.


program main;
var x, y, z : integer;
begin
	readln(x, y, z);
    writeln(z , ' ', x , ' ', y);
end.


program main;
var
	a, b, c : integer;
begin
	readln(a,b,c);
    writeln(c,' ',b,' ',a);
end.


program main;
var
    a, b, c : integer;

begin
    readln(a, b, c);
    writeln(c, ' ', a, ' ', b);
end.


program hihi;
var A, B, C, temporary: integer;
begin
	readln(A, B, C);
    temporary:=B;
    B:=A;
    A:=temporary;
    temporary:=C;
    C:=A;
    A:=temporary;
    writeln(A, B, C);
end.


program main;
var
	a,b,c : integer;
begin
	read(a,b,c);
    write(c,' ',a,' ',b);
end.


program test;

var
    a, b, c : integer;
begin
    read(a, b ,c);
    writeln(c, ' ', a, ' ', b)
end.


program main;

var
	x, y, z : integer;

begin
	readln(x, y, z);
    writeln(z, ' ', x, ' ', y);
end.


program main;

var
	x, y, z : integer;

begin
	readln(x, y, z);
    writeln(x, ' ', y, ' ', z);
end.


program main;
var x, y, z, t : integer;
begin
  readln(x, y, z);
  writeln(z, ' ', x, ' ', y);
end.


program main;
var n, m, i, t, c : integer;
	a : array[1..100] of integer;
begin
t := 0;
c := 0;
read(n, m);
for i := 1 to n do begin
	read(a[i]);
    t := t + a[i];
end;
for i := 1 to n do begin
	if t*(1/(4*m)) - a[i] < 0
    	then c := c + 1;
end;
if c >= m then write('No') else write('Yes');
end.

Score : 200 points

Problem Statement

We have held a popularity poll for N items on sale. Item i received A_i votes.

From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes.

If M popular items can be selected, print Yes; otherwise, print No.

Constraints

1 \leq M \leq N \leq 100

1 \leq A_i \leq 1000

A_i are distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
A_1 ... A_N

Output

If M popular items can be selected, print Yes; otherwise, print No.

Sample Input 1

4 1
5 4 2 1

Sample Output 1

Yes

There were 12 votes in total. The most popular item received 5 votes, and we can select it.

Sample Input 2

3 2
380 19 1

Sample Output 2

No

There were 400 votes in total. The second and third most popular items received less than \dfrac{1}{4\times 2} of the total number of votes, so we cannot select them. Thus, we cannot select two popular items.

Sample Input 3

12 3
4 56 78 901 2 345 67 890 123 45 6 789

Sample Output 3

Yes


program main;
var n, m, i, t, c : integer;
	a : array[1..100] of integer;
begin
t := 0;
c := 0;
read(n, m);
for i := 1 to n do begin
	read(a[i]);
    t := t + a[i];
end;
for i := 1 to n do begin
	if t*(1/(4*m)) - a[i] < 0
    	then c := c + 1;
end;
if c >= m then write('Yes') else write('No');
end.


program main;
var n, m, i, t, c : integer;
	a : array[1..100] of integer;
begin
t := 0;
c := 0;
read(n, m);
for i := 1 to n do begin
	read(a[i]);
    t := t + a[i];
end;
for i := 1 to n do begin
	if t*(1/(4*m)) - a[i] < 0
    	then c := c + 1;
end;
if ((c >= m) and (m > 0)) then write('Yes') else write('No');
end.


program main;
var n, m, i, t, c : integer;
	a : array[1..100] of integer;
begin
t := 0;
c := 0;
read(n, m);
for i := 1 to n do begin
	read(a[i]);
    t := t + a[i];
end;
for i := 1 to n do begin
	if t*(1/(4*m)) - a[i] < 0
    	then c := c + 1;
end;
if ((c >= m) and (m <= n)) then write('Yes') else write('No');
end.


program main;
var n, m, i, t, c : integer;
	a : array[1..100] of integer;
begin
t := 0;
c := 0;
read(n, m);
for i := 1 to n do begin
	read(a[i]);
    t := t + a[i];
end;
for i := 1 to n do begin
	if t*(1/(4*m)) - a[i] < 0
    	then c := c + 1;
end;
if ((c >= m) and (m >= n)) then write('Yes') else write('No');
end.


program main;
var n, m, i, t, c : integer;
	a : array[1..100] of integer;
begin
t := 0;
c := 0;
read(n, m);
repeat
   read(n, m);
until n >= m;
for i := 1 to n do begin
    repeat
	read(a[i]);
	until a[i] <= 1000;
    t := t + a[i];
end;
for i := 1 to n do begin
	if t*(1/(4*m)) - a[i] < 0
    	then c := c + 1;
end;
if c >= m then write('Yes') else write('No');
end.


program main;
var n, m, i, t, c : integer;
	a : array[1..1000] of integer;
begin
t := 0;
c := 0;
read(n, m);
for i := 1 to n do begin
	read(a[i]);
    t := t + a[i];
end;
for i := 1 to n do begin
	if t*(1/(4*m)) - a[i] < 0
    	then c := c + 1;
end;
if c >= m then write('Yes') else write('No');
end.


program train;
var
    total : longInt;
    i, count, N, M : integer;
    a : array[1..100] of integer;

begin
    total := 0;
    read(N, M);
    for i := 1 to N do begin
        read(a[i]);
        total := total + a[i];
        end;
    count := 0;
    for i := 1 to N do
        if a[i] >= total/(4*M)
            then count := count + 1;
    if count <> M
        then writeln('No')
        else writeln('Yes');
end.


program train;
var
    total : longInt;
    i, N, M : integer;
    a : array[1..100] of integer;

begin
    total := 0;
    read(N, M);
    for i := 1 to N do begin
        read(a[i]);
        total := total + a[i];
        end;
    if a[M] < total/(4*a[M])
        then write('No')
        else write('Yes');
end.


program train;
var
    total : longInt;
    i, N, M : integer;
    a : array[1..100] of integer;

begin
    total := 0;
    read(N, M);
    for i := 1 to N do begin
        read(a[i]);
        total := total + a[i];
        end;
    if a[M] < total/4
        then write('No')
        else write('Yes');
end.


program train;
var
    total : longInt;
    i, count, N, M : integer;
    a : array[1..1000000] of integer;

begin
    total := 0;
    read(N, M);
    for i := 1 to N do begin
        read(a[i]);
        total := total + a[i];
        end;
    count := 0;
    for i := 1 to N do
        if a[i] > total/(4*M)
            then count := count + 1;
    if (count = M) or (count > M)
        then writeln('Yes')
        else writeln('No');
end.


program train;
var
    total : longInt;
    i, count, N, M : integer;
    a : array[1..1000] of integer;

begin
    read(N, M);
    for i := 1 to N do begin
        read(a[i]);
        total := total + a[i];
        end;
    count := 0;
    for i := 1 to N do
        if a[i] > total/(4*M)
            then count := count + 1;
    if (count = M) or (count > M)
        then writeln('Yes')
        else writeln('No');
end.


program main;

var N, M, i: integer;
  A: array[1..100] of integer;
  total, count: integer;

begin

  readln(N, M);
  for i := 1 to N do read(A[i]);
  total := 0;
  for i := 1 to N do total := total + A[i];

  count := 0;
  for i := 1 to N do
    if A[i] >= total/(4*M)
      then count := count + 1;

  if count >= M
    then writeln('Yes')
    else writeln('No');

end.


program main;
var
    n, m, sum, i, count, comp : integer;
    a : array[1..100] of integer;

begin
    readln(n, m);

    sum := 0;
    for i := 1 to n do begin
        read(a[i]);
        sum += a[i];
    end;

    comp := sum div (4 * m);
    if ((sum mod (4 * m)) > 0) then
        comp := comp + 1;

    count := 0;
    for i := 1 to n do
        if (a[i] >= comp) then
            count := count + 1;

    if (count >= m) then
        writeln ('Yes')
    else
        writeln ('No');
end.


program main;
var
    n, m, sum, i, count : integer;
    a : array[1..100] of integer;

begin
    readln(n, m);

    sum := 0;
    for i := 1 to n do begin
        read(a[i]);
        sum += a[i];
    end;

    sum := sum div (4 * m);
    if (sum mod (4 * m) > 0) then
        sum := sum + 1;

    count := 0;
    for i := 1 to n do
        if a[i] >= sum then
            count := count + 1;

    if (count >= m) then
        writeln ('Yes')
    else
        writeln ('No');
end.


program main;
var
    n, m, sum, i, count : integer;
    a : array[1..100] of integer;

begin
    readln(n, m);

    sum := 0;
    for i := 1 to n do begin
        read(a[i]);
        sum += a[i];
    end;

    sum := sum div (4 * m);
    if (sum mod (4 * m) > 0) then
        sum := sum + 1;

    count := 0;
    for i := 1 to n do
        if a[i] > sum then
            count := count + 1;

    if (count >= m) then
        writeln ('Yes')
    else
        writeln ('No');
end.


program main;
var
    n, m, sum, i, count : integer;
    a : array[1..100] of integer;

begin
    readln(n, m);

    sum := 0;
    for i := 1 to n do begin
        read(a[i]);
        sum += a[i];
    end;

    sum := sum div (4 * m); count := 0;
    for i := 1 to n do
        if a[i] > sum then
            inc(count);

    if (count >= m) then
        writeln ('Yes')
    else
        writeln ('No');
end.


program PopularVote;
var
	N, M, i, count : integer;
	total : int64;
	r :real;
	a : array[1..100] of integer;
begin
	readln(N, M); count := 0; total := 0;

	for i := 1 to N do begin
		read(a[i]);
		total := total + a[i] ;
	end;

	r := total*(1 / (4 * M));
	for i := 1 to N do
		if a[i] >= r
			then count := count + 1;

	if count >= M
		then writeln('Yes')
		else writeln('No');
end.


program PopularVote;
var
	N, M, i, count, total  : integer;
	r :real;
	a : array[1..100] of integer;
begin
	readln(N, M); count := 0; total := 0;

	for i := 1 to N do begin
		read(a[i]);
		total := total + a[i] ;
	end;
	r := total*(1 / (4 * M));
	for i := 1 to N do
		if a[i] > r
			then count := count + 1;

	if count >= M
		then writeln('Yes')
		else writeln('No');
end.


program main;
var
m, n, i, total, count : integer;
a : array[1..1000] of integer;

begin
	read(n, m);
    total := 0;
    for i := 1 to n do begin
    	read(a[i]);
        total := total + a[i];
    end;

    count := 0;

    for i := 1 to n do begin
        if (a[i]/total) >= (1/(4*m))
            then count := count + 1
    end;
    if count >= m
        then writeln('Yes')
            else writeln('No');
end.


program main;
var
m, n, i, total, count : integer;
a : array[1..1000] of integer;

begin
	read(n, m);
    total := 0;
    for i := 1 to n do begin
    	read(a[i]);
        total := total + a[i];
    end;

    count := 0;

    for i := 1 to n do begin
        if (a[i]/total) > (1/(4*m))
            then count := count + 1
    end;
    if count >= m
        then writeln('Yes')
            else writeln('No');
end.


program main;
var
m, n, i, total, max : integer;
a : array[1..1000] of integer;

begin
	read(n, m);
    total := 0;
    max := 0;
    for i := 1 to n do begin
    	read(a[i]);
        total := total + a[i];
        if a[i] > max
            then max := a[i];
    end;
    if (max / total) > (1 /(4*m))
        then writeln('Yes')
            else writeln('No');
end.


program main;
var
m, n, i, total : integer;
a : array[1..1000] of integer;

begin
	read(n, m);
    total := 0;
    for i := 1 to n do begin
    	read(a[i]);
        total := total + a[i];
    end;
    if (n / total) > (1 /(4*m))
        then writeln('Yes')
            else writeln('No');
end.


program main;
var
m, n, i, total : integer;
a : array[1..1000] of integer;

begin
	read(n, m);
    total := 0;
    for i := 1 to m do begin
    	read(a[i]);
        total := total + a[i];
    end;
    if (n / total) > (1 /(4*m))
        then writeln('Yes')
            else writeln('No');
end.


program main;
var
m, n, i, total : integer;
a : array[1..1000] of integer;

begin
	read(m, n);
    total := 0;
    for i := 1 to m do begin
    	read(a[i]);
        total := total + a[i];
    end;
    if (n / total) > (1 /(4*m))
        then writeln('Yes')
            else writeln('No');
end.


program main;
var
m, n, i, total : integer;
a : array[1..1000] of integer;

begin
	read(m, n);
    total := 0;
    for i := 1 to m do begin
    	read(a[i]);
        total := total + a[i];
    end;
    if (n / total) > (1 /(4*m))
        then writeln('yes')
            else writeln('no');
end.


program main;
var a: array[1..100] of integer;
    m,n,i,v,total : integer;
    q: real;
begin
    v:=0;
    q:=0;
    total:=0;

    readln(m,n);

    for i := 1 to m do begin
        read(a[i]);
        total:= total + a[i];
    end;

    q:=(1/(4*n))*total;

    for i := 1 to m do
        if a[i] >= q
        then inc(v);

    if v >= n
    then writeln('Yes')
    else writeln('No');
end.


program hihi;
var
	N, M, i, total, count : integer;
	A : array[1..100] of integer;
begin
	readln(N, M);
    for i:=1 to N do
    	read(A[i]);
    total:=0;
    for i:=1 to N do
    	total:= total + A[i];
    count:=0;
    for i:=1 to N do
    	if A[i]>= total / (4 *M)
        	then count:= count + 1;
    if count >= M
    	then writeln('Yes')
        else writeln('No');
end.


program main;
var
	n, m, i, cnt, sum : longint;
    a : array[1..1000] of longint;
begin
	readln(n, m);
    cnt := 0;
    sum := 0;
    for i := 1 to n do begin
    	read(a[i]);
        sum := sum + a[i];
   end;
   for i := 1 to n do begin
   		if(a[i]*4*m >= sum)
        	then inc(cnt);
   end;
   if cnt >= m
   		then writeln('Yes')
        else writeln('No');
end.


program main;
var
    x, y, i, count : integer;
    vote : real;
    A : array[1..1000] of integer;
begin
    readln(x, y);
    vote := 0;
    count := 0;
    for i := 1 to x do begin
        read(A[i]);
        vote := vote + A[i];
    end;
    vote := vote/(4*y);
    for i := 1 to x do
        if A[i] >= vote
            then count := count + 1;
    if count >= y
        then writeln('Yes')
        else writeln('No');
end.


program main;
var
    x, y, i, count : longint;
    vote : real;
    A : array[1..1000] of integer;
begin
    readln(x, y);
    vote := 0;
    count := 0;
    for i := 1 to x do begin
        read(A[i]);
        vote := vote + A[i];
    end;
    vote := vote/(4*y);
    for i := 1 to x do
        if A[i] >= vote
            then count := count + 1;
    if count >= 2
        then writeln('Yes')
        else writeln('No');
end.


program main;
var
    x, y, i, count : integer;
    vote : real;
    A : array[1..1000] of integer;
begin
    readln(x, y);
    vote := 0;
    count := 0;
    for i := 1 to x do begin
        read(A[i]);
        vote := vote + A[i];
    end;
    vote := vote/(4*y);
    for i := 1 to x do
        if A[i] >= vote
            then count := count + 1;
    if count >= 2
        then writeln('Yes')
        else writeln('No');
end.


program main;
var
    i,j,k:integer;
    req:real;
    sum,n,m:integer;
    arr:array[1..10000] of integer;
begin
    readln(n,m);
    sum:=0;
    for i:=1 to n do begin
        read(arr[i]);
        sum:=sum+arr[i];
    end;
    req:=sum/4/m;
    for i:=1 to n do if (arr[i]>=req) then m:=m-1;
    if (m<=0) then writeln('Yes') else writeln('No');
end.


program Popularvote;
var
    list : array[1..100] of Longint;
    x, y, i, j, total, select : Longint;

begin
    total := 0;
    select := 0;
    readln(x, y);
    for i := 1 to x do begin
        read(list[i]);
        total += list[i];
    end;
    for j := 1 to x do begin
        if list[j] >= (total / (y * 4)) then
            select += 1;
    end;
    if select >= y then
        writeln('Yes')
    else
        writeln('No');
end.


program hi;
var
    n, m, i, sum, cnt: integer;
    a: array[0..110] of integer;

begin
    sum := 0; cnt := 0;
    readln(n, m);
    for i := 0 to n do begin
        read(a[i]);
        sum := sum + a[i];
    end;
    for i := 0 to n do begin
        if a[i] >= sum / (4 * m) then
            cnt := cnt + 1;
    end;
    if cnt >= m then
        writeln('Yes')
    else
        writeln('No');
end.


program main;
var
	N, M, i, sum, count : integer;
    A : array[1..100] of integer;
begin
	readln(N, M);
    sum := 0 ;
    count := 0;
    for i := 1 to N do begin
    	read(A[i]);
        sum := sum + A[i];
    end;

    for i := 1 to N do begin
    	if A[i] >= sum / (4 * M)
        then count := count + 1;
   	end;

    if count >= M
    then writeln('Yes')
    else writeln('No');
end.


program main;

var
	n, m, sum, cnt : integer;
	i : integer;
   	a : array[0..105] of integer;

begin
	sum := 0;
    cnt := 0;
	readln(n, m);
    for i := 0 to n do begin
    	read(a[i]);
        sum := sum + a[i];
    end;

    for i := 0 to n do begin
    	if a[i] >= sum / (4 * m) then
        	cnt := cnt + 1;
    end;

    if cnt >= m then
    	writeln('Yes')
    else
    	writeln('No');
end.


program test;

var
    cnt, t, i, n, m : integer;
    a : array[1..1005] of integer;
begin
    readln(n, m);
    t:=0;
    for i:=1 to n do begin
        read(a[i]);
        t := t+a[i]
    end;
    for i:=1 to n do begin
        if (a[i] >= 1/4/m*t) then cnt := cnt + 1;
    end;
    if cnt >= m then writeln('Yes') else writeln('No');

end.


program main;
var
  N, M, i, total, count : integer;
  A : array[1..100] of integer;
begin
  readln(N, M);
  for i := 1 to N do
    read(A[i]);

  // calculate total
  total := 0;
  for i := 1 to N do
    total := total + A[i];

  // count number of enough votes
  count := 0;
  for i := 1 to N do
    if A[i] >= total / (4 * M) then
      count := count + 1;

  if count >= M then
    writeln('Yes')
  else
    writeln('No');
end.


var n, m, i, sum, val, cnt : longint;
    a : array[1..1000] of longint;

begin
    readln(n, m);
    sum := 0;
    for i := 1 to n do
    begin
        read(a[i]);
        sum := sum + a[i];
    end;
    val := (sum + 4 * m - 1) div (4 * m);
    cnt := 0;
    for i := 1 to n do
    if (a[i] >= val) then inc(cnt);

    if (cnt < m) then writeln('No')
    else writeln('Yes');
end.


type SortDataType=Longint;
function SortCmp(const a,b:SortDataType):Boolean;forward;
procedure SortImpl(var A:Array of SortDataType;L,R:Longint);
var
	tmp:SortDataType;
	mid,il,ir:Longint;
begin
	if R-L<20 then begin
		for ir:=R-1 downto L+1 do for il:=L to ir-1 do if SortCmp(A[il+1],A[il])then begin
			tmp:=A[il];
			A[il]:=A[il+1];
			A[il+1]:=tmp;
		end;
	end else begin
		mid:=(L+R)div 2;
		if SortCmp(A[mid],A[L])then begin
			tmp:=A[mid];
			A[mid]:=A[L];
			A[L]:=tmp;
		end;
		if SortCmp(A[R-1],A[mid])then begin
			tmp:=A[R-1];
			A[R-1]:=A[mid];
			A[mid]:=tmp;
			if SortCmp(A[mid],A[L])then begin
				tmp:=A[mid];
				A[mid]:=A[L];
				A[L]:=tmp;
			end;
		end;
		il:=L;
		ir:=R-1;
		while il<=ir do begin
			while SortCmp(A[il],A[mid])do inc(il);
			while SortCmp(A[mid],A[ir])do dec(ir);
			if il<ir then begin
				tmp:=A[il];
				A[il]:=A[ir];
				A[ir]:=tmp;
				if mid=il then mid:=ir else if mid=ir then mid:=il;
				inc(il);
				dec(ir);
			end else if il=ir then begin
				inc(il);
				dec(ir);
			end;
		end;
		SortImpl(A,L,il);
		SortImpl(A,il,R);
	end;
end;
procedure Sort(var A:Array of SortDataType;size:Longint);
begin
	SortImpl(A,0,size);
end;
function SortCmp(const a,b:SortDataType):Boolean;
begin
	SortCmp:=a>b;
end;
var
	X,Y,A,B,C,i:Longint;
	p,q,r:Array[1..100000]of Longint;
	s:Array[1..300000]of Longint;
	ans:int64;
begin
	read(X,Y,A,B,C);
	for i:=1 to A do read(p[i]);
	for i:=1 to B do read(q[i]);
	for i:=1 to C do read(r[i]);
	Sort(p,A);
	Sort(q,B);
	for i:=1 to X do s[i]:=p[i];
	for i:=1 to Y do s[X+i]:=q[i];
	for i:=1 to C do s[X+Y+i]:=r[i];
	Sort(s,X+Y+C);
	for i:=1 to X+Y do inc(ans,s[i]);
	writeln(ans);
end.

Score : 500 points

Problem Statement

You are going to eat X red apples and Y green apples.

You have A red apples of deliciousness p_1,p_2, \dots, p_A, B green apples of deliciousness q_1,q_2, \dots, q_B, and C colorless apples of deliciousness r_1,r_2, \dots, r_C.

Before eating a colorless apple, you can paint it red or green, and it will count as a red or green apple, respectively.

From the apples above, you will choose the apples to eat while making the sum of the deliciousness of the eaten apples as large as possible.

Find the maximum possible sum of the deliciousness of the eaten apples that can be achieved when optimally coloring zero or more colorless apples.

Constraints

1 \leq X \leq A \leq 10^5

1 \leq Y \leq B \leq 10^5

1 \leq C \leq 10^5

1 \leq p_i \leq 10^9

1 \leq q_i \leq 10^9

1 \leq r_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y A B C
p_1 p_2 ... p_A
q_1 q_2 ... q_B
r_1 r_2 ... r_C

Output

Print the maximum possible sum of the deliciousness of the eaten apples.

Sample Input 1

1 2 2 2 1
2 4
5 1
3

Sample Output 1

12

The maximum possible sum of the deliciousness of the eaten apples can be achieved as follows:

Eat the 2-nd red apple.

Eat the 1-st green apple.

Paint the 1-st colorless apple green and eat it.

Sample Input 2

2 2 2 2 2
8 6
9 1
2 1

Sample Output 2

25

Sample Input 3

2 2 4 4 4
11 12 13 14
21 22 23 24
1 2 3 4

Sample Output 3

74


var a,b,c:int64;
begin
readln(a,b,c);
if(a+b>c)then writeln('No')
else begin if(4*a*b<(c-a-b)*(c-a-b))then writeln('Yes') else writeln('No');end;
end.

Score : 300 points

Problem Statement

Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?

Constraints

1 \leq a, b, c \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

a \ b \ c

Output

If \sqrt{a} + \sqrt{b} < \sqrt{c}, print Yes; otherwise, print No.

Sample Input 1

2 3 9

Sample Output 1

No

\sqrt{2} + \sqrt{3} < \sqrt{9} does not hold.

Sample Input 2

2 3 10

Sample Output 2

Yes

\sqrt{2} + \sqrt{3} < \sqrt{10} holds.


{**
 * Author  : Nguyen Canh Toan
 * Problem : C - Sqrt Inequality
 * Link    : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c
**}
uses math;
const std='tmp';
var a,b,c:int64;
    input,output:text;
procedure main();
var ans:int64;
begin
  read(a,b,c);
  if (c-(a+b+2*sqrt(a)*sqrt(b))>0) then write('Yes') else write('No');
end;
BEGIN
  //assign(input,std+'.inp');reset(input);
  //assign(output,std+'.out');rewrite(output);
    main();
  //close(input);
  //close(output);
END.


var a,b:byte;
begin
readln(a, b);
if (a<9) and (b<9) then writeln(a*b) else writeln('-1');
end.

Score : 100 points

Problem Statement

Having learned the multiplication table, Takahashi can multiply two integers between 1 and 9 (inclusive) together. He cannot do any other calculation.

Given are two integers A and B.

If Takahashi can calculate A \times B, print the result; if he cannot, print -1 instead.

Constraints

1 \leq A \leq 20

1 \leq B \leq 20

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

If Takahashi can calculate A \times B, print the result; if he cannot, print -1.

Sample Input 1

2 5

Sample Output 1

10

2 \times 5 = 10.

Sample Input 2

5 10

Sample Output 2

-1

5\times 10 = 50, but Takahashi cannot do this calculation, so print -1 instead.

Sample Input 3

9 9

Sample Output 3

81


var a,b:byte;
begin
readln(a, b);
if ((a=9) and (b=1)) or ((a=9) and (b=9)) or ((a=1) and (b=9)) then write(a*b) else write('-1');

end.


program ex_1;
var
  s:string;
  k,u,x,us:longint;
  ans:qword;
begin
  readln(s);
  readln(k);
  while u<=(length(s)) do
    begin
	  inc(u);
	  inc(x);
	  if s[u+1]<>s[u] then begin
	    if x<>1 then begin
		  ans:=ans+(x div 2);
		end;

	    x:=0;
	  end;
	end;
  while s[us]=s[us+1] do inc(us);
  ans:=ans*k;
  if (s[1]=s[length(s)]) and (us mod 2=1) then ans:=ans-k+1;
  write(ans);
end.

Score : 300 points

Problem Statement

Given is a string S. Let T be the concatenation of K copies of S.
We can repeatedly perform the following operation: choose a character in T and replace it with a different character.
Find the minimum number of operations required to satisfy the following condition: any two adjacent characters in T are different.

Constraints

1 \leq |S| \leq 100

S consists of lowercase English letters.

1 \leq K \leq 10^9

K is an integer.

Input

Input is given from Standard Input in the following format:

S
K

Output

Print the minimum number of operations required.

Sample Input 1

issii
2

Sample Output 1

4

T is issiiissii. For example, we can rewrite it into ispiqisyhi, and now any two adjacent characters are different.

Sample Input 2

qq
81

Sample Output 2

81

Sample Input 3

cooooooooonteeeeeeeeeest
999993333

Sample Output 3

8999939997


var a:integer;
    s:string;
begin
  readln(a);
  readln(s);
  if a>=3200 then writeln(s)
  else writeln('red');
end.

Score : 100 points

Problem Statement

You will be given an integer a and a string s consisting of lowercase English letters as input.

Write a program that prints s if a is not less than 3200 and prints red if a is less than 3200.

Constraints

2800 \leq a < 5000

s is a string of length between 1 and 10 (inclusive).

Each character of s is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

a
s

Output

If a is not less than 3200, print s; if a is less than 3200, print red.

Sample Input 1

3200
pink

Sample Output 1

pink

a = 3200 is not less than 3200, so we print s = pink.

Sample Input 2

3199
pink

Sample Output 2

red

a = 3199 is less than 3200, so we print red.

Sample Input 3

4049
red

Sample Output 3

red

a = 4049 is not less than 3200, so we print s = red.


var a:int64;
 s:string;
 begin
 readln(a);
 read(s);
 if a>=3200 then write(s) else write('red')
 end.