Ugh, those cups. Several months ago, Diedre Neal, the sixth-grade assistant principal at Alice Deal Middle School, started noticing them all over the cafeteria. During lunch, the children — notably the girls — were clapping their hands, beating out a rhythm on upturned plastic cups, then flipping them over and slamming them onto the table. Over and over again.

Clap, clap, ba-da-boom, boom, boom, slam. Boom slam. Boom slam.

“Put them away,’’ Neal would say, annoyed by the racket. It didn’t help. If they didn’t have cups, the girls hammered out the rhythm with their fists. Or on empty yogurt containers. Neal soon realized the girls weren’t just being just rambunctious — they were all banging out the same pattern, singing the same song.

“When I’m gone, when I’m gone, you’re gonna miss me when I’m gone . . .

A new hand-clapping game — similar to schoolyard classics such as “Miss Mary Mack” and “Slide” and “Down by the Banks” — was spreading through the school. It was being transmitted from student to student, face to face, as in the old days. Inside of a week, the rhythm became ubiquitous.

The flulike spread of “Cups” allowed Neal to experience something that social scientists are just beginning to understand. The games are encoded with sociocultural significance, said Elizabeth Tucker, a folklorist and English professor at Binghamton University in New York. They have existed since at least the late 19th century, and their functions include teaching dexterity and serving as tools for forming friendships. And somehow, new research is showing, these primitive clapping and chanting games have endured around the world, despite competition from hand-held technology.

Before Cups, Neal said she hardly ever saw hand games at Deal, a 1,200-student school that has clubs for everything from board games to Rubik’s Cubes.

“What we see are Kindles,’’ Neal said.

Until now. The game’s swift ascendancy at Deal suggests an alternative theory: Technology might not be what kills hand-clapping games. Instead it could be what saves them.

Kyra Gaunt, a social science professor at Baruch College in New York, researches hand games. There are so many distractions these days, Gaunt said, that hand games are harder for children to master. And as playtime has become more structured — soccer leagues and play dates — students are discovering them in different ways, through Web searches or in music classes.

The history of Cups at Deal Middle School, researched with a bunch of 11-year-olds over apple slices and hot dogs in a single lunch period:

It starts with Adam:

“I learned it because I liked the beat. I was taught by this girl named Libya.”

Libya could not be reached for comment, because she was out playing.

False start.

Edmee learned it from Suzanna. And Suzanna, she thinks, learned it from Sophie. And Sophie learned it from Anne. And they all saw Jalen doing it.

Says Jalen Ciagne, 11, “I saw it in the movie, ‘Pitch Perfect,’ and I thought it was really cool.’’

Pitch Perfect,” a 2012 comedy about a female college a cappella team competing for a national title, came out last fall and was released on DVD in December. It was not long after the DVD release that Neal starting seeing all those cups.

In the film, a character played by Anna Kendrick auditions for the team by singing and performing the Cups rhythm. Kendrick declined to be interviewed for this article, but she told David Letterman that she learned the rhythm by watching a video on the Internet.

Jalen, being industrious, found on YouTube the video that Kendrick mentioned. It was a home-shot recording by two young Londoners from a band called Lulu and the Lampshades.

Luisa “Lulu” Gerstein is 27. She couldn’t strum a guitar when she started the Lampshades, but she could flip over a cup. She liked the chorus of an American folk song, “You’re Gonna Miss Me When I’m Gone,” and she added some lyrics to goad her friends into joining her on a 10-day bike trip to Berlin.

“I’ve got a ticket for the long way ’round / Two bottles of whiskey for the way / And I sure would like some sweet company / And I’m leaving tomorrow, what d’ya say?”

Gerstein posted the no-frills video in 2009 on a lark. It became the band’s biggest hit. Three years later, the rhythm appeared in a Hollywood movie. Now children at Deal — and all over the Web — are singing and banging down cups to her song.

Only it’s not really hers. She didn’t make up the Cups rhythm; she learned it in a percussion class. At school. Fifteen years ago.

“I just figured it was one of those things that everyone knew,” she said. “I had no idea. ”

(Since then, the band has changed its name to the Landshapes, in part to disassociate itself from the tune.)

So, who invented Cups?

No one really knows.

And it doesn’t matter. That’s just how clapping games are.

Gaunt, the professor and author of “The Games Black Girls Play,” said two truisms have emerged from her research. Like other products of our oral culture, hand games are almost impossible to trace to the source. And they are in­cred­ibly durable.

“They are the original social media,’’ Gaunt said. Hand games were originally passed from friend to friend on playgrounds and “go viral,” spreading from school to school and from state to state.

She points to “Miss Mary Mack,” the clapping and chanting game whose titular character dresses in black-black-black with silver buttons-buttons-buttons all down her back-back-back. That game, she discovered, can be found in most every English-speaking country. It is also more than 120 years old. In Ypsilanti, Mich., the rhyme is a little more bluesy; in New York, the pace is a little faster.

But the clapping pattern is the same — arm crossed over the chest, palms slapping the thighs and then a patty-cake clap. Games like Miss Mary Mack stay intact, Gaunt says, because they involve something called “embodied language.” Years after adults first played them, they remember the rhythm, which enables them to re-create the rest.

At a recent class at Cherokee Lane Elementary School in Adelphi, music teacher Emily Koons made an announcement after her fourth-graders diligently practiced F’s and D’s on their recorders.

“Let’s play Hambone!” she told them.

“Yea!” they responded, giggling.

The children slap their hands on their thighs so fast that they begin to blur. They make fish mouths and slap their cheeks, making a hollow sound. They clasp their hands as if they are about to pray, then move them back and forth and rub them together.

No one knew how to play the game — whose Southern roots extend to the days of slavery — until Koons taught them. She thought the game would help the class understand jazz improvisation, while preserving a fading part of American culture.

Afterward, they all started practicing in the school yard.

“It’s not that kids don’t want to play” hand games, Koons said. “They just need to be taught.”

A few weeks ago, a student came up to Koons and asked whether she knew any games with cups.

The craze is still going strong at Deal. Students recently learned a variation using the Robyn song “Call Your Girlfriend.”

For Neal, this means more noise in the cafeteria as hundreds of students flip Solo cups and sing.

“Stop! Stop!” Neal commanded a group of friends one recent day. “Do you realize you’re off rhythm? You realize that?”

The girls fell silent.

Neal smiled. “Try it again.”

An earlier version of this story misidentified the city where a bluesy regional variation of “Miss Mary Mack” can be found.