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 American League West leaders on Tuesday night.

Matt Olson and Sean Murphy each homered twice as 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 their seventh of nine and remained a half-game 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 victory over the Seattle Mariners on Sunday and a 15-0 thrashing of Oakland on Monday, in which they hit seven home runs.

However, 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 had 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 A.J. Hinch said.

All nine Oakland starters had at least two hits and six finished with three each. Olson and Murphy had three hits and four RBIs apiece, while 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 third 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, STATS data showed.

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 the Chicago White Stockings in 1876 had a streak of four such games and the Cleveland Spiders had three in a row in 1893.

In other results, it was:

‧ Tigers 12, Yankees 11

‧ Phillies 6, Braves 5

‧ Dodgers 7, Orioles 3

‧ Blue Jays 4, Red Sox 3

‧ Brewers 4, Marlins 3

‧ Mets 3, Diamondbacks 2

‧ Twins 5, Nationals 0

‧ Rays 5, Rangers 3

‧ White Sox 7, Royals 3

‧ Rockies 2, Cardinals 1

‧ Giants 5, Pirates 4

‧ Indians 8, Angels 0

‧ Padres 9, Cubs 8

‧ Mariners 4, Reds 3