UTPC Contest 09-30-22 Div. 2 (Beginner)
A. Jeopardy!
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Girls Who Code College Loops is a chapter of the national Girls Who Code organization. We aim to provide all students the opportunity to learn skills that they may not get the chance to elsewhere. We aim to bring together people into a community in order to learn topics like game development, web development, programming languages, interview techniques, and more! Learn more about GWC

This... is... Jeopardy! GWC is hosting a Jeopardy night (as of the time this is being written), and they've been working tirelessly to prepare a set of clues and answers.

Each clue has a corresponding point value of 100, 200, 300, 400, or 500. To improve your chances, you would like to know: how many clues are worth each point value?

Input

The first line contains a single integer $$$N$$$ ($$$1 \le N \le 100$$$), representing the total number of clues that follow.

$$$N$$$ lines follow, each representing one clue. Each line consists of one number, the point value of the question, followed by the text of the question. It is guaranteed that the total length of the clues will be less than $$$10^5$$$ characters.

Output

Output 5 numbers on one line, separated by spaces: the number of questions worth 100, 200, 300, 400, and 500 points, respectively.

Examples
Input
3
400 This was UT Austin's first female graduate and first female faculty member. (Jessie Andrews)
200 This first female engineering professor at UT was also the first female electrical engineering professor in the country. (Edith Clarke)
400 This golf player was also the first female student to receive an athletic scholarship at UT. (Nancy Hale)
Output
0 1 0 2 0 
Input
2
100 This famous building in New York has its very own zipcode, 10118. (Empire State Building)
400 This war in August of 1896 is the shortest recorded war in history, lasting just around 40 minutes. (Anglo-Zanzibar War)
Output
1 0 0 1 0 

B. Extravagant Elephants
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

The Robotics & Automation Society (RAS) is sending robot elephants to the moon! But as we all know, robotics is trivial, but robotic elephant analysis is not.

There are $$$n$$$ robot elephant candidates to be sent to the moon. Each elephant has a name $$$s$$$, a complexity rating $$$c$$$, and a mass $$$m$$$. An elephant's extravagance is defined as $$$|s| \cdot c$$$, the product of the length of its name and its complexity rating.

RAS is capable of sending whichever elephant they'd like to the moon. However, they realized that if an elephant has strictly more mass than the moon itself, then they'll end up with a moon on the elephant, and not an elephant on the moon!

Clearly, RAS wants to maximize the extravagance of the robot elephant it sends to the moon, without altering the structure of the solar system. Can you help RAS send robot elephants to the moon?

Input

The first line of input contains two integers, $$$n$$$ ($$$1 \leq n \leq 1000$$$) and $$$M$$$ ($$$1 \leq M \leq 10^6$$$), representing the number of elephants and the mass of the moon, respectively.

Then, $$$n$$$ lines follow, where the $$$i$$$th line describes the $$$i$$$th elephant. Each of these lines contain a string $$$s$$$ ($$$|s| \leq 20$$$), and two integers $$$c$$$ and $$$m$$$ ($$$1 \leq c, m, \leq 10^6$$$). $$$s$$$ represents the name of the elephant and only contains non-whitespace characters, $$$c$$$ represents the complexity rating of the elephant, and $$$m$$$ is the mass of the elephant. All names are unique.

Output

Print "[name] to the moon!", where [name] is the name of the most extravagant elephant that RAS can send to the moon. If there are multiple suitable elephants with the same extravagance, pick the one that appears first in the input.

If RAS cannot send any elephants to the moon, print "dead meme :(".

Example
Input
3 100
Squidward 5 10
$GME 100 99
PinkPrincess 1000 1000
Output
$GME to the moon!

