cprint { start-thread { byte[] input2 = toUTF8("hello hello"); int de1 = 3; int de2 = 16; S decode = '0.'; L tree = ll("", ll(), ll()); int window_start = 1; int window_end = 15; double low = 1; double high = 1; double middle = 1; new StringBuilder compressed; for count2 to 50000: { window = subByteArray(input2, window_start - 1, window_end); window_start++; window_end++; int char_location = 15; int remove = 2; int char_index = 1; LPair> predictions = ll( pair(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()_+-=[]{}\|';":/.,?><€ƒ„†…‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝޝ ‚\t\nßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ", rep(0.00001, 226))); int node = 1; while not (char_index == 0 or char_location == 0) and window_end != 16: if char_location != 15: char = window[char_location - 1] char_index = tree[node - 1].find(char) + 1 char_location = char_location + 1 if char_index != 0 and char_location == 16: predictions.insert(1, tree[node - 1: node + 1]) node = 1 char_location = char_location - remove remove = remove + 1 elif char_index != 0: node = tree[(node + 2 - 1)][char_index - 1] predict = ['', []] remaining = 1 for q over predictions): j = predictions[q] sum2 = sum(j[-1]) w = sum2 / (226 if len(j[-1]) == 226 else 7 * len(j[-1]) * [0.72, 0.86, 0.95, 0.93, 0.97][len(j[-1]) - 1] if len(j[-1]) < 6 else len(j[-1]) * 7) w = 0.96 if w > 20 else 0.92 if w > 10 else 0.89 if w > 3 else 0.75 if w > 1.5 else 0.64 if w > 1 else 0.57 if w > 0.7 else 0.5 if w > 0.5 else 0.44 if w > 0.4 else w _25ofRoof = (w * [0.916, 0.88, 0.78, 0.96, 0.9, 0.83, 0.82, 0.54, 0.49, 0.25, 0.25, 0.27, 0.33, 0.53, 0.5, 0.53, 0.72][len(predictions) - 1 - q]) * remaining remaining = remaining - _25ofRoof for g in range(len(j[0])): k = j[-1][g] freq = j[-1][g] char_index = predict[0].find(k) + 1 if char_index == 0: predict[0] = predict[0] + k predict[-1].append((freq / sum2) * _25ofRoof) else: predict[-1][char_index - 1] = (predict[-1][char_index - 1] + ((freq / sum2) * _25ofRoof)) summ = 1 - sum(predict[-1]) for n in range(len(predict[-1])): predict[-1][n] = predict[-1][n] + summ / len(predict[-1]) low = high; decodepart = float('0.' + str(decode[de1 - 1: de2])) for m in range(len(predict[0])): x = predict[0][m] high = low low = low - predict[-1][m] * middle if decode == '0.' and x == window[-1]: break elif high > decodepart and decodepart > low: window = window + x input2 = input2 + x break char_location = 0; while not (str(low)[char_location] != str(high)[char_location] or char_location == len(str(low))): char_location++; char_location--; compressed.append(str(low)[2: char_location]); char_location -= 2; for count to char_location: { high *= 10; low *= 10 de1++; de2++; } middle = floor(low); high -= middle; low -= middle; middle = high - low; node = 1; for (byte i : window) { char_index = tree[node - 1].find(i) + 1; if (char_index == 0) { tree[node - 1] = tree[node - 1] + i; tree[node + 1 - 1].append(1); tree[node + 2 - 1].append(len(tree) + 1); tree.extend(('', [], [])); node = len(tree) - 2; } else { tree[(node + 1 - 1)][char_index - 1] = tree[(node + 1 - 1)][char_index - 1] + 1; node = tree[(node + 2 - 1)][char_index - 1]; } } } } }