A D.C. teen says an officer tried to defuse a conflict with her impressive dance skills. (Antwain Bynum)

Twice this week, the nation was moved by the way a white cop confronted a black teenage girl and her mobile phone. For very different reasons.

In South Carolina, the teen was texting in math class and wouldn’t put her phone away. Teens and their phones, right?

But the campus officer who went to the class responded in the worst possible way — yanking, slamming and dragging the girl across the classroom. It was a violent 11 seconds of video that made millions of people gasp and, thankfully, got the cop fired.

Sadly, in this time of a national awakening to stunning incidents of Bad Cop brutality — from ruthless arrests caught on camera to fatal shootings — this has become what we expect to see.

But many of this country’s 780,000 sworn police officers know how to do their jobs the right way.

Richland County, S.C., Sheriff's Deputy Ben Fields was called in to Spring Valley High School to remove a student. A classmate filmed the deputy slamming the student to the ground and dragging her through the classroom. (Reginald Seabrooks/YouTube)

In Washington, police showed up in a neighborhood near Nationals Park baseball stadium to break up a fight between two groups of teens. After it was over, 17-year-old Aaliyah Taylor, a senior at Ballou High School, walked up to the officer and started playing “Watch Me (Whip/Nae Nae)” on her phone. Instead of clearing out, as the police officer had demanded that she and the rest of the crowd do, she started dancing the Nae Nae. You can totally see a teen doing this, right?

That officer had a choice: Yell at the teen for being defiant and disrespectful? Go rogue and slam the teen to the ground, South Carolina-style?

Nope. The officer began dancing, too, matching Aaliyah move for move. It was a hilarious, uplifting and refreshing 56 seconds of video that immediately went viral.

It shouldn’t be news that a police officer used her humanity to defuse a tense situation instead of escalating it, that a white cop didn’t use force against a black teen. But for many people in Aaliyah’s community, it was.

All seven of her siblings have been cuffed or arrested by police for nonviolent crimes, such as breaking curfew, she told The Washington Post’s Perry Stein. And her brother and six sisters all told her that the officers were rough with them. We saw that video in South Carolina. We know it happens.

Aaliyah lives in a rapidly changing city that is becoming less and less welcoming to people who look like her.

Okay, you've seen the D.C. cop dance-off. But what about the breakdancing cop in Detroit, or the New Orleans officers doing "The Wobble"? Here's the definitive mash-up. (Gillian Brockell/The Washington Post)

Her neighborhood near Ballou High in Southeast is a world of jump-outs and street corner pat-downs. Dozens of students at her school have been killed in the past decade. You’re wearing a hoodie? Dark pants? You’re going to get stopped. Kids in her neighborhood run when they see police.

Surveys and studies — Gallup, Pew, USA Today — show that African Americans nationwide aren’t confident in the way police interact with their communities.

“I thought all cops were cruel because that’s how I saw them,” Aaliyah explained later.

The police officer, rather than taking her down like a drug kingpin caught in a sting, laughed at Aaliyah’s challenge to her authority, warned her that she had better moves and started dancing — clunky cop shoes, turtle-shell body armor and all.

“Instead of us fighting, she tried to turn it around and make it something fun,” Aaliyah said. “I never expected cops to be that cool. There are some good cops.”

Yes, Aaliyah: There are some good cops.

The police officer, who has been on the force for about three years and recently returned from a tour of duty in Iraq, told The Post she was embarrassed that her take on community policing had gotten so much attention.

“This is what we do every day,” she said.

D.C. Police Chief Cathy L. Lanier later reinforced that, issuing a statement calling the dance-off one “of the many positive police-community interactions that take place daily in Washington, D.C.”

Maybe not with so much style, but, yes, this does happen every day, all over the country. (Actually, cops in Utah, San Diego, Sacramento, Texas, New York and Philadelphia have all been filmed dancing the Nae Nae on duty this year. Seriously.)

But it’s also true that Bad Cops — and the long-standing refusal of many departments and prosecutors to hold them accountable for their actions — ruin the reputation, hard work and personal sacrifice of the tens of thousands of Good Cops.

One America is gasping at the brutality of the South Carolina video — the kind of stuff black Americans have been talking about all along — while another America is stunned that Good Cop actually exists.

We’re slowly making progress.

Dance on, Good Cop.

Twitter: @petulad