"""bound.py with a sharper transversal bound: T <= min over choices of the 'third' slice k of
   a_i a_j - (27 - a_k) * max(0, a_i + a_j - 27)   (each x in H_k has >= a_i+a_j-27 representations)."""
import sys, bound
from math import comb
def U2(p):
    a, b, c = p
    g = bound.g
    best = 10**9
    for (i, j, k) in ((a, b, c), (b, c, a), (c, a, b)):
        best = min(best, i * j - (27 - k) * max(0, i + j - 27))
    return g[a] + g[b] + g[c] + best
bound.U = U2
if __name__ == "__main__":
    for n in range(int(sys.argv[1]), int(sys.argv[2]) + 1):
        print(f"n={n} UB2={bound.upper_bound(n)}  (LB1={bound.lb_construction(n)})", flush=True)
