Biden administration officials blame Mr. Trump and former President George W. Bush for running up debt, particularly with tax cuts. They claim credit for a decline in the budget deficit under Mr. Biden, even though that mostly occurred because the federal government stopped passing emergency aid bills as the pandemic eased its grip on the economy.

“I’m not going to sit and be lectured by MAGA Republicans in Congress about fiscal responsibility,” Mr. Biden wrote on Twitter on Sunday.

The budget office’s math is unsparing: It shows both parties acting, often together, to increase deficits and debt in recent years.

Mr. Biden has signed laws that are set to add just under $5 trillion to the debt over the next decade, by the C.B.O.’s estimation. The actual amount could be far less because of a quirk in how the C.B.O. accounts for two bills: the infrastructure bill Mr. Biden signed in 2021 and legislation enacted last year to expand health care for military veterans exposed to toxic burn pits. That quirk, which requires the budget office to assume certain spending will continue indefinitely even though Congress has not authorized it to do so, could be inflating the cost of the bills by nearly $1.3 trillion.

The estimate of the burn pits legislation could be counting nearly $400 billion in spending twice. The bill essentially shifts a large amount of spending on veterans from discretionary spending, which Congress approves annually, to mandatory spending, which essentially runs on autopilot. The budget office recognizes the new mandatory spending but assumes Congress will not cut discretionary veterans’ spending commensurately. Similarly, the infrastructure law calls for spending on projects like roads and broadband to increase in the near term and then taper off. C.B.O. estimates that tapering will never actually happen, and that spending will keep rising at the rate of inflation in later years.

But Mr. Biden has added to the debt not just by signing laws. He has also taken unilateral action that independent experts say could cost the federal government hundreds of billions of dollars. That includes the president’s plan to forgive student loan debts for a wide swath of borrowers who earn less than $125,000 a year. The plan, which is currently on hold as it faces a challenge before the Supreme Court, would add $400 billion to deficits over the next 30 years if carried out, according to budget office estimates.

Mr. Trump, by comparison, signed laws adding nearly $7 trillion to the debt in the course of his four-year term, by the budget office’s estimation. That number does not include the cost of making permanent the individual tax cuts passed in 2017 that are set to expire after 2025; C.B.O. assumes those cuts will expire as scheduled.