alexjercan/bugnet huggingface dataset:
Problem B: Artistic Art Museum

Mr. Knight is a chief architect of the project to build a new art museum. One day, he was struggling to determine the design of the building. He believed that a brilliant art museum must have an artistic building, so he started to search for a good motif of his building. The art museum has one big theme: "nature and human beings." To reflect the theme, he decided to adopt a combination of a cylinder and a prism, which symbolize nature and human beings respectively (between these figures and the theme, there is a profound relationship that only he knows).

Shortly after his decision, he remembered that he has to tell an estimate of the cost required to build to the financial manager. He unwillingly calculated it, and he returned home after he finished his report. However, you, an able secretary of Mr. Knight, have found that one field is missing in his report: the length of the fence required to surround the building. Fortunately you are also a good programmer, so you have decided to write a program that calculates the length of the fence.

To be specific, the form of his building is union of a cylinder and a prism. You may consider the twodimensional projection of the form, i.e. the shape of the building is considered to be union of a circle C and a polygon P. The fence surrounds the outside of the building. The shape of the building may have a hole in it, and the fence is not needed inside the building. An example is shown in the figure below.

Input

The input contains one test case.

A test case has the following format:

R

N x1 y1 x2 y2 ... xn yn

R is an integer that indicates the radius of C (1 ≤ R ≤ 1000), whose center is located at the origin. N is the number of vertices of P, and (xi, yi) is the coordinate of the i-th vertex of P. N, xi and yi are all integers satisfying the following conditions: 3 ≤ N ≤ 100,|xi| ≤ 1000 and |yi| ≤ 1000.

You may assume that C and P have one or more intersections.

Output

Print the length of the fence required to surround the building. The output value should be in a decimal fraction may not contain an absolute error more than 10-4.

It is guaranteed that the answer does not change by more than 10-6 when R is changed by up to 10-9.

Sample Input 1

2
8 -1 2 1 2 1 -3 2 -3 2 3 -2 3 -2 -3 -1 -3

Output for the Sample Input 1

22.6303
Problem C: Complex Integer Solutions

Let f(x) = a0 + a1x + a2x2 + ... + adxd be the function where each ai (0 ≤ i ≤ d) is a constant integer (and ad is non-zero) and x is a variable. Your task is to write a program that finds all complex integer solutions of the equation f(x) = 0 for a given f(x). Here, by complex integers, we mean complex numbers whose
real and imaginary parts are both integers.

Input

The input consists of two lines. The first line of the input contains d, the degree of f(x). The second line contains (d + 1) integers a0, ... , ad, the coeffcients of the equation. You may assume all the following: 1 ≤ d ≤ 10, |ai| ≤ 106 and ad ≠ 0.

Output

There should be two lines in the output. In the first line, print the number m of complex integer solutions. In the second line, print m solutions separated by space. Each solution should be counted and printed exactly once even if it is a multiple root. The solutions should be printed in ascending order of their real parts then their imaginary parts, and in the following fashion: 0, -2, i, -3i, 2+i, and 3-4i.

Sample Input 1

4
-2 0 0 0 2

Output for the Sample Input 1

4
-1 -i i 1

Sample Input 2

8
0 0 25 15 17 -10 1 -1 1

Output for the Sample Input 2

5
-1-2i -1+2i 0 2-i 2+i
Problem D: Dial Key

You are a secret agent from the Intelligence Center of Peacemaking Committee. You've just sneaked into a secret laboratory of an evil company, Automated Crime Machines.

Your mission is to get a confidential document kept in the laboratory. To reach the document, you need to unlock the door to the safe where it is kept. You have to unlock the door in a correct way and with a great care; otherwise an alarm would ring and you would be caught by the secret police.

The lock has a circular dial with N lights around it and a hand pointing to one of them. The lock also has M buttons to control the hand. Each button has a number Li printed on it.

Initially, all the lights around the dial are turned off. When the i-th button is pressed, the hand revolves clockwise by Li lights, and the pointed light is turned on. You are allowed to press the buttons exactly N times. The lock opens only when you make all the lights turned on.

