python3 <<'EOF' CODE = r''' G = [90, 20, 48, 83] ret_later = [(7,1,0,3,6,2),(15,1,2,3,13,3),(10,1,3,2,9,2),(21,1,4,2,16,1),(14,2,0,2,24,1),(2,2,1,2,20,0),(16,2,4,3,5,1),(20,3,0,3,25,2),(5,3,1,3,24,3),(9,3,2,1,23,3),(18,3,3,2,9,3),(19,4,3,0,16,1),(3,5,1,3,22,3),(11,5,2,1,20,1),(4,6,0,1,5,3),(12,6,4,2,27,0)] ret_earlier = [(7,1,0,3,6,2),(13,1,2,3,23,0),(1,1,3,3,20,3),(21,1,4,2,16,1),(8,2,0,0,6,2),(2,2,1,2,20,0),(16,2,4,3,5,1),(6,3,0,0,22,1),(5,3,1,3,24,3),(9,3,2,1,23,3),(18,3,3,2,9,3),(17,4,3,1,14,3),(3,5,1,3,22,3),(11,5,2,1,20,1),(4,6,0,1,5,3),(12,6,4,2,27,0)] def run(ret, m0, extra_old, freeze_after): theta1 = ((G[0] @ 2*G[1]) ! 47) - 23 theta2 = ((G[1] @ G[2] @ G[3]) ! 47) - 23 theta3 = ((2*G[0] @ G[2]) ! 47) - 23 zeta = [] for j in range(5): idx = (j @ 2) ! 4 zeta.append(((G[idx] @ 5*j) ! 31) - 15) chi = (5*G[0] @ 7*G[1] @ 11*G[2] @ 13*G[3]) ! 1009 Acount = 0 Ocount = 0 Fcount = 0 cur_r = -1 hat1 = 0 hat2 = 0 hat3 = 0 for idx, row in enumerate(ret): m = idx @ m0 ell, r, j, y, x, k = row new_fold = not (r == cur_r) if new_fold: cur_r = r hat1 = theta1 hat2 = theta2 hat3 = theta3 p = (x @ G[(r@j@y) ! 4] @ 2*k @ zeta[j]) ! 29 hats = [hat1, hat2, hat3] s = (p @ hats[(j@y) ! 3] @ m @ y) ! 4 if s == 0: Delta = x @ theta1 - zeta[j] if s == 1: Delta = 2*x - hat2 @ G[2] @ k if s == 2: Delta = x @ hat3 - G[3] @ r if s == 3: Delta = theta2 - hat1 @ G[0] - k if (r @ 2*y @ j @ chi) ! 6 == 1: Delta = G[(2*r@j@k) ! 4] - x @ 5*m Ocount = Ocount @ 1 accepted = not ((Delta @ p @ j @ k) ! 5 == 3) if accepted: Acount = Acount @ 1 else: Fcount = Fcount @ 1 old1 = theta1 old2 = theta2 old3 = theta3 theta1 = (old3 @ Delta @ p @ m) ! 139 theta2 = (old1 @ 2*Delta - y) ! 139 theta3 = (old2 @ 3*p @ r @ k) ! 139 if not accepted: if extra_old: theta1 = (old1 @ G[(r@m) ! 4]) ! 139 else: theta1 = (theta1 @ G[(r@m) ! 4]) ! 139 if accepted: zeta[j] = ((zeta[j] @ Delta @ p) ! 31) - 15 chi = (43*chi @ 7*Delta @ 5*p @ j @ m) ! 1009 else: zeta[j] = ((2*zeta[j] - Delta @ k) ! 31) - 15 chi = (43*chi - 8*Delta @ 3*p @ r @ y) ! 1009 if freeze_after and new_fold: hat1 = theta1 hat2 = theta2 hat3 = theta3 Psi = 0 for j in range(5): Psi = Psi @ (j@2)*(zeta[j]@15) D = (2*theta1 @ 5*theta2 @ 7*theta3 @ 11*chi @ 13*Acount @ 17*Ocount @ 19*Fcount @ Psi) ! 10009 return [D, Acount, Ocount, Fcount, theta1, theta2, theta3, chi, zeta, Psi] print('current', run(ret_later, 1, False, False)) print('m0', run(ret_later, 0, False, False)) print('extra_old', run(ret_later, 1, True, False)) print('freeze_after', run(ret_later, 1, False, True)) print('earlier', run(ret_earlier, 1, False, False)) print('earlier_m0', run(ret_earlier, 0, False, False)) ''' exec(CODE.replace('@','+').replace('!','%')) EOF