HOUSTON — The Oakland Athletics could think of no better way to erase the memory of a blowout loss to the Houston Astros than to turn things around on the AL West leaders on Tuesday night.

Matt Olson and Sean Murphy each homered twice, and the Athletics tagged Wade Miley for seven runs in the first inning and scored a season high in a 21-7 rout of the Astros.

After being blanked in a lopsided loss on Monday, Oakland recovered to win its seventh of nine and remained ahead of Cleveland for the second AL wild-card spot.

“It’s awesome to respond to — there’s no other way to put it — the [butt]-kicking that we got yesterday,” Olson said. “To be able to come back. We always know we can compete against these guys, and to do it in the fashion that we did today was nice.”

The Astros were coming off a 21-1 win over Seattle on Sunday and a 15-0 thrashing of Oakland on Monday in which they hit seven homers.

But on Tuesday, the A’s tied a franchise record with 25 hits and built a 7-0 lead in the first inning without an extra-base knock. They still ended up tying a season high with six homers after not hitting any in their previous two games. Their 25 hits were the most they’d hit since 1969.

Khris Davis hit Oakland’s first long ball in the second inning. Olson went deep in the third and added another homer in a six-run fourth that also featured blasts by Sean Murphy and Marcus Semien to push the lead to 17-2. The A’s set a franchise record for runs scored through the first four innings.

Murphy homered again in the fifth, and Semien added an RBI double.

“They executed pretty flawlessly, and they crushed the ball later in the game,” Houston manager AJ Hinch said.

All nine Oakland starters had at least two hits, and six players finished with three each. Olson and Murphy had three hits and four RBIs apiece and Davis and Semien drove in three runs each.

Olson has a career-high 31 homers this season, joining Mark McGwire (eight times) and Jason Giambi (twice) as the only Oakland first basemen to top 30.

The Astros got two homers each from George Springer and Martin Maldonado to give them a franchise-record 252 this season as their five-game winning streak ended.

Houston became the first team in the majors to score 20 or more runs in a game and allow 20 or more runs in a different game in a three-game span since Aug. 6-7, 1894, when the Brooklyn Bridegrooms did it, according to STATS.

The Astros are the third MLB team to have three straight games decided by 14 or more runs and the first since the 1800s when in 1876 the Chicago White Stockings had a streak of four such games and the Cleveland Spiders had three in a row in 1893.

Tanner Roark (10-8) yielded eight hits and five runs in 5 2/3 innings for his third straight win.

After Miley (13-5) had allowed five runs without getting an out in his last start against Seattle, Hinch was asked before the game what he’d like to see from his left-hander this time.

“I want him to get an out,” Hinch joked.

Hinch certainly wasn’t laughing when one out was all Miley managed before he was pulled with the Athletics leading 6-0. Miley allowed seven singles and walked one before he was replaced by Cy Sneed. He was charged with seven earned runs, which tied a season worst. The eight hits Oakland piled up in the first inning tied a season high.

“A lot of cutters in and you can either beat it on the ground or you can try to stay inside it and hit it the other way,” Melvin said of his team’s approach against Miley. “Just not trying to do too much and the hole’s open at second and just trying to pass the baton on to the next guy.”

Miley took his first loss since June 17. In his previous tough start, Houston rallied to win in 13 innings.

He was at a loss as to why things have gone so awry after he pitched so well all season.

“I’d be lying if I said I’m not thinking, ‘What the hell is going on,'” Miley said. “[But] it’s just baseball, it’s a humbling game, I’ve just got to get back to work and try to get after it.”