For example, in the case with N = 6, M = 2, L1 = 2 and L2 = 5, you can unlock the door by pressing buttons 2, 2, 2, 5, 2 and 2 in this order.

There are a number of doors in the laboratory, and some of them don’t seem to be unlockable. Figure out which lock can be opened, given the values N, M, and Li's.

Input

The input starts with a line containing two integers, which represent N and M respectively. M lines follow, each of which contains an integer representing Li.

It is guaranteed that 1 ≤ N ≤ 109, 1 ≤ M ≤ 105, and 1 ≤ Li ≤ N for each i = 1, 2, ... N.

Output

Output a line with "Yes" (without quotes) if the lock can be opened, and "No" otherwise.

Sample Input 1

6 2
2
5

Output for the Sample Input 1

Yes

Sample Input 2

3 1
1

Output for the Sample Input 2

Yes

Sample Input 3

4 2
2
4

Output for the Sample Input 3

No
Problem E: Dungeon Master

Once upon a time, in a fantasy world far, far away, monsters dug caves and dungeons for adventurers. They put some obstacles in their caves so it becomes more difficult and more exciting for the adventurers to reach the goal.

One day, Emils, one of the monsters in the caves, had a question about the caves. How many patterns of a cave can they make, by changing the locations of the obstacles in it?

Here's the detail of the question. A cave consists of W × H squares. Monsters can put obstacles at some of the squares, so that adventurers can't go into them. The total number of obstacles is fixed, and there can't be two or more obstacles in one square. Adventurers enter the cave from the top-left square, and try to reach the bottom-right square. They can move from one square to any of the four adjacent squares, as long as there are no obstacles in the destination square. There must be at least one path between any two squares that don't have obstacles. There must be no obstacles in the top-left square, nor in right-bottom square. The question is, given the width W and height H of the cave, and the number S of obstacles, how many patterns of the caves the monsters can make. As the obstacles have the same look, they should not
be distinguished each other.

It was a very interesting mathematical question. Emils couldn't solve this question by himself, so he told it to his colleagues instead. None of them could answer to it, though. After that, the question soon got popular among the monsters working in the caves, and finally, they became unable to sleep well as they always thought about the question.

You are requested to write a program that answers to the question.

Input

The input has a line, containing three integers W, H, and S, separated by a space. W and H are the horizontal and vertical sizes of the cave, and S is the number of obstacles to put in the cave. It is guaranteed that 2 ≤ W, H ≤ 8, and that 0 ≤ S ≤ W × H.

Output

Output the number of patterns of the cave, in a line.

Sample Input 1

2 2 2

Output for the Sample Input 1

0

Sample Input 2

2 2 1

Output for the Sample Input 2

2
Problem F: Exciting Bicycle

You happened to get a special bicycle. You can run with it incredibly fast because it has a turbo engine. You can't wait to try it off road to enjoy the power.

You planned to go straight. The ground is very rough with ups and downs, and can be seen as a series of slopes (line segments) when seen from a lateral view. The bicycle runs on the ground at a constant speed of V. Since running very fast, the bicycle jumps off the ground every time it comes to the beginning point of a slope slanting more downward than the previous, as illustrated below. It then goes along a parabola until reaching the ground, affected by the gravity with the acceleration of 9.8m/s2.

It is somewhat scary to ride the bicycle without any preparations - you might crash into rocks or fall into pitfalls. So you decided to perform a computer simulation of the ride.

Given a description of the ground, calculate the trace you will run on the ground by the bicycle. For simplicity, it is sufficient to output its length.

Input

The first line of the input has two integers N (2 ≤ N ≤ 10000) and V (1 ≤ V ≤ 10000), separated by a space. It is followed by N lines. The i-th line has two integers Xi and Yi (0 ≤ Xi, Yi ≤ 10000). V[m/s] is the ground speed of the bicycle. The (i - 1) line segments (Xi, Yi)-(Xi+1, Yi+1) form the slopes on the ground, with the sky in the positive direction of the Y axis. Each coordinate value is measured in meters.

The start is at (X1, Y1), and the goal is at (XN, YN). It is guaranteed that Xi < Xi+1 for 1 ≤ i ≤ N - 1.

