[Question]
  [
Here's an easy one, with just enough complexity to make golfing non-trivial.
## Input
1. A list of non-negative numbers representing people waiting in line for Thanksgiving dessert. The first (leftmost) number is first in line, and the list can contain repeats (think of each number as a person's first name):
```
Note: Pie not part of actual input.
        (
         )
    __..---..__
,-='  /  |  \  `=-.
:--..___________..--;   6 4 3 1 2 3 0
\.,_____________,./
```
2. A non-empty subset of that list, representing a group of colluding friends who will ["chat and cut"](https://www.youtube.com/watch?v=Iqfizyjfv0s&t=29s) to skip ahead in line. All colluders will move just behind the friend already closest to the front of the line, but otherwise retain their relative positions. Everyone they skip past will also retain their relative position.
## Output
The new list, after a successful (possibly multi-way) chat and cut. For example, in the list above, for a friend group of `0 2 4`, the output would be:
```
6 4 2 0 3 1 3
```
If the friend group was `4 3`, the output would be:
```
6 4 3 3 1 2 0
```
### Notes
This is code golf with standard site rules.
* A single colluder `x` in the colluder list makes everyone in line with that number a colluder.
* The list of people waiting may contain repeats.
* The colluder list will not contain repeats.
* The colluder list may not be sorted.
* The colluder list will have between 2 and U items, where U is the number of unique elements in the queuer list.
## Test Cases
The format is:
1. People in line.
2. List of colluders.
3. Output.
```
5 4 3 2 1 0
3 1
5 4 3 1 2 0
1 2 1 3 1 9 
1 9
1 1 1 9 2 3
1 2 3 4 5
4 5
1 2 3 4 5
7 6 1 5 2 4 3
4 5 6
7 6 5 4 1 2 3
7 6 1 5 2 4 3
1 2 3
7 6 1 2 3 5 4
7 6 1 5 2 4 3
3 6
7 6 3 1 5 2 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4 5 4
5 4
1 2 3 4 5 4
```
  
[Answer]
# [J](http://jsoftware.com/), 12 bytes
*-1 thanks to FrownyFrog!*
```
[/:OR\@e.-e.
```
[Try it online!](https://tio.run/##dY9fC4IwFMXf/RSHIlTKtT9qqAVSEARR4Ku@hRK99AH68OtuTRlFjN3BPb977tlDz1g4YFcixAocJd2E4dCcj7pdl9emq3uW9Exf9gzUmHd1u2XRYslfJxaTFsRBEPS3@xM5UigISKocUVUNMb0S6X@ZOm44yqwsCeAYDBgjKZFNQ9xxwjKmVxBH1XLCnsKYe5yi6Ywoqo5yPcdsKJQgQtotlkNuSaOY3cJz/KatNtEf72z87Q@tPGc1Kl9ZhzGhn1a/AQ "J – Try It Online")
For `6 4 3 1 2 3 0` and `0 2 4`:
```
[/:OR\@e.-e.
   OR        OR …
     \       each prefix of …
      @e.    the bitmask of friends, or:
   OR\@e.    after the first friend? (0 1 1 1 1 1 1)
          e. the bitmask of friends  (0 1 0 0 1 0 1)
         -   minus                   (0 0 1 1 0 1 0)
[/:          (stable) sort the people based on the list
                                     (6 4 3 1 2 3 0)
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~9~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ΣåDi©}®‹
```
-1 byte thanks to *@ovs*.
[Try it online](https://tio.run/##yy9OTMpM/f//3OLDS10yD62sPbTuUcPO//@jTXVMdQx1jIDYGIgtY7miQSQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9WmWCvpJCYl6KgZA9kPGqbBGRUJoT@P7c4ovjwUpfMQytrD6171LDzf62Oocahlf@jo6NNdUx0jHWMdAx1DGJ1oo11DGNjdRSiow3BQkCujiVQGETChY2BOkyBgiASLGiuYwZUZwqUAhoFkdAxwy4F1o9dyhimB2oHTDWQBRY2BarF4qpYAA).
**Explanation:**
```
Σ        # (Stable) sort the first (implicit) input-list by:
 å       #  Check that the current item is in the second (implicit) input-list
         #  (1 if truthy; 0 if falsey)
  Di }   #  Duplicate it, pop this copy, and if it's 1:
    ©    #   Store 1 in variable `®` (without popping) (variable `®` is -1 by default)
      ®‹ #  Check that the duplicated check is smaller than `®`
         #  (1 if truthy; 0 if falsey)
```
Here the same TIOs with map instead of sort-by, so you can see any leading non-friends become `0`, all friends become `0` as well, and any non-friends after the first friend become `1`:  
[Try it online](https://tio.run/##yy9OTMpM/f//3NbDS10yD62sPbTuUcPO//@jTXVMdQx1jIDYGIgtY7miQSQA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9WmWCvpJCYl6KgZA9kPGqbBGRUJoT@P7c1ovjwUpfMQytrD6171LDzf62Oocahlf@jo6NNdUx0jHWMdAx1DGJ1oo11DGNjdRSiow3BQkCujiVQGETChY2BOkyBgiASLGiuYwZUZwqUAhoFkdAxwy4F1o9dyhimB2oHTDWQBRY2BarF4qpYAA).
[Answer]
# [R](https://www.r-project.org/), ~~49~~ ~~47~~ ~~45~~ 42 bytes
*Edit: -2 bytes, and then -3 more bytes, thanks to Giuseppe*
```
function(l,f)l[order(cummax(p<-l%in%f)-p)]
```
[Try it online!](https://tio.run/##dY/NCoMwEITvPsVCEQxEUBM81ScpPYT8oBA3JVlp@/Q2tS296GVhZ2c@duKqR0UKjV5oWN2CmqaAleeO@UuIxsZKL/OsHtXtXPtywtKx@sauqx901XPJBW95l2fDCpelJi@SFX/ohoIT9CChgwYEtCCK4iCehaOw2KIZsRfOHrKJ4D5ahIAWggMaLbg4WTQJEqlICZSPVpknKPpeA9LP6ie02w99Zjb7X7wLyE@F9QU "R – Try It Online")
**Commented:**
```
function(l,f`           # function with arguments:
                        # l = line
                        # f = friends
p=l%in%f)               # define p as TRUE at positions of friends in the line
l[order                 # now output l, in the order of (lowest>highest):
-(                      # minus (so now highest>lowest)
p                       # 1 for each friend
+2*!cumsum(p)           # +2 for anyone ahead of the first friend
))]                     # (so, in the end, anyone ahead of all friends gets -2,
                        # the friends get -1, 
                        # and anyone else behind the first friend gets zero).
```
---
**Previous approach: [R](https://www.r-project.org/), ~~67~~ ~~59~~ 54 bytes**
*Edit: -8 bytes thanks to Giuseppe, then -5 more bytes thanks to Robin Ryder*
```
function(l,f,p=which(l%in%f))c(l[z<-c(1:p-1,p)],l[-z])
```
[Try it online!](https://tio.run/##hY7BCoMwEETvfsVCERKIkKh4KPVLxEOICQmEVXRF6s/bVFp6aellYWfnzc58GK9J42BWag@3oqEwIovCiandfDCexTxg7jg3LHb7rTBMXadCiYn3InbF3vMjtoY1ohaVUKJMU/LMJUmmpebZ58EzlsMFGqihBAkVKKiy7AeehF9wdaIp4hucPGQXgs1bhBEtjA7IW3BzsDgssJCeaQEdZ6uHO2h6XUektzUGtGeHJmXK/y2OBw "R – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), ~~79~~ 72 bytes
```
def f(x,y):m=min(map(x.index,y));print x[:m]+sorted(x[m:],cmp,y.count,1)
```
*-7 bytes thanks to @ovs*
[Try it online!](https://tio.run/##FchBCsMgEAXQq2Q50k@oSbMx9CTiokSlLmaUxIKe3tC3fKXXb5ZlDB/iFKmhK8NvTkL8KdTmJD78U@3lTFKnZg27x5XPGjw1y8bh4II@H/knFVqNSHbDCysWaDwd7Art1LgB "Python 2 – Try It Online") [All testcases](https://tio.run/##XZFNa4QwEIbv@RVDTgkNsq51y1os7KVQ6KGwR9fDopEGNIpGcH@9nUn2g25CCPPMO2@SyXBxv73drmutG2jEoi4y6/LOWNGdB7FExtaaoHwftZtHC0uRdeXL1I9O12IpuqxUVTeoS1T1s3Uqlmt1nvQEOXDOU3iFBLYQw4YlELMQx0g2jMU@QeGehUVzjzQJyQTVKaP1iNgb7FCVIkArSsLOM7KOQ@1/SYCBkQsKnyXJ1SO5sfv5zzu@ibGmH4EeCcb6fYqmoTVO8JM9WS4zBjiwaUovg66wT9iMojDWiUqCL6bK1lh9LZSlx0Rung9LLktv2M8OfcIXeTCMaAmCFz@H47HkYBrS5Pn9VN3iHXnxefj6LrlUdCOef3BFsvUP).
I take a unique approach here using Python's `sorted` function, which performs a stable sort. Might not be the shortest Python approach, but it is interesting.
```
def f(x,y):  # x = input line, y = list of colluders
  m = min(map(x.index,y)) # index of the first colluder in line
  print
    x[:m] # The first m people do not change positions
    sorted(
      x[m:],   # we sort the people after the first m
      cmp,    # default comparison function
      y.count, # key function is y.count: returns 0 for numbers not in y
                 # and 1 for numbers in y
      1        # sort in descending order
    )
```
[Answer]
# [Haskell](https://www.haskell.org/), 59 bytes
```
(h:t)%c|all(/=h)c=h:t%c
l%c=[x|b<-[1<0..],x<-l,elem x c/=b]
```
[Try it online!](https://tio.run/##lZBNDoIwEEb3nGIWkkAygsiP0dAjuHbRNAZqkxIHRYWEGO@OUFR06aZp30zfNxmd3Y6KqOscvaldWz4yIsdn2pWsB7a0yJaMt488nfMgXXiewDadEypSJbQgfZaL7tKoRt2AAecxQoQQIiwRAoSFQODB@xWacz2x0HTHA1ghJKYcm8og@R9PViEseSZqDuo6DjZkv1rMAO/cyDiSr9/DNfxFo7DMilPvKrNqu4fqWpxqmMG9qHZFrcGxXXjt4RPcPQE "Haskell – Try It Online")
Test cases and inspiration from [ovs's solution](https://codegolf.stackexchange.com/a/215562/20260).
We use `[1<0..]` to generate the list `[False,True]`. Having handled the prefix of non-colluding numbers, we then pass over the remainder twice, first to take colluding numbers, then to take non-colluding ones. A same-length alternative is:
**59 bytes**
```
(h:t)%c|all(/=h)c=h:t%c
l%c=[x|b<-[id,not],x<-l,b$elem x c]
```
[Try it online!](https://tio.run/##lZDLDoIwEEX3fMUsIIFkiA8eRiOf4NpF0xioTWgcHgokxPjvCAVEl26a9sz03MmkcXWTRF1np4fascQrJrJXUeqIqAeWMMgSEWtfydFl6op5UXNsjy5hYkqSGbQgeHdvZCMriICxAMFH8BC2CBuENUdgm/nl6XO/ME93BwPYIYS6HOjKIPkfL1bODVEQNVf5GAcbsqcWPcCc62tH@PV7uHq/aBRmscp7VxaXpwuUD5XXYMJTlWdVp2BbDkx7@AR3bw "Haskell – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
e€»\_$Ụị⁸
```
[Try it online!](https://tio.run/##y0rNyan8/z/1UdOaQ7tj4lUe7l7ycHf3o8Yd/w8vV4r8/z862lRHwURHwVhHwUhHwVBHwSBWRyHaEMYzBpOWCDFjsGpTkIC5joIZWNoULAMyhHRhhKkQnpGOsY6JjqmOSWws0G0g66GqwG6AWW0CNsYMyQAQ0xhVCGxmNNgoAA "Jelly – Try It Online")
More or less a translation of xash's J answer.
```
e€           For each person in line, are they a friend?
    _        Subtract that from
  »\ $       its cumulative maxima,
      Ụ      sort the indices,
       ị⁸    index back into the line.
```
`iⱮ»\_$Ụị` almost saves a byte by taking colluders on the left and the line on the right, but it doesn't succeed at preserving the order of duplicate colluders in cases such as `[1,2,3,4,5,4], [5,4]`.
# [Jelly](https://github.com/DennisMitchell/jelly), 12 bytes
```
iⱮṂœṖ⁸e¬¥Þ€F
```
[Try it online!](https://tio.run/##y0rNyan8/z/z0cZ1D3c2HZ38cOe0R407Ug@tObT08LxHTWvc/h9erhT5/390tKmOgomOgrGOgpGOgqGOgkGsjkK0IYxnDCYtEWLGYNWmIAFzHQUzsLQpWAZkCOnCCFNjY4GOAdkHFQZbCrPLBKzPDEkHiGmMKgQ2BAA "Jelly – Try It Online")
[Answer]
# [Factor](https://factorcode.org/), 62 bytes
```
[ '[ _ member? ] 2dup find . swapd cut rot partition 3append ]
```
[Try it online!](https://tio.run/##lVCxTsMwEN3zFY@pW0RiUgQIMVYsLIipqpCbXCSLxjb2Waiq@u3BTgkJ7cRg6d47v3t3r5U1G9e/vT6/rO7Ruj0@yGnawdNnIF2Th3XEvLdOaQYbs/M5k2fUptsqLaPa4yHLrjCwStvAPjvggAo3EChR4BrHDJEpBiTiu5sxIv6rfvAtlpGrIpu0/@PGWceIk3/yGTuj3@SUquUf5akWZ@wwD@jXWKzxjo66LbknbFA2waJVukEO/yVtgzownGFY6VixMhpCWkvxx6YvO2nHjEzgs5CS1RRSMSxcXhw2Dynp5mufAkk4dSZO/MZ0edQj8v4b "Factor – Try It Online")
The extensive `sequences` library is quite helpful here. Takes `line cheaters` on the stack, and returns the modified line through the stack. Prints a garbage to stdout each time it is run.
### Ungolfed
```
[                  ! ( line cheaters ) start anonymous lambda definition
  '[ _ member? ]   ! ( line fun ) convert cheaters array to membership function
  2dup find .      ! ( line fun idx ) find index of first cheater
  swapd cut        ! ( fun left right ) cut line at that index
  rot partition    ! ( left cheaters rest ) partition the right into
                   !   cheaters and non-cheaters, using the membership function
  3append          ! ( ans ) concatenate the three arrays
]                  ! end anonymous lambda definition
```
---
# [Factor](https://factorcode.org/), 74 bytes
```
[ dupd '[ _ member? 1 0 ? ] map dup cum-max swap v- zip sort-values keys ]
```
[Try it online!](https://tio.run/##hZBPT8JAEMXvfIp3Qw8ltkWMeOBouHAxnhpi1jJA4/aPnSmKhM9ed5e2oBHMXmbfzPzmzSxVLHlZPz9NZ49jKOY8ZizLLd6ozEgjVbIesChJWBKTcv8N2SYG03tFWUzc47yUJFtB8lzzQIgFD73pbIyVrkTyrNdFuIJOMkK8JiVkIJ7nhD6u6wiLqligH@EFKaWvVE7g4wYTzM3gwmYRV6mXqk/whxE2Hr6SAna6t1G6Ija@t4x5HSutjYUddrjFEKHhBIa0Nw@IOjVwfKvtXI2N0Fmdo8oS8ew6juS7d2@6whOS7yihyxxIbXSJZBlD42LfVEa/VDjSMT5HusPI7eJ3rqJG9Y0euC33DWnkWJdIB4rlnSe1ky6Twq7rPClsHP1/p/ZKP@/UaqfKH6T6Gw "Factor – Try It Online")
Factor's standard library is feature-rich enough that it can almost directly replicate [xash's J solution](https://codegolf.stackexchange.com/a/215560/78410). Except that it's 5~10 times bloated byte-count-wise.
### Ungolfed
```
: glutton ( line cheaters -- line' )  ! takes two arrays on the stack
                                      ! and returns the cheated line as an array
  dupd                       ! duplicate line under cheaters
  '[ _ member? 1 0 ? ] map   ! for each number in line, 1 if it is a cheater,
                             ! 0 otherwise
  dup cum-max swap v-        ! cumulative maximum minus self (of the above)
  zip sort-values keys       ! sort line by the above
;
```
[Answer]
# [Haskell](https://www.haskell.org/), 65 bytes
```
q!c|f<-(`elem`c),(h,t)<-span(not.f)q=h++((`filter`t)=<<[f,not.f])
```
[Try it online!](https://tio.run/##lZDLDoIwEEX3fsWQuGjDYEQexgQ@wbULQoRgGxrLu2yM/45SQHTpppneO3PuZPK0uzMph6ExsicPLJIwyYoko0hyVDSwujotSVmpHadNmJsmIQkXUrE2UTQMgoijNmM6ND3rWQchRJGH4CI4CAcEG2EfI0T28nP0e1o1R3d7o3BE8LXtaWeE/C@v1DjeZJWU/Y2102Jj9tyiF1hyXc3wv6bH0vmVJmCRivLNKtL6fIW6FaWCLTxEfREqB2JQmO/wCR5e "Haskell – Try It Online")
**Commented**:
```
q!c|
    f<-(`elem`c),        -- f is a function to check whether a number is a colluder
    (h,t)<-span(not.f)q  -- h is the longest prefix of non-colluders, t the remaining list
   =
    h++                  -- the result is h and ...
    (  =<<               -- ... the concatenation of the results of ...
     (`filter`t)         -- ... filtering the remaining list by ...
         [f,not.f])      -- ... f and not f (colluders and not colluders in t)
```
---
# [Haskell](https://www.haskell.org/), 66 bytes
With some inspiration from xnor's and AZTECCO's answers I came up with a pointfree function that is just 1 byte longer.
```
(takeWhile<>g.(not.)<>((.).g<*>dropWhile)).flip(all.(/=))
g=filter
```
[Try it online!](https://tio.run/##lZAxb4MwEIX3/IobOtiV4zQlpKoETF0zZ6CossAGKwd2jFn64@sG04h27HLyvXf3vZM7MV4kYtC9Nc7Dm/CCn8xgdAOEZAWlG5W/B@LFRZ47jTIrWk4G4znNCkI45W32WDTO2OhSyhVqSwQiJ7v8tt3mSqOXLlwnOckRcijLlMGBQcLgmcGewVPFoNzfuyTW11VL4nQ6Cy8MjtFOozND/i@v1Kra1AZxaqRbDpuzf0biAffcQ2Qcf23Pz@SvtAB7oYcbqxf29AHW6cHDA3xqe9a@AwVr3vIf4atWKNoxbGtrvwE "Haskell – Try It Online") In GHC version 8.4.1 and above `(<>)` is included in the Prelude, in the old version on TIO it has to be imported manually.
[Answer]
# [Racket](https://racket-lang.org/), 145 bytes
```
(λ(a b)(let([m(apply min(map(λ(x)(index-of a x))b))])(append(take
a m)(call-with-values(λ()(partition(λ(x)(member x b))(drop a m)))append))))
```
[Try it online!](https://tio.run/##jZDBTsMwDIbve4pf4jD7UIlSOrRnQRzcNYVoSRplYeuejXfglYrTTeLAkHaxbPnzZ8tJdnuT5wcn4R1pKVbUm8EGg2Gm7y8SdEzOZHr1JDG6M7wN5CWW5sRkQ2@mahwgmJg75jcunAk9ZdmblcAz7cS56mTzR3UU92kOZZYpSso22zFcVd74ziRMupGpT2NEGWa@6DThmfU6e4hOzi6ABqypxTMaPKHGI6@pQa3YH6heAG1iy6Xa/gc1amsVKfEG8oKNOloFdekFw@YecHHfAza3fdfb@DfTZ/wA "Racket – Try It Online")
That's even longer than my Red solution :)
It's insane that `partition` returns two separate values rather than a list with two sublists - that's why I need to use `call-with-values` and put `partition` within an additional lambda...
[Answer]
# [Ruby 2.7](https://www.ruby-lang.org/), 39 bytes
```
->q,c{q.flat_map{c-[_1]!=c ?q-q-=c:_1}}
```
[Try it online!](https://tio.run/##hVFBboMwELzziim9GhTHoVEjuXmIa1XUBQWplXAwUiLg7RSvIaG95GJ7d2ZnZ@Rz@3kdSzkmb5aZzqbld@4@fvK666veJKrST9LgaBObSHOohmF0ReMaSKgIUCpj2DEIhi0DZ9hoBjVVXGtGOF8QQeerx@n@gwtSyTxI9wzuGV5oLCOWX7RQJuQBa1Z@wBIrobuX1byvdKSj4lIXxhVfS/Jb8MDbBA1OtQ84b1@665C@FewEEb7m3nyGiYzc3AGxzvBf3fuk70mL3JzQobcMpkfdTj8WP3dnWSrf0QOmAlJiSZU2p6p0OCJ@b7d7LmIcwnNn4iHGMP4C "Ruby – Try It Online") (40 bytes because TIO's Ruby version doesn't support numbered block parameters)
Relies on the `Array::-` method, which returns all elements of the first array not present in the second. Given a queue `q` and colluders `c`, the ordered lists of non-colluders and colluders are `q-c` and `q-(q-c)`, respectively.
```
->q,c{
  q.flat_map{ # For each person in the queue
    c-[_1]!=c # Are they a colluder?
      ?q-q-=c # If they are the first colluder, replace them with all colluders (in same order as they appear in the queue) and remove remaining colluders from the queue in one fell swoop. Second and subsequent colluders will be replaced by an empty array.
      :_1     # If not a colluder, leave them alone
  }
}
```
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 20 bytes
```
{x@<{(|\x)-x}x in y}
```
[Try it online!](https://tio.run/##ZYyxDoMwDER/5TbsgappCKg1A//RdkVCSHQ1Cvn21ETZWM7n5zuv7W/NeX5FncZIx0e51aRYNuwpR1LZZX6bfjndGqKADh4PONzFjGMhV1bzeMopFXlLBjnFwIDeTsGw1QtEf8WldsW@ZOtPqZM5/wE "K (oK) – Try It Online")
An experiment in making a K port of [xash's J answer](https://codegolf.stackexchange.com/a/215560/75681) - please upvote his/hers solution!
[Answer]
# [Haskell](https://www.haskell.org/), ~~83~~ 72 bytes
```
import Data.List.Split
q?c|h:t<-splitOneOf c q=id=<<h:filter(`elem`c)q:t
```
[Try it online!](https://tio.run/##lVA9b4MwEN35FTd0SKRrFGJMFATKkjFVhg4dEGos4girhvBhlqr/nfoMKclYWbLvvXfv3cmF6L6k1sOgyvrWGjgII1ZH1ZnVe62V8Zp9/lNEJn7tCJ4qebpCDk2iLkkcF9FVaSPbxVlqWZ7zZROZoellLztIIE05QoDAEDYIPsI6Q0j9O2Lu3s0cc92ciC1C6GTuFAr5Pz2nZvg8wt6QZV5@07q/yHZclvaZbG6p@y6jIXxIpJI9U@MQjoGNLYWqbGIp6rdPqFtVGXiBb1V/KFPAYr@E6Yf@xg9kRIY@bnCdeTaTzs4i5pB9rc5tvcUQqdefNMKjTqNHTDnccsHsfUyx6Bc "Haskell – Try It Online")
* Longer than @xnor and @ovs great answers but I think it's worth posting because it's quite short and it has a simple and interesting approach.
* Thanks to @ovs for the precious advices, saved a lot and looks more golfy now!
```
q?c ... =             - infix function taking q-ueue and c-olluders lists
|h:t&lt-splitOneOf c q  - split queue at colluders 
id=<<                 - concat map :
h:filter(`elem`c)q:t    - first split, colluders and the remaining 
```
[Answer]
# [Perl 5](https://www.perl.org/), 75 bytes
```
sub{$f=1;map$_%1e5,sort map$_+1e5*++$r+1e9*($_~~@_&&($f=2)?1:$f),@{+shift}}
```
[Try it online!](https://tio.run/##fZLdTsJAEIXv@xSTZoEuHRKWWhQaYl/AO@@aplFssUba0i1GQuDSB/ARfZE62z9QidmLPTvnfDO7yWZh/mqX6x2LFqXcPu5pF876IWNBT4Q2yjQvoDqadByaJstJzIYGC45HN@j3DQIm/FbMWcTR3ZvyOY6Kw6F0tK0M4T6UxXx@l@aho0VpboAHno1XaOEEBY59BADPQlEJaD1B7tj3UauL4IkqroxZjbSikmrNKGH9RizqZre5M3nyzoBrnFIfmyy6AiUVgNN6nPLU1cTvKX@gOtFB9SRC/4WsZk4DWa174T1NDs4Lnbz0/Abx7I794fka31fQemewDbIlsvA94wuXBU5TB3eVFrCAPotUxGVLXluxNF7SODEGMECV4c14gFO56tbVZZbHSRHpvdHkRsLXxydAbySmEt4kKakj6JEBLttQluYAVxXVutpVL51rB@0pTcKgoK8VJyun/AY "Perl 5 – Try It Online")
```
sub{
  $f=1;           #f = 1 if first colluder not found, = 2 after 1st colluder
  map$_%1e5,      #remove part used for sort, input elems remain in sorted order
  sort            #sorts numerically as all elems have same number of digits now
  map             #converts each elem in input queue to sum of:
    $_            #the elem itself
   +1e5 * ++$r    #plus 100000 times the input rank in the queue
   +1e9 * (       #plus 1 billion times the "rank overriding number" which is:
      $_~~@_&&($f=2) #true if current elem is colluder (if so, set $f=2)
      ? 1         #...1 if colluder
      : $f        #...or $f if not colluder (f is 1 before 1st colluder, 2 after)
    ),
    @{+shift}     #input queue
}
```
Works for input elems 0-99999 and for queues up to 10000 elems. Increase 1e5 and 1e9 to 1e8 and 1e16 accordingly (spending one more byte of code) to avoid this, after which computer memory size becomes a bottleneck for most setups I guess.
[Answer]
# JavaScript (ES10), 60 bytes
Expects `(people)(subset)`, where `people` is an array and `subset` is a Set.
```
a=>b=>a.flatMap(i=>b.has(i)?j=a.filter(x=>j&b.has(x)):i,j=1)
```
[Try it online!](https://tio.run/##jZBBDoIwEEX3noKVaZMRrBUMJsUTuHJJWFQtWkKAAFFvj9OCkaAmtquZ@f/1dzJ5k82p1lW7KMqz6lLRSREdRSTdNJftXlZEY@1eZUM03WUC@zpvVU0eIsrm/eBB6VZDJhjtTmXRlLly8/JCUhL7sAYOK2CwTCgp1N05qJbEHFhCKXXM8TynVzHULWcTALNmMwzHAFu@AQzMDVHLvwE48v2x3ZaDfQAMqql9AwGSfRxjxAkCAgtBu1GZT7BvCX4irHqM6FMg6G8EHzI4LwR/6X7s4eN90xov0ra6Jw "JavaScript (Node.js) – Try It Online")
Or [Try it with map()](https://tio.run/##jZBBDoIwEEX3noKVaZMRqRWMJsVDuCQsqhYtQSBAlNvjtGAkqIntpjPz/@tvU3mX9anSZbPIi7PqEtFJER5FKN2bLInGs3uVNdF0nwrpJjprVEVaEabzftBSutOQCka7U5HXRabcrLiQhEQ@rIHDChh4MSW5ejgH1ZCIA4sppY5Zy6XTqxjqvNkEwKzZDLdjgC3fAAZmb1HLvwE48v2x3ZaDfQAMqql9AwGSfRxjxAkCAgtBu1GZR7BvCX4irHqM6FMg6G8EHzI4LwR/6X78w8f9pjX@SNvqng) to get a better picture of the process.
### How?
The variable `j` is initially set to `1`.
We walk through the queue with [`flatMap()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap). Each identifier `i` that is not included in the group of friends is copied as-is:
```
b.has(i) ? … : i
```
As soon as a guy from the group of friends is reached, we append all friends at once in their order of appearance in the queue, and assign the result to `j`:
```
j = a.filter(x => j & b.has(x))
```
Arrays holding at least two elements are turned into `NaN` when coerced to a number. So the next time a friend is encountered, `j & b.has(x)` will be falsy(1) and `filter()` will return an empty array. As a result, all following friends are ignored as expected.
---
(1): It could actually be truthy if `j` is updated to a singleton array holding an odd identifier. But that would mean that there's only one friend in the queue, so the test `b.has(i)` would not be triggered another time in that case anyway.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~201~~ \$\cdots\$ ~~172~~ 171 bytes
Saved ~~12~~ a whopping ~~29~~ 30 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)!!!
```
#define z 0;for(i=-1;++i<n;
#define P&&printf("%d ",l[i]
q;p;i;j;f(l,n,c,m)int*l,*c;{q=p=z!p P))for(j=m;j--;)l[i]==c[j]?q=p?q:i,l[i]^=p=-1:z)0>l[i]P^-1);z)i>=q&0<=l[i]P);}
```
[Try it online!](https://tio.run/##hVVdU@JAEHznV@zlSovgpM58gq7Rh6t79x3R8obBi7WsEbDkoPjrx21Ckp1o1FRZhJ7u3ukhcdB7QNzvv09plmkSG3EqZ0@LfpZ6vjw5yS607NW16@PjfJHp1azvHE2FA2qcTXrPMpeZfJSzvgINCHPXMAYKBii3z2mebr7l4tp1C8/HdC4fPU@6hTBNcfw4uTKUq@fzrPS6NXTPP9@4p5fF1@tbz3flxs0u0@fj04u0xFy525dN9ItjhAJhPoV2xbYnzGWOEUVFZCI1SczHhdBSmCA1o7iaFMujqQP97MoRzrnjuGUXrix5ux5n3mjH4Lve/D7T/dqqOEf544k5auv7fgyhuSIIIQAfTneyIWFFCsFnKHVJfSPmUhVUpNK0qJ8Bd27KZ9y5Qf1SEEDILUNrGUIEMferam2UPlGo6FAbQmLOig0jap2GUeMICfdkutho/Lddxl/4xqwn7tvSFf0ad@6bfOGb1L9Vq1umCmsddx22JsT9PqzQhxU1ejPvtmNVbaP0mWYgVrRcLe/UgaN8UAGoEFQEKgaVgBqCGr3n44GPPmAAGAJGgDFgAjgEZHxR@@uDYJlt6Mn8R/DdH9XtwNxDDQcMDiwcMji0cMTgyMIxg2MLJwxOLDxk8NDCIwaP3PeBsB0IWSC0gZAFQhsIWSC0gZAFQhsIWSC0gZAFQhsIWSC0gZAFQh5oIGidE65oWgYSW/KBAqAQKAKKgRKgIdCoS3GnK03lTGwKZKdAbApkp0BsCmSnQGwKZKdAbApkp0BsCmSnQGwKZKdAbArUTAH/3C8GYnH4QZ2b9a/gZn320/zFDgj@PXQqhd0mekrraqOUtxei8q@ee3teDZRLp@DyxXPYWcaofh1LxkRyglBaWIbupPx@mY2VZuCc5pj/7Rscip2o9KB5rF1Xvlt8OT3lisTrfbbK9IOxFMos@PPDlmuRS0ulXdnOgE2H2Nkgsgz4PkPdBz4p9TItWpgtMtLTZWcLCKg7Qmh6NW0vV280s6pl@EDWZh8edNNr83p0xSnTsNfhozw1pTMGQVc7Xvuywl1vt/@HM3X/sNx7r/8B "C (gcc) – Try It Online")
Function takes a list of people waiting in line, its length, a list of colluding friends, and its length. Prints the new list to `stdout`.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 26 bytes
```
≔⁻θ⁻θηε≔⌕θ§ε⁰ζＩ…θζＩεＩ✂⁻θηζ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/9@xuDgzPU/DNzOvtFijUEcBzsjQ1NRRSNW05oKqcMvMSwGJO5Z45qWkVmik6igYgJRUAZUEFGXmlWg4JxYDicrknFTnjPwCkNoqTU1U2VQ0fnBOZnKqBpKdUD3//0dHm@somOkoGOoomOooGOkomOgoGMfqKEQbgnnGsbH/dctyAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
≔⁻θ⁻θηε
```
Get the sublist of the colluding friends. This is actually calculated by removing the entries of colluding friends from the original list, then removing those entries from the original list.
```
≔⌕θ§ε⁰ζ
```
Get the position of the first of the colluding friends in the original list.
```
Ｉ…θζ
```
Output everyone ahead of the first of the colluding friends.
```
Ｉε
```
Output the colluding friends.
```
Ｉ✂⁻θηζ
```
Output everyone else who wasn't ahead. (We already calculated this list but it actually costs a byte to save this rather than recalculating it.)
[Answer]
# [Red](http://www.red-lang.org), 124 bytes
```
func[a b][m: 0 until[m: m + 1 find b a/:m]rejoin[take/part a m - 1
collect[foreach c a[if find b c[keep c]]]difference a b]]
```
[Try it online!](https://tio.run/##bU@7bsMwDJytrzhkLYLEdZ0gHvIRWQkOskShSmzZEJTvdyU76VCUAx/HOz6i2OUmlli5Dot7BkMaPdPY4YhnSH4o6YgP1HA@WPTQh27kKPfJB0r6IYdZxwSdSXvUykzDICaRm6Jo8w0DTd69tYYeIjMMM1vvnEQJRlA28vJWbAcoZKMWX2jwmZcfmRrUrCqq1zoXuDAV98KazG2ZitvEZ5wyqc2tPGRt4FTIf/BV@w/ebOzXaP5NVKWYMEcfEmicBlt@L6HHbn/dwZV/wBUvPw "Red – Try It Online")
]