How to calculate combination from given n,r and rank?
I assume that your rank starts at $0$, as this simplifies the code (for me).

The core question you must be able to answer is how many elements there are in a substructure of yours.
So in your example, we're ordering combinations lexicographically so we can use the binomial coeffecient to find how many elements there are of our substructures. We'll first try to find the first element of our combination.

Suppose our first element is $x$, then there are $\binom {n-x}{r-1}$ ways the rest of the elements can be chosen. So how do we find $x$? We repeatedly compare our rank to $\binom {n-x}{r-1}$. Is our rank smaller than this, then we must be in this range of sets. Otherwise we subtract this from our rank to skip these sets and try the next $x$.

Once we have found our $x$, we move on to the second element, etc until we are done. Initially we search with $x = 1$, but we increment $x$ after each element found because we want a strictly increasing lexicographically ordered set.

def binom(n, k):
    if k &gt; n: return 0
    if n - k &lt; k: k = n - k
    r = 1
    for d in range(1, k+1):
        r = r*n//d
        n -= 1
    return r

def derank_one(n, r, rank, x):
    while True:
        size = binom(n - x, r - 1)
        if rank &lt; size:
            return x, rank
        if size &lt;= 0:
            raise ValueError("rank is out of range for this set")
        rank -= size
        x += 1

def derank(n, r, rank):
    x = 1
    result = []
    while r &gt; 0:
        x, rank = derank_one(n, r, rank, x)
        result.append(x)
        r -= 1
        x += 1
    return result


And indeed we find that derank(10, 5, 71) == [1, 3, 5, 6, 7] ($71$ because we count starting from $0$).