You may assume that the distance of x-coordinate between the falling point and any endpoint (except for the jumping point) is not less than 10-5m.

Output

Output the length you will run on the ground with the bicycle, in meters. The value may be printed with any number of digits after the decimal point, should have the absolute or relative error not greater than 10-8.

Sample Input 1

5 10
0 0
10 10
20 0
30 10
40 0

Output for the Sample Input 1

22.22335598

Sample Input 2

2 10
0 0
10000 0

Output for the Sample Input 2

10000.00000000

Sample Input 3

4 10000
0 0
1 1
9999 0
10000 10000

Output for the Sample Input 3

11.21323169

Sample Input 4

4 50
0 10000
1 10000
2 0
10000 0

Output for the Sample Input 4

7741.23024274
Problem H: Magic Walls

You are a magician and have a large farm to grow magical fruits.

One day, you saw a horde of monsters, approaching your farm. They would ruin your magical farm once they reached your farm. Unfortunately, you are not strong enough to fight against those monsters. To protect your farm against them, you decided to build magic walls around your land.

You have four magic orbs to build the walls, namely, the orbs of Aquamarine (A), Bloodstone (B), Citrine (C) and Diamond (D). When you place them correctly and then cast a spell, there will be magic walls between the orbs A and B, between B and C, between C and D, and between D and A. The walls are built on the line segments connecting two orbs, and form a quadrangle as a whole. As the monsters cannot cross the magic walls, the inside of the magic walls is protected.

Nonetheless, you can protect only a part of your land, since there are a couple of restrictions on building the magic walls. There are N hills in your farm, where the orbs can receive rich power of magic. Each orb should be set on the top of one of the hills. Also, to avoid interference between the orbs, you may not place two or more orbs at the same hill.

Now, you want to maximize the area protected by the magic walls. Please figure it out.

Input

The input begins with an integer N (4 ≤ N ≤ 1500), the number of the hills. Then N line follow. Each of them has two integers x (0 ≤ x ≤ 50000) and y (0 ≤ y ≤ 50000), the x- and y-coordinates of the location of a hill.

It is guaranteed that no two hills have the same location and that no three hills lie on a single line.

Output

Output the maximum area you can protect. The output value should be printed with one digit after the decimal point, and should be exact.

Sample Input 1

5
2 0
0 1
1 3
4 2
3 4

Output for the Sample Input 1

7.5

Sample Input 2

4
0 0
0 3
1 1
3 0

Output for the Sample Input 2

3.0
Problem I: Sort by Hand

It's time to arrange the books on your bookshelf. There are n books in the shelf and each book has a unique number; you want to sort the books according to the numbers. You know that the quick sort and the merge sort are fast sorting methods, but it is too hard for you to simulate them by hand - they are efficient for computers, but not for humans. Thus, you decided to sort the books by inserting the book with the number i into the i-th position. How many insertions are required to complete this task?

Input

The first line of the input is n (1 ≤ n ≤ 20), which is the number of books. The second line contains n integers v1, ... , vn (1 ≤ vi ≤ n), where vi indicates the number of the book at the i-th position before the sorting. All vi's are distinct.

Output

Print the minimum number of insertions in a line. If it is impossible for him to complete the sort, print "impossible" (without quotes).

Sample Input 1

3
1 2 3

Output for the Sample Input 1

0

Sample Input 2

3
2 1 3

Output for the Sample Input 2

1

Sample Input 3

3
3 2 1

Output for the Sample Input 3

2

Sample Input 4

20
4 14 11 13 17 10 1 12 2 6 16 15 8 7 19 18 3 5 9 20

Output for the Sample Input 4

14
Problem J: Substring Expression

Trees are sometimes represented in the form of strings. Here is one of the most popular ways to represent unlabeled trees:

Leaves are represented by "()".

Other nodes (i.e. internal nodes) are represented by "( S1 S2 ... Sn )", where Si is the string representing the i-th subnode.

For example, the tree depicted in the figure below is represented by a string "((()())())".

