C, 374
By moving memory
Not the shortest but can it get any faster?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *s;
void m (int d, int f, int p)
{
memmove (s+p+f, s+p, strlen(s)-p+1); // Shift a part of the string to make room for our insertion
memcpy (s+p, s+d, f); // Copy the desired reference in place
}
int main ()
{
s = malloc (168);
strcpy (s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");
m (0, 4, 21);
m (8, 6, 33);
m (3, 11, 54);
m (28, 5, 100);
m (3, 11, 105);
m (118, 14, 135);
m (134, 16, 151);
puts (s);
}
It's 374 chars long after minification.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char*s;void m(int d,int f,int p){memmove(s+p+f,s+p,strlen(s)-p+1);memcpy(s+p,s+d,f);}int main(){s=malloc(168);strcpy(s,"I'm Slim Shady. Yes, the real.\nAll you others are just imitating.\nSo, won't the please stand up?\nP. ");m(0,4,21);m(8,6,33);m(3,11,54);m(28,5,100);m(3,11,105);m(118,14,135);m(134,16,151);puts(s);}