The 2012 elections reached new heights in terms of the resources invested by outside groups, though some of the most expensive races of the cycle saw relatively small third-party expenditures.

But resources invested by outside groups greatly affected the overall cost of individual Congressional contests, even as that money proved not to be the determining factor in the outcome of every race. In California’s 52nd District, one of the costliest House races in the country, the outside spending slightly surpassed candidate spending, doubling the total cost of that campaign.

There are several ways to tabulate the cost of each race.

For this list, CQ Roll Call used the outside group spending figures for each race tracked by the Center for Responsive Politics and added the total disbursements (as of Nov. 26) filed to the Federal Election Commission by only the Democratic and Republican general election candidates. (One race featured two Democrats, thanks to California’s new primary format.) Outside group expenditures include funds invested by the congressional campaign committees, super PACs and political activist groups.

The following are the Top 5 most expensive House and Senate races, according to CQ Roll Call’s formula.

This state likely would have been ranked near the top for outside spending overall if not for a pledge signed by Brown and Warren that helped keep much of the noise away. But that hardly had an effect on spending here, as Warren and Brown spent more combined than in any other race in the country. And it appeared to still be competitive heading into the final week of campaigning: Each candidate spent more than $5 million after Oct. 17.

In a state not competitive in the presidential contest, this race was the biggest game in town. Despite Brown’s strengths as a candidate and his ability to attract moderate Democrats, he could not overcome the Democratic bent of the state and Obama’s strong showing. In Mitt Romney’s home state, the president won with 61 percent of the vote and by a margin of more than 700,000 votes, and Warren walked away with an 8-point victory.

Virginia: Democrat Tim Kaine vs. Republican George Allen

Candidates: $31,080,417

Outside: $49,891,298

Total: $80,971,715

The open-seat race to replace retiring Democratic Sen. Jim Webb was second only to the presidential among federal races that received the most outside spending. The nearly $50 million spent by national party campaign committees and other outside groups is reflective of both the competitiveness of the race and the costly media markets here in one of the newest swing states in the country.

Kaine, who consistently outraised Allen throughout the long race, ended up winning by 5 points. But polling until the last month continued to indicate it was a margin-of-error race between the two former governors, and neither campaign believed Kaine had that kind of edge. The sheer number of ads on the airwaves in Hampton Roads, Richmond and Northern Virginia was remarkable. The $28 million spent against Kaine was apparently not enough.

Ohio: Democratic Sen. Sherrod Brown vs. Republican Josh Mandel

Candidates: $42,231,563

Outside: $36,976,592

Total: $79,208,155

In another state blanketed by both presidential and Senate ads, the amount of outside spending swelled as airtime prices ballooned. Brown received about $5 million more in negative advertising than Mandel, yet still won by 5 points. The spending is somewhat misleading, as this contest, which Republicans had high hopes for, never actually made it into the top tier of competitive races.

Mandel did not make an election-defining mistake like some of his fellow Republican Senate candidates, but he also couldn’t overcome Brown’s positive favorable ratings or Obama’s strong showing in the state. The nearly $11 million combined spent by Crossroads GPS and the U.S. Chamber of Commerce against Brown wasn’t enough, either. The Democratic Senatorial Campaign Committee and Democratic-aligned Majority PAC combined to spend about $8 million.

Like Massachusetts, the candidates in Connecticut were responsible for most of the spending in this race. Well, really one candidate: McMahon. The former WWE CEO loaned her campaign close to $49 million and spent nearly as much as she advertised on the expensive New York City media market.

Despite her spending, McMahon was running in a very Democratic state in a presidential year. Obama won the state by 18 points and nearly 300,000 votes, meaning McMahon would have needed about one-fifth of voters to cross over and support her. Murphy topped McMahon by 12 points.

This race emerged relatively late on the radar of GOP outside groups, who, coming out of the primary, allowed Baldwin to define Thompson, a former three-term governor, and frame the general election. But an all-out spending war ensued as both parties saw the swing state at the presidential and Senate levels as winnable.

The DSCC and Majority PAC were the two biggest outside spenders in this race, dropping nearly $11 million combined. The NRSC and Crossroads GPS followed, combining nearly $10 million in spending.

As Democrats hoped, Baldwin’s voting record, hometown of Madison and status as potentially the first openly gay candidate to be elected to the Senate proved not to be hindrances of any kind to her statewide success. She defeated Thompson by more than 5 points.

One of the closest and nastiest House races of the cycle also ended up being the most expensive. The vast majority of spending came from West, a high-profile, fiery member of the GOP freshman class, who spent nearly $18 million. Much of the outside spending came from the Democratic-aligned House Majority PAC and West-supporting Treasure Coast Jobs Coalition, with each spending just under $2.5 million.

Ultimately, the conservative West was unable to overcome the even partisan split of the redrawn district and Obama’s strong performance statewide. That helped Murphy, who, despite spending more than $4 million himself, was vastly outspent in the coastal district.

After an unsuccessful bid for president, Bachmann found herself in a re-election campaign far more competitive than she could have anticipated. The third-term incumbent ended up topping Graves, a Minnesota hotelier, by a single point.

There was very little outside spending here, despite the closeness of the race. The vast majority of expenditures came from Bachmann, whose national fundraising network allowed her to spend more than $14 million — a mind-boggling sum for a House member, especially in a media market outside of New York or California.

The self-described “best surfer in Congress” will now have plenty of time to hang loose in his beloved Pacific Ocean after falling just short of re-election. Peters, a San Diego port commissioner, defeated Bilbray by less than 7,000 votes and 1 point.

The redrawn San Diego-based district got tougher for Bilbray to defend, and he couldn’t hold on amid a barrage of outside spending targeting both candidates. Among House races, it ranked fifth in the nation in outside spending. The two House campaign committee arms each spent just less than $2.5 million, with $1.4 million from the GOP-aligned Americans for Tax Reform and $900,000 from Democratic-aligned House Majority PAC.

There may never again be a congressional race like this one. For the most part, the race was decided the day the new maps were approved. The two longtime members were drawn into the same San Fernando Valley district, but Sherman already represented about 60 percent of it, matching the percentage of the vote he took last month.

Still, Berman’s popularity on Capitol Hill contrasted with Sherman’s reputation for working the district and resulted in a tension-filled race — one that bubbled over at an October debate in front of a community college audience filled with political science students. Talk about a lesson in politics.

Both candidates spent about $6 million, while Sherman received big help from a national Realtors’ group and a California super PAC.

Democrats did Biggert no favors in redistricting, and she ended up being one of four Illinois Republican incumbents to lose last month. Despite the challenging district and worthy foe in Foster, a former congressman, the race still looked competitive. However, Foster won by a surprisingly high 16-point margin.

Both candidates easily eclipsed $3 million in spending, but the outside spending poured in as well. The NRCC spent more than $2 million, and the DCCC approached $1.5 million. Other groups supporting both candidates exceeded $1 million in spending as well — a lot of force for a race that turned out to be not close at all.