A strange boy Norward is playing with such strings. He has found that a string sometimes remains valid as the representation of a tree even after one successive portion is removed from it. For example, removing the underlined portion from the string "((()())())" results in "((()))", which represents the tree depicted below.

However, he has no way to know how many ways of such removal there are. Your task is to write a program for it, so that his curiosity is fulfilled.

Input

The input contains a string that represents some unlabeled tree. The string consists of up to 100,000 characters.

Output

Print the number of portions of the given string such that removing them results in strings that represent other valid trees.

Sample Input 1

((()())())

Output for the Sample Input 1

10
Problem K: Up Above the World So High

One of the questions children often ask is "How many stars are there in the sky?" Under ideal conditions, even with the naked eye, nearly eight thousands are observable in the northern hemisphere. With a decent telescope, you may find many more, but, as the sight field will be limited, you may find much less at a time.

Children may ask the same questions to their parents in a spaceship billions of light-years away from the Earth. Their telescopes are similar to ours with circular sight field. It can be rotated freely, that is, the sight vector can take an arbitrary value.

Given a set of positions of stars and the spec of a telescope, your task is to determine the maximum
number of stars that can be seen through the telescope at a time.

Input

The first line of a test case contains a positive integer N not exceeding 100, meaning the number of stars. Each of the N lines following it contains three integers, sx, sy and sz. They give the position (sx, sy, sz) of the star described in Euclidean coordinates. You may assume that -1000 ≤ sx ≤ 1000, -1000 ≤ sy ≤ 1000, -1000 ≤ sz ≤ 1000 and (sx, sy, sz) ≠ (0, 0, 0).

Then comes a line containing a positive integer ψ (0 < ψ < 90), which represents the angular radius, in degrees, of the sight field of the telescope. The telescope is at the origin of the coordinate system (0, 0, 0).

You may assume that change of the angular radius ψ by less than 0.01 degrees does not affect the answer, and that ∠POQ is greater than 0.01 degrees for any pair of distinct stars P and Q and the origin O.

Output

One line containing an integer meaning the maximum number of stars observable through the telescope should be output. No other characters should be contained in the output.

Sample Input 1

2
1 0 0
0 1 0
40

Output for the Sample Input 1

1

Sample Input 2

2
1 0 0
0 1 0
50

Output for the Sample Input 2

2

Note

This problem statement is taken from "How I Wonder What You Are!" in ACM-ICPC Asia Regional Contest 2006, Yokohoma, with small but substantial changes.
Problem A: Approximate Circle

Consider a set of n points (x1, y1),
..., (xn,yn) on a Cartesian space.
Your task is to write a program for regression to a circle x2
+ y2 + ax + by
+ c = 0. In other words, your program should find a circle that
minimizes the error. Here the error is measured by the sum over square distances
between each point and the circle, which is given by:

Input

The input begins with a line containing one integer n (3 <= n
<= 40,000). Then n lines follow. The i-th line contains
two integers xi and yi (0 <= xi,
yi <= 1,000), which denote the coordinates of the i-th
point.

You can assume there are no cases in which all the points lie on a
straight line.

Output

Print three integers a, b and c,
separated by space, to show the regressed function. The output values should be
in a decimal fraction and should not contain an
error greater than 0.001.

Sample Input 1

4
0 0
100 0
100 100
0 100

Output for the Sample Input 1

-100.000 -100.000 0.000

Sample Input 2

3
0 0
10 0
5 100

Output for the Sample Input 2

-10.000 -99.750 0.000
Problem B: Blame Game

Alice and Bob are in a factional dispute. Recently a big serious problem
arised in a project both Alice and Bob had been working for. This problem was
caused by lots of faults of Alice's and Bob's sides; those faults are closely
related.

Alice and Bob started to blame each other. First, Alice claimed it was
caused by Bob's fault. Then Bob insisted his fault was led by Alice's fault.
Soon after, Alice said that her fault should not have happened without Bob's
another fault. So on so forth. It was terrible. It was totally a blame game.
Still, they had their pride. They would not use the same fault more than once in
their claims.

All right, let's see the situation in terms of a game.

