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.
3139
1 2<H1><font color="#000">Problem E:</font> Molecular Formula</H1>3 4<p>5Your mission in this problem is to write a computer program that manipulates molecular for-6mulae in <i>virtual chemistry</i>. As in real chemistry, each molecular formula represents a molecule7consisting of one or more atoms. However, it may not have chemical reality.8</p>9<p>10The following are the definitions of atomic symbols and molecular formulae you should consider.11</p>12 13<ul>14<li> An atom in a molecule is represented by an atomic symbol, which is either a single capital15 letter or a capital letter followed by a small letter. For instance H and He are atomic16 symbols.17</li>18<li>19 A molecular formula is a non-empty sequence of atomic symbols. For instance, HHHeHHHe20 is a molecular formula, and represents a molecule consisting of four H’s and two He’s.21</li>22<li>23 For convenience, a repetition of the same sub-formula <img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_molecularFormula1"> where <i>n</i> is an integer24 between 2 and 99 inclusive, can be abbreviated to (<i>X</i>)<i>n</i>. Parentheses can be omitted if25 X is an atomic symbol. For instance, HHHeHHHe is also written as H2HeH2He, (HHHe)2,26 (H2He)2, or even ((H)2He)2.</li>27</ul>28 29 30<p>31The set of all molecular formulae can be viewed as a formal language. Summarizing the above32description, the syntax of molecular formulae is defined as follows.33</p>34 35<center>36<img src="https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_molecularFormula2">37</center>38 39<p>40Each atom in our virtual chemistry has its own atomic weight. Given the weights of atoms,41your program should calculate the weight of a molecule represented by a molecular formula.42The molecular weight is defined by the sum of the weights of the constituent atoms. For43instance, assuming that the atomic weights of the atoms whose symbols are H and He are 1 and444, respectively, the total weight of a molecule represented by (H2He)2 is 12.45</p>46 47 48<H2>Input</H2>49 50<p>51The input consists of two parts. The first part, the Atomic Table, is composed of a number of52lines, each line including an atomic symbol, one or more spaces, and its atomic weight which is a positive integer no more than 1000. No two lines include the same atomic symbol.53</p>54<p>55The first part ends with a line containing only the string END OF FIRST PART.56</p>57<p>58The second part of the input is a sequence of lines. Each line is a molecular formula, not59exceeding 80 characters, and contains no spaces. A molecule contains at most 10<sup>5</sup> atoms. Some60atomic symbols in a molecular formula may not appear in the Atomic Table.61</p>62<p>63The sequence is followed by a line containing a single zero, indicating the end of the input.64</p>65 66<H2>Output</H2>67 68<p>69The output is a sequence of lines, one for each line of the second part of the input. Each line70contains either an integer, the molecular weight for a given molecular formula in the correspond-71ing input line if all its atomic symbols appear in the Atomic Table, or UNKNOWN otherwise. No72extra characters are allowed.73</p>74 75<H2>Sample Input</H2>76<pre>77H 178He 479C 1280O 1681F 1982Ne 2083Cu 6484Cc 33385END_OF_FIRST_PART86H2C87(MgF)2As88Cu(OH)289H((CO)2F)9990091 92</pre>93 94<H2>Output for the Sample Input</H2>95<pre>961497UNKNOWN9898997426100</pre>101 102 