def calculateHeaders(tokens: list, rawHeaders: tuple) -> tuple:
    """
    Takes sanitised, tokenised URCL code and the rawHeaders.
    
    Calculates the new optimised header values, then returns them.
    """
    
    BITS = rawHeaders[0]
    bitsOperator = rawHeaders[1]
    MINREG = 0
    MINHEAP = rawHeaders[3]
    MINSTACK = rawHeaders[4]
    RUN = rawHeaders[5]
    
    for line in tokens:
        for token in line:
            if token.startswith("R"):
                if token[1: ].isnumeric():
                    number = int(token[1:])
                    if number > MINREG:
                        MINREG = number
    
    headers = (BITS, bitsOperator, MINREG, MINHEAP, MINSTACK, RUN)
    return headers