Valentine's Day is approaching, and Phoenix is looking for a date. He has a list of potential candidates and is seeking to ask one of them out for the occasion, but as the indecisive agent he is, he's not sure who he wants to ask. Phoenix originally thought of finding a bouquet of daisies and mumbling "love me" and "love me not," he decided a more modern way of doing this would be more fitting. Instead, he is going to look at everybody's phone numbers! He decided that if the sum of the digits in someone's phone number is even, then he will ask them out. Otherwise, he will not. Given Phoenix's phone book, can you tell him who he should ask out given his plan?
The first line of input contains $$$n (1 \le n \le 10^3)$$$, the number of contacts Phoenix has in his phone book that he is considering potentially asking out on a Valentine's Day date.
The next $$$n$$$ lines each contain a name (alphanumeric characters, no spaces), followed by a space and then a phone number that is up to 9 digits.
Output every name that Phoenix should ask out on a separate line, in the order in his phonebook.
5 Jett 012345678 Viper 111111111 Neon 987654321 Raze 512610294 Reyna 192830492
Jett Raze Reyna
Skariah is looking forward to spending Valentine's Day with his girlfriend! His girlfriend of 5 years, Rachel, has gifted Skariah a box of chocolates every year in their relationship. Skariah believes that this year is no exception. This year, however, Skariah has adopted a new, low-carb diet. This diet requires that he eats no more than $$$s$$$ grams of sugar every day.
Given $$$n$$$ integers, where each integer represents the grams of sugar in one of the chocolates, what is the maximum number of chocolates that Skariah can consume without going over his carbohydrate/sugar limit?
The first line of input represents $$$n$$$ ($$$1 \leq n \leq 10^5$$$), the number of chocolates in the gifted box. The next line of input, $$$s$$$ ($$$0 \leq s \leq 10^4$$$), represents Skariah's sugar limit. The last line, containing $$$n$$$ integers, represents the grams of sugar in each chocolate in the box. Each chocolate can have $$$x$$$ grams of sugar, where ($$$1 \leq x \leq 2000$$$).
Print a single number - the maximum number of chocolates that Skariah can consume without going over his carbohydrate/sugar limit.
1 4 5
0
5 5 1 2 3 4 5
2
Test Case 1: The only chocolate available has more grams of sugar than allowed so we output 0.
Test Case 2: We can take the first two chocolates for a total of 3 grams of sugar. This is less than the sugar allowed of 5. However, we cannot eat another chocolate without consuming more than 5 grams, so we output 2.
With Valentine's Day just around the corner, Sophie is ready to release her new dating app, Cinder. She assigns you the job of writing the program to generate usernames for each new person who registers for the app based on their given name. Sophie is very particular about her app so she asks for the following scheme for the usernames:
Each time a user registers, the system is sent a request with their name (call this string $$$s$$$). If $$$s$$$ is not yet in the database, it is inserted into the database and the user gets the response OK to signify that they were able to register. If $$$s$$$ is already in the database, the system will create a new string $$$s'$$$ and insert $$$s'$$$ into the database before returning $$$s'$$$ back to the user as their new username. The string $$$s'$$$ is formed by adding a number to the end of $$$s$$$ (so $$$s$$$, $$$s1$$$, $$$s2$$$, $$$s3$$$ ...) where each time the number $$$i$$$ appended is the smallest positive integer such that $$$s'$$$ = $$$s$$$ + $$$i$$$ is not already in the system.
Given $$$n$$$ users, implement a program that will return the right username for each person (or OK if the name wasn't in the system already).
The first line will contain a single integer $$$n$$$ (where $$$1 \leq n \leq 10^{5}$$$) representing the number of new users (aka incoming requests),
The following $$$n$$$ lines will each contain a request (name of the new user) in the order the system gets the requests. Each request is a non-empty string consisting of only lowercase letters and will not be longer than $$$32$$$ characters.
For each of the $$$n$$$ request lines, print the system response (so OK if the name wasn't in the database already or the new username if it was already there).
4 marta mia mia alexia
OK OK mia1 OK
6 weston mohamed gabriel weston mohamed gabriel
OK OK OK weston1 mohamed1 gabriel1
Sadio has set up a grand night for Valentine's day. After dinner and dessert, he plans to take his significant other to the top of the tallest building in the city and use the lens he set up there to show his significant other the $$$n$$$ places around the city where they had memorable moments (date spots, favorite restaurants, etc).
Sadio goes to test the lens out before the big night and realizes that moving and refocusing the lens takes way too much time. To fix this, he decides to buy a new lens that captures enough of an angle in order to see all $$$n$$$ places at the same time. The cost of the lens increases linearly with the angle that it captures (so a lens that captures $$$90$$$ degrees would cost more than that which captures $$$89$$$ degrees). Note, when we say that the lens captures x degrees, it is equivalent to having two rays from the origin which make an angle of x degrees, and all the points on/within the two rays are seen.
The city can be represented as a grid where the tallest building (so where Sadio and his partner will be) is at $$$(0, 0)$$$ and each of the $$$n$$$ special points is located at integer coordinates $$$(x, y)$$$. Given that Sadio has already spent so much money planning tonight, he wants to spend as little as possible on the new lens. What is the minimum angle such that the lens with that angle can view all $$$n$$$ locations? The lens can view a location even if that location is on the very border of what the lens can see.
The first line contains a single integer $$$n$$$ (where $$$1 \leq n \leq 10^{5}$$$) which represents the number of special places.
The next $$$n$$$ lines each contain two space-separated integers $$$x_{i}$$$ and $$$y_i$$$ which represent the coordinates of the $$$i$$$th special place ($$$-1000 \leq x_i, y_i \leq 1000$$$).
It is guaranteed that no two special places are at the same point and there is no special place at $$$(0, 0)$$$.
A single decimal which equals the minimum angle, in degrees, such that all $$$n$$$ points are contained. The answer will be considered valid if the relative or absolute error doesn't exceed $$$10^{-6}$$$.
2 3 0 0 3
90.0000000000
3 -3 0 0 3 -3 -3
135.0000000000
admin'OR1=1 is tired of celebrating Singles Awareness Day – not once have they ever had success with dating! This year, things are going to be different. admin'OR1=1 is going to change their name!
The reason is simple: admin'OR1=1 is simply not a name that is compatible with many other names. And as we all know, name compatibility is the key to successful relationships. The compatibility score $$$t$$$ of two names, $$$s_1$$$ and $$$s_2$$$ is defined as the sum of minimum occurrences of each letter. In other words, $$$$$$t = \sum_{a \in A} min(c_{s_1,a}, c_{s_2,a})$$$$$$ where $$$A$$$ denotes the set of letters, and $$$c_{s,a}$$$ denotes the number of times $$$a$$$ appears in $$$s$$$.
admin'OR1=1 has already compiled the names of $$$n$$$ people they plan on asking out (after the name change). In order to maximize their chances, admin'OR1=1 wants to maximize the total sum of compatability scores between their new name and all of the $$$n$$$ names. However, due to governmental restrictions, their new name can only be $$$m$$$ characters long. Can you help admin'OR1=1 pick a new name?
The first line contains two integers, $$$n$$$ and $$$m$$$ ($$$1 \leq n,m \leq 1000$$$), representing the number of names and the maximum length of admin'OR1=1's new name.
Then, $$$n$$$ lines follow, where the $$$i$$$-th line contains $$$s_i$$$, the name of the $$$i$$$-th person. Names will only consist of lowercase Latin letters.
The sum of lengths of all $$$s_i$$$ will be no more than $$$1000$$$.
Output a string consisting only of lowercase Latin characters of length at most $$$m$$$, which maximizes the sum of compatibility scores with all given names.
If there are multiple names that maximize the compatibility, output any of them.
3 5 alice bob charlie
alice
3 3 umar winston lulu
uwu
In preparation for Valentine's Day, Yaroslav is searching for the perfect date. He has decided to take his partner Rostislav hiking to the top of a local mountain to view the sunset.
The hiking area is described as a $$$N \times N$$$ grid of height values $$$h_{i,j}$$$ and the two will be starting at $$$(0, 0)$$$, traveling to the peak (maximal height) within the area.
Yaroslav wants to minimize the total energy expended during their hike, instead preferring to stare into Rostislav's dreamy eyes. Ascending or descending by $$$d$$$ costs $$$d^2$$$ energy. Since they are still novice hikers, they can only travel between grid cells that share a side.
Given the height grid of the surrounding land, help Yaroslav find the easiest hike and make their sunset date perfect.
The first line contains a single integer $$$1 \leq N \leq 500$$$
The $$$i+1$$$th line contain $$$N$$$ integers $$$1 \leq h_{i,j} \leq 1000$$$
A single integer, denoting the minimum energy spent to climb to the peak.
3 1 2 4 4 5 6 4 8 7
11
There will be a unique peak.
As Valentine's Day approaches, Harmony wants to get a gift for her sweetheart. Specifically, she has in mind to buy a brilliant ruby gemstone, representing her heart. When she goes to look at different rubies at the jewelry store, Harmony sees that each one is cut uniquely with a different number and arrangement of facets. In fact, each stone can be represented as a binary tree that has been reflected and connected with edges across the leaves, producing a symmetrical pattern of connected facets.
In order to select the best ruby out of the available stones, Harmony comes up with a metric for the quality of a ruby. A ruby's radiance is equal to the number of unique cycles which can be found within its facet pattern. Write a program to help Harmony evaluate radiance and select the finest ruby!
The first line of input contains an integer $$$V$$$ ($$$2 \leq V \leq 10^6$$$) denoting the number of vertices in the binary tree representing a ruby's facet pattern. $$$V - 1$$$ lines follow, each containing two space-separated integers $$$u$$$ and $$$v$$$ which represent endpoints for an edge in the tree (in general, any tree with $$$n$$$ vertices has exactly $$$n - 1$$$ edges). You are also given that $$$u$$$ is a parent of $$$v$$$ in the tree, and the tree will always be rooted at the first vertex $$$1$$$.
Print the number of unique cycles which can be found in the graph generated by connecting each leaf vertex in the binary tree to its equivalent in a reflected copy of the tree.
11 1 9 5 3 2 7 1 5 9 2 8 10 2 8 5 4 3 6 3 11
10