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 C:</font> Leaky Cryptography</H1>3 4<p>5The ACM ICPC judges are very careful about not leaking their problems, and all communications are encrypted. However, one does sometimes make mistakes, like using too weak an6encryption scheme. Here is an example of that.7</p>8<p>9The encryption chosen was very simple: encrypt each chunk of the input by flipping some bits10according to a shared key. To provide reasonable security, the size of both chunk and key is 3211bits.12</p>13<p>14That is, suppose the input was a sequence of <i>m</i> 32-bit integers.15</p>16<center>17<p>18 <i>N</i><sub>1</sub> <i>N</i><sub>2</sub> <i>N</i><sub>3</sub> ... <i>N<sub>m</sub></i>19</p>20</center>21<p>22After encoding with the key <i>K</i> it becomes the following sequence of <i>m</i> 32-bit integers.23</p>24<center>25<p>26 27(<i>N</i><sub>1</sub> ∧ <i>K</i>) (<i>N</i><sub>2</sub> ∧ <i>K</i>) (<i>N</i><sub>3</sub> ∧ <i>K</i>) ... (<i>N</i><sub><i>m</i></sub> ∧ <i>K</i>)28</p>29</center>30 31<p>32where (<i>a</i> ∧ <i>b</i>) is the bitwise <i>exclusive or</i> of <i>a</i> and <i>b</i>.33</p>34 35<p>36Exclusive or is the logical operator which is 1 when only one of its operands is 1, and 0 otherwise.37Here is its definition for 1-bit integers.38</p>39<center>40<pre>41 0 ⊕ 0 = 0 0 ⊕ 1 = 142 1 ⊕ 0 = 1 1 ⊕ 1 =043</pre>44</center>45<p>46As you can see, it is identical to addition modulo 2. For two 32-bit integers <i>a</i> and <i>b</i>, their bitwise47exclusive or <i>a</i> ∧ <i>b</i> is defined as follows, using their binary representations, composed of 0's and 1's.48</p>49<center>50<p>51 <i>a</i> ∧ <i>b</i> = <i>a</i><sub>31</sub> ... <i>a</i><sub>1</sub><i>a</i><sub>0</sub> ∧ <i>b</i><sub>31</sub> ... <i>b</i><sub>1</sub><i>b</i><sub>0</sub> = <i>c</i><sub>31</sub> ... <i>c</i><sub>1</sub><i>c</i><sub>0</sub>52</p>53</center>54<p>55where56</p>57<center>58<p>59 <i>c<sub>i</sub></i> = <i>a<sub>i</sub></i> ⊕ <i>b<sub>i</sub></i> (<i>i</i> = 0, 1, ... , 31).60</p>61</center>62<p>63For instance, using binary notation, 11010110 ∧ 01010101 = 10100011, or using hexadecimal, 64</p>65<pre>66d6 ∧ 55 = a3.67</pre>68<p>69Since this kind of encryption is notoriously weak to statistical attacks, the message has to be70compressed in advance, so that it has no statistical regularity. We suppose that <i>N</i><sub>1</sub> <i>N</i><sub>2</sub> ... <i>N<sub>m</sub></i>71is already in compressed form.72</p>73<p>74However, the trouble is that the compression algorithm itself introduces some form of regularity:75after every 8 integers of compressed data, it inserts a checksum, the sum of these integers. That76is, in the above input, <i>N</i><sub>9</sub> = ∑<sup>8</sup><sub><i>i</i>=1</sub> <i>N<sub>i</sub></i> = <i>N</i><sub>1</sub> + ... + <i>N</i><sub>8</sub>, where additions are modulo 2<sup>32</sup>.77 78</p>79 80<p>81Luckily, you could intercept a communication between the judges. Maybe it contains a problem for the finals!82</p>83<p>84As you are very clever, you have certainly seen that you can easily find the lowest bit of the key,85denoted by <i>K</i><sub>0</sub>. On the one hand, if <i>K</i><sub>0</sub> = 1, then after encoding, the lowest bit of ∑<sup>8</sup><sub><i>i</i>=1</sub> <i>N<sub>i</sub></i> ∧ <i>K</i> is unchanged, as <i>K</i><sub>0</sub> is added an even number of times, but the lowest bit of <i>N</i><sub>9</sub> ∧ <i>K</i> is changed,86so they shall differ. On the other hand, if <i>K</i><sub>0</sub> = 0, then after encoding, the lowest bit of ∑<sup>8</sup><sub><i>i</i>=1</sub> <i>N<sub>i</sub></i> ∧ <i>K</i> shall still be identical to the lowest bit of <i>N</i><sub>9</sub> ∧ <i>K</i>, as they do not change. For instance, if the lowest bits after encoding are 1 1 1 1 1 1 1 1 1 then <i>K</i><sub>0</sub> must be 1, but if87they are 1 1 1 1 1 1 1 0 1 then <i>K</i><sub>0</sub> must be 0.88</p>89<p>90So far, so good. Can you do better?91</p>92<p>93You should find the key used for encoding.94</p>95 96<H2>Input</H2>97 98<p>99The input starts with a line containing only a positive integer <i>S</i>, indicating the number of100datasets in the input. <i>S</i> is no more than 1000.101</p>102<p>103It is followed by <i>S</i> datasets. Each dataset is composed of nine 32-bit integers corresponding104to the first nine chunks of a communication. They are written in hexadecimal notation, using105digits ‘0’ to ‘9’ and lowercase letters ‘a’ to ‘f’, and with no leading zeros. They are separated106by a space or a newline. Each dataset is ended by a newline.107</p>108 109<H2>Output</H2>110 111<p>112For each dataset you should output the key used for encoding. Each key shall appear alone on113its line, and be written in hexadecimal notation, using digits ‘0’ to ‘9’ and lowercase letters ‘a’114to ‘f’, and with no leading zeros.115 116</p>117 118<H2>Sample Input</H2>119<pre>12081211 1 1 1 1 1 1 1 81223 2 3 2 3 2 3 2 61233 4 4 7 7 b a 2 2e124e1 13 ce 28 ca 6 ab 46 a6d125b08 49e2 6128 f27 8cf2 bc50 7380 7fe1 723b1264eba eb4 a352 fd14 6ac1 eed1 dd06 bb83 392bc127ef593c08 847e522f 74c02b9c 26f3a4e1 e2720a01 6fe660071287a4e96ad 6ee5cef6 3853cd8812960202fb8 757d6d66 9c3a9525 fbcd7983 82b9571c ddc54bab 853e52da13022047c88 e5524401131</pre>132 133<H2>Output for the Sample Input</H2>134<pre>1350136213761381c61394924afc7140ffff95c5141546991d142901c4a16143</pre>144 145 