C. Robot Inspection
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Karl is the chief of meat at the local eclair factory. Each day he arrives at the factory (next door to his house) and pulls out his trusty telescope to ensure the quality of every eclair in the Food Machine$$$^{\text{TM}}$$$. Using his telescope, he measures the weight of each eclair (it obviously has a built-in scale) and checks for anomalies. An anomaly is present if the weight of an eclair is exactly equal to the sum of its proper divisors (a proper divisor is a positive integer less than the weight which divides the weight). In that case, Karl will declare the eclair a robot and have it taken away for further inspection. Given a list of eclair weights, can you utilize Karl's telescope to find out which of them are actually robots in disguise?

Input

The input will begin with a line containing a single integer, $$$n\ (1 \leq n \leq 10^4)$$$, the number of eclairs that Karl must inspect. The next line will consist of $$$n$$$ space-separated integers, the $$$i$$$th of which denotes the weight, $$$w_i\ (1 \leq w_i \leq 500)$$$, of the $$$i$$$th eclair (or robot in disguise).

Output

The output should consist of a single integer, the number of eclairs which are detected as anomalies by Karl's telescope, also known as the number of eclairs which are actually robots in disguise.

Examples
Input
2
6 28
Output
2
Input
3
496 100 499
Output
1

D. Hardcore Haircuts
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

EGaDS has designed a new game, themed around a barbershop called Hardcore Haircuts.

In the game, Harry the Hairy Hairball wants a new haircut! The question, of course, is which one?

Harry has $$$N$$$ hairs and although he knows he wants one of them to be cut, he has forgotten which one. Now, Harry has entered your hair salon and is feeling quite harried, since he doesn't know what to ask for. He does, however have a sorted list of the planned lengths of each hair after the haircut, $$$v_i$$$.

Luckily, you can see Harry's head and observe the lengths of his current hairs. You've also written this down as a sorted list of lengths, given by $$$u_i$$$.

Given the desired lengths of his hairs $$$v_i$$$ and the current lengths, $$$u_i$$$ please determine which hair should be cut. Please hurry to help Harry determine which hair should be harvested!

Input

Line 1 is a single integer, $$$1 \leq N \leq 10^4$$$, representing the number of hairs Harry has.

Line 2 has $$$N$$$ sorted values $$$0 \leq v_i \leq 1000$$$, representing the desired lengths of his hairs.

Line 3 has $$$N$$$ sorted values $$$0 \leq u_i \leq 1000$$$, representing the current lengths of his hairs.

Note that exactly one hair will be cut.

Output

Two integers, denoting the initial and new lengths of the hair.

Example
Input
3
1 2 3
1 3 4
Output
4
2 

E. Diverse Debaters
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

ACM 4 Change is hosting a series of ethical debates, and they have brought a panel of $$$N$$$ speakers who are experts on a variety of ethical topics to open the floor. Each speaker is distinguished by a unique ID $$$i$$$ ($$$1 \leq i \leq N$$$) and specializes in a particular area denoted by an integer $$$a_i$$$. After lining up all the speakers in a row in increasing order of ID, the officers for ACM need to select some number of speakers to kickstart debates during the meeting. They want exactly $$$K$$$ distinct areas of expertise to be represented by the minimum possible number of speakers, but require all the picked speakers to be part of a contiguous sequence in the row (e.g. if speakers with IDs $$$a$$$ and $$$b$$$ are picked with $$$a \leq b$$$, any speaker with ID $$$x$$$ with $$$a \leq x \leq b$$$ must also be selected). What is the minimum number of panel members that must be chosen to speak?

Input

The first line of input contains two space separated-integers $$$N$$$ and $$$K$$$ ($$$1 \leq N, K \leq 10^5$$$), representing the number of panel speakers and the exact number of distinct topics A4C would like debaters to go over, respectively. The second line of input contains $$$N$$$ space-separated integers $$$a_i$$$ ($$$1 \leq a_i \leq 10^5$$$) that represent the topic of expertise of the $$$i$$$-th speaker. Two speakers with IDs $$$i$$$ and $$$j$$$ have the same area of expertise if and only if $$$a_i = a_j$$$.

