text:
Output the list of musical notes
This task is simple: Write a program or function that outputs the list of all musical notes (using English note names) from A♭ to G♯.
All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of one. Sharp or flat notes that can be described with a single letter, like B♯ (C) or F♭ (E) should not be outputted.
Here is an example of the output:
Ab, A, A#, Bb, B, C, C#, Db, D, D#, Eb, E, F, F#, Gb, G, G#

Specifications

The program or function must not take any input.
The notes may be printed in any order, and in any list output permitted by our standard I/O rules
The sharp and flat Unicode symbols (♯/♭) may be substituted with b
and #
As always, Standard loopholes are forbidden.
As this is code-golf, the smallest program, in bytes, wins.

related

May we output "C " instead of "C"?

@Arnauld yes you may

By the way, B# exists in music notation; it's for example in the key signature for the key of C#, where it serves as the leading tone.

So no naturals, double-flats or double-sharps either? :-) (I kid, those are only needed for certain scales.)

I don't know, it feels like Cb is missing here ;)

No input. Does that include any pointers to output to?

Malbolge, 482 370 353 bytes
R1: Removed commas inbetween (as not required by the challenge)
R2: Shave off a few bytes
('<;_#!=6Z|{8xUwvt,PrqonKmk)"FhCUTdb?`+<;:[Z7YtVU2T|/g-O+i(gJrHc#EC~B{@zZxw:tt'r5Qo"!l/K-hUfe?bP``_Lo~[}|X2VCTR3Q+N`_^9+7Hji3ffdAc~w|u;]\wpon4VUSSQ.PONcb(JI^]#DCYX|@?>=<:u9NMRKo32MFj.C,Ae)>'<%:^"!~5:3WxwwuRts0q(Lnml)"Fhgfe"y?a`_zyxq7YXWlUj0RgfkjMb(JI^c\[Z~BAV?T=Rv987Mq44310FEi-,G@)>b&%#"8=6Z{{yyw/Sut1*)('Km$k(!Efe{zyx>`uz]r8ZXnm3TTih.PkNchg`&HFF[DY}Az

Try it online!

CP-1610 assembly (Intellivision), 31 DECLEs1 = 39 bytes
A routine taking an output pointer in R4 and writing the notes there, separated with spaces. In the example code, we write directly to the screen.
Hex dump (routine only)
275 001 2BD 03C 048 1DB 2B8 012 044 2A9 2BA 108 078 201 003 262
261 263 2FA 008 37A 140 225 00B 089 22C 011 2B7 018 210 000

Full source
                ROMW    10              ; use 10-bit ROM width
                ORG     $4800           ; map this program at $4800

                ;; ------------------------------------------------------------- ;;
                ;;  test code                                                    ;;
                ;; ------------------------------------------------------------- ;;
4800            SDBD                    ; set up an interrupt service routine
4801            MVII    #isr,     R0    ; to do some minimal STIC initialization
4804            MVO     R0,       $100
4806            SWAP    R0
4807            MVO     R0,       $101

4809            EIS                     ; enable interrupts

480A            MVII    #$200,    R4    ; R4 = backtab pointer
480C            CALL    notes           ; invoke our routine

480F            DECR    R7              ; loop forever

                ;; ------------------------------------------------------------- ;;
                ;;  ISR                                                          ;;
                ;; ------------------------------------------------------------- ;;
      isr       PROC

4810            MVO     R0,       $0020 ; enable display

4812            CLRR    R0
4813            MVO     R0,       $0030 ; no horizontal delay
4815            MVO     R0,       $0031 ; no vertical delay
4817            MVO     R0,       $0032 ; no border extension
4819            MVII    #$D,      R0
481B            MVO     R0,       $0028 ; light-blue background
481D            MVO     R0,       $002C ; light-blue border

481F            JR      R5              ; return from ISR

                ENDP

                ;; ------------------------------------------------------------- ;;
                ;;  routine                                                      ;;
                ;; ------------------------------------------------------------- ;;
      notes     PROC

4820            PSHR    R5              ; save return address

4821            SDBD                    ; R5 = pointer to @@chr
4822            MVII    #@@chr,   R5
4825            CLRR    R3              ; R3 = 0 (space)
4826            MVII    #$12,     R0    ; R0 = bitmask = $12
4828            SWAP    R0,       2     ; extend it to $1212

4829  @@loop    MVI@    R5,       R1    ; R1 = next symbol
482A            MVII    #('A'-32)*8, R2 ; R2 = 'A' character

482C  @@note    SARC    R0              ; right shift the bitmask
482D            BC      @@next          ; skip this note if the carry is set

482F            MVO@    R2,       R4    ; append the note
4830            MVO@    R1,       R4    ; append the symbol
4831            MVO@    R3,       R4    ; append a space

4832  @@next    ADDI    #8,       R2    ; advance to the next note
4834            CMPI    #('H'-32)*8, R2 ; is it now a 'H'?
4836            BLT     @@note          ; if not, process the inner loop

4838            TSTR    R1              ; was the symbol a space?
4839            BNEQ    @@loop          ; if not, process the outer loop

483B            PULR    R7              ; return

483C  @@chr     DECLE   ('#'-32)*8      ; '#'
483D            DECLE   ('b'-32)*8      ; 'b'
483E            DECLE   0               ; space

                ENDP

Output

screenshot from jzIntv

1. A CP-1610 opcode is encoded with a 10-bit value, known as a 'DECLE'. This routine is 31 DECLEs long, starting at $4820 and ending at $483E (included).

Python 3, 50 bytes
print(*map(''.join,zip(3*'ADGBCEF',7*' '+5*'#b')))

Try it online!
Python 2: 48 bytes
This code can be adjusted as to include B# and Cb, at the cost of no additional bytes. This can be achieved by replacing 5 with 6.

Additionally, it is (finally) shorter than just outputting the plain string:
Python 3, 51 bytes
exit('Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G#')

Try it online!
Python 2: 50 bytes

This is a very creative solution

05AB1E, 16 15 13 bytes
Au…b #âŽ7×bûÏ

-2 bytes thanks to @maxb.
Try it online.
Outputs as a list, where the single-char notes are with a trailing space.
Explanation:
Au             # Push the lowercase alphabet, and uppercase it
  …b #         # Push string "b #"
      â        # Take the cartesian product of both strings to create all possible pairs:
               #  ["Ab","A ","A#","Bb","B ","B#",...,"Zb","Z ","Z#"]
       Ž7×     # Push compressed integer 1999
          b    # Convert it to a binary string "11111001111"
           û   # Palindromize it to "111110011111110011111"
            Ï  # Only leave the notes in the list at the truthy values (1), (the trailing
               # items beyond the length of this binary string are also discarded)
               # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Ž7× is 1999.
Ž7× could alternatively be ₄·< (1000, double, decrease by 1) for the same byte-count.

Is the 7£ really necessary? Seems to run fine without it.

Perl 6, 41 bytes
{S:g/[E|B]\#...//}o{'A'..'G'X~'b #'.comb}

Try it online!
Simple cross product of the notes and the sharps/flats, followed by removing the extra invalid notes. This is an anonymous code block that produces the string:
Ab A  A# Bb B   C  C# Db D  D# Eb E   F  F# Gb G  G#

Jelly, 18?* 20 bytes
ØAḣ7µp⁾b#Żs6ḣ€4ẎḊ;W€

A monadic Link returning a list of lists of characters.
* If a mixed list of (a) lists of characters and (b) characters is acceptable remove the trailing W€ for 18.
Try it online!
How?
ØAḣ7µp⁾b#Żs6ḣ€4ẎḊ;W€ - Link: no argument
ØA                   - list of characters     [A-Z]
  ḣ7                 - head to 7              "ABCDEFG"
    µ                - new monadic link (call that X)
      ⁾b#            - list of characters     "b#"
     p               - Cartesian product      ["Ab","A#","Bb","B#","Cb","C#","Db","D#","Eb","E#","Fb","F#","Gb","G#"]
         Ż           - prepend a zero       [0,"Ab","A#","Bb","B#","Cb","C#","Db","D#","Eb","E#","Fb","F#","Gb","G#"]
          s6         - split into sixes    [[0,"Ab","A#","Bb","B#","Cb"],["C#","Db","D#","Eb","E#","Fb"],["F#","Gb","G#"]]
            ḣ€4      - head each to 4      [[0,"Ab","A#","Bb"],["C#","Db","D#","Eb"],["F#","Gb","G#"]]
               Ẏ     - tighten              [0,"Ab","A#","Bb","C#","Db","D#","Eb","F#","Gb","G#"]
                Ḋ    - dequeue                ["Ab","A#","Bb","C#","Db","D#","Eb","F#","Gb","G#"]
                  W€ - wrap each (of X)       ["A","B","C","D","E","F","G"]
                 ;   - concatenate            ["Ab","A#","Bb","C#","Db","D#","Eb","F#","Gb","G#","A","B","C","D","E","F","G"]

@mirabilos this is 20 bytes of source code, the Unicode characters each represent a byte of the source code - see the code page linked by the word bytes in the header.

Retina 0.8.2, 33 bytes

ABCDEFG
.
 $&b $& $&#
 [BE]#...

Try it online! Explanation:

ABCDEFG

Insert the base note names.
.
 $&b $& $&#

Expand each note to include flat and sharp versions.
 [BE]#...

Delete B#, E# and also the notes following them (Cb and Eb).

R, 50 bytes
cat("Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#")

Try it online!
Boring answer.
R, 60 bytes
cat(outer(LETTERS[1:7],c("#","","b"),paste0)[-c(2,5,17,20)])

Try it online!

I think the list of examples of redundant notes isn't meant to be exhaustive--the example output also omits Cb and E#.

Charcoal, 21 bytes
Φ⪪⭆…α⁷⭆b #⁺ιλ²§↨⊖⊘φ²κ

Try it online! Link is to verbose version of code. Explanation:
    α                   Predefined variable uppercase alphabet
   … ⁷                  First 7 letters i.e. `ABCEDFG`
  ⭆                     Map over characters and join
       b #              Literal string `b #`
      ⭆                 Map over characters and join
          ⁺ιλ           Concatenate outer and inner characters
 ⪪           ²          Split back into substrings of length 2
