We consider the minimal thermodynamic cost of an individual computation, where a single input x is transformed into a single output y. In prior work, Zurek proposed that this cost was given by K(x|y), the conditional Kolmogorov complexity of x given y (up to an additive constant which does not depend on x or y). However, this result was derived from an informal argument, applied only to deterministic computations, and had an arbitrary dependence on the choice of physical protocol (via the additive constant). Here we use stochastic thermodynamics to derive a generalized version of Zurek's bound from a rigorous Hamiltonian formulation. Our bound applies to all quantum and classical processes, whether noisy or deterministic, and it explicitly captures the dependence on the protocol. We show that K(x|y) is a fundamental cost of mapping x to y which must be paid using some combination of heat, noise, and protocol complexity, implying a tradeoff between these three resources. We also show that this bound is achievable. Our result is a kind of "algorithmic fluctuation theorem" which has implications for the relationship between the Second Law and the Physical Church-Turing thesis.