<%
datasets = table.index.levels[0]
threads = table.index.levels[1]
progs = table.index.levels[2]
minvals = {}
for d in datasets:
    for t in threads:
        vals = sorted(table.loc[d, t, :]['MemoryMB'].tolist())
        minvals[(d,t)] = vals[0]
%>
\begin{table}[ht]
\centering
\begin{tabular}{l${'r' * len(threads)}}
\sisetup{detect-weight=true,detect-inline-weight=math}
    % if len(threads) == 1:
    Program & \multicolumn{1}{c}{Memory usage (MB)} \\\hline
    % else:
    Program & ${" & ".join("\multicolumn{{1}}{{c}}{{{} Threads}}".format(t) for t in threads)} \\\hline
    % endif
    % for d in datasets:
        ${d} \\\\
        % for p in progs:
            ${p}
            % for t in threads:
            <% val = table.loc[d, t, p]['MemoryMB'] %>
            % if val == minvals[(d, t)]:
            & \hlcell{${val}}
            % else:
            & ${val}
            % endif
            
            % endfor 
            \\\\
        % endfor
    % endfor
\end{tabular}
\caption{\label{tab:${name}}${caption}}
\end{table}
