<jupyter_start><jupyter_text>Stampede2Machines like Stampede2 are designed to perform extremely high precision calculations, where every decimal place matters. This was extremely important in the LIGO Experiment, which needed to detect fluctuations in space-time at a scale of 1/20th the width of a proton. (That's a very small number.) These values are stored in scientific notation, with a mantissa and exponent. For example, the value `2.653E10` has a mantissa of `2.653` and an exponent of `10`. Two problems in these types of calculations are Numeric *Overflow* and *Underflow*. Numeric Overflow occurs when the mantissa becomes high enough to result in a loss of significant digits. This is due to the fact that the number of digits in the mantissa is limited by the size of the variable that stores it. **For our purposes, let's say that the maximum number of digits for the mantissa is 1 whole number and 10 decimal places.**Here is an example of a situation where overflow occurs:```2.653E+10 + 9.5912498745E+10= 26530000000 + 95912498745= 122442498745= 1.2244249874E+11       Oops! We lost the 5 at the end```Numeric Underflow occurs when an operation, such as addition, between two numbers of extremely different scale result in no change to the stored value of the larger number. Here is an example:```2.653E+10 + 9.5E-4= 26530000000 + 0.00095= 26530000000.00095= 2.6530000000E+10      Oops! We didn't store the .00095 at the end!``` InputYour program must accept input from a text file `stampede2.dat`. This first line of the file contains an integer *`N`* which specifies the number of test cases. Each test case consists of two numbers written in scientific notation (mantissa, followed by `E` and then an exponent value). The numbers are separated by a space. OutputFor each test case, assume that the numbers are being added together. For each case, output `OVERFLOW` if Numeric Overflow occurs, `UNDERFLOW` if Numeric Underflow occurs, or `SAFE` if the addition operation is safe. Sample File Input `stampede2.dat````82.653E+10 9.5912498745E+102.653E+10 9.5E-42.653E+10 9.59E+42.653E+4 9.2E+109.5E-4 2.653E+102.653E+10 7.27391E+52.36E-4 6.274E-52.36E-1 6.274992757E-5``` Sample Output to Screen```OVERFLOWUNDERFLOWSAFESAFEUNDERFLOWSAFESAFEOVERFLOW```<jupyter_code>import math
from decimal import Decimal

file = open("stampede2.dat", "r")
cases = int(file.readline().strip())
parser = lambda token: float(token.split('E')[0]) * math.pow(10, float(token.split('E')[1]))

for i in range(cases):
    tokens = [ token.strip() for token in file.readline().split() ]
    leftvalue = parser(tokens[0])
    rightvalue = parser(tokens[1])
    sum = leftvalue + rightvalue
    scientific = '%.10E' % Decimal(sum)
    int_portion = str(sum).split('.')[0]
    frac_portion = str(sum).split('.')[1]
    if len(int_portion) > 11 or len(frac_portion) > 11:
        print("OVERFLOW")
    elif parser(scientific) == max(leftvalue, rightvalue):
        print("UNDERFLOW")
    else:
        print("SAFE")<jupyter_output>OVERFLOW
UNDERFLOW
SAFE
SAFE
UNDERFLOW
SAFE
SAFE
OVERFLOW
{'fraction_non_alphanumeric': 0.09525357607282185, 'fraction_numerical': 0.08387516254876463, 'mean_word_length': 4.614963503649635, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '396500', 'license': 'MIT', 'n_tokens_mistral': 1126, 'n_tokens_neox': 939, 'n_words': 381, 'path': 'solutions/stampede2.ipynb', 'repo_name': 'jchuahtacc/tacc_invitational_2018', 'size': '3076'}