Φ                       Filter where nonzero
                  φ     Predefined variable 1000
                 ⊘      Halved i.e. 500
                ⊖       Decremented i.e 499
               ↨   ²    Converted to base 2 i.e. [1, 1, 1, 1, 1, 0, 0, 1, 1]
              §     κ   Cyclically indexed by outer index
                        Implicitly print matching values on separate lines

Stax, 17 15 bytes
║♠+I▬┌ó£ΔφΔ`╗╨Å

Run and debug it
Bonus program: print the fancy symbols

Japt, 23 22 bytes
;B¯7
ï"b #" fÏÄ %9%8<6

Try it
;B          Alphabet
  ¯7        First seven characters ("ABCDEFG")
            Assign to U
ï"b #"       Cartesian product with "b #" ("Ab,A ,A#,Bb,B ,B#,Cb,C ,C#,Db,D ,D#,Eb,E ,E#,Fb,F ,F#,Gb,G ,G#")
f           Filter:
 ÏÄ           Is index + 1
   %9%8       Mod 9 Mod 8
     <6       Less than 6
            End filter ("Ab,A ,A#,Bb,B ,C ,C#,Db,D ,D#,Eb,E ,F ,F#,Gb,G ,G#")

Your code contains <6 but it's <5 in the explanation.

@TheOnlyMrCat Edited

dzaima/APL REPL, 38 28 25 bytes
(⊤2056111)⌿,' b#'∘.,⍨7↑⎕A

Try it online!

I think that you can remove the ⎕←.

@EriktheOutgolfer hmm yeah, if I switch to REPL

Oh right, I forgot to count the {} LOL.

Zsh, 36 bytes
<<<${${(F):-{A..G}{b,,#}}//[BE]#???}

An uglier solution, but it saves two characters. (F) joins a list on newlines, and //[BE]#??? removes the parts of the string we need.
Try it online!

Zsh, 38 bytes
<<<${${:-{A..G}{b,,#}}:#([BE]#|[CF]b)}

I always enjoy it when Zsh beats Perl (hopefully I don't speak too soon...).
<<<${${:-{A..G}{b,,#}}:#([BE]#|[CF]b)}
     ${:-             }                 # empty-fallback, basically an anonymous parameter expansion
         {A..G}{b,,#}                   # Cross product range A-G with b,(nothing),#
   ${                 :#             }  # Remove matching elements
                        ([BE]#|[CF]b)   # B#, E#, Cb, Fb
<<<                                     # Print to stdout

Try it online!

PHP, 65 bytes
Makes the list with a loop. Items are separated by _ with a trailing separator.
for(;$l=ABCDEFG[$i++];)echo$l._.[$a="$l#_",$a.$b=$l.b_,$b][$i%3];

Try it online!

PHP, 43 bytes
PHP outputs anything as is, when not inside <?php and ?> tags.
Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#

Try it online!

Commodore C64/TheC64 Mini (probably other Commodore 8-bit BASIC variants) - 52 tokenized BASIC bytes
 0?"{CTRL+N}Ab A A# Bb B C C# Db D D# Eb E F F# Gb GG#

Pressing the CTRL key plus N on the C64 keyboard goes into 'business mode' on the character set for upper/lower case characters. We may print this out in a string in one byte / token; and as we have 40 columns, the space from G to G# is not required.
We do not need to close the string in this case as it is not a multi-statemented line with a : separator.
How this looks on a Commodore C64 (and compatibles) screen is shown below.

Ruby, 43 bytes
p (2..18).map{|i|"FCGDAEB"[i%7]+"b #"[i/7]}

Try it online!
With the range 0..20 this would print an array containing all the flats, all the naturals and all the sharps. The undesired ones Fb Cb E# B# are omitted by using the range 2..18
The notes are printed out ordered according to https://en.wikipedia.org/wiki/Circle_of_fifths , or in other words ascending by 7 semitones (a frequency ratio of almost exactly 1.5) each time.
This leads to the note letter order given, in which each note is five degrees inclusive (known as a "fifth") above the previous one. For example F->C is FGABC

I like that you ascend by fifths.  Nice.

brainfuck, 106 bytes
+++[[-<+>>++<]>]<<[-<->]++<<++<,+<-<[->+>+<<]<+[>>>>>+>-[<.<<<.>.[<]]>[>]<+[---<.<.<.[<]]>[>]<++<.<<.<<<-]

Try it online!
Outputs each note separated by carriage returns.

Lost, 105 bytes
v<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>
>%?"Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G\9"-+@

Outputs with #b and space delimiter.
Try it online or verify that it's deterministic.
Explanation:
Explanation of the language in general:
Lost is a 2D path-walking language. Most 2D path-walking languages start at the top-left position and travel towards the right by default. Lost is unique however, in that both the start position AND starting direction it travels in is completely random. So making the program deterministic, meaning it will have the same output regardless of where it starts or travels, can be quite tricky.
A Lost program of 2 rows and 5 characters per row can have 40 possible program flows. It can start on any one of the 10 characters in the program, and it can start traveling up/north, down/south, left/west, or right/east.
In Lost you therefore want to lead everything to a starting position, so it'll follow the designed path you want it to. In addition, you'll usually have to clean the stack when it starts somewhere in the middle.
Explanation of the program:
All arrows, including the reflect \ in the string, will lead the path towards the leading > on the second line. From there the program flow is as follows:

>: travel in an east/right direction
%: Put the safety 'off'. In a Lost program, an @ will terminate the program, but only when the safety is 'off'. When the program starts, the safety is always 'on' by default, otherwise a program flow starting at the exit character @ would immediately terminate without doing anything. The % will turn this safety 'off', so when we now encounter an @ the program will terminate (if the safety is still 'on', the @ will be a no-op instead).
?: Clean the top value on the stack. In some program flows it's highly likely we have a partial string on the stack, so we use this to wipe the stack clean of that potential string.
": Start a string, which means it will push the integer code-points of the characters used.
Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G\9: Push the code-points for these characters, being 65 98 32 65 32 65 35 32 66 98 32 66 32 67 32 67 35 32 68 98 32 68 32 68 35 32 69 98 32 69 32 70 32 70 35 32 71 98 32 71 32 71 92 57 respectively
": We're done pushing code-points of this string
-+: Subtract the top two values from one another: (92-57=) 35
@: Terminate the program if the safety is 'off' (which it is at this point). After which all the values on the stack will be output implicitly. Using the -A program argument flag, these code-points will be output as characters instead.

Minor note: The top part could also have been v<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< instead. Lost will wrap around to the other side when moving in a direction. So using v<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>> could be a slightly shorter path, and since it's the same byte-count anyway, why not use it. :)

Jelly, 21 bytes
ØAḣ7;p¥⁾b#“¿€×Ø‘œPẎẎ€

Try it online!

Brachylog, 36 bytes
"#b"ẹ,Ẹ↺;Ṇh₇ᵗ↔{∋ᵐc}ᶠ⟨h₅ct₁₄⟩⟨h₁₂ct₅⟩

Try it online!
I'm currently in the process of brute-forcing the powerset index that would let me get rid of ⟨h₅ct₁₄⟩⟨h₁₂ct₅⟩ (and by extension ↺, since the output doesn't need to be in the same order as the example output), but it's taking quite a while... maybe I should put a minute aside to actually work out what order sublists are generated in, and compute the index that way...

Canvas, 23 bytes
Ｚ７ｍ｛#＋¹¹b＋］｛“╷!↕„２┬²＠？Ｐ

Try it here!
22 bytes with extra newlines in the output

Pyth, 23 21 bytes
s<R7c.>*<r1G7"b #"2 9

Try it online!
s<R7c.>*<r1G7"b #"2 9   Implicit: G=lowercase alphabet
         r1G            Convert G to upper case
        <   7           First 7 characters
       *     "b #"      Cartesian product with "b #"
     .>           2     Rotate the above 2 places to the right
    c               9   Chop into pieces of length 9
 <R7                    Trim each to length 7
s                       Flatten, implicit print

Edit: Partial rewrite to save 2 bytes, previous version: s%2c*<r1G7"b #"xLG"fhoq Try it online!

T-SQL, 124 bytes
SELECT value+a
FROM STRING_SPLIT('A-B-C-D-E-F-G','-')
    ,(VALUES('b'),(''),('#'))b(a)
WHERE value+a NOT IN ('B#','E#','Cb','Fb')

Line breaks are for display purposes only.
Longer but much more interesting than the trivial version (50 bytes):
PRINT'Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#'

Keg, 43 bytes
The string, compressed.
AbAA\#BbBCC\#DbDD\#EbEFF\#GbGG\#(:H<[ $]')'

TIO

Z80Golf, 31 29 bytes
00000000: 9d5b dc6d df7f 0603 3e40 d13c cb3a 3008  .[.m....>@.<.:0.
00000010: fff5 7b2f ffaf fff1 20f1 10ec 76         ..{/.... ...v

Try it online!
Explanation:
Z80Golf is just a simple fantasy machine based on the Z80 8-bit CPU. The program is loaded at memory location 0x0000, and the rest of the memory is filled with zeroes. Output is done by calling 0x8000, which will output the value of register A as a character.
The program starts with the data that will be processed, 6 bytes in total. Each pair of bytes specifies a note suffix, and a bitmask controlling which of the letters can be combined with this note. To save bytes, the suffix character is inverted (xor 0xff) -- this allows the data to be executed as instructions with little side effects, making it possible to remove a jump that skips this data:
               ;    GFEDCBA
    db 0xff^'b', 0b01011011 ; Ab Bb Db Eb Gb
    db 0xff^'#', 0b01101101 ; A# C# D# F# G#
    db 0xff^' ', 0b01111111 ; A  B  C  D  E  F  G
skip_data:

This is how the CPU decodes this:
    sbc a, l  ; a subtraction with carry on registers we don't care about
    ld e, e   ; put the E register back into itself. This instruction is useless
              ; but still exists to make the encoding regular.
    call c, 0xdf6d ; if the carry flag is set, call a function. The carry flag isn't set
              ; because of the initial register values (all zeroes) when the sbc above
              ; was executed
    ld a, a   ; as above, put A back into itself.

This data is read two bytes at a time into the DE register pair. The stack pointer is used to point to the next element. It starts out at 0, and because the Z80 uses a full, descending stack, any pops will read the next data pair -- all stack operations are 16-bit.
The outer loop is implemented with a decrementing counter in the B register, for which the Z80 provides special support in the form of the djnz instruction:
    ld b, 3
process_pair:
    ...
    djnz process_pair
    halt

The current letter is held in the A register. Because the increment fits well at the start of the loop, we load one less than the actual start value of A:
process_pair:
    ld a, 'A'-1
    pop de ; D = bitmask, E = suffix character
process_note:
    inc a
    srl d ; put the current bitmask bit in the carry flag
          ; also sets the zero flag if this is the last note in the pair
    jr nc, skip
    ; Print the note. Note that we need to preserve the zero flag to check it in the
    ; loop condition later.
    rst $38 ; Short encoding of call $0038.
            ; Because the program is so short, the memory in the 0038..8000 range
            ; is filled with zeroes, which happens to be the encoding for a no-op.
            ; The execution will therefore fall-through to the character-print hook.
    push af ; Save the letter on the stack (which will be just to the left of the
            ; unprocessed data) to free up A for printing other characters.
            ; (only 16-bit register pairs can be saved, so we also push the flags)
    ld a, e
    cpl     ; Undo the inversion used to make the execution fall-through the data.
            ; Done again each iteration because it takes less bytes to operate
            ; on the A register.
    rst $38 ; Print the suffix.
    xor a   ; Standard assembly practice of setting a register to zero by XORing it
            ; with itself. Saves a byte over a simple `ld a, 0`.
    rst $38 ; Print a null byte as a separator.
    pop af  ; Restore the current letter from the stack.
skip:
    jr nz, process_note ; If the zero flag (last changed at the srl d) is not set,
                        ; loop once again
    djnz process_pair
    halt

APL (Dyalog Unicode), 45 bytes
2↓(,¨⎕A)⎕R', &'⊢'AbAA#BbBCC#DbDD#EbEFF#GbGG#'

Try it online!
Simple ⎕Replace operation, prepending , to each element in the string that matches each letter in the ⎕Alphabet, then dropping the first 2 characters, which are ,.

Brainfuck, 214 Bytes
>>>>++++++++[<++++<++++<++++++++++++<++++++++>>>>-]<<+++<++<+.>.>>.<<<.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<+.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<+.>>>.<<<.>>.>.<<<+.>.>>.<<<.>>>.<<<.>>.>.<<<+

Try it Online!

Perl 5, 47 41  bytes
say for'AbA#DbD#GbG#BbEbC#F#'=~/../g,A..G

Try it online!

JavaScript (Node.js), 84 bytes
_=>[...'ABCDEFG'].map((n,i)=>`${i%3!=2?n+'b,':''}${n}${i%3!=1?`,${n}#`:''}`).join`,`

Try it online!
Just returning the string (as shown below) would be shorter by 36 bytes, but where's the fun in that?
_=>'Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#'

brainfuck, 255 115 bytes
--[----->+<]>-----[<+>>+>+<<-]>>+<<<-[->+++<]>+++[->>>+>+<
<<<]>>>>--->+++++++[-<<<<.>.>>.<<<.>>>.<<<.>>.>.<<<+>>>>]

Try it online!

I would upvote this, but it's wrong. There's no black note between B and C, or between E and F. So you're not supposed to output. B#, Cb, E# or Fb. Also, I don't see anything in the spec about it being OK to use lowercase.

@LevelRiverSt the challenge didn't state anywhere that we don't have notes between B and C & E and F

All notes without a name consisting of a single letter (i.e. black notes on a musical keyboard) should have their name printed twice, once as the sharp of a note, once as the flat of one. Sharp or flat notes that can be described with a single letter, like B♯ (C) or F♭ (E) should not be outputted. That seems fairly clear to me, and I'm seeing no edit history on the OP on my screen.

Bash 5, 42 bytes
x=`echo {A..G}{b,,#}`;echo ${x//[BE]#???/}

Output:
Ab A A# Bb B C C# Db D D# Eb E F F# Gb G G#

C, 57 bytes
Trivial version 57 bytes in C (gcc)
#include <stdio.h>

f(){puts("Ab,A,A#,Bb,B,C,C#,Db,D,D#,Eb,E,F,F#,Gb,G,G#");}

int main()
{
    f();
}

Try it Online!

You can omit #include <stdio.h>, and the rules also allow you to define just a function that produces the output, you don't have to have a main(). So: f(){puts(...);} would be a valid code golf submission. Don't forget to include the actual code!


text:
Interpreter for number theory, modulo n
A sentence of number theory (for our purposes) is a sequence of the following symbols:

0 and ' (successor) - successor means +1, so 0'''' = 0 + 1 + 1 + 1 + 1 = 4

+ (addition) and * (multiplication)

= (equal to)

( and ) (parentheses)

the logical operator nand (a nand b is not (a and b))

forall (the universal quantifier)

v0, v1, v2, etc. (variables)
Here is an example of a sentence:

forall v1 (forall v2 (forall v3 (not (v1*v1*v1 + v2*v2*v2 = v3*v3*v3))))

Here not x is shorthand for x nand x -- the actual sentence would use (v1*v1*v1 + v2*v2*v2 = v3*v3*v3) nand (v1*v1*v1 + v2*v2*v2 = v3*v3*v3), because x nand x = not (x and x) = not x.
This states that for every combination of three natural numbers v1, v2, and v3, it is not the case that v13 + v23 = v33 (which would be true because of Fermat's Last Theorem, except for the fact that it would get 0^3+0^3=0^3).
Unfortunately, as proved by Gödel, it is not possible to determine whether or not a sentence in number theory is true.
It is possible, however, if we restrict the set of natural numbers to a finite set.
So, this challenge is to determine whether or not a sentence of number theory is true, when taken modulo n, for some positive integer n. For example, the sentence
forall v0 (v0 * v0 * v0 = v0)

(the statement that for all numbers x, x3 = x)
Is not true for ordinary arithmetic (e.g. 23 = 8 ≠ 2), but is true when taken modulo 3:
0 * 0 * 0 ≡ 0 (mod 3)
1 * 1 * 1 ≡ 1 (mod 3)
2 * 2 * 2 ≡ 8 ≡ 2 (mod 3)

Input and output format
The input is a sentence and positive integer n in any "reasonable" format. Here are some example of reasonable formats for the sentence forall v0 (v0 * v0 * v0 = v0) in number theory modulo 3:
("forall v0 (v0 * v0 * v0 = v0)", 3)
"3:forall v0 (((v0 * v0) * v0) = v0)"
"(forall v0)(((v0 * v0) * v0) = v0) mod 3"
[3, "forall", "v0", "(", "(", "(", "v0", "*", "v0", ")", "*", "v0", ")", "=", "v0", ")"]
(3, [8, 9, 5, 5, 5, 9, 3, 9, 6, 3, 9, 6, 4, 9, 6]) (the sentence above, but with each symbol replaced with a unique number)
"f v0 = * * v0 v0 v0 v0"
[3, ["forall", "v0", ["=", ["*", "v0", ["*", "v0", "v0"]], "v0"]]]
"3.v0((v0 * (v0 * v0)) = v0)"

Input can be from stdin, a command line argument, a file, etc.
The program can have any two distinct outputs for whether the sentence is true or not, e.g. it could output yes if it's true and no if it's not.
You do not need to support one variable being the subject of a forall twice, e.g. (forall v0 (v0 = 0)) nand (forall v0 (v0 = 0)). You can assume that your input has valid syntax.
Test cases
forall v0 (v0 * v0 * v0 = v0) mod 3
true

forall v0 (v0 * v0 * v0 = v0) mod 4
false (2 * 2 * 2 = 8 ≡ 0 mod 4)

forall v0 (v0 = 0) mod 1
true (all numbers are 0 modulo 1)

0 = 0 mod 8
true

0''' = 0 mod 3
true

0''' = 0 mod 4
false

forall v0 (v0' = v0') mod 1428374
true

forall v0 (v0 = 0) nand forall v1 (v1 = 0) mod 2
true (this is False nand False, which is true)

forall v0 ((v0 = 0 nand v0 = 0) nand ((forall v1 (v0 * v1 = 0' nand v0 * v1 = 0') nand forall v2 (v0 * v2 = 0' nand v0 * v2 = 0')) nand (forall v3 (v0 * v3 = 0' nand v0 * v3 = 0') nand forall v4 (v0 * v4 = 0' nand v0 * v4 = 0')))) mod 7
true
(equivalent to "forall v0 (v0 =/= 0 implies exists v1 (v0 * v1 = 0)), which states that every number has a multiplicative inverse modulo n, which is only true if n is 1 or prime)

forall v0 ((v0 = 0 nand v0 = 0) nand ((forall v1 (v0 * v1 = 0' nand v0 * v1 = 0') nand forall v2 (v0 * v2 = 0' nand v0 * v2 = 0')) nand (forall v3 (v0 * v3 = 0' nand v0 * v3 = 0') nand forall v4 (v0 * v4 = 0' nand v0 * v4 = 0')))) mod 4
false

This is code-golf, so try to make your program as short as possible!

Are variable names always in the format v number?

@JoKing They can if you want them to be- you can use var number, or even just 1 + number (so 1 would be v0, 2 would be v1, etc.)

Can we then assume there won't be more than 9 variables, so we don't have to go into double digits?

@JoKing You should allow for (theoretically) an infinite number of variables. It's okay if the maximum number of variables is bounded by the maximum size of an integer, but you shouldn't have such a low limit. You can choose one of the other input formats if this is a problem for you.

Are variables necessarily numbered, or would a format using alphabetical tokens be valid?

@UnrelatedString Sure, so long as they can be arbitrarily long.

(the sentence above, but with each symbol replaced with a unique number): I think it's best to clarify, only unique numbers would be considered reasonable? (I'd recommend so, because otherwise I can see a lot of potential loopholes)

Can one use 'v number instead of v number' if we choose the prefix-syntax option?

I can't get the 8th testcase to work. Even WolframAlpha says it should be false.

@TFeld You're right. I meant to do forall v0 (v0 != 0 implies exists v1 (v0 * v1 = 1)) - that'll be a lot longer

If possible, please add some test cases that contains more than one variable.

@Mr.Xcoder You can use 'v number or even ' v number

@TFeld Okay I think I've fixed it (it works for 4 and 7 with your solution, at least)

What is the precedence of nand?

@EmbodimentofIgnorance In the test cases, nand is applied last, but you can have any precedence you want, as long as you allow parentheses. You can even insist on your input being fully parenthesized, e.g.: (forall v0 (((v0 * v0) * v0) = v0)).

Python 2, 252 236 bytes
def g(n,s):
 if str(s)==s:return s.replace("'","+1")
 o,l,r=map(g,[n]*3,s);return['all((%s)for %s in range(%d))'%(r,l,n),'not((%s)*(%s))'%(l,r),'(%s)%%%d==(%s)%%%d'%(l,n,r,n),'(%s)%s(%s)'%(l,o,r)]['fn=+'.find(o)]
print eval(g(*input()))

Try it online!
Takes input as the nested prefix-syntax, with f instead of forall and n instead of nand:
[3, ["f", "v0", ["=", ["*", "v0", ["*", "v0", "v0"]], "v0"]]]

Right now it's outputting Python code, but it should have two distinct outputs for if the sentence is true or false. You can use print(eval(g(*input()))).

@LeoTenenbaum Yeah, I had that on the first version, but forgot to add it back in after golfing

APL (Dyalog Unicode), 129 bytesSBCS
{x y z←3↑⍵⋄7≤x:y×7<x⋄5≡x:∧/∇¨y{⍵≡⍺⍺:⍵⍺⋄x y z←3↑⍵⋄7≤x:⍵⋄6≡x:x(⍺∇y)⋄x(⍺∇⍣(5≢x)⊢y)(⍺∇z)}∘z¨⍳⍺⍺⋄y←∇y⋄6≡x:1+y⋄y(⍎x⊃'+×⍲',⊂'0=⍺⍺|-')∇z}

Try it online!
Takes a prefix syntax tree as in TFeld's python answer, but using an integer encoding. The encoding is
plus times nand eq forall succ zero ← 1 2 3 4 5 6 7

and each variable is assigned a number starting from 8. This encoding is slightly different from the one used in the ungolfed version below, because I tweaked it while golfing the code.
The task involves only two inputs (the AST and the modulo), but writing it as an operator instead of a function avoids mentioning the modulo many times (as it is always carried over recursive calls).
Ungolfed with comments
⍝ node types; anything ≥8 will be considered a var
plus times eq nand forall succ zero var←⍳8
⍝ AST nodes have 1~3 length, 1st being the node type
⍝ zero → zero, succ → succ arg, var → var | var value (respectively)

⍝ to (from replace) AST → transform AST so that 'from' var has the value 'to' attached
replace←{
  ⍵≡⍺⍺:⍵⍺             ⍝ variable found, attach the value
  x y z←3↑⍵
  zero≤x: ⍵           ⍝ zero or different variable: keep as is
  succ≡x: x(⍺∇y)      ⍝ succ: propagate to y
  forall≡x: x y(⍺∇z)  ⍝ forall: propagate to z
  x(⍺∇y)(⍺∇z)         ⍝ plus, times, eq, nand: propagate to both args
}
⍝ (mod eval) AST → evaluate AST with the given modulo
eval←{
  x y z←3↑⍵
  zero≡x:   0
  var≤x:    y                    ⍝ return attached value
  forall≡x: ∧/∇¨y replace∘z¨⍳⍺⍺  ⍝ check all replacements for given var
  succ≡x:   1+∇y
  plus≡x:   (∇y)+∇z
  times≡x:  (∇y)×∇z
  eq≡x:     0=⍺⍺|(∇y)-∇z         ⍝ modulo equality
  nand≡x:   (∇y)⍲∇z              ⍝ nand symbol does nand operation
}

Try it online!

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Number in overlapping range
You are given two integers between lets say 1 and 12, one and two
and a integer between lets say 0 and 4 which is called range.  The challange is to decide if one is inside or equal the range from two ± range.   The range is restarting with 1 after 12 and vise versa.
For example, if one = 2, two = 11 and range = 3, the result is true, as one is the the range [8, 9, 10, 11, 12, 1, 2].
The input has to be 3 seperated integers, the order doesn't matter. Input via string with seperators possible. But the Input has to consist of numbers reading as '10' and not 'A' e.g.
Test cases:
one=7  two=6  range=0   result=false
one=5  two=6  range=1   result=true
one=8  two=11 range=3   result=true
one=1  two=11 range=3   result=true
one=2  two=10 range=3   result=false
one=11 two=1  range=2   result=true
one=6  two=1  range=4   result=false
one=12 two=1  range=3   result=true

Shortest valid answer in bytes wins.

Welcome to the site! While this challenge is understandable, there are still a few issues. For example, why between 1 and 12, and 0 and 4 particularly? Also, please keep in mind that homework questions are not on-topic here, so if this is homework (or similar), I'd recommend loosening the requirements of the challenge (allowing the integers/range to be any number, etc.). Finally, what do you mean by "Restarting with 1 after 12 and vise versa."?

@cairdcoinheringaahing Hey thank you, I picked those numbers randomly, but two has to be bigger than one. How big the range is does not really matter. With restarting I mean that your range overlaps over two so if one is 2 and two is 11 and the range is 3, one is still inside the range because it restarts at two with one

So if one is 2, two is 11, and range is 3, is the task basically to check if one is in the list [8, 9, 10, 11, 12, 1, 2]? That the range cycles round if it goes out of bounds?

Exactly, sorry If my description was irritating

Not irritating, just needed some clarification. I've edited in that example into the challenge.

one and two really should be called A and B for the sake of clarity. Also, it's still unclear IMO what is given as input and what is a constant. Are $1$ and $12$ the input values, or are the input values guaranteed to be in $[1..12]$?

@Arnauld From what I understand the second. Inputs one and two are guaranteed to be in the range $[1,12]$ and input range is guaranteed to be in the range $[0,4]$.

@KevinCruijssen That's what I think too. But a really confusing part is with 1 (one) after 12 (two).

Suggested test case: one=12; two=1; range=3 → true. My answer failed to check if 12 was in the range due to the modulo-12 I used.

So the range cycles modulo 12 in the set [1 2 ... 12]? That should be part of the challenge text, not just a comment

@LuisMendo I think that's what OP is trying to say with "The range is restarting with 1 (one) after 12 (two) and vise versa.", but that sentence causes quite a bit of confusion instead..

@KevinCruijssen I can't read :-) I hadn't seen that sentence. But yes, it is confusing

Stax, 7 bytes
₧╝g╙╖²╞

Run and debug it
It takes input as space separated [range] [one] [two] and outputs 0 for false, 1 for true.
In pseudo-code:
d = abs(one - two)
return min(d, 12 - d) <= range

Hm, that's probably almost a python submission.

Jelly, 10 8 10 bytes
ŒR’+%12‘Ɠe

Try it online!
Saved 2 bytes thanks to Mr. Xcoder
+2 bytes due a bug if one = 12
I believe this meets the criteria. Takes one from STDIN, range as left argument and two as right argument

ŒR+%12Ɠe (ŒR is (inclusive) range from $-|z|$ to $|z|$) saves 2 bytes. Takes one from STDIN, range as the first argument and two as the second argument. Try it online!

@Mr.Xcoder So it does! Thanks

Your solution has the same problem as my 05AB1E answer had: it fails if one is 12 (i.e. one=12; two=1; range=3 should result in truthy).

@KevinCruijssen I believe that is fixed, but I'm on mobile so haven't fully tested it

JavaScript (ES6), 38 bytes
(a,b,r)=>((a=a<b?b-a:a-b)>6?12-a:a)<=r

Try it online!

JavaScript (Node.js), 53 bytes
Silly branchless method. Expects BigInts. Returns \$0\text{n}\$ or \$1\text{n}\$.
(a,b,r)=>0x4C5C038B885n>>((a-=b)*a+347n*r)%282n%46n&1n

Try it online!

Python 2, 52 bytes
lambda a,b,c:a in[i%12or 12for i in range(b-c,b-~c)]

Try it online!
Python 2, 52 bytes
lambda a,b,c:any(set(range(b-c,b-~c))&{a,a-12,a+12})

Try it online!

Python 3, 50 bytes
lambda a,b,c:any({*range(b-c,b-~c)}&{a,a-12,a+12})

Try it online!

05AB1E, 11 8 7 bytes
α6Ýûsè@

-3 bytes by porting @Arnauld's JavaScript answer, so make sure to upvote him!
-1 byte thanks to @Grimy.
Inputs in the same order as the challenge description: one; two; range.
Try it online or verify all test cases.
Explanation:
α        # Take the absolute difference between the first two (implicit) inputs one & two
 6Ý      # Push the list [0,1,2,3,4,5,6]
   û     # Palindromize it: [0,1,2,3,4,5,6,5,4,3,2,1,0]
    sè   # Swap to get the earlier number again, and use it to index into the list
      @  # Then check if the (implicit) input range is larger than or equal to this value
         # (after which the result is output implicitly)

D12α‚ß could be 6Ýûsè.
...what do you mean i just rewrote 75% of your answer?

"what do you mean i just rewrote 75% of your answer" hehe xD Nice approach though, thanks!

Java 10, 70 38 bytes
(o,t,r)->((o=o<t?t-o:o-t)>6?12-o:o)<=r

-32 bytes by porting @Arnauld's JavaScript answer.
Try it online.
Explanation:
(o,t,r)->                  // Method with three integer parameters and boolean return-type
 ((o=o<t?t-o:o-t)          //  Replace `o` with abs(t-o)
   >6?                     //   And if it's smaller than 6:
      12-o                 //    Use 12-o
     :                     //   Else (it's larger than or equal to 6):
      o                    //    Use o itself
 )<=r                      //  And check if that is smaller than or equal to r

Python 2, 31 bytes
lambda o,t,r:5-r<(o-t+6)%12<7+r

Try it online!
Python 2, 33 bytes
lambda o,t,r:abs((o-t+6)%12-6)<=r

Try it online!

Would it be possible to brute-force a solution smaller than this? There are only 720 input combinations.

@mbomb007 I think it would be hard. The expression is 18 bytes, which is longer than things I've brute-force before which capped out at ~11 bytes. So while there's relatively few inputs, the number of expressions to check would be very large, even limiting to operations already in the answer. Maybe it's doable with some template. Do you have something in mind?

Not really. I just thought that since there are only 720 cases to account for, maybe something like a K-map could be used to simplify or find a nice solution. However, K-maps are typically for boolean expressions.

Julia 1.0, 35 bytes
f(o,t,r)=o in@.mod(t-1+(-r:r),12)+1

Try it online!

JavaScript, 37 bytes
r=>b=>g=a=>a-12<b-r?g(a+12):a-12<=b+r

Try it online!

Write +12 3 times, but I cannot save more bytes...

Wolfram Language (Mathematica), 24 bytes
Abs@Mod[#-#2,12,-6]<=#3&

Try it online!

Japt, 11 bytes
aV
aC mU §W

Try it

Haskell, 42 bytes
t#r=(`elem`[1+(n-1)`mod`12|n<-[t-r..t+r]])

two # range returns a function which when applied to one returns a Bool.
Try it online!

Ruby, 45 characters
->o,t,r{[*1..12].rotate(t-r-1)[0..r*2].any?o}

Nothing fancy, just a chance to use Array#rotate.
Sample run:
irb(main):001:0> ->o,t,r{[*1..12].rotate(t-r-1)[0..r*2].any?o}[2, 11, 3]
=> true

Try it online!

Haskell, 27 bytes
o%t=(abs(mod(o-t+6)12-6)<=)

Try it online!

Charcoal, 11 bytes
‹⁵⁺Ｎ↔⁻⁶↔⁻ＮＮ

Try it online! Link is to verbose version of code. Takes the size of the range as the first input. Output uses Charcoal's default Boolean format of - for true, nothing for false. Explanation:
         ＮＮ Two inputs
       ↔⁻   Absolute difference
      ⁶     Literal 6
    ↔⁻      Absolute difference
  ⁺Ｎ        Plus range
‹⁵          Is greater than 5

R, 48 bytes
function(a,b,r){a%in%c(9:12,1:12,1:4)[-r:r+b+4]}

Try it online!
Pretty straightforward, I struggled for a while to find the best way to test if a was in the given range. There is likely a method I haven't seen or tried yet.

C# (Visual C# Interactive Compiler), 78 bytes 80 bytes 72 bytes
(a,b,r)=>Enumerable.Range(b-r,2*r+1).Select(x=>(x+12)%12).Contains(a%12)

Try it online!
Edit: Range was incorrect, I forgot to count the item itself, adding 2 bytes. But I bit the bullet dealing with C#'s modulus actually being remainder, saving 8 bytes. Technically, this code actually treats 12 as 0, but this is still valid in this context.

C#, 158 bytes
using System;public class P{public static void Main(string[]a){int w=Math.Abs(int.Parse(a[0])-int.Parse(a[1]));Console.Write((w>6?12-w:w)<=int.Parse(a[2]));}}

Try Online

MathGolf, 7 bytes
-±_B,╓≥

Try it online!
Other valid 7-byters include:
-±7rñ§≥
-7rñ╡§≥

I found a 4-byter which solves every test case, but doesn't solve the problem in general:
-±Σ≥

Try it online!
The approach of the 7-byters are basically ports of existing 7-byte solutions. The 4-byter relies on the fact that the digit sum of the absolute difference of the first two is less than the third input for all test cases. That correlates with the desired output for the test cases, but not in general.

Perl 5, 63 bytes
sub f{grep$_[0]==$_%12,(1..36)[11+$_[1]-$_[2]..11+$_[1]+$_[2]]}

Try it online!
Ungolfed:
sub f {
  my($one, $two, $range) = @_;
  my @n = (1..36);
  return 0 + grep $one==$_%12, @n[ 11+$two-$range ..
                                   11+$two+$range ];
}

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Shortest Program To Find Lowest Common Ancestor of Two Nodes in a Binary Tree
Any two separate nodes in a binary tree have a common ancestor, which is the root of a binary tree. The lowest common ancestor(LCA) is thus defined as the node that is furthest from the root and that is the ancestor of the two nodes.
The following are binary trees and the lowest common ancestors of the some of their nodes.

The LCA of 13 and 15 is 14.
The LCA of 47 and 49 is 48.
The LCA of 4 and 45 is 40.
The LCA of 13 and 14 is 14.
The LCA of 15 and 47 is 40.
Challenge
Write the shortest program possible that accepts as input the root of a binary tree and references to any two nodes in the binary tree. The program returns a reference to the LCA node of the two inputted nodes.
Assumption
Assume there is a least common ancestor present for any two nodes in the binary tree.
Input
The root of a binary tree and references to any two nodes in the binary tree that the lowest common ancestor must be found for. The root of the binary tree may be in the form of a reference to the root object or even a list that is a valid representation of a binary tree.
Output
If using a pointer-based representation of a tree returns a reference to the node that is the LCA of the two inputted nodes.
If using a list representation returns the node_id for the lowest common ancestor of the two inputted nodes.
Definition of a Binary Tree
A tree is an object that contains a value and either three other trees or pointers to them.
The structure of the binary tree looks something like the following:
typedef struct T
{
   struct T *l;
   struct T *r;
   struct T *p; //this is the parent field
   int v;
}T;

If using a list representation for a binary tree and since certain node values in the binary tree may reappear, the list representation must have an additional node_id parameter that looks something like this:
[[node_id,node_value],left_tree, right_tree, parent_tree]

Could you provide exact input and output examples? Also, what if my programming language doesn't support references, pointers and structures?

If your language does not support references, you can use a list-like representation of a tree: [root_value, left_node, right_node, parent_node].

How is the list representation supposed to work? Having both the parent tree and child trees as sublists leads to an obvious infinite regress (and if they're not sublists, we're back to needing a reference-based representation).

R with ape package, 12 bytes
ape::getMRCA

Built-in. Called as ape::getMRCA(tree, c(node1, node2)).

Thanks R, for providing the first answer.

Python 2, 155 151 bytes
def f(a,b,T):g=lambda U:U and(U[0]in[a,b]or T[0]in[a,b]or g(U[1])or g(U[2]));L,R=map(g,T[1:]);return(L and R)and T[0]or L and f(a,b,T[1])or f(a,b,T[2])

Try it online!
This assumes that nodes are defined as
[node_id, left_node, right_node]

as it seems silly to define the nodes as
[node_id, not_neccessarily_unique_node_value, left_node, right_node, parent_node]

because both the other_not_neccessarily_unique_node_value and parent_node are completely ignored in this problem.
The g function evaluates whether U is a ancestor of the nodes identified by either a or b.
Starting with the root node, if g is true of both the left child and the right child OR this node is either the a node_id or the b node_id, then this node is the LCA. Otherwise, exactly one of the two children - the left child or the right child - is then either the LCA or has the LCA as a child.

Ruby, 86 bytes
f=->t,x,y=p{t==x ?(!y||f[x,y])&&t:t&&(f[t.l,x,y]||f[t.r,x,y]||y&&(f[t,x]&&f[t,y])&&t)}

Try it online!
If I understand correctly, sorting by value isn't guaranteed and we're returning node references so the value isn't actually used for anything. We're just checking a node's l and r values to see if they contain x and y. The function returns a falsey value if either of the provided nodes isn't in the tree so that it can be called recursively.

You are right about your assumptions, histocrat. But I think I should add an assumption in the question making it clear that there is at least common ancestor present in the binary tree.

You can add that assumption, but recursive answers like this can't take advantage of it since they will encounter subtrees for which it no longer holds.

Jelly, 15 13 bytes
œiⱮn/œpḢƊḢœị⁸

Try it online!
A dyadic link taking the tree as left argument and the two node ids as right argument. Returns the full node of the lowest common ancestor.
Node ids are floating point. On TIO I’ve used vaguely hierarchical ids, but the actual numbers are arbitrary.

Haskell, 72 70 bytes
a#b|let g t@(i:%c)=(g=<<c)++[i|t!a,t!b];(i:%c)!e=i==e||any(!e)c=head.g

The tree data structure is data T = (Int,Int) :% [T], i.e. a pair (<id>,<value>) and a list of child trees per node. Needs no link to parent within the node. Returns the (<id>,<value>) pair of the LCA.
Try it online!

Wolfram Language (Mathematica), 53 bytes
Head@#&@@Cases[{#},a_/;!a~FreeQ~#2&&!a~FreeQ~#3,∞]&

Try it online!
FirstCase seems to be traversing the tree in a different order than Cases...
Function which takes the tree and two node values, and returns the value of the lowest common ancestor.
Represents the tree as an expression, where the head contains the value, and uses Null (or anything else that is guaranteed to not be a node) to represent the absense of a leaf.
For the example tree given, the structure looks like this:

Charcoal, 38 bytes
Ｗ∧η⊞Ｏυη≔§⊟Φθ⁼§κ⁰η⁴ηＷ¬№υζ≔§⊟Φθ⁼§κ⁰ζ⁴ζＩζ

Try it online! Link is to verbose version of code. Takes input as a list of [id, value, leftid, rightid, parentid], where a 0 value means no id. Explanation:
Ｗ∧η⊞Ｏυη≔§⊟Φθ⁼§κ⁰η⁴η

Walk the tree up from the first input node id, saving the found ids in the predefined empty list.
Ｗ¬№υζ≔§⊟Φθ⁼§κ⁰ζ⁴ζ

Walk the tree up from the second input node id until one of the ids matches.
Ｉζ

Print the matching id. (If strings were acceptable as ids, the Ｉ would not be necessary, but if both strings and numbers had to be supported, then that would cost an extra byte.)

05AB1E, 10 bytes
ΔDʒ˜ÃQ}`}н

Try it online!
First input is a tree in the format described in this answer, because I have no idea how the format in the question is supposed to work. Second input is a pair of node ids.
Explanation:
Δ       }     # repeat until top of stack doesn't change
 Dʒ   }       #  filter a copy of tree by
   ˜          #   flatten
    Ã         #   list intersection with the second input
     Q        #   equals the second input
       `      #  dump all results on the stack
         н    # get the first element (the node id)


text:
Elimination ordering
Your task is to remove smallest amount elements from a list, so the most elements are on their corresponding place. The element is on it's corresponding place, when it's value is equal to it's position.
Let's look at this example list:
1 5 3 2 5

This list has three elements on their corresponding place (1 on position 1, 5 on position 5, 3 on position 3).
Input
The input is a sequence of decimals in any reasonable format. For example:
1 3 2 3 6

Output
The output is a sequence of decimals in any reasonable format which contains, as its first element, the amount of elements removed from the input then the corresponding, 1-based element positions removed.
For example, for input given above, the (correct) output:
1 2

instructs us to remove one element, the one at index two (the first 3), which will leave us with 1 2 3 6 which has three elements at their index positions.
This output would be incorrect:
2 2 5

Since although removing the two elements at indexes two and five would leave us with 1 2 3 which also has three elements at their index positions, we've removed more than the minimal necessary.
More complicated example
1 2 3 3 4 5 6

In this case you can remove either of 3's, but not both (so 1 3 and 1 4 are both acceptable outputs).
1 3 2 3 4 5 6 7 8

In this case, if you would remove 3 on position 2, it would pass more elements, than if you would remove 3 on position 4 (so 1 4 is incorrect while 1 2 is correct).
1 3 2 3 5 6 7 8 9

Here removing 3 on position 2 is a mistake, because this actually makes the situation worse in obvious way (there are now less correctly placed elements than before). (the correct output is 0 since removing no elements is the best thing to do)
1 7 2 8 1 3 9

In this case we want to remove the three elements at positions 2, 4, and 5 (leaving us 1 2 3 9 for three in the correct location) so the correct output would be 3 2 4 5)
Rules

This is code golf, so the shortest code wins!
Loopholes are forbidden.
Assume that input is valid, contains nothing more than digits and spaces, and the input numbers inside the string are decimals in range of 0 <= n <= 99.
Please include a link to an online interpreter for your code.
If anything is unclear, please let me down in the comments.

Can we use 0 based indices?

@EmbodimentofIgnorance I want to make it uniform, so only 1 based indices are allowed.

Pyth, 20 bytes
lBhMh.Ms.eqktb.DQZyU

Try it online!

It was stated clearly that you have to.

Ok, edited the answer. I still don't understand why.

Because there is such requirement in the answer.

Jelly, 18 bytes
JŒPṚœPF=J$SʋÞ⁸ṪL;$

Try it online!
How?
JŒPṚœPF=J$SʋÞ⁸ṪL;$ - Link: list of numbers, A
J                  - range of length (A) [1,2,3,...,len(A)]
 ŒP                - all partitions      [[1],[2],...,[1,2],[1,3],...,[2,3],...]
   Ṛ               - reversed (so longest to shortest)
            Þ      - sort (the p's in all partitions) by:
             ⁸     -   (using the chain's left argument, A, as the right argument)
           ʋ       -   last four links as a dyad, i.e. f(p, A):
    œP             -     partition A at the indices in p
      F            -     flatten (to give result of dropping the values at indices in p)
         $         -     last two links as a monad:
        J          -       range of length (of the flatten result)
       =           -       equals? (vectorises)
          S        -     sum
              Ṫ    - tail (i.e. the shortest p which yields the maximal sum)
                 $ - last two links as a monad:
               L   -   length (of that result)
                ;  -   concatenate

An alternative for =J$ is ĖE€


text:
Build a mob of suspiciously happy lenny faces ( ͡° ͜ʖ ͡°)
I was going through a bizarre thread on Reddit, and came across this:
( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°) ͡°)
It's representing a group of people smiling somewhat suspiciously.
(In the challenge below though, spaces to the left of the right eyes were dropped somehow while I was writing the challenge. Note the spec).

Your goal is to create a group of smiling lenny faces n deep with the following rules:

At depth one, a full face (( ͡° ͜ʖ ͡°)) is shown.
At depth two, half faces are shown. On the left side, a little over half the face (( ͡° ͜ʖ) is represented. On the right however, the right side is shown, and the mouth is omitted (ʖ ͡°))
Any deeper, and only the sides of head and eyes are shown (( ͡° and ͡°). There's a space between the eye and left side of the head, but there are, despite appearances, no spaces on the right side. The spacing is due the ͡ character which messes with things a bit.

Input:

n, showing how many layers deep of faces to show.
n will always be in the range 0 <= n <= 500. You are not required to handle anything outside of this range.
n may be offset by 1 so that 0 means one face instead of no faces. You'll need to handle -1 then though.

Output:

A string, or character array, or anything remotely comparable (like a list of single-character strings in Python/Javascript). It can also be printed directly. Trailing white-space is fine.

You can submit a complete program, or a function.

Since it's difficult to see what characters are involved, here's it laid out in Python:
>> [ord(c) for c in '( ͡° ͜ʖ ͡°)']
[40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 41]

>> [ord(c) for c in '( ͡°( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°)͡°)͡°)']
[40, 32, 865, 176, 40, 32, 865, 176, 40, 32, 865, 176, 32, 860, 662, 40, 32, 865, 176, 32, 860, 662, 32, 865, 176, 41, 662, 32, 865, 176, 41, 865, 176, 41, 865, 176, 41]

Test Cases:
face_crowd(0)
''

face_crowd(1)
'( ͡° ͜ʖ ͡°)'

face_crowd(2)
'( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°)'

face_crowd(5)
'( ͡°( ͡°( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°)͡°)͡°)͡°)'

face_crowd(10)
'( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)'

face_crowd(500)
'( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°)ʖ ͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°)'

Here's an extraordinarily naive recursive reference implementation (posted on my Github). I tried to keep it as plain as possible for clarity; but there's a lot of duplication
I posted it externally because I wanted to wrap it in a spoiler in case people don't want to see a reference, but that complicates copying the code. I figure it's not important to the challenge really, so it isn't a big deal if it goes down I can paste it here if it's deemed important.

This is code-golf, so the least number of bytes in each language wins.

It looks even more suspicious when rendered on TIO. :p

The spec and the test cases seem to be inconsistent; the spec has a space at the beginning of the right part of the latter depths, while the test cases do not.

@Arnauld Oh wow. Ya, everywhere seems to show it a little differently.

@tjjfvi I'm not sure what you mean. Are you referring to the )͡°)͡°)͡°)͡°)͡°)͡°)͡°)͡°) part? There are no spaces in there.

@tjjfvi If you mean the unformatted example at the very top vs the formatted examples, that's due to the  ͡  character. It drifts off to the right, so it looks like there's a space to the left of it. The amount of drift seems to depend on how it's being shown.

Related

@Carcigenicate When I looked at the source markdown, it seemed that there was a space. Perhaps I am wrong. Thanks for the clarification!

May the index be off by one, so that face_crowd(0)-> '( ͡° ͜ʖ ͡°)'?

there are, despite appearances, no spaces on the right side : this is not consistent with your very 1st example at the top of the challenge whose ASCII codes are 40,32,865,176,40,32,865,176,32,860,662,40,32,865,176,32,860,662,32,865,176,41,662,32,865,176,41,32,865,176,41, with a space before the right eye of the last face. So, what is the correct version?

The code blocks don't show correctly for me on mobile.

@Arnauld Hmm, I'm not sure those spaces got dropped while I was playing around in the REPL. Well, it's specified in more detail later on, so I'd rather not go against the explicit spec now.

@Jitse Yes. I updated the question spec. Note then that you still need to handle no faces, which will be -1 if 0 means one face.

@Evorlor Ya, it's anoyying. I have to use the full site to read the question.

Seems to work on iPhone, just not Android

@Arnauld I love URL edition too: -͡-͜ʖ-͡

Haskell, 89 87 80 bytes
7 bytes off thanks to xnor
(!!)$"":x:iterate(4#8)(7#6$x)
x="( ͡° ͜ʖ ͡°)"
(a#b)y=take a x++y++drop b x

Try it online!
To start we assign ( ͡° ͜ʖ ͡°) to a string x for convenience.
x="( ͡° ͜ʖ ͡°)"

Then we build a list of the answers and index it to find the solution.    This is done by hardcoding the first two answers as the first two elements of the list and then iterating a function that adds the first 4 characters and the last 4 characters to front and back of the string across the third answer.
(!!)$"":x:iterate(4#8)(7#6$x)

We also have the special function (#) which adds a specified amount of ( ͡° ͜ʖ ͡°) to the front and back of a string:
(a#b)y=take a x++y++drop b x

JavaScript (ES6), 66 bytes
f=n=>n?"( ͡°"+(--n>1?f(n):" ͜ʖ"+(n?f(n)+"ʖ ":" "))+"͡°)":""

Try it online!
Or try it with the following snippet for a better rendering.

f=n=>n?"( ͡°"+(--n>1?f(n):" ͜ʖ"+(n?f(n)+"ʖ ":" "))+"͡°)":""

for(n = 0; n <= 10; n++) {
  o.innerHTML += '"' + f(n) + '"\n';
}
pre { font-family:Arial }

Commented
In the following code, we use the character set "eEMN" (eyebrow, eye, mouth and nose respectively) in order to preserve the formatting.
f = n =>           // f is a recursive function taking the number n of remaining
                   // faces to draw
  n ?              // if n is greater than 0:
    "( eE" + (     //   append the left cheek + a space + the left eye
      --n > 1 ?    //   decrement n; if it's still greater than 1:
        f(n)       //     append the result of a recursive call
      :            //   else (n = 0 or 1):
        "MN" + (   //     append the mouth and the nose
          n ?      //     if n = 1:
            f(n)   //       append the result of a recursive call
            + "N " //       followed by the nose + a space
          :        //     else (n = 0):
            " "    //       append a space and stop recursion
        )          //
    )              //
    + "eE)"        //   append the right eye + the right cheek
  :                // else:
                   //   the special case n = 0 is reached only if the original
    ""             //   input is 0; just return an empty string

Python 3, 75 bytes
f=lambda i:L[:7+~2%~i]+f(i-1)+L[6+2%i:]if i>1else L*i
L='( ͡° ͜ʖ ͡°)'

Try it online!
-6 bytes thanks to xnor

I did some brute-force searching and found that 4+3*(i<3) can be 7+~2%~i and 8-2*(i<3) can be 6+2%i.

@xnor Brilliant, thanks!

Excel, 85 bytes
=IF(A1>1,REPT("( ͡°",A1-1)&" ʖ( ͡° ͜ʖ ͡°)ʖ "&REPT("͡°)",A1-1),REPT("( ͡° ͜ʖ ͡°)",A1))

Naive solution for n>1.  Second repeat required to handle 0 testcase.

Do you need the last REPT?

The last REPT is required to handle the 0 case.

Retina 0.8.2, 56 bytes
.+
$*< $&$*>
 >>
 >ʖ >
<(?=<? )
< ͜ʖ
<
( ͡°
>
͡°)

Try it online! Explanation:
.+
$*< $&$*>

Generate the cheeks, but use <s and >s because (s and )s would need to be quoted. A space in the middle ends up between the middle man's nose and left eye.
 >>
 >ʖ >

If the man in the middle has a man on his left, give that man a nose and a space between it and his left eye.
<(?=<? )
< ͜ʖ

Add the mouth and nose to the man in the middle and the man to his right if any. We don't see the left eye of the man to his right so he doesn't need a space, and we gave the man in the middle a space on the first stage.
<
( ͡°

Fix the right cheeks and add the right eyes.
>
͡°)

Fix the left cheeks and add the left eyes.

@Arnauld Phew, it took me some time, but I think I managed to fix it for only a single extra byte!

Inform 7, 262 bytes
To say x:say "[Unicode 865][Unicode 176]".
To say y:say Unicode 860.
To say z:say Unicode 662.
To say p (N - number):say "( [x][p N minus 1][x])".
To say p (N - 2):say "( [x] [y][z][p 1][z][x])".
To say p (N - 1):say "( [x] [y][z] [x])".
To say p (N - 0):say "".

This takes advantage of Inform 7's function overloading: the most specific overload will be run, and the function that takes a number (any integer) as its argument is less specific than the function that takes the number two (and only two) as its argument.
There are some repeated bits of text, like "( [x]", which could potentially be abstracted as functions of their own—but I7 is so verbose, defining a new function takes more bytes than this would save! The only places defining a new function seems to save bytes is for the non-ASCII characters, since the syntax for printing them is even more verbose than the syntax for function definitions.
Boilerplate to run this:
Foo is a room. When play begins: say p 7.

Replace 7 with a non-negative integer of your choice.

Nice to see an Inform answer!

C++ (gcc), 102 bytes
#include <string>
std::string f(int n){return n?"( ͡°"+(--n>1?f(n):" ͜ʖ"+(n?f(n)+"ʖ ":" "))+"͡°)":"";}

Try it online!
Shameless port of Arnauld's JavaScript solution.

Maybe you have to include #include  # 103

Indeed, thanks for reminding me :)

Suggest #import<map> instead of #include <string>

Perl 5 -p, 96 bytes
$\='( ͡° ͜ʖ ͡°)'if$_--;$\="( ͡° ͜ʖ$\ʖ ͡°)"if$_-->0;$\="( ͡°$\ ͡°)"while$_-->0}{

Try it online!

81 bytes

Stax, 42 bytes
ü/┐▐Φd¬•U►^τ∩█┴êZ3↔uº'µ3ó(▀◄Ü▒iÇÆ'[∞_¥▄>A√

Run and debug it
I think it appears not to work in Firefox in Windows.  But that's just because the FF default font for monospace is Courier, which seems not to support these fancy unicode modifiers or whatever.  I think.

Java 7, 133 90 89 bytes
String f(int n){return--n<0?"":"( ͡°"+(n>1?f(n):" ͜ʖ"+(n>0?f(n)+"ʖ ":" "))+"͡°)";}

Port of @Arnauld's recursive JavaScript answer, since it's shorter than my initial first attempt using a Java 8+ lambda.
Try it online.
Explanation:
String f(int n){               // Recursive method with integer parameter & String return-type
  return--n                    //  Decrease the input by 1 first
           <0?                 //  And if the input is now -1:
              ""               //   Return an empty string
             :                 //  Else:
             "( ͡°"             //   Return the left part of Lenny's face
             +(n>1?            //   And if the modified input is larger than 1:
                   f(n)        //    Append a recursive call with this now decreased input
                  :            //   Else (the input is here either 0 or 1):
                   " ͜ʖ"        //    Append Lenny's nose
                   +(n>0?      //    And if the input is larger than 0 (thus 1):
                         f(n)  //     Append a recursive call
                         +"ʖ " //     As well as the right part of its nose
                        :      //    Else (thus 0):
                         " "   //     Append a space instead
            ))+"͡°)";}          //   And also append the right part of Lenny's

Python 3, 66 bytes
f=lambda i:i*'x'and"( ͡° ͜ʖ"[:7+~2%~i]+f(i-1)+"ʖ ͡°)"[2%i:]

Try it online!
The index calculation idea is borrowed from @xnor in @Jitse's solution.

Julia 1.0, 85 bytes
f(n,s="( ͡° ͜ʖ ͡°)")=n<3 ? ["",s,s[1:10]s*s[10:17]][n+1] : s[1:5]f(n-1)s[12:17]

Try it online!

Japt, 47 bytes (UTF-8)
?"( ͡°{´U>1?ß:" ͜ʖ"+(U?'ʖiß:S} ͡°)":P

Saved a byte thanks to Shaggy
Try it

47 bytes?

The expected output for U=0 is an empty string so you may want to ask for confirmation on outputting a space instead.

Python 3, 80 chars, 86 bytes
x='( ͡° ͜ʖ ͡°)'
n=3-1
print(x[:4]*(n-1)+x[:7]*(n!=0)+x+x[6:]*(n!=0)+x[8:]*(n-1))

Try it online!
To put input, change the 3 to whatever input you want, leaving the -1 alone.
If anyone knows a better way to do input that would reduce the char count let me know.
Nothing fancy going on here, just string slicing and abuse of booleans

Canvas, 46 bytes
b＊5USy{↖ｑYｑ⇵≡„a¹„┬Ｈｃ＋
⁷ｍ；⁷±ｍ±└＋＋
Ｈ？３４⁸］］⁷］５７⁸｝

Try it here!

Charcoal, 41 bytes
ＮθＰ⭆θ✂ʖ ͡°)⊗‹¹ι←⭆θ✂ʖ͜ °͡ (∧‹¹ι³

Try it online! The deverbosifier tries to quote the second string for some reason, but it doesn't seem to be necessary, but here's the verbose version if you want it. Explanation:
Ｎθ

Input the number of faces.
Ｐ⭆θ✂ʖ ͡°)⊗‹¹ι

Print the left sides of the faces (on our right as we see them). These consist of the string ʖ ͡°) repeated up to twice, and then that string without the first two characters repeated the remaining number of times.
←⭆θ✂ʖ͜ °͡ (∧‹¹ι³

Print the right sides of the faces (on our left as we see them). These consist of the (reversed) string ʖ͜ °͡ ( repeated up to twice, and then that string without the first two characters repeated the remaining number of times.
The more observant among you will have noticed that the middle face has its nose generated twice which is why I'm printing in such a way that they overlap.


text:
Decompose Commutators
A theorem in this paper1 states that every integral n-by-n matrix M over the integers with trace M = 0 is a commutator, that means there are two integral matrices A,B of the same size as M such that M = AB - BA.
Challenge
Given an integral matrix M with trace M = 0 find some integral matrices A,B such that M = AB - BA.
Details

Let A,B be two matrices of compatible size, then AB denotes the matrix product of A and B which in general does not commute, so in general AB = BA does not hold. We can "measure" how close two matrices are to commuting with eachother by measuring how close the commutator - which is defined as AB - BA - is to being zero. (The commutator is sometimes also written as [A, B].)
The trace of a matrix is the sum of the diagonal entries.
The decomposition is not necessarily unique. You have to provide one decomposition.

Examples
Since the decomposition is not unique, you might get different results that are still valid. In the following we just consider some possible example.
M:       A:      B:
[ 1  0]  [1  1]  [1  0]
[-2 -1]  [1 -1]  [1  1]

In the trivial case of 1 x 1 matrices only M = 0 is possible, and any two integers A,B will solve the problem
M:   A:   B:
[0]  [x]  [y] for any integers x,y

Note that for M = 0 (a zero matrix of arbitrary size) implies AB = BA, so in this case any two matrices (A, B) that commute (for example if they are inverse to each other) solve the problem.
M:     A:     B:
[0 0]  [2 3]  [3   12]
[0 0]  [1 4]  [4   11]

M:           A:         B:
[11 12  12]  [1  1  1]  [1  2  3]
[ 7  4   0]  [0  1  1]  [4  5  6]
[ 0 -7 -15]  [0  0  1]  [7  8  9]

M:                    A:          B:
[-11811 -9700 -2937]  [ 3 14 15]  [ 2 71 82]
[ -7749 -1098  8051]  [92 65 35]  [81 82 84]
[  3292  7731 12909]  [89 79 32]  [59  4 52]

1: "Integral similarity and commutators of integral matrices"
by Thomas J.Laffey, Robert Reams, 1994

"Math = winning :)" Well, my math skills suck, and I don't 100% understand the challenge because of it. ;) Mainly the examples, and what $AB$ and $BA$ actually means we should do with the matrices. I understand that $M=0$ implies $AB=BA$ and the diagonal from the top-left to bottom-right in $M$ sums to 0. I don't really understand what $AB$ is though. Without looking at the examples, seeing this I would assume we multiple the values in $A$ and $B$ at the same coordinates, but in that case $AB-BA$ is always 0. Could you perhaps explain the first 3x3 example to me?

^ How $A$ [[1,1,1],[0,1,1],[0,0,1]] and $B$ [[1,2,3],[4,5,6],[7,8,9]] would becomes the matrix $M$ [[11,12,12],[7,4,0],[0,-7,-15]] with $M=AB-BA$? EDIT: Actually, only for $M=0$ the $AB=BA$ applies I now re-read. So for a matrix containing only 0s, any $A$ and $B$ would be a correct result. I still don't really understand the challenge for non-$M=0$ cases though. (Probably my bad Math and matrices knowledge in general. ;p)

@KevinCruijssen, $AB$ is matrix multiplication of $A$ and $B$. Matrix multiplication is non-commutative: in general $AB \neq BA$. Multiplication works on the basis (using more programming-languagy syntax than the usual syntax for matrix indexing) $$(AB)[x][y] = \sum_i A[x][i] B[i][y]$$ Subtraction is pointwise: $$(C - D)[x][y] = C[x][y] - D[x][y]$$

@PeterTaylor Ah ok, your explanation, and taking a close look at the Wikipedia Matrix Multiplication page made it clearer, thanks! So $AB$ takes the dot-product of the $i$'th row of $A$ and $j$'th column of $B$ for every coordinate $i,j$ in the two matrices. I.e. calculating $AB-BA$ for the $11$ in the top-left of the matrix $M$ is $((1×1 + 1×4 + 1×7)-(1×1 + 2×0 + 3×0))$.

@KevinCruijssen Yes that is correct!

@KevinCruijssen and anyone else who is unfamiliar with matrix multiplication:  Matrix "multiplication" is really the composition of linear functions.  Each matrix represents a linear function on vectors and the result of "multiplication" represents the function which is the composition of the two functions represented by the input matrices.  This also explains why it is non-commutative.

05AB1E, 36 29 bytes
ÄàD(Ÿsgãsgãã.ΔD2FsN._`øδ*O}-Q

-7 bytes thanks to @ovs in another answer of mine.
Extremely slow since I'm using a brute-force approach with three cartesian products. But performance is irrelevant for code-golf challenges I guess (would love to see this same challenge as fastest-code or fastest-algorithm).
Try it online (only works for matrices of size 2x2, and even then usually times out if the absolute maximum of the integers in the matrix \$M\$ is too large..)
Verify whether the output \$[A,B]\$ results in the input \$M\$.
Explanation:
Assumes all the integers used in the resulting matrices \$[A,B]\$ will be within the range \$[-\max(\lvert M\rvert), \max(\lvert M\rvert)]\$. If you know any way to prove or disprove this assumption, let me know.
Note that there are of course matrices \$[A, B]\$ with integers larger than the integers of the resulting matrix \$M\$. But this \$M\$ will have other possible \$[A, B]\$ which are within this min-max range. I.e. \$[A,B]=\$ [[[1,2],[3,4]], [[-1,-2],[-3,-3]]] will have \$M=\$ [[0,2],[-3,0]], but using this \$M\$ to find a possible \$[A,B]\$ will result in [[[3,2],[3,3]], [[2,2],[3,3]]], which are all within the range \$[-3,3]\$.
Let me start with an explanation of 2FsN._`øδ*O}-, which will calculate \$M = AB-BA\$ of a given matrix-pair \$[A,B]\$ (which is the same code as in the verifier TIO-link above).
2F       # Loop 2 times:
  s      #  Swap the top two values on the stack
         #  (so the matrix-pair is at the top again after the first iteration)
   N._   #  Rotate the pair of matrices the (0-based) loop-index amount of times
         #  (to reverse the order from [A,B] to [B,A] in the second iteration)
      `  #  Push both matrices separated to the stack
  ø      #  Zip/transpose the top matrix; swapping rows/columns
   δ     #  Apply double-vectorized:
    *    #   Multiply
     O   #  And then sum each inner row together
 }       # After the loop:
  -      # Subtract the values at the same positions in the two matrices from each other

As for the rest of the program to create all possible matrices and brute-force over them:
Ä        # Convert each integer in the (implicit) input-matrix `M` to its absolute value
 à       # Pop and push the flattened maximum of these absolute values of `M`
  D(     # Duplicate it, and negate the maximum
    Ÿ    # Pop both and push a list in the range [max, -max]
s        # Swap to get the input matrix again
 g       # Pop and push its length to get the matrix dimension
  ã      # Create the cartesian product of the [max, -max]-list that many times
         # (i.e. if the input-matrix has a dimension of 3, we'll now have all possible
         #  triplets of integers within the [max, -max]-range)
sgã      # Do the same, to create all possible combinations of these triplets
         # (so we now have all possible matrices of the same dimensions as the input-matrix,
         #  using integers within the [max, -max]-range)
ã        # Cartesian product yet again (defaults to 2) to create all possible pairs of matrices
.Δ       # Then find the first pair of matrices which is truthy for:
  D      #  Duplicate the current pair
   2FsN._`øδ*O}-
         #  Calculate M as mentioned above
    Q    #  And check if its equal to the (implicit) input-matrix
         # (after which this matrix-pair is output implicitly as result)

Just to give an idea of how inefficient this brute-force approach is:
The given example input-matrix \$M=\$ [[11,12,12],[1,1,1],[1,2,3]] of the challenge description, will create all possible matrix-pairs of the same 3x3 dimensions with integers in the range \$[-12,12]\$. This means the list of matrix-pairs will contain \$(((12^2+1)^3)^3)^2=802830827198685151406498569488525390625\$ matrix-pairs.
And the given example input-matrix \$M=\$ [[-11811,-9700,-2937],[3,14,15],[2,71,82]] would result in \$(((11811^2+1)^3)^3)^2=400239694511528196808960294025932709663435907226315389994060779277222573307615163703296535923733538440194289670070277830289553752923910908747710464\$ matrix-pairs..

To be safe, you could use entries between -n and n, and increase n in an outer loop. I wonder if you really need a special case for the 1x1 matrix.

@ChristianSievers I'll try that suggestion, although it would still be fairly large I'm afraid. Some 2x2 inputs with integers below with a difference of about 20 already time out I'm afraid.. As for the second part, you're completely right. I had a 36 byte answer before, and added the case about 1x1 matrices after I noticed it didn't work. But I had input another integer than [[0]], which was the reason it didn't work.. I will roll-back, thanks!

The min/max-range is not enough to find a solution for [[0,1],[1,0]]. There is one with values from -1..1.

@ChristianSievers Thanks for letting me know. Fixed by changing the range $[min(M), max(M)]$ to $[-\max(\lvert M\rvert), \max(\lvert M\rvert)]$. Let me know if you find any counter examples for this range (which will probably force me to temporarily or permanently delete my answer).