Output

Output the minimum number of panel speakers necessary to meet the requirements of having exactly $$$K$$$ distinct topics covered. If this is not possible with the given speakers, output $$$-1$$$ instead.

Examples
Input
4 2
1 2 2 3
Output
2
Input
5 1337
1 22 333 4444 55555
Output
-1
Note

In the first sample case, the first two speakers or the last two speakers can be selected.

In the second sample case, there are not enough distinct topics covered by the panel speakers.

F. Bat-shoe Toss
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Freetail Hackers is an organization focused on bringing students who are passionate about technology together to build cool tech, learn new skills, and become involved in the hackathon and tech communities. We put on HackTX, an annual hackathon that brings students from all over the country to build new technology. Learn more about Freetail Hackers

For their field day event, Freetail Hackers has decided to play one of their favorite bat-related games, Bat-shoes. Bat-shoes is played similarly to Horseshoes, but with multiple pegs and some special rules.

There are $$$N$$$ pegs in a row and $$$N$$$ people on a team facing the pegs. The goal of the game is to toss bat-shoes onto the pegs, where each person tosses bat-shoes onto the peg directly in front of them.

Each person starts out with a different number of bat-shoes, given by $$$a_1,...,a_N$$$. Players then toss in the order given (i.e. $$$1...N$$$). Players can score extra points by forming an increasing sequence – that is, if player $$$i$$$ tosses $$$x_i$$$ bat-shoes onto their peg, then player $$$i+1$$$ tosses $$$x_{i+1} \gt x_i$$$ bat-shoes onto their peg, player $$$i+2$$$ tosses $$$x_{i+2} \gt x_{i+1}$$$ bat-shoes onto their peg, and so on ($$$0 \lt x_i \le a_i$$$ for all $$$i$$$).

Your team wants to know: what's the maximum length increasing sequence your team can create, if you play optimally?

Input

The first line contains one integer $$$N$$$ ($$$1 \le N \le 10^6$$$), the number of pegs and the number of people on your team.

The next line contains $$$N$$$ integers $$$a_1,...,a_N$$$ ($$$1 \le a_i \le 10^6$$$), representing the number of batshoes the players start out with.

Output

Output an integer representing the maximum length increasing sequence your team can create if everyone plays optimally.

Example
Input
6
2 5 6 2 7 9
Output
4
Note

In the example, your team can create an increasing sequence of length 4 if player 3 tosses 1 batshoe onto their peg, player 4 tosses 2 batshoes, player 5 tosses 7 batshoes, and player 6 tosses 9 batshoes ($$$1 \lt 2 \lt 7 \lt 9$$$). It can be shown that this is the maximum length increasing sequence you can obtain.

G. Larry Longsleeves
time limit per test
5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Larry Longsleeves is reknown for having the finest collection of long shirts and long pants in the world. After winning the International Longsleeve Showdown five years in a row, he's confident that he's uncovered the secrets of stylish outfits. To maximize on his discovery, he's decided to start his own clothing company, with the help of Convergent!

In his pitch, Larry plans to reveal that each outfit, consisting of just one shirt and one pair of pants, can be reduced to a style score $$$s$$$! Even better, there's a formula to compute it, based solely on $$$a$$$, the length of the shirt sleeves, and $$$b$$$, the length of the pant sleeves: $$$s = |a^2-b^2|$$$. But while a higher value of $$$s$$$ is preferred, an outfit can only truly be stylish if $$$s$$$ is prime. This insight, as Larry claims, will allow his brand to suggest the best outfit combinations for the customers and beat out his competition.

However, the members of Convergent aren't convinced. After all, while Larry has won the International Longsleeve Showdown many times, he also has the most extensive wardrobe in the world — perhaps he just got lucky when selecting the winning outfits?

