Team Ai
Datasetpublic

prithivMLmods/Coder-Stat

Coder-Stat Dataset Overview The Coder-Stat dataset is a collection of programming-related data, including problem IDs, programming languages, original statuses, and source code snippets. This dataset is designed to assist in the analysis of coding patterns, error types, and performance metrics. Dataset Details Modalities Tabular: The dataset is structured in a tabular format. Text: Contains text data, including source code snippets.… See the full description on the dataset page: https://huggingface.co/datasets/prithivMLmods/Coder-Stat.

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
3likes139downloads
p00852.html134 linesDownload Raw Back to problem_descriptions
1 2<H1><font color="#000">Problem H:</font> The Best Name for Your Baby</H1>3 4<p>5In the year 29XX, the government of a small country somewhere on the earth introduced a law restricting first names of the people only to traditional names in their culture, in order to preserve their cultural uniqueness. The linguists of the country specifies a set of rules once every year, and only names conforming to the rules are allowed in that year. In addition, the law also requires each person to use a name of a specific length calculated from one's birth date because6otherwise too many people would use the same very popular names. Since the legislation of that law, the common task of the parents of new babies is to find the name that comes first in the alphabetical order among the legitimate names of the given length because names earlier in the alphabetical order have various benefits in their culture.7</p>8<p>9Legitimate names are the strings consisting of only lowercase letters that can be obtained by10repeatedly applying the rule set to the initial string "S", a string consisting only of a single uppercase S.11</p>12<p>13Applying the rule set to a string is to choose one of the rules and apply it to the string. Each14of the rules has the form <i>A</i> -&gt; <i>&alpha;</i>, where <i>A</i> is an uppercase letter and <i>&alpha;</i> is a string of lowercase and/or uppercase letters. Applying such a rule to a string is to replace an occurrence of the15letter <i>A</i> in the string to the string <i>&alpha;</i>. That is, when the string has the form "<i>&beta;A&gamma;</i>", where <i>&beta;</i> and16<i>&gamma;</i> are arbitrary (possibly empty) strings of letters, applying the rule rewrites it into the string "<i>&beta;&alpha;&gamma;</i>". If there are two or more occurrences of A in the original string, an arbitrary one of them17can be chosen for the replacement.18</p>19<p>20Below is an example set of rules.21</p>22 23<pre>24S -&gt; aAB  (1)25A -&gt;      (2)26A -&gt; Aa   (3)27B -&gt; AbbA (4)28</pre>29 30<p>31Applying the rule (1) to "S", "aAB" is obtained. Applying (2) to it results in "aB", as A is replaced by an empty string. Then, the rule (4) can be used to make it "aAbbA". Applying (3) to the first occurrence of A makes it "aAabbA". Applying the rule (2) to the A at the end results in "aAabb". Finally, applying the rule (2) again to the remaining A results in "aabb". As no uppercase letter remains in this string, "aabb" is a legitimate name. 32</p>33<p>34We denote such a rewriting process as follows.35</p>36 37<pre>38  (1)     (2)    (4)       (3)        (2)       (2)39S --&gt; aAB --&gt; aB --&gt; aAbbA --&gt; aAabbA --&gt; aAabb --&gt; aabb40</pre>41 42<p>43Linguists of the country may sometimes define a ridiculous rule set such as follows.44</p>45 46<pre>47S -&gt; sA (1)48A -&gt; aS (2)49B -&gt; b  (3)50</pre>51 52<p>53The only possible rewriting sequence with this rule set is:54</p>55 56 57<pre>58  (1)    (2)     (1)      (2)59S --&gt; sA --&gt; saS --&gt; sasA --&gt; ...60</pre>61 62<p>63which will never terminate. No legitimate names exist in this case. Also, the rule (3) can never be used, as its left hand side, B, does not appear anywhere else.64</p>65<p>66It may happen that no rules are supplied for some uppercase letters appearing in the rewriting steps. In its extreme case, even S might have no rules for it in the set, in which case there are no legitimate names, of course. Poor nameless babies, sigh!67</p>68<p>69Now your job is to write a program that finds the name earliest in the alphabetical order among the legitimate names of the given length conforming to the given set of rules.70</p>71 72 73 74<H2>Input</H2>75 76<p>77The input is a sequence of datasets, followed by a line containing two zeros separated by a space representing the end of the input. Each dataset starts with a line including two integers <i>n</i> and <i>l</i> separated by a space, where <i>n</i> (1 &le; <i>n</i> &le; 50) is the number of rules and <i>l</i> (0 &le; <i>l</i> &le; 20) is the required length of the name. After that line, <i>n</i> lines each representing a rule follow. Each of these lines starts with one of uppercase letters, A to Z, followed by the character "=" (instead of "-&gt;") and then followed by the right hand side of the rule which is a string of letters A to78Z and a to z. The length of the string does not exceed 10 and may be zero. There appears no space in the lines representing the rules.79</p>80 81<H2>Output</H2>82 83<p>84The output consists of the lines showing the answer to each dataset in the same order as the input. Each line is a string of lowercase letters, a to z, which is the first legitimate name conforming to the rules and the length given in the corresponding input dataset. When the given set of rules has no conforming string of the given length, the corresponding line in the output should show a single hyphen, "-". No other characters should be included in the output.85</p>86 87<H2>Sample Input</H2>88<pre>894 390A=a91A=92S=ASb93S=Ab942 595S=aSb96S=971 598S=S991 0100S=S1011 0102A=1032 0104A=105S=AA1064 5107A=aB108A=b109B=SA110S=A1114 20112S=AAAAAAAAAA113A=aA114A=bA115A=1160 0117</pre>118 119<H2>Output for the Sample Input</H2>120<pre>121abb122-123-124-125-126 127aabbb128aaaaaaaaaaaaaaaaaaaa129</pre>130 131 132 133 134