Alice and Bob have a number of faults. Some pairs of Alice and Bob faults
have direct relationship between them. This relationship is bidirectional; if a
fault X is led by another fault Y, they can say either "X was due to Y." or
"even with X, the problem could be avoided without Y." Note that not both, since
they never pick up the same fault in their claims.

Alice and Bob take their turns alternatively. Alice takes the first turn
by claiming any of Bob's faults. Then Bob makes his claim with Alice's fault
directly related to the claimed fault. Afterward, in each turn, one picks up
another's fault directly related to the fault claimed in the previous turn. If
he/she has no faults that have not been claimed, then he/she loses this game.

By the way, you have been working both under Alice and Bob. You know all
the faults and relationships. Your task is to write a program to find out which
would win this game, under the assumption that they always take their optimal
strategies. If you could choose the winning side, you would not have to take the
responsibility for the arisen problem.

Input

Each input contains one test case. The first line of the input contains
two integers N and M (0 <= N, M <=
500), which denote the numbers of Alice's and Bob's faults respectively. Alice's
faults are numbered from 1 to N; so are Bob's from 1 to M.
Then N lines follow to describe the relationships among the faults.
The i-th line begins with a non-negative integer Ki
(0 <= Ki <= M). It is then followed by Ki
positive integers, where the j-th number bi,j
(1 <= bi,j <= M) indicates there is a direct
relationship between the i-th Alice's fault and the bi,j-th
Bob's fault. It is guaranteed that
bi,j != bi,j'
for all i, j, j'
such that 1 <= i <= N and 1 <= j < j'
<= Ki.

Output

Print either "Alice" or "Bob" to indicate the winner of the blame game.

Sample Input 1

1 1
1 1

Output for the Sample Input 1

Bob

Sample Input 2

3 3
3 1 2 3
1 3
1 3

Output for the Sample Input 2

Alice
Problem C: Earn Big

A group of N people is trying to challenge the following game
to earn big money.

First, N participants are isolated from each other. From this
point, they are not allowed to contact each other, or to leave any information
for other participants. The game organizer leads each participant, one by one,
to a room with N boxes. The boxes are all closed at the beginning of
the game, and the game organizer closes all the boxes whenever a participant
enters the room. Each box contains a slip of paper on which a name of a distinct
participant is written. The order of the boxes do not change during the game.
Each participant is allowed to open up to M boxes. If every
participant is able to open a box that contains a paper of his/her name, then
the group wins the game, and everybody in the group earns big money. If anyone
is failed to open a box that contains a paper of his/her name, then the group
fails in the game, and nobody in the group gets money.

Obviously, if every participant picks up boxes randomly, the winning
probability will be (M/N)N. However, there is a far more
better solution.

Before discussing the solution, let us define some concepts. Let P
= {p1, p2, ..., pN} be a set of the
participants, and B = {b1, b2, ..., bN}
be a set of the boxes. Let us define f, a mapping from B
to P, such that f(b) is a participant whose name is
written on a paper in a box b.

Here, consider a participant pi picks up the boxes
in the following manner:

Let x := i.

If pi has already opened M boxes,
then exit as a failure.

pi opens bx.

If f(bx) = pi, then exit as a
success.

If f(bx) = pj (i != j),
then let x := j, and go to 2.

Assuming every participant follows the algorithm above, the result of the
game depends only on the initial order of the boxes (i.e. the definition of f).
Let us define g to be a mapping from P to B,
such that g(pi) = bi. The participants win the
game if and only if, for every i ∈ {1, 2, ..., N}, there exists
k(<=M) such that (fg)k
(pi) = pi.

Your task is to write a program that calculates the winning probability
of this game. You can assume that the boxes are placed randomly.

Input

The input consists of one line. It contains two integers N and
M (1 <= M <= N <= 1,000) in this order,
delimited by a space.

Output

For given N and M, your program should print the
winning probability of the game. The output value should be in a decimal fraction and should not contain an error greater than 10-8.

Sample Input 1

2 1

Output for the Sample Input 1

0.50000000

Sample Input 2

100 50

Output for the Sample Input 2

0.31182782