In any case, it is your job to help out Larry. He needs a stylish outfit, and fast. As his second in command, personal butler, and best friend, can you look through his wardrobe and find Larry Longsleeves an outfit to win Convergent over?

Input

The first line of input contains two integers, $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 10^4$$$), representing the number of shirts and pants Larry has, respectively.

The second line contains $$$n$$$ integers, $$$a_1, \ldots, a_n$$$ ($$$1 \leq a_i \leq 10^6$$$), representing the sleeve length of each shirt that Larry has.

The third line contains $$$m$$$ integers, $$$b_1, \ldots, b_m$$$ ($$$1 \leq b_i \leq 10^6$$$), representing the sleeve length of each pair of pants that Larry has.

Output

Output the highest style score achievable of any of Larry's stylish outfits, or $$$-1$$$ if no combination of Larry's shirts and pants yields a stylish outfit.

Examples
Input
2 3
2 4
1 3 5
Output
7
Input
1 3
2
4 6 8
Output
-1

H. Competing Clubs
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

After a mostly peaceful week, UT Austin's CS week has devolved into an all-out turf war.

UT Austin can be seen as a $$$N \times N$$$ grid with $$$K$$$ clubs located at various (distinct) points.

Clubs patrol their turf by walking between edges in the $$$4$$$ cardinal directions. A club controls a cell of this grid if its path to that cell is shorter than all other clubs. In the case of ties, the club with the lowest index wins.

UTPC hasn't joined in yet, but rather than fight over land, we seek only to develop a rivalry with another club by positioning ourselves to take their land. Given that we're the last club to join, we won't win any tiebreakers.

Given the grid size and clubs, determine how much of that club's turf UTPC could take for each club.

Input

Three numbers, $$$1 \leq N \leq 750$$$ and $$$1 \leq K \leq min(10^4,\frac{N^2}{2})$$$.

The next $$$K$$$ lines are a list of the $$$K$$$ club locations.

It is guaranteed that there will not be more than one club or building per cell.

Output

$$$K$$$ lines, for each club, the amount of its turf UTPC could take.

Example
Input
4 3
1 2
2 3
3 2
Output
2
4
2

I. Moldy Sandwich
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

We're a student org created by transfer students, for transfer students. We know firsthand how tough it can be to find your way and your people after transferring into the CS major or into UT more generally. If you're an internal transfer, external transfer, or ATP student we hope to see you!

The CS Transfer Society is hosting a scavenger hunt in the GDC! At the time of writing this I have no idea what the objectives are, so I'll assume that the goal is to collect as many moldy sandwiches as possible!

The GDC can be (grossly) represented by an $$$N$$$ by $$$N$$$ grid. The CS Transfer Society has placed $$$M$$$ moldy sandwiches inside the GDC, marked by '#'. All other locations are marked as '.'.

You are participating on behalf of your CS week organization and, of course, are looking to win! However, time is running out. You know that with $$$K$$$ time you can explore any $$$K$$$ by $$$K$$$ square and collect all the moldy sandwiches in that square. (All squares have sides parallel to the sides of the original square).

You would like to know: for each $$$1 \le i \le M$$$, what value of $$$K$$$ is required to collect $$$i$$$ sandwiches, if you choose to explore the optimal $$$K$$$ by $$$K$$$ square?

Input

The first line contains a single integer $$$N$$$ ($$$1 \le N \le 10^3$$$), the side length of the square representing the GDC.

The next $$$N$$$ lines of $$$N$$$ characters each represent the current layout of the GDC, where '#' marks a moldy sandwich and '.' is filled in otherwise. It is guaranteed that the number of moldy sandwiches $$$M$$$ will be at least $$$1$$$ and will not exceed $$$100$$$.

Output

Print out $$$M$$$ integers in a single line: the minimum time needed to collect $$$i$$$ sandwiches for all $$$1 \le i \le M$$$.

Example
Input
4
..#.
.#..
...#
....
Output
1 2 3