When faced with a large group of similar looking people, the Slim-Shady Algorithm can be applied to deduce which member of the group is the authentic person whom you are seeking.

The algorithm is applied by simply announcing "Won't the real X please stand up" over and over again (where X denotes the name of the person you are seeking) until the real person stands up.

## Running time

The algorithm runs in O(N) time, which makes it a linear-running algorithm.

A more complex version can achieve O(log N) efficiency, but this requires the use of a tree. Note that there is an overhead cost associated with cutting down the tree to get the log.

## Known bugs

Many users report that the algorithm tends to become locked when making the announcement, refusing to accept any input and instead just repeating "Please stand up, please stand up,..." A reported (but untested) fix for this is to turn up the bass, fool!. A much rarer bug has been dubbed the "megalomania remix", where the machine stops its search for the real Slim Shady and starts claiming that it is the real Slim Shady, and all other possible candidates are "just imitating".

## History of the Slim Shady Algorithm

The first known reference to the Slim Shady Algorithm was its successful use by the Roman general Spartacus to identify the rebel Crassus. However, it was formally derived in 1914 by the renowned Serbian amateur mathematician Gavrilo Princip, with the assistance of Archduke Franz Ferdinand of Austria and a .32 caliber pistol. In 1993, the Slim Shady Algorithm was proved to have vital practical importance in the field of Nu-Math. In 1999 a song based on the algorithm was penned by rapper, gay rights activist, and lion-tamer Eminem. The song went on to see unheard-of success, becoming the only single in history to go infinity platinum. (In case you didn't already recognize this, infinity platinum is super cool.)

## The Actual Algorithm's implementations

The following is a selection of actual implementations of the Algorithm, written by tediously funny people.

All you other Slim Shadys are just imitating

slim_shady : Boolean := FALSE ;
slim_shady_stood_up : Boolean := FALSE ;

Begin
End If ;
End Loop ;

In C
#include <stdio.h>

int main(int argc, char **argv)
{

}

system("complain --life --everything-else");

return 0;
}

In C++
#include <iostream>
#include "standup.h"
#include "slim.h"

int main(int argc, char **argv)
{

}

std::cout << "Slim Shady stood up\n";
return 0;
}

In C#
using System;
using System.Text;

{
{
static void Main(string[] args)
{

string Sinput="";
while (true)
{
Console.WriteLine("Will the real Slim Shady please stand up? When  Standing, press S");
if (Sinput == "S")
{
Console.WriteLine("Standing: Thank You");
return;
}
}
}
}
}

import IO

people <- sittingPeople
result <- runListT \$ do
shady <- msum \$ map return people
case result of
[x] -> return x
_ -> error "Slim Shady has been cloned; panicking (you should, too)"

In Pascal
Var RealStanding : Boolean;
Begin
While RealStanding = False
Do
End.

In Java
import java.io.*;
import java.crowd;

private static boolean m_slimshady = false;
public static void main(String[] args){
try{
// NOTE crowd.getWhoStoodUp() may return null in case of no upstanding.
// By comparing from the static string we avoid the exception.
} catch (Exception x) {
x.printStackTrace();
System.exit(10);
}
}
System.out.println("The real Slim Shady stood up");
}
}

In Javascript

for ( var i = 0; i < possiblyShady.length; i += 1 ) {
}
else {
console.log( possiblyShady[ i ].name + " is the real slim shady." );
return;
}
}
console.log( "There is no real slim shady." );

In Python
# it's safe to return here, because it's clear that any remaining
# shadies in this sequence are just imitating
return None

In Lisp
(format t "The real Thlim Shady hath thtood up.")

In Scheme
'()

In MATLAB

switch length(stood_up)

case 1
disp('The real Slim Shady stood up.')

case 0

otherwise
feed2zombies(crowd(stood_up(2:end)));

end

In mIRCscript
if (%realslimshady != 1) { /echo -t Would the real Slim Shady please stand up? | /halt  }
/echo -t The real Slim Shady stood up.
}

In PHP
\$standing_up = 0;

if (!\$standing_up) {
\$standing_up++;
}
}
else {
if (\$standing_up > 1) {
trigger_error("Multiple shadies found.  Then what he said about there being a shady in all of us is true.", E_USER_ERROR);
}
else {
exit("ICE ICE BABY!");
}
}
}

In QBASIC
5 ON ERROR RESUME NEXT
15 PRINT "(otherwise please press <CTRL><C> to cancel)"
20 IF STANDING<>TRUE THEN GOTO 10 ELSE GOTO 30
30 PRINT "WOOT!"
40 END

In Visual Basic
Endwhile

In Ruby
homies.find{ |some_guy| some_guy.name == 'Slim Shady'}
end

In Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
DevelopersDevelopers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers DevelopersDevelopers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
DevelopersDevelopersDevelopersDevelopers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers\
DevelopersDevelopersDevelopersDevelopersDevelopersDevelopersDevelopersDevelopersDevelopersDevelopers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers DevelopersDevelopersDevelopersDevelopersDevelopersDevelopers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers DevelopersDevelopers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers Developers Developers Developers Developers
Developers Developers Developers Developers Developers Developers

In Brainfuck
+++++++++++++++++++++++++++++++++>>++++++++++[>+++++++++>+++++++++++>+++++++++++>++++++++++++
>+++>++++++++++++>++++++++++>++++++++++>+++>++++++++>++++++++++>++++++++++>+++++++++++>+++>++
++++++>+++++++++++>+++++++++++>+++++++++++>+++>++++++++>++++++++++>++++++++++>++++++++++>++++
++++++++>+++>+++++++++++>+++++++++++>++++++++++>++++++++++>++++++++++++>++++++++++>+++>++++++
++++++>++++++++++++>++++++++++>+++++++++++>++++++++++>+++>++++++++++++>+++++++++++>+++++><<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-]>--->+>>---->++>---->++++>+>++>++>+>--->-->++>+++>-->
----->->++>+++>++++>--->>+>++>++>-->+>--->----->+>++>----->---->--->>>++>--->++>----><<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[>>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>.>
.>.>.>.>.>.>.>.>.>.>.>.>.>.<<<<<<